diff --git a/share/doc/handbook/kerneldebug.sgml b/share/doc/handbook/kerneldebug.sgml index e2b17756ea2..dd617a43e39 100644 --- a/share/doc/handbook/kerneldebug.sgml +++ b/share/doc/handbook/kerneldebug.sgml @@ -1,4 +1,4 @@ - + Kernel Debugging @@ -482,6 +482,36 @@ Debugger (msg=0xf01b0383 "Boot flags requested debugger") window (which gives you an automatic source code display in another Emacs window) etc. +

Remote GDB can also be used to debug LKMs. First build the LKM + with debugging symbols: + +# cd /usr/src/lkm/linux +# make clean; make COPTS=-g + + + Then install this version of the module on the target machine, load it + and use modstat to find out where it was loaded: + +# linux +# modstat +Type Id Off Loadaddr Size Info Rev Module Name +EXEC 0 4 f5109000 001c f510f010 1 linux_mod + + + Take the load address of the module and add 0x20 (probably to account + for the a.out header). This is the address that the module code was + relocated to. Use the add-symbol-file command in GDB to tell the + debugger about the module: + +(kgdb) add-symbol-file /usr/src/lkm/linux/linux_mod.o 0xf5109020 +add symbol table from file "/usr/src/lkm/linux/linux_mod.o" at +text_addr = 0xf5109020? +(y or n) y +(kgdb) + + + You now have access to all the symbols in the LKM. + Debugging a console driver

Since you need a console driver to run DDB on, things are more