Setting Up Kernel-Mode Debugging of a Virtual Machine in Visual Studio

You can use Microsoft Visual Studio to set up and perform kernel-mode debugging of a virtual machine. The virtual machine can be located on the same physical computer as the debugger or on a different computer that is connected to the same network. To use Visual Studio for kernel-mode debugging, you must have the Windows Driver Kit (WDK) integrated with Visual Studio. For information about how to install the integrated environment, see Windows Driver Development.

As an alternative to using Visual Studio to set up debugging of a virtual machine, you can do the setup manually. For more information, see Setting Up Kernel-Mode Debugging of a Virtual Machine Manually.

The computer that runs the debugger is called the host computer, and the virtual machine that is being debugged is called the target virtual machine.

Configuring the Target Virtual Machine

  1. In the virtual machine, in an elevated Command Prompt window, enter the following commands.

    bcdedit /debug on
    bcdedit /dbgsettings serial debugport:n baudrate:115200

    where n is the number of a COM port on the virtual machine.

    Note  By default, COM ports are not presented in generation 2 virtual machines. For information about how to create a COM port, see Generation 2 Virtual Machines.

  2. Reboot the virtual machine.
  3. In the virtual machine, configure the COM port to map to a named pipe. The debugger will connect through this pipe. For more information about how to create this pipe, see your virtual machine's documentation.

Configuring the Host Computer

The host computer can be the same physical computer that is running the virtual machine, or it can be a separate computer.

  1. On the host computer, in Visual Studio, on the Driver menu, choose Test > Configure Computer.
  2. Click Add New Computer.
  3. For Computer name, enter the name of the physical computer that is running the target virtual machine.
  4. Select Manually configure debuggers and do not provision, and click Next.
  5. For Connection Type, select Serial.
  6. Check Pipe, and check Reconnect.
  7. If the debugger is running on the same computer as the virtual machine, enter the following for Pipe name:

    \\.\pipe\PipeName.

    If the debugger is running on a different computer from the virtual machine, enter the following for Pipe name:

    \\VMHost\pipe\PipeName

    where, VMHost is the name of the physical computer that is running the target virtual machine, and PipeName is the name of the pipe that you associated with the COM port on the target virtual machine.

  8. Click Next. Click Finish.

Starting the Debugging Session

  1. On the host computer, in Visual Studio, on the Tools menu, choose Attach to Process.
  2. For Transport, choose Windows Kernel Mode Debugger.
  3. For Qualifier, select the name of the physical computer that is running the target virtual machine.
  4. Click Attach.

Generation 2 Virtual Machines

By default, COM ports are not presented in generation 2 virtual machines. You can add COM ports through PowerShell or WMI. For the COM ports to be displayed in the Hyper-V Manager console, they must be created with a path.

To enable kernel debugging using a COM port on a generation 2 virtual machine, follow these steps:

  1. Disable Secure Boot by entering this PowerShell command:

    Set-VMFirmware –Vmname VmName –EnableSecureBoot Off

    where VmName is the name of your virtual machine.

  2. Add a COM port to the virtual machine by entering this PowerShell command:

    Set-VMComPort –VMName VmName 1 \\.\pipe\PipeName

    For example, the following command configures the first COM port on virtual machine TestVM to connect to named pipe TestPipe on the local computer.

    Set-VMComPort –VMName TestVM 1 \\.\pipe\TestPipe

For more information, see Generation 2 Virtual Machine Overview.

Related topics

Setting Up Kernel-Mode Debugging in Visual Studio

 

 

Send comments about this topic to Microsoft

표시:
© 2014 Microsoft