Debugging KLD -- cannot access memory at 'address'
Aijaz Baig
aijazbaig1 at gmail.com
Tue Apr 4 06:50:51 UTC 2017
Hello.
I am unable to get quite a 'handle' on debugging KLDs. I have compiled my
modules with the DEBUG_FLAGS set to -g3 and have also installed it using
the same flags so that /boot/kernel/ contains not only the module binary
(kernel object) but also the symbol file.
So I do a
make DEBUG_FLAGS=-g3
make install DEBUG_FLAGS=-g3
under the directory containing the KLD which ultimately copies the binary
as well as the symbol file.
After connecting kgdb to the remote (debugged) machine, I load my module
which automatically asks me if I need to load the symbols from the symbol
file, to which I click yes
sudo kgdb kernel.debug
(kgdb) set remotebaud 9600
(kgdb) target remote /dev/cuau0
Remote debugging using /dev/cuau0
kdb_sysctl_enter (oidp=<value optimized out>, arg1=<value optimized out>,
arg2=0xfffffe001e3397f0,
req=<value optimized out>) at /usr/src/sys/kern/subr_kdb.c:446
446 kdb_why = KDB_WHY_UNSET;
Current language: auto; currently minimal
(kgdb) kldstat
Id Refs Address Size Name
1 8 0x80200000 17e10c8 kernel
2 1 0x819e2000 4cf0 vmxnet.ko
3 1 0x81c11000 23dc vmmemctl.ko
4 1 0x81c14000 47a echo.ko
(kgdb) add-kld /boot/kernel/echo.ko
add symbol table from file "/boot/kernel/echo.ko.symbols" at
.text_addr = 0xffffffff81c14000
set_modmetadata_set_addr = 0xffffffff81c14228
set_sysinit_set_addr = 0xffffffff81c14238
.rodata.str1.1_addr = 0xffffffff81c14240
.data_addr = 0xffffffff81c142f8
.bss_addr = 0xffffffff81c14420
(y or n) y
Reading symbols from /boot/kernel/echo.ko.symbols...
location expression too complex...done.
(kgdb) b echo_write
Breakpoint 1 at 0xffffffff81c14161: file echo.c, line 89.
(kgdb) getsyms
Id Refs Address Size Name
1 8 0x80200000 17e10c8 kernel
2 1 0x819e2000 4cf0 vmxnet.ko
3 1 0x81c11000 23dc vmmemctl.ko
4 1 0x81c14000 47a echo.ko
Select the list above with the mouse, paste into the screen
and then press ^D. Yes, this is annoying.
1 8 0x80200000 17e10c8 kernel
2 1 0x819e2000 4cf0 vmxnet.ko
3 1 0x81c11000 23dc vmmemctl.ko
4 1 0x81c14000 47a echo.ko
(kgdb) n
95 strlen += MIN(uio->uio_iov->iov_len, bufferspace-1);
(kgdb) x/d strlen
Cannot access memory at address 0x0
(kgdb) info locals
strlen = Cannot access memory at address 0x0
I am unable to fathom what am I missing. Keen to hear
--
Best Regards,
Aijaz Baig
More information about the freebsd-hackers
mailing list