debuggingmodules

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
debuggingmodules [2005/09/29 17:09] – CsabaHenkdebuggingmodules [2020/10/19 22:58] (current) – Remove 1 broken link. SashaVigole
Line 1: Line 1:
-The [http://www.freebsd.org/doc/en_US.ISO8859-1/books/developers-handbook/index.html %%FreeBSD%% Developers' Handbook] has a +The information in that chapter is somewhat out of date. Here I give simple (that is, less general) instructions which will work with recent (''%%RELENG_6%%'', ''%%7.0-CURRENT%%'') kernels.
-chapter entitled [http://www.freebsd.org/doc/en_US.ISO8859-1/books/developers-handbook/kerneldebug-kld.html Debugging Loadable Modules Using GDB]. +
- +
-The information in that chapter is somewhat out of date. Here I give simple (that is, less general) instructions which will work with recent (''%%RELENG_6%%'', +
-''%%7.0-CURRENT%%'' kernels.+
  
 Here we assume that you have a recipe to make the kernel panic in some function of your module (or at least, you find it likely that using your Here we assume that you have a recipe to make the kernel panic in some function of your module (or at least, you find it likely that using your
 module will result in a panic), and you want to get an useable backtrace. module will result in a panic), and you want to get an useable backtrace.
  
-  - Create a kernel with debugging enabled. I don't go into details here.+  - Create a kernel with debugging enabled. (I don't go into details here, consult with Developers' Handbook.)
   - Compile your module with something similar to ''%%make DEBUG_FLAGS=-g%%''.   - Compile your module with something similar to ''%%make DEBUG_FLAGS=-g%%''.
   - Load the module (eg., ''%%kldload foo.ko%%'').   - Load the module (eg., ''%%kldload foo.ko%%'').
Line 18: Line 14:
 <code> <code>
  kgdb /usr/obj/usr/src/sys/GENERIC/kernel.debug /var/crash/vmcore.2}}}  kgdb /usr/obj/usr/src/sys/GENERIC/kernel.debug /var/crash/vmcore.2}}}
 + recently, there is no separate {{{kernel.debug}}}, so now the above will look like
 + {{{
 + kgdb /usr/obj/usr/src/sys/GENERIC/kernel /var/crash/vmcore.2}}}
  ) and add the module's symbol table as it's written in Developers' Handbook, using the pre-computed relocation address, and the ''debug version'' of your   ) and add the module's symbol table as it's written in Developers' Handbook, using the pre-computed relocation address, and the ''debug version'' of your 
  module (eg., {{{foo.ko.debug}}}).  module (eg., {{{foo.ko.debug}}}).
Line 23: Line 22:
  
 You can automate the computation of the relocation address with the help of the following You can automate the computation of the relocation address with the help of the following
-[http://www.freshports.org/lang/ruby18 Ruby] script:+[[http://www.freshports.org/lang/ruby18|Ruby]] script:
 {{{ {{{
 #!/usr/bin/env ruby #!/usr/bin/env ruby
  • debuggingmodules.1128013748.txt.gz
  • Last modified: 2005/09/29 17:09
  • by CsabaHenk