KMDF driver debugging on Hyper-V VM's

Hi,

I have just started working on WDF. I wanted to debug one of the sample driver provided by WDK.

I have couple of VM’s hosted on Hyper-V hypervisor. I am using one VM for development purpose and other to test driver implementation. I have setup target machine for debugging with the help of following link.

http://blogs.technet.com/b/askcore/archive/2013/07/02/how-to-live-debug-a-vm-in-hyper-v.aspx?Redirected=true

In this document they have explained about having development setup on Hyper-V hypervisor itself. In my case I am using VM hosted on Hyper-V for development purpose and which will have windbg running on it.

On my setup windbg is not able to connect to target machine, it says “Waiting to reconnect…” and “Debuggee not connected”.

I tried similar stuffs by setting up named pipe for both (dev and test) VM’s on ESX, WinDbg could successfully connect to target machine hosted on ESX. I am not sure why it is not working for Hyper-V.?

Could you please provide your inputs to resolve this issue?

Thanks in advance.

Hello Mr. Amit

1st the link you have shared here is not opening.
2nd kindly recheck your setting with this.

Examples: Debugging over a Virtual Serial Port http://www.vmware.com/support/ws5/doc/ws_devices_serial_advanced_example_debugging.html

Connecting an Application on the Host to a Virtual Machine http://www.vmware.com/support/ws5/doc/ws_devices_serial_host_app_to_vm.html
Set up the virtual serial port in a virtual machine to connect to an application on the host computer.

  1. In VMware Workstation
  2. Go to VM > Settings
  3. Click Add button.
  4. Serial Port then Next
  5. Output to named pipe then Next
  6. Use default pipe name (\.\pipe\com_1)or as per user choice in this format, \.\pipe<namedpipe>
    7. Select This end is the server, if you plan to start this end of the connection first. or else This end is the client.
    8. Select The other end is an application
    9. By default Connect at power on and Yield CPU on poll
    10. Click Advanced if you want to configure this serial port to use polled mode. This option is of interest primarily to developers who are using debugging tools that communicate over a serial connection. For more information, see Special Configuration Options for Advanced Users.
    11. Finish, power on virtual machine.

    After Power on the Virtual Machine
    12. VM > Removable Devices > Serial Port (n) > Connect, if not.

    Now, virtual serial port is ready to use.


    Copy all four files to .cat, .inf, .sys & .dll into the target computer then add driver by using device manager on target computer

    Use KmdfSmall page for all the things to setup Visual Studio Manually Configure debuggers and do not provision
    First Attach process to attach the driver with virtual machine Then Debug process

    http://msdn.microsoft.com/en-in/library/windows/hardware/jj200334(v=vs.85).aspx

    After all go to the again KmdfSmall page for further activities


    http://stackoverflow.com/questions/14790579/visual-studio-2012-remote-kernel-debugging-vm

    Kernel-Mode Debugging in a VM using Visual Studio 2012
    http://www.codeproject.com/Tips/545835/Kernel-Mode-Debugging-in-a-VM-using-Visual-Studio

    Introduction
    This article is about how to setup Kernel-Mode debugging in a VM using Visual Studio 2012. This article will be helpful for people new to driver development that wish to create, build, deploy, and debug a simple “HelloKernel”. project.
    Background
    The setup process can be divided to three parts:
    ? Setting up the Virtual Machine
    ? Setting up Visual Studio 2012
    ? Setting up your HelloKernel Project
    Each part will be explained step by step.
    How to Setup the Virtual Machine
    The Virtual Machine setup was tested on VMWare 9.0 running Windows 7 x64 OS.
    ? Create a new VM, use default settings (tested on VmWare, Win7 x64)
    ? Add a serial port to the VM, follow these steps:
    o Right click VM -> Settings -> Add -> Serial Port -> Output to named pipe
    o Named pipe = \.\pipe\com_2
    o First Combobox = The end is the server
    o Second Combobox = The other end is an application
    o Connect at power on = Checked
    o Finish
    o Yield CPU on poll = Checked
    ? In the VM, in an elevated Command Prompt window, enter the following commands:
    o bcdedit /debug on
    o bcdedit /dbgsettings serial debugport:2 baudrate:115200
    o
    ? In Windows, search for “Manage advanced sharing settings”:
    o -Set “Turn on file and printer sharing”
    o -Set “Turn off password protected sharing”
    o
    ? In Windows, search for “Computer Management”:
    o -Local Users and Groups -> Users:
    o -Administrator -> Right Click -> Properties -> Uncheck Account is disabled
    o -Administrator -> Right Click -> Set Password -> Set your password
    ?
    ? Reboot the VM
    How to Setup Visual Studio 2012
    ? Install Visual Studio 2012 and WDK 8.
    ? On the main toolbar, press Driver-> Test -> Configure Computers -> Add New Computer:
    o Computer name = VM name
    o Select Provision computer and choose debugger settings
    o Next
    o Connection Type = Serial
    o Pipe = Checked
    o Reconnect = Checked
    o Port = \.\pipe\com_2
    o Target Port = com2
    o Next -> Finish
    (Don’t worry if Status is Undetermined)
    ? You may be prompt for Username\Password, enter Administrator\YourPassword
    ? Important! Currently Visual Studio 2012 has a weird defect that causes the steps above to fail if your Windows username has spaces in it, The active username must have no spaces!
    How to Setup Your HelloKernel Project
    ? Use the following tutorial to create your HelloKernel project: http://msdn.microsoft.com/en-us/library/windows/hardware/hh439665(v=vs.85).aspx
    ? In order to debug your project do the following: -Press F5 -When VS12 changes to DebugMode, on the main toolbar press Debug -> Break All -In the “Debugger Immediate Window” write the following commands:
    o -bu HelloKernel!DriverEntry (tells the debugger to break on DriverEntry)
    o -g (Tells the debugger to continue).
    ? Your code should break on DriverEntry, and you can start debugging

    How to: Specify Symbol Locations and Loading Behavior
    Option to load Symbol or .pdb files
    http://msdn.microsoft.com/en-us/library/vstudio/x54fht41(v=vs.100).aspx
    http://msdn.microsoft.com/en-in/library/windows/hardware/ff560260(v=vs.85).aspx
    ________________________________________

    No need for every time attach to process in VS

    I think you have already setup everything, only you need to re-check.

I’d like to join

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: 21 November 2013 14:13
To: Kernel Debugging Interest List
Subject: RE:[windbg] KMDF driver debugging on Hyper-V VM’s

Hello Mr. Amit

1st the link you have shared here is not opening.
2nd kindly recheck your setting with this.

Examples: Debugging over a Virtual Serial Port
http://www.vmware.com/support/ws5/doc/ws_devices_serial_advanced_example_deb
ugging.html

Connecting an Application on the Host to a Virtual Machine
http://www.vmware.com/support/ws5/doc/ws_devices_serial_host_app_to_vm.html
Set up the virtual serial port in a virtual machine to connect to an
application on the host computer.

  1. In VMware Workstation
  2. Go to VM > Settings
  3. Click Add button.
  4. Serial Port then Next
  5. Output to named pipe then Next
  6. Use default pipe name (\.\pipe\com_1)or as per user choice in this
    format, \.\pipe<namedpipe>
    7. Select This end is the server, if you plan to start this end of the
    connection first. or else This end is the client.
    8. Select The other end is an application
    9. By default Connect at power on and Yield CPU on poll
    10. Click Advanced if you want to configure this serial port to use
    polled mode. This option is of interest primarily to developers who are
    using debugging tools that communicate over a serial connection. For more
    information, see Special Configuration Options for Advanced Users.
    11. Finish, power on virtual machine.

    After Power on the Virtual Machine
    12. VM > Removable Devices > Serial Port (n) > Connect, if not.

    Now, virtual serial port is ready to use.


    Copy all four files to .cat, .inf, .sys & .dll into the target computer then
    add driver by using device manager on target computer

    Use KmdfSmall page for all the things to setup Visual Studio Manually
    Configure debuggers and do not provision
    First Attach process to attach the driver with virtual machine Then Debug
    process

    http://msdn.microsoft.com/en-in/library/windows/hardware/jj200334(v=vs.85).a
    spx

    After all go to the again KmdfSmall page for further activities


    http://stackoverflow.com/questions/14790579/visual-studio-2012-remote-kernel
    -debugging-vm

    Kernel-Mode Debugging in a VM using Visual Studio 2012
    http://www.codeproject.com/Tips/545835/Kernel-Mode-Debugging-in-a-VM-using-V
    isual-Studio

    Introduction
    This article is about how to setup Kernel-Mode debugging in a VM using
    Visual Studio 2012. This article will be helpful for people new to driver
    development that wish to create, build, deploy, and debug a simple
    “HelloKernel”. project.
    Background
    The setup process can be divided to three parts:
    ? Setting up the Virtual Machine
    ? Setting up Visual Studio 2012
    ? Setting up your HelloKernel Project
    Each part will be explained step by step.
    How to Setup the Virtual Machine
    The Virtual Machine setup was tested on VMWare 9.0 running Windows 7 x64 OS.
    ? Create a new VM, use default settings (tested on VmWare, Win7 x64)
    ? Add a serial port to the VM, follow these steps:
    o Right click VM -> Settings -> Add -> Serial Port -> Output to named
    pipe
    o Named pipe = \.\pipe\com_2
    o First Combobox = The end is the server
    o Second Combobox = The other end is an application
    o Connect at power on = Checked
    o Finish
    o Yield CPU on poll = Checked
    ? In the VM, in an elevated Command Prompt window, enter the following
    commands:
    o bcdedit /debug on
    o bcdedit /dbgsettings serial debugport:2 baudrate:115200
    o
    ? In Windows, search for “Manage advanced sharing settings”:
    o -Set “Turn on file and printer sharing”
    o -Set “Turn off password protected sharing”
    o
    ? In Windows, search for “Computer Management”:
    o -Local Users and Groups -> Users:
    o -Administrator -> Right Click -> Properties -> Uncheck
    Account is disabled
    o -Administrator -> Right Click -> Set Password -> Set your
    password
    ?
    ? Reboot the VM
    How to Setup Visual Studio 2012
    ? Install Visual Studio 2012 and WDK 8.
    ? On the main toolbar, press Driver-> Test -> Configure Computers ->
    Add New Computer:
    o Computer name = VM name
    o Select Provision computer and choose debugger settings
    o Next
    o Connection Type = Serial
    o Pipe = Checked
    o Reconnect = Checked
    o Port = \.\pipe\com_2
    o Target Port = com2
    o Next -> Finish
    (Don’t worry if Status is Undetermined)
    ? You may be prompt for Username\Password, enter
    Administrator\YourPassword
    ? Important! Currently Visual Studio 2012 has a weird defect that
    causes the steps above to fail if your Windows username has spaces in it,
    The active username must have no spaces!
    How to Setup Your HelloKernel Project
    ? Use the following tutorial to create your HelloKernel project:
    http://msdn.microsoft.com/en-us/library/windows/hardware/hh439665(v=vs.85).a
    spx
    ? In order to debug your project do the following: -Press F5 -When
    VS12 changes to DebugMode, on the main toolbar press Debug -> Break All -In
    the “Debugger Immediate Window” write the following commands:
    o -bu HelloKernel!DriverEntry (tells the debugger to break on
    DriverEntry)
    o -g (Tells the debugger to continue).
    ? Your code should break on DriverEntry, and you can start debugging

    How to: Specify Symbol Locations and Loading Behavior
    Option to load Symbol or .pdb files
    http://msdn.microsoft.com/en-us/library/vstudio/x54fht41(v=vs.100).aspx
    http://msdn.microsoft.com/en-in/library/windows/hardware/ff560260(v=vs.85).a
    spx
    ________________________________________

    No need for every time attach to process in VS

    I think you have already setup everything, only you need to re-check.


    WINDBG is sponsored by OSR

    OSR is hiring!! Info at http://www.osr.com/careers

    For our schedule of WDF, WDM, debugging and other seminars visit:
    http://www.osr.com/seminars

    To unsubscribe, visit the List Server section of OSR Online at
    http://www.osronline.com/page.cfm?name=ListServer