In case you need to debug the kernel on a VM running on Hyper-V, this is how you can do it with a Windows Server 2012 R2 VM Generation 2:
- After the VM has been created, a COM port is needed. By default, you cannot create a COM port with the Hyper-V Manager UI. That’s one of the differences between Gen1 and Gen2. You have to use Powershell to get your COM port. First of all shut down the VM and disable SecureBoot (replace YourVMName with the name of your VM and make sure you run all commands with “run as administrator”):
Set-VMFirmware -VMName YourVMName -EnableSecureBoot Off
- Then create the COM port as follow:
Set-VMComPort -VMName YourVMName 1 \\.\pipe\DebugIT
The “1” is the COM port you want to use (feel free to adjust it if needed) and the pipe path. The last string of the pipe can as well be adjusted, you could use something else than DebuIT.
- Start the VM
- Enable debugging:
bcdedit /debug on
bcdedit /dbgsettings serial debugport:n baudrate:115200
where n is the port number defined in step 2.Reboot the VM.
- Open up WinDbg and choose File –> Kernel Debug
- Configure the COM connection according to the screen shot:
- You will see “Waiting to reconnect…” afterwards. That’s ok because we haven’t started yet debugging. Choose Debug –> Break (or Ctrl+Break). That’s it, you’re now able to debug the kernel of the running VM: