Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Sep 2017 21:00:38 -0400
From:      Farhan Khan <khanzf@gmail.com>
To:        Andriy Voskoboinyk <s3erios@gmail.com>
Cc:        "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>
Subject:   Re: Debugging symbols on kernel module
Message-ID:  <64eca59f-f937-cb8e-0a45-0ea8abcf2411@gmail.com>
In-Reply-To: <op.y632mmqxiew4ia@thinkpad-x220>
References:  <e2def9e8-4356-2699-b127-e5e93ac11319@gmail.com> <op.y632mmqxiew4ia@thinkpad-x220>

next in thread | previous in thread | raw e-mail | index | archive | help
As suggested, I set my /etc/make.conf to this:

CFLAGS+=	-O0 -g
DEBUG_FLAGS+=	-g3

And it worked. Thank you, Andriy!

On 09/25/2017 03:48 AM, Andriy Voskoboinyk wrote:
> Hi,
> 
> for debugging purposes I'm adding next line in make.conf:
> 
> CFLAGS+=    -O0 -g
> 
> Works for modules but not for the kernel
> (KSTACK_PAGES needs to be increased for the whole kernel build).
> 
>> Hi all,
>>
>> I am working on a kernel module but am getting some unexpected code
>> execution. Dtrace probes reveal that the kernel executes:
>> "rtwn.ko`r88ee_init_bb+0x219" and then jumps to an unexpected function.
>>
>> I would like to track down exactly which line that is. I compiled the
>> module with this:
>>
>> # make DEBUG_FLAGS=-g3 -C sys/modules/rtwn/
>>
>> This produced the rtwn.ko.debug and rtwn.ko.full files. But when I
>> load them, I still do not have debugging symbols:
>>
>> $ kgdb rtwn.ko
>> GNU gdb (GDB) 8.0 [GDB v8.0 for FreeBSD]
>> Copyright (C) 2017 Free Software Foundation, Inc.
>> License GPLv3+: GNU GPL version 3 or later
>> <http://gnu.org/licenses/gpl.html>;
>> This is free software: you are free to change and redistribute it.
>> There is NO WARRANTY, to the extent permitted by law.  Type "show
>> copying"
>> and "show warranty" for details.
>> This GDB was configured as "x86_64-portbld-freebsd12.0".
>> Type "show configuration" for configuration details.
>> For bug reporting instructions, please see:
>> <http://www.gnu.org/software/gdb/bugs/>.
>> Find the GDB manual and other documentation resources online at:
>> <http://www.gnu.org/software/gdb/documentation/>.
>> For help, type "help".
>> Type "apropos word" to search for commands related to "word"...
>> Reading symbols from rtwn.ko...Reading symbols from
>> /usr/src/sys/modules/rtwn/rtwn.ko.debug...(no debugging symbols
>> found)...done.
>> (no debugging symbols found)...done.
>> (kgdb) file rtwn.ko.debug
>> Reading symbols from rtwn.ko.debug...(no debugging symbols found)...done.
>> (kgdb) file rtwn.ko.full
>> Reading symbols from rtwn.ko.full...(no debugging symbols found)...done.
>>
>> How do I properly load debugging symbols for the module?
>>
>> Thanks,
>>
>> Farhan Khan
>> _______________________________________________
>> freebsd-hackers@freebsd.org mailing list
>> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
>> To unsubscribe, send any mail to
>> "freebsd-hackers-unsubscribe@freebsd.org"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?64eca59f-f937-cb8e-0a45-0ea8abcf2411>