Windows virtual machines are more common now-a-days and debugging them becomes a common task for the developers. In this tip, we will learn how to setup a "Kernel Debug"(KD) connection to the Virtual Machine(VM) guest Operating System(OS).
In this tip, I will refer to two terms "Guest Operating System" and "Host Operating System". Host Operating System here means server where the Hyper-V Manager is installed and the Guest Operating System is the one installed inside the VM.
Setting up the Hyper-V manager (Host OS)
- Open the settings window of the VM you want to setup with kernel debugging
- Edit the settings window for COM1. In this example, I'm using the pipe name "
Setting up the Hyper-V client (Guest OS)
- In an elevated Command Prompt window, enter the following commands, where n is the number of the COM port used for debugging on the target computer, and rate is the baud rate used for debugging:
bcdedit /debug on
bcdedit /dbgsettings serial debugport:n baudrate:rate
Note: The baud rate must be the same on the host computer and target computer. The recommended rate is 115200.
In this example, please use "bcdedit /dbgsettings serial debugport:1 baudrate:115200"
Setting up Windbg (Host OS)
- Install Windbg in the host OS from here.
- Open Windbg.exe and edit the kernel debug option from the file menu
- Set baud rate and port to match with step 2 and 3.
Set the baud rate to "115200" and this should be the same as step 3 baud rate.
Set port to "\\.\pipe\vm1" this port name comes from step 2 "named pipe path".
- Restart the Hyper-V guest OS and when the VM starts Guest OS should be connected to the Windbg.
Initial version: 02/04/2014