65.9K
CodeProject is changing. Read more.
Home

How to Setup a Windbg Kernel Debugger to Debug Hyper-V Windows Client

starIconstarIconstarIconstarIconstarIcon

5.00/5 (2 votes)

Feb 4, 2014

CPOL

1 min read

viewsIcon

18410

Debug your driver within a VM

Introduction

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)

  1. Open the settings window of the VM you want to setup with kernel debugging

  2. Edit the settings window for COM1. In this example, I'm using the pipe name "vm1".

Setting up the Hyper-V client (Guest OS)

  1. 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)

  1. Install Windbg in the host OS from here.

  2. Open Windbg.exe and edit the kernel debug option from the file menu

  3. 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".

  4. Restart the Hyper-V guest OS and when the VM starts Guest OS should be connected to the Windbg.

History

  • Initial version: 02/04/2014