This topic has not yet been rated - Rate this topic

Local Kernel-Mode Debugging

KD and WinDbg can perform local kernel debugging. This kind of debugging is kernel debugging on a single computer. In other words, the debugger is debugging the computer that it is running on.

Setting Up Local Kernel-Mode Debugging

Open a Command Prompt window as Administrator. Enter bcdedit /debug on. Reboot the computer.

Starting a Local Kernel-Mode Debugging Session

To start a local kernel-mode debugging session, do one of the following:

  • Run WinDbg as Administrator. On the File menu, choose Kernel Debug. Open the Local tab, and click OK.
  • Open a Command Prompt window as Administrator. Enter windbg -kl.
  • Open a Command Prompt window as Administrator. Enter kd -kl.
  • Use the .attach -k command.

Commands That Are Not Available

Not all commands are available in a local kernel debugging session. Typically, you cannot use any command that causes the target computer to stop, even momentarily, because you cannot resume operation.

In particular, you cannot use the following commands:

  • Execution commands, such as g (Go), p (Step), t (Trace), wt (Trace and Watch Data), tb (Trace to Next Branch), gh (Go with Exception Handled), and gn (Go with Exception Not Handled)

  • Shutdown and dump file commands, such as .crash, .dump, and .reboot

  • Breakpoint commands, such as bp, bu, ba, bc, bd, be, and bl

  • Register display commands, such as r and variations

  • Stack trace commands, such as k and variations

If you are performing local kernel debugging with WinDbg, all of the equivalent menu commands and buttons are also unavailable.

Commands That Are Available

All memory input and output commands are available. You can freely read from user memory and kernel memory. You can also write to memory. Make sure that you do not write to the wrong part of kernel memory, because it can corrupt data structures and frequently causes the computer to stop responding (that is, crash).

Difficulties in Performing Local Kernel Debugging

Local kernel debugging is a very delicate operation. Be careful that you do not corrupt or crash the system.

One of the most difficult aspects of local kernel debugging is that the machine state is constantly changing. Memory is paged in and out, the active process constantly changes, and virtual address contexts do not remain constant. However, under these conditions, you can effectively analyze things that change slowly, such as certain device states.

Kernel-mode drivers and the Windows operating system frequently send messages to the kernel debugger by using DbgPrint and related functions. These messages are not automatically displayed during local kernel debugging. You can display them by using the !dbgprint extension.

LiveKD

The LiveKD tool simulates local kernel debugging. This tool creates a "snapshot" dump file of the kernel memory, without actually stopping the kernel while this snapshot is made. (Therefore, the snapshot might not actually show a single instant state of the computer.)

LiveKD is not part of the Debugging Tools for Windows package. You can download LiveKd from the Windows Sysinternals site.

 

 

Send comments about this topic to Microsoft

Build date: 4/9/2013

© 2013 Microsoft. All rights reserved.