Live Kernel-Mode Debugging Using KD
In a Command Prompt window, you can initiate a live kernel-mode debugging session when you launch KD. Enter one of the following commands.
- kd [-y SymbolPath] -k net:port=PortNumber,key=Key
- kd [-y SymbolPath] -k 1394:channel=1394Channel[,symlink=1394Protocol]
- kd [-y SymbolPath] -k usb:targetname=USBString
- kd [-y SymbolPath] -k com:port=ComPort,baud=BaudRate
- kd [-y SymbolPath] -k com:pipe,port=\\VMHost\pipe\PipeName[,resets=0][,reconnect]
- kd [-y SymbolPath] -k com:modem
- kd [-y SymbolPath] -kl
- kd [-y SymbolPath] -k
For more information, see KD Command-Line Options.
For debugging over a serial (COM port) or 1394 connection, you can use environment variables to specify the connection settings.
Use the following variables to specify a serial connection.
- set _NT_DEBUG_PORT = ComPort
- set _NT_DEBUG_BAUD_RATE = BaudRate
Use the following variables to specify a 1394 connection.
- set _NT_DEBUG_BUS = 1394
- set _NT_DEBUG_1394_CHANNEL = 1394Channel
- set _NT_DEBUG_1394_SYMLINK = 1394Protocol
For more information, see Kernel-Mode Environment Variables.
A list of directories where symbol files are located. Directories in the list are separated by semicolons. For more information, see Symbol Path.
A port number to use for network debugging. You can choose any number from 49152 through 65535. For more information, see Setting Up a Network Connection Manually.
The encryption key to use for network debugging. We recommend that you use an automatically generated key, which is provided by bcdedit when you configure the target computer. For more information, see Setting Up a Network Connection Manually.
The 1394 channel number. Valid channel numbers are any integer between 0 and 62, inclusive. 1394Channel must match the number used by the target computer, but does not depend on the physical 1394 port chosen on the adapter. For more information, see Setting Up a 1394 Connection Manually.
The connection protocol to be used for the 1394 kernel connection. This can almost always be omitted, because the debugger will automatically choose the correct protocol. If you wish to set this manually, and the target computer is running Windows XP, 1394Protocol should be set equal to "channel". If the target computer is running Windows Server 2003 or later, 1394Protocol should be set equal to "instance". If it is omitted, the debugger will default to the protocol appropriate for the current target computer. This can only be specified through the command line or the environment variables, not through the WinDbg graphical interface.
A USB connection string. This must match the string specified with the /targetname boot option. For more information, see Setting Up a USB 3.0 Connection Manually and Setting Up a USB 2.0 Connection Manually.
The name of the COM port. This can be in the format "com2" or in the format "\\.\com2", but should not simply be a number. For more information, see Setting Up a Serial Connection Manually.
The baud rate. This can be 9600, 19200, 38400, 57600, or 115200.
When debugging a virtual machine, VMHost specifies the name of the physical computer on which the virtual machine is running. If the virtual machine is running on the same computer as the kernel debugger itself, use a single period (.) for VMHost. For more information, see Setting Up a Connection to a Virtual Machine.
The name of the pipe created by the virtual machine for the debugging connection.
Specifies that an unlimited number of reset packets can be sent to the target when the host and target are synchronizing. This parameter is only needed when debugging certain kinds of virtual machines.
Causes the debugger to automatically disconnect and reconnect the pipe if a read/write failure occurs. Additionally, if the named pipe is not found when the debugger is started, the reconnect parameter will cause it to wait for a pipe of this name to appear. This parameter is only needed when debugging certain kinds of virtual machines.
Causes the debugger to perform local kernel-mode debugging. For more information, see Local Kernel-Mode Debugging.
The following batch file could be used to set up and start a debugging session over a COM port connection.
set _NT_SYMBOL_PATH=d:\mysymbols set _NT_DEBUG_PORT=com1 set _NT_DEBUG_BAUD_RATE=115200 set _NT_DEBUG_LOG_FILE_OPEN=d:\debuggers\logfile1.log kd
The following batch file could be used to set up and start a debugging session over a 1394 connection.
set _NT_SYMBOL_PATH=d:\mysymbols set _NT_DEBUG_BUS=1394 set _NT_DEBUG_1394_CHANNEL=44 set _NT_DEBUG_LOG_FILE_OPEN=d:\debuggers\logfile1.log kd
The following command lines could be used to start WinDbg without any environment variables.
- kd -y d:\mysymbols -k com:port=com2,baud=57600
- kd -y d:\mysymbols -k com:port=\\.\com2,baud=115200
- kd -y d:\mysymbols -k 1394:channel=20,symlink=instance
- kd -y d:\mysymbols -k net:port=50000,key=AutoGeneratedKey