Setting breakpoints
The KDB kernel debugger creates a table of breakpoints that it maintains. When a breakpoint is set, the debugger temporarily replaces the corresponding instruction with the trap instruction. The instruction overlaid by the breakpoint operates when you issue any subcommand that would cause that instruction to be initiated.
For more information about setting or clearing breakpoints, see Breakpoint and steps subcommands.
Setting a breakpoint is essential for debugging kernel extensions. The general steps for setting a breakpoint are the following:
- Locate the assembler instruction corresponding to the C statement
of the kernel system that you are debugging.
The process of locating the assembler instruction and obtaining its offset is explained in Viewing and modifying global data.
- Get the offset of the assembler instruction from the listing.
- Locate the address where the kernel extension is loaded.
- Add the address of the assembler instruction to the address where kernel extension is loaded.
- Set the breakpoint with the KDB b (break) subcommand.
Note: To continue with the demokext example, set
a break at the C source line 67, which increments the demokext_j variable.
The list file indicates that this line starts at an offset of 0xE0.