Windows supports debugging over a serial cable, USB, IEEE 1394 Firewire, and Ethernet. USB and IEEE 1394 are not applicable for virtual machines, and Ethernet requires Windows 8 or later. While a serial connection is universally usable, it is slow.
Debugging using the Hyper-V debug transport, supported on Windows Vista and later, offers significant benefits. It provides excellent performance due to direct host-to-guest transfers, it is easy to set up and requires minimal support from the hypervisor. It can be used with the debugger running on the same host as the VM or with the debugger and VM on separate machines connected over a network.
Prerequisites
A VM configured for Hyper-V paravirtualization running a Windows Vista or newer Windows guest. You can check
the effective paravirtualization provider for your VM with the output of the following
$ VBoxManage showvminfoVM-name
A sufficiently up-to-date version of the Microsoft WinDbg debugger required to debug the version of Windows in your VM.
While Windows 8 and newer Windows guests ship with Hyper-V debug support, Windows 7 and Vista do not. To use
Hyper-V debugging with a Windows 7 or Vista guest, copy the file
Only Windows 8.0 ships
VM and Guest Configuration
Power off the VM.
Enable the debug options with the following
$ VBoxManage modifyvmVM-name --paravirt-debug "enabled=1"
The above command assumes your debugger will connect to your host machine on UDP port 50000. However, if you need to run the debugger on a remote machine you may specify the remote address and port here. For example:
$ VBoxManage modifyvmVM-name \ --paravirt-debug "enabled=1,address=192.168.32.1,port=55000"
See
Start the VM.
In the guest, start an elevated command prompt and execute the following commands:
For a Windows 8 or newer Windows guest:
bcdedit /dbgsettings net hostip:5.5.5.5 port:50000 key:1.2.3.4
For a Windows 7 or Vista guest:
bcdedit /set loadoptions host_ip=5.5.5.5,host_port=50000,encryption_key=1.2.3.4
bcdedit /set dbgtransport kdvm.dll
The IP address and port in the
The encryption key in the
Run one or more of the following commands to enable debugging for the appropriate phase or component of your Windows guest:
bcdedit /set debug on
bcdedit /set bootdebug on
bcdedit /set {bootmgr} bootdebug on
Please note that the
Start Microsoft WinDbg on your host machine or remote host.
From the File menu, select Kernel Debug. On the NET tab, specify the UDP port number you used in the
In the Key field, enter
Click OK to start listening for connections. Microsoft WinDbg typically shows a Waiting to Reconnect message during this phase.
Alternatively, to directly start a debug session, run WinDbg from the command line as follows :
windbg.exe -k net:port=50000,key=1.2.3.4
See the WinDbg documentation for the complete command line syntax.
Reboot your Windows guest and it should then connect as a debuggee with Microsoft WinDbg.