Monday, February 6, 2012

Kernel Debugging


[Ref: http://publib.boulder.ibm.com/infocenter/aix/v6r1/index.jsp?topic=%2Fcom.ibm.aix.kdb%2Fdoc%2Fkdb%2Fkdb.htm]
 
kdb command
This command is implemented as an ordinary user-space program and is typically used for
post-mortem analysis of a previously-crashed system by using a system dump file. The kdb command includes subcommands specific to the manipulation of system dumps.
 
KDB kernel debugger
- The KDB kernel debugger is integrated into the kernel and allows full control of the system while a debugging session is in progress. The KDB kernel debugger allows for traditional debugging tasks such as setting breakpoints and single-stepping through code.
- KDB needs to be enabled when the system boots.
- To check if the KDB is enabled or not, issue

$> bosdebug -L
Memory debugger           off
Memory sizes              0
Network memory sizes      0
Kernel debugger           off
Real Time Kernel          off
Backtracking fault log    on
Kernext Memory Tracking   off

- To create a kernel image with KDB enabled, issue
$> bosdebug -D 
This will turn on the kernel debugger. You need to bosboot and reboot in order to take this effect.
$> bosboot -a && reboot
[After of about 20-30 mins, you will have a KDB enabled image}
bosboot: Boot image is 49180 512 byte blocks.
- KDB enabled kernel image is ready. All you gotto do now is, reboot.
If you have HMC kinda machine (where you remotely try to reboot the machine), while booting, you can see Kernel Debugging is enabled.
$> reboot
 -------------------------------------------------------------------------------
                                Welcome to AIX.
                   boot image timestamp: 11:02:54 12/26/2011
                 The current time and date: 11:18:52 12/26/2011
        processor count: 1;  memory size: 2048MB;  kernel size: 28147575
         boot device: /vdevice/v-scsi@30000003/disk@8100000000000000:2
                       kernel debugger setting: enabled
-------------------------------------------------------------------------------