kgdb kernel module says no symbols found

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 somewhere that I did not expect.

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:

Code:
$ cd /usr/src/sys/modules/rtwn/
$ 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.

I also tried to manually load the symbols with file rtwn.ko.debug but have the same result. The rtwn.ko.debug file is not empty (63408 bytes). Am I doing something wrong?
 
Andriy Voskoboinyk over on the FreeBSD hackers email list helped me out.
Put the following two items in your /etc/make.conf
Code:
CFLAGS+= -O0 -g -g3
DEBUG_FLAGS+= -g3
And the debugging symbols should load.
 
Back
Top