How to debug a live FreeBSD kernel?

• 本文约 95 字,阅读大致需要 1 分钟 | *nix and Win32 Kernel

To quote Matthew Dillon:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
    You can actually run gdb on a live kernel like this:

    gdb -k /dev/mem /path/to/kernel.debug

    You can then use the 'proc' command to switch to a process (give it a
    pid), and do a stack backtrace.  That part only really works if the
    process is blocked on something (i.e. not running).

    But you can also dig around kernel globals and various data structures
    and that can be quite useful on a live system.

					-Matt
					Matthew Dillon 
					<dillon@backplane.com>