Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

Hyper-V Kernel Debugging

OSR_Community_UserOSR_Community_User Member Posts: 110,217
I've decided to try out Hyper-V this week, and I've heard here and there
that Hyper-V allows for really quick kernel debugging. Is this true? How do
I go about kernel debugging 'properly' on Hyper-V?

-Brandon

Comments

  • Maxim_S._ShatskihMaxim_S._Shatskih Member Posts: 10,396
    Redirect the guest's COM1 to a pipe, and then use this pipe name in WinDbg's command line (see WinDbg docs).

    --
    Maxim S. Shatskih
    Windows DDK MVP
    [email protected]
    http://www.storagecraft.com

    "Brandon Falk" <[email protected]> wrote in message news:[email protected]
    I've decided to try out Hyper-V this week, and I've heard here and there that Hyper-V allows for really quick kernel debugging. Is this true? How do I go about kernel debugging 'properly' on Hyper-V?


    -Brandon
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    Is it any faster than 115200, or is it just a typical COM debugging session?

    -Brandon

    On Mon, Nov 5, 2012 at 3:14 PM, Maxim S. Shatskih wrote:

    > Redirect the guest's COM1 to a pipe, and then use this pipe name in
    > WinDbg's command line (see WinDbg docs).
    >
    > --
    > Maxim S. Shatskih
    > Windows DDK MVP
    > [email protected]
    > http://www.storagecraft.com
    >
    > "Brandon Falk" wrote in message
    > news:[email protected]
    > I've decided to try out Hyper-V this week, and I've heard here and there
    > that Hyper-V allows for really quick kernel debugging. Is this true? How do
    > I go about kernel debugging 'properly' on Hyper-V?
    >
    >
    > -Brandon
    >
    > ---
    > NTDEV is sponsored by OSR
    >
    > 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
    >
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,152
    Brandon Falk wrote:
    > Is it any faster than 115200, or is it just a typical COM debugging
    > session?

    You should be able to answer that. It's all virtual. There is no
    serial hardware involved, so it runs infinitely fast. So to speak.

    --
    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    I've had issues with VMWare where the emulated hardware emulates the speed
    as well. I guess I'll test it out to see. Hopefully it's infinitely fast :)

    -Brandon

    On Mon, Nov 5, 2012 at 4:02 PM, Tim Roberts wrote:

    > Brandon Falk wrote:
    > > Is it any faster than 115200, or is it just a typical COM debugging
    > > session?
    >
    > You should be able to answer that. It's all virtual. There is no
    > serial hardware involved, so it runs infinitely fast. So to speak.
    >
    > --
    > Tim Roberts, [email protected]
    > Providenza & Boekelheide, Inc.
    >
    >
    > ---
    > NTDEV is sponsored by OSR
    >
    > 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
    >
  • Bill_WandelBill_Wandel Member - All Emails Posts: 237
    It is not infinitely fast.



    Bill Wandel



    From: [email protected]
    [mailto:[email protected]] On Behalf Of Brandon Falk
    Sent: Monday, November 05, 2012 5:09 PM
    To: Windows System Software Devs Interest List
    Subject: Re: [ntdev] Hyper-V Kernel Debugging



    I've had issues with VMWare where the emulated hardware emulates the speed
    as well. I guess I'll test it out to see. Hopefully it's infinitely fast :)



    -Brandon

    On Mon, Nov 5, 2012 at 4:02 PM, Tim Roberts wrote:

    Brandon Falk wrote:
    > Is it any faster than 115200, or is it just a typical COM debugging
    > session?

    You should be able to answer that. It's all virtual. There is no
    serial hardware involved, so it runs infinitely fast. So to speak.

    --
    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.



    ---
    NTDEV is sponsored by OSR

    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



    --- NTDEV is sponsored by OSR 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
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    Hi All,

    I am new to KMDF USB driver.
    I need to develop a USB Function Driver to implement a USB CDC ACM profile.


    Output:

    1) Device Manager should display the USB CDC ACM profiles as virtual COM port

    2) When teraterm/Hyperterminal connected to the Virtual COM port, AT command /response should be working through the port
    Can anyone let me know how to proceed?
    I also want to know the difference between Virtual Serial port and usb cdc acm class driver.

    Thanks in advance,
    Shruthi




    From: [email protected] [mailto:[email protected]] On Behalf Of Bill Wandel
    Sent: Tuesday, November 06, 2012 3:48 AM
    To: Windows System Software Devs Interest List
    Subject: RE: [ntdev] Hyper-V Kernel Debugging

    It is not infinitely fast.

    Bill Wandel

    From: [email protected] [mailto:[email protected]] On Behalf Of Brandon Falk
    Sent: Monday, November 05, 2012 5:09 PM
    To: Windows System Software Devs Interest List
    Subject: Re: [ntdev] Hyper-V Kernel Debugging

    I've had issues with VMWare where the emulated hardware emulates the speed as well. I guess I'll test it out to see. Hopefully it's infinitely fast :)

    -Brandon
    On Mon, Nov 5, 2012 at 4:02 PM, Tim Roberts > wrote:
    Brandon Falk wrote:
    > Is it any faster than 115200, or is it just a typical COM debugging
    > session?
    You should be able to answer that. It's all virtual. There is no
    serial hardware involved, so it runs infinitely fast. So to speak.

    --
    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.


    ---
    NTDEV is sponsored by OSR

    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

    --- NTDEV is sponsored by OSR 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

    ---
    NTDEV is sponsored by OSR

    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

    ________________________________
    SASKEN BUSINESS DISCLAIMER: This message may contain confidential, proprietary or legally privileged information. In case you are not the original intended Recipient of the message, you must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message and you are requested to delete it and inform the sender. Any views expressed in this message are those of the individual sender unless otherwise stated. Nothing contained in this message shall be construed as an offer or acceptance of any offer by Sasken Communication Technologies Limited ("Sasken") unless sent with that express intent and with due authority of Sasken. Sasken has taken enough precautions to prevent the spread of viruses. However the company accepts no liability for any damage caused by any virus transmitted by this email.
    Read Disclaimer at http://www.sasken.com/extras/mail_disclaimer.html
  • Maxim_S._ShatskihMaxim_S._Shatskih Member Posts: 10,396
    There is no speed emulation in Hyper-V's COM port, so, it is very fast (though not infinitely).

    According to what MS's people told on this forum once, it was designed with WinDbg in mind, if not even _for_ WinDbg.

    --
    Maxim S. Shatskih
    Windows DDK MVP
    [email protected]
    http://www.storagecraft.com

    "Brandon Falk" <[email protected]> wrote in message news:[email protected]
    I've had issues with VMWare where the emulated hardware emulates the speed as well. I guess I'll test it out to see. Hopefully it's infinitely fast :)


    -Brandon


    On Mon, Nov 5, 2012 at 4:02 PM, Tim Roberts <[email protected]> wrote:

    Brandon Falk wrote:
    > Is it any faster than 115200, or is it just a typical COM debugging
    > session?


    You should be able to answer that. It's all virtual. There is no
    serial hardware involved, so it runs infinitely fast. So to speak.

    --
    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.



    ---
    NTDEV is sponsored by OSR

    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
  • Petr_KurtinPetr_Kurtin Member Posts: 275
    please read new windbg help topic for Hyper-V role: "Setting Up Network
    Debugging of a Virtual Machine Host"





    From: [email protected]
    [mailto:[email protected]] On Behalf Of Brandon Falk
    Sent: Monday, November 05, 2012 7:18 PM
    To: Windows System Software Devs Interest List
    Subject: [ntdev] Hyper-V Kernel Debugging



    I've decided to try out Hyper-V this week, and I've heard here and there
    that Hyper-V allows for really quick kernel debugging. Is this true? How do
    I go about kernel debugging 'properly' on Hyper-V?



    -Brandon

    --- NTDEV is sponsored by OSR 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
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    Feels a lot like 115200 to me. Although I'm using a Win XP VM right now. Is
    there some special configuration besides typical bcdedit/boot.ini settings
    to add debugging? I'm going to try out a modern Windows 8 vm with network
    and serial debugging and do some testing.

    -Brandon

    On Tue, Nov 6, 2012 at 7:58 AM, Petr Kurtin wrote:

    > please read new windbg help topic for Hyper-V role: ?Setting Up Network
    > Debugging of a Virtual Machine Host?****
    >
    > ** **
    >
    > ** **
    >
    > *From:* [email protected] [mailto:
    > [email protected]] *On Behalf Of *Brandon Falk
    > *Sent:* Monday, November 05, 2012 7:18 PM
    >
    > *To:* Windows System Software Devs Interest List
    > *Subject:* [ntdev] Hyper-V Kernel Debugging****
    >
    > ** **
    >
    > I've decided to try out Hyper-V this week, and I've heard here and there
    > that Hyper-V allows for really quick kernel debugging. Is this true? How do
    > I go about kernel debugging 'properly' on Hyper-V?****
    >
    > ** **
    >
    > -Brandon****
    >
    > --- NTDEV is sponsored by OSR 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****
    >
    > ---
    > NTDEV is sponsored by OSR
    >
    > 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
    >
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    Petr, I'm pretty sure that Brandon was interested in debugging a guest, not the host. And while it is possible to debug the Hyper-V parent partition using network debugging, it's more interesting for most people to debug the guest.

    If the guest is Windows 8 or Server 2012, or if you manually copy kdvm.dll from Windows 8 to Windows 7, you can debug the guest as if it were a network debugging target, but without ever putting it on a network. We've added a debugger transport DLL which passes packets to the Hyper-V parent for placement on the network. This requires a little extra setup, and the integration didn't make it all the way into Visual Studio. So if you're comfortable using Windbg or Kd, you can enable another debugging path which is very fast and which doesn't incur the overhead of the emulated serial port for the guest.

    To set it up in the guest OS, you type, for example:

    bcdedit /set dbgtransport kdvm.dll
    bcdedit /set {default} loadoptions host_ip="1.2.3.4",host_port="50000",encryption_key="cl.ea.rt.ext"
    bcdedit /set debug on

    The encryption key is up to you, but must be validly formed. The port is a dummy value which is ignored.

    In the host OS, you tell it which guest(s) you want to enable this for and which ports to use, using the Hyper-V WMI interface. The port is actually used here. (Pick a useful and valid port.) I use a PowerShell script to do this, and it is below.

    To start windbg or kd.exe in a way that will connect to this, type:

    windbg -k net:port=50000,target=nameofhostmachinehere,key=cl.ea.rt.ext

    Note again that this isn't talking to the guest's networking stack. It's talking to the parent OS's networking stack, using the parent OS's name. The guest can be network connected, or not.

    You can run the debugger itself either in the Parent OS or somewhere else. To the debugger, this is just another network debugging session.


    - Jake Oshins
    Windows Hyper-V Team

    Powershell script begins here:

    #
    # Argument initialization
    #

    $nextarg = "none"
    $DebugPort = "unassigned"
    $targetcomputer = "."
    $VMName = ""
    $AutoAssign = "false"
    $DebugOff = "false"

    function funHelp()
    {
    [email protected]"

    DESCRIPTION:
    NAME: synthdebug.ps1
    Displays (and optionally sets) the debugport for synthetic debugging.

    PARAMETERS:
    -computerName Specifies the name of the computer upon which to run the script
    -help prints help file
    -vmname name of the VM of interest
    -port (optional) ID of the channel to use for debugging
    -debugoff
    -autoassign

    SYNTAX:
    synthdebug.ps1 [-computerName targetcomputer] -vmname NameOfVM [-port PortNumber]

    "@
    $helpText
    exit
    }


    foreach ($argument in $args)
    {
    # parse commands with no following arguments
    switch ($argument)
    {
    "?" {funHelp}
    "help" {funHelp}
    "-help" {funHelp}
    "/?" {funHelp}
    "-?" {funHelp}
    "autoassign" {$AutoAssign = "true"}
    "-autoassign" {$AutoAssign = "true"}
    "/autoassign" {$AutoAssign = "true"}
    "debugoff" {$DebugOff = "true"}
    "-debugoff" {$DebugOff = "true"}
    "/debugoff" {$DebugOff = "true"}
    default {}
    }

    # parse values that followed a switch

    switch ($nextarg)
    {
    "vmname" {$VMName = $argument}
    "-vmname" {$VMName = $argument}
    "/vmname" {$VMName = $argument}
    "port" {$DebugPort = $argument}
    "-port" {$DebugPort = $argument}
    "/port" {$DebugPort = $argument}
    "-computername" {$targetcomputer = $argument}
    default {}
    }

    $nextarg = $argument
    }

    if ($VMName -eq "")
    {
    funHelp
    }

    #Get a VMManagementService object
    $VMManagementService = gwmi -class "Msvm_VirtualSystemManagementService" -namespace "root\virtualization" -computername $targetcomputer

    #Get the VM object that we want to modify
    $query = "SELECT * FROM Msvm_ComputerSystem WHERE ElementName='" + $VMName + "'"
    $VM = gwmi -query $query -namespace "root\virtualization" -computername $targetcomputer

    #Get the VirtualSystemGlobalSettingData of the VM we want to modify
    $query = "Associators of {$VM} WHERE AssocClass=MSVM_ElementSettingData ResultClass=Msvm_VirtualSystemGlobalSettingData"
    $VMSystemGlobalSettingData = gwmi -query $query -namespace "root\virtualization" -computername $targetcomputer

    # Set a new debugport
    if ($DebugPort -ne "unassigned")
    {
    #Change the ElementName property
    $VMSystemGlobalSettingData.DebugPort = $DebugPort
    $VMSystemGlobalSettingData.DebugPortEnabled = 1

    #Update the VM with ModifyVirtualSystem
    $Result = $VMManagementService.ModifyVirtualSystem($VM.__PATH,$VMSystemGlobalSettingData.psbase.GetText(1))
    }

    # Enable auto assigned debug ports
    if ($AutoAssign -ne "false")
    {
    #Change the ElementName property
    $VMSystemGlobalSettingData.DebugPortEnabled = 2

    #Update the VM with ModifyVirtualSystem
    $Result = $VMManagementService.ModifyVirtualSystem($VM.__PATH,$VMSystemGlobalSettingData.psbase.GetText(1))
    }

    # Turn off debugging
    if ($DebugOff -ne "false")
    {
    #Change the ElementName property
    $VMSystemGlobalSettingData.DebugPortEnabled = 0

    #Update the VM with ModifyVirtualSystem
    $Result = $VMManagementService.ModifyVirtualSystem($VM.__PATH,$VMSystemGlobalSettingData.psbase.GetText(1))
    }



    $VMSystemGlobalSettingData

    exit



    -------------------------------------------------------------------------


    From: [email protected] [mailto:[email protected]] On Behalf Of Petr Kurtin
    Sent: Tuesday, November 6, 2012 4:59 AM
    To: Windows System Software Devs Interest List
    Subject: RE: [ntdev] Hyper-V Kernel Debugging

    please read new windbg help topic for Hyper-V role: "Setting Up Network Debugging of a Virtual Machine Host"


    From: [email protected] [mailto:[email protected]] On Behalf Of Brandon Falk
    Sent: Monday, November 05, 2012 7:18 PM
    To: Windows System Software Devs Interest List
    Subject: [ntdev] Hyper-V Kernel Debugging

    I've decided to try out Hyper-V this week, and I've heard here and there that Hyper-V allows for really quick kernel debugging. Is this true? How do I go about kernel debugging 'properly' on Hyper-V?

    -Brandon
    --- NTDEV is sponsored by OSR 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

    ---
    NTDEV is sponsored by OSR

    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
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    Thanks a lot Jake!

    Would it be okay if I made a video of setting this all up and put it on
    YouTube? I'd be supplying the script you posted.

    Also, what is a good way to benchmark communication speeds in WinDbg? If
    there isn't a way, what would be a good way to write an
    extension/benchmarking script? I feel like it'd be nice to have.

    -Brandon

    On Wed, Nov 7, 2012 at 1:30 PM, Jake Oshins wrote:

    > Petr, I'm pretty sure that Brandon was interested in debugging a guest,
    > not the host. And while it is possible to debug the Hyper-V parent
    > partition using network debugging, it's more interesting for most people to
    > debug the guest.
    >
    > If the guest is Windows 8 or Server 2012, or if you manually copy kdvm.dll
    > from Windows 8 to Windows 7, you can debug the guest as if it were a
    > network debugging target, but without ever putting it on a network. We've
    > added a debugger transport DLL which passes packets to the Hyper-V parent
    > for placement on the network. This requires a little extra setup, and the
    > integration didn't make it all the way into Visual Studio. So if you're
    > comfortable using Windbg or Kd, you can enable another debugging path which
    > is very fast and which doesn't incur the overhead of the emulated serial
    > port for the guest.
    >
    > To set it up in the guest OS, you type, for example:
    >
    > bcdedit /set dbgtransport kdvm.dll
    > bcdedit /set {default} loadoptions
    > host_ip="1.2.3.4",host_port="50000",encryption_key="cl.ea.rt.ext"
    > bcdedit /set debug on
    >
    > The encryption key is up to you, but must be validly formed. The port is
    > a dummy value which is ignored.
    >
    > In the host OS, you tell it which guest(s) you want to enable this for and
    > which ports to use, using the Hyper-V WMI interface. The port is actually
    > used here. (Pick a useful and valid port.) I use a PowerShell script to
    > do this, and it is below.
    >
    > To start windbg or kd.exe in a way that will connect to this, type:
    >
    > windbg -k net:port=50000,target=nameofhostmachinehere,key=cl.ea.rt.ext
    >
    > Note again that this isn't talking to the guest's networking stack. It's
    > talking to the parent OS's networking stack, using the parent OS's name.
    > The guest can be network connected, or not.
    >
    > You can run the debugger itself either in the Parent OS or somewhere else.
    > To the debugger, this is just another network debugging session.
    >
    >
    > - Jake Oshins
    > Windows Hyper-V Team
    >
    > Powershell script begins here:
    >
    > #
    > # Argument initialization
    > #
    >
    > $nextarg = "none"
    > $DebugPort = "unassigned"
    > $targetcomputer = "."
    > $VMName = ""
    > $AutoAssign = "false"
    > $DebugOff = "false"
    >
    > function funHelp()
    > {
    > [email protected]"
    >
    > DESCRIPTION:
    > NAME: synthdebug.ps1
    > Displays (and optionally sets) the debugport for synthetic debugging.
    >
    > PARAMETERS:
    > -computerName Specifies the name of the computer upon which to run the
    > script
    > -help prints help file
    > -vmname name of the VM of interest
    > -port (optional) ID of the channel to use for debugging
    > -debugoff
    > -autoassign
    >
    > SYNTAX:
    > synthdebug.ps1 [-computerName targetcomputer] -vmname NameOfVM [-port
    > PortNumber]
    >
    > "@
    > $helpText
    > exit
    > }
    >
    >
    > foreach ($argument in $args)
    > {
    > # parse commands with no following arguments
    > switch ($argument)
    > {
    > "?" {funHelp}
    > "help" {funHelp}
    > "-help" {funHelp}
    > "/?" {funHelp}
    > "-?" {funHelp}
    > "autoassign" {$AutoAssign = "true"}
    > "-autoassign" {$AutoAssign = "true"}
    > "/autoassign" {$AutoAssign = "true"}
    > "debugoff" {$DebugOff = "true"}
    > "-debugoff" {$DebugOff = "true"}
    > "/debugoff" {$DebugOff = "true"}
    > default {}
    > }
    >
    > # parse values that followed a switch
    >
    > switch ($nextarg)
    > {
    > "vmname" {$VMName = $argument}
    > "-vmname" {$VMName = $argument}
    > "/vmname" {$VMName = $argument}
    > "port" {$DebugPort = $argument}
    > "-port" {$DebugPort = $argument}
    > "/port" {$DebugPort = $argument}
    > "-computername" {$targetcomputer = $argument}
    > default {}
    > }
    >
    > $nextarg = $argument
    > }
    >
    > if ($VMName -eq "")
    > {
    > funHelp
    > }
    >
    > #Get a VMManagementService object
    > $VMManagementService = gwmi -class "Msvm_VirtualSystemManagementService"
    > -namespace "root\virtualization" -computername $targetcomputer
    >
    > #Get the VM object that we want to modify
    > $query = "SELECT * FROM Msvm_ComputerSystem WHERE ElementName='" + $VMName
    > + "'"
    > $VM = gwmi -query $query -namespace "root\virtualization" -computername
    > $targetcomputer
    >
    > #Get the VirtualSystemGlobalSettingData of the VM we want to modify
    > $query = "Associators of {$VM} WHERE AssocClass=MSVM_ElementSettingData
    > ResultClass=Msvm_VirtualSystemGlobalSettingData"
    > $VMSystemGlobalSettingData = gwmi -query $query -namespace
    > "root\virtualization" -computername $targetcomputer
    >
    > # Set a new debugport
    > if ($DebugPort -ne "unassigned")
    > {
    > #Change the ElementName property
    > $VMSystemGlobalSettingData.DebugPort = $DebugPort
    > $VMSystemGlobalSettingData.DebugPortEnabled = 1
    >
    > #Update the VM with ModifyVirtualSystem
    > $Result =
    > $VMManagementService.ModifyVirtualSystem($VM.__PATH,$VMSystemGlobalSettingData.psbase.GetText(1))
    > }
    >
    > # Enable auto assigned debug ports
    > if ($AutoAssign -ne "false")
    > {
    > #Change the ElementName property
    > $VMSystemGlobalSettingData.DebugPortEnabled = 2
    >
    > #Update the VM with ModifyVirtualSystem
    > $Result =
    > $VMManagementService.ModifyVirtualSystem($VM.__PATH,$VMSystemGlobalSettingData.psbase.GetText(1))
    > }
    >
    > # Turn off debugging
    > if ($DebugOff -ne "false")
    > {
    > #Change the ElementName property
    > $VMSystemGlobalSettingData.DebugPortEnabled = 0
    >
    > #Update the VM with ModifyVirtualSystem
    > $Result =
    > $VMManagementService.ModifyVirtualSystem($VM.__PATH,$VMSystemGlobalSettingData.psbase.GetText(1))
    > }
    >
    >
    >
    > $VMSystemGlobalSettingData
    >
    > exit
    >
    >
    >
    > -------------------------------------------------------------------------
    >
    >
    > From: [email protected] [mailto:
    > [email protected]] On Behalf Of Petr Kurtin
    > Sent: Tuesday, November 6, 2012 4:59 AM
    > To: Windows System Software Devs Interest List
    > Subject: RE: [ntdev] Hyper-V Kernel Debugging
    >
    > please read new windbg help topic for Hyper-V role: "Setting Up Network
    > Debugging of a Virtual Machine Host"
    >
    >
    > From: [email protected] [mailto:
    > [email protected]] On Behalf Of Brandon Falk
    > Sent: Monday, November 05, 2012 7:18 PM
    > To: Windows System Software Devs Interest List
    > Subject: [ntdev] Hyper-V Kernel Debugging
    >
    > I've decided to try out Hyper-V this week, and I've heard here and there
    > that Hyper-V allows for really quick kernel debugging. Is this true? How do
    > I go about kernel debugging 'properly' on Hyper-V?
    >
    > -Brandon
    > --- NTDEV is sponsored by OSR 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
    >
    > ---
    > NTDEV is sponsored by OSR
    >
    > 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
    >
    >
    > ---
    > NTDEV is sponsored by OSR
    >
    > 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
    >
  • Jeffrey_Tippet_[MSFT]Jeffrey_Tippet_[MSFT] Member - All Emails Posts: 577
    My favorite two benchmarks are:

    !stacks 2 ndis!
    !ndiskd.pendingnbls

    Since these are the two things I do most often :)
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    This is a public forum. I'll never post anything here that you can't repeat.

    Thanks for asking though,
    Jake Oshins
    Microsoft

    From: Brandon Falk [mailto:[email protected]]
    Sent: Friday, November 16, 2012 1:07 PM
    To: Windows System Software Devs Interest List
    Cc: Jake Oshins
    Subject: Re: [ntdev] Hyper-V Kernel Debugging

    Thanks a lot Jake!

    Would it be okay if I made a video of setting this all up and put it on YouTube? I'd be supplying the script you posted.

    Also, what is a good way to benchmark communication speeds in WinDbg? If there isn't a way, what would be a good way to write an extension/benchmarking script? I feel like it'd be nice to have.

    -Brandon

    On Wed, Nov 7, 2012 at 1:30 PM, Jake Oshins > wrote:
    Petr, I'm pretty sure that Brandon was interested in debugging a guest, not the host. And while it is possible to debug the Hyper-V parent partition using network debugging, it's more interesting for most people to debug the guest.

    If the guest is Windows 8 or Server 2012, or if you manually copy kdvm.dll from Windows 8 to Windows 7, you can debug the guest as if it were a network debugging target, but without ever putting it on a network. We've added a debugger transport DLL which passes packets to the Hyper-V parent for placement on the network. This requires a little extra setup, and the integration didn't make it all the way into Visual Studio. So if you're comfortable using Windbg or Kd, you can enable another debugging path which is very fast and which doesn't incur the overhead of the emulated serial port for the guest.

    To set it up in the guest OS, you type, for example:

    bcdedit /set dbgtransport kdvm.dll
    bcdedit /set {default} loadoptions host_ip="1.2.3.4",host_port="50000",encryption_key="cl.ea.rt.ext"
    bcdedit /set debug on

    The encryption key is up to you, but must be validly formed. The port is a dummy value which is ignored.

    In the host OS, you tell it which guest(s) you want to enable this for and which ports to use, using the Hyper-V WMI interface. The port is actually used here. (Pick a useful and valid port.) I use a PowerShell script to do this, and it is below.

    To start windbg or kd.exe in a way that will connect to this, type:

    windbg -k net:port=50000,target=nameofhostmachinehere,key=cl.ea.rt.ext

    Note again that this isn't talking to the guest's networking stack. It's talking to the parent OS's networking stack, using the parent OS's name. The guest can be network connected, or not.

    You can run the debugger itself either in the Parent OS or somewhere else. To the debugger, this is just another network debugging session.


    - Jake Oshins
    Windows Hyper-V Team

    Powershell script begins here:

    #
    # Argument initialization
    #

    $nextarg = "none"
    $DebugPort = "unassigned"
    $targetcomputer = "."
    $VMName = ""
    $AutoAssign = "false"
    $DebugOff = "false"

    function funHelp()
    {
    [email protected]"

    DESCRIPTION:
    NAME: synthdebug.ps1
    Displays (and optionally sets) the debugport for synthetic debugging.

    PARAMETERS:
    -computerName Specifies the name of the computer upon which to run the script
    -help prints help file
    -vmname name of the VM of interest
    -port (optional) ID of the channel to use for debugging
    -debugoff
    -autoassign

    SYNTAX:
    synthdebug.ps1 [-computerName targetcomputer] -vmname NameOfVM [-port PortNumber]

    "@
    $helpText
    exit
    }


    foreach ($argument in $args)
    {
    # parse commands with no following arguments
    switch ($argument)
    {
    "?" {funHelp}
    "help" {funHelp}
    "-help" {funHelp}
    "/?" {funHelp}
    "-?" {funHelp}
    "autoassign" {$AutoAssign = "true"}
    "-autoassign" {$AutoAssign = "true"}
    "/autoassign" {$AutoAssign = "true"}
    "debugoff" {$DebugOff = "true"}
    "-debugoff" {$DebugOff = "true"}
    "/debugoff" {$DebugOff = "true"}
    default {}
    }

    # parse values that followed a switch

    switch ($nextarg)
    {
    "vmname" {$VMName = $argument}
    "-vmname" {$VMName = $argument}
    "/vmname" {$VMName = $argument}
    "port" {$DebugPort = $argument}
    "-port" {$DebugPort = $argument}
    "/port" {$DebugPort = $argument}
    "-computername" {$targetcomputer = $argument}
    default {}
    }

    $nextarg = $argument
    }

    if ($VMName -eq "")
    {
    funHelp
    }

    #Get a VMManagementService object
    $VMManagementService = gwmi -class "Msvm_VirtualSystemManagementService" -namespace "root\virtualization" -computername $targetcomputer

    #Get the VM object that we want to modify
    $query = "SELECT * FROM Msvm_ComputerSystem WHERE ElementName='" + $VMName + "'"
    $VM = gwmi -query $query -namespace "root\virtualization" -computername $targetcomputer

    #Get the VirtualSystemGlobalSettingData of the VM we want to modify
    $query = "Associators of {$VM} WHERE AssocClass=MSVM_ElementSettingData ResultClass=Msvm_VirtualSystemGlobalSettingData"
    $VMSystemGlobalSettingData = gwmi -query $query -namespace "root\virtualization" -computername $targetcomputer

    # Set a new debugport
    if ($DebugPort -ne "unassigned")
    {
    #Change the ElementName property
    $VMSystemGlobalSettingData.DebugPort = $DebugPort
    $VMSystemGlobalSettingData.DebugPortEnabled = 1

    #Update the VM with ModifyVirtualSystem
    $Result = $VMManagementService.ModifyVirtualSystem($VM.__PATH,$VMSystemGlobalSettingData.psbase.GetText(1))
    }

    # Enable auto assigned debug ports
    if ($AutoAssign -ne "false")
    {
    #Change the ElementName property
    $VMSystemGlobalSettingData.DebugPortEnabled = 2

    #Update the VM with ModifyVirtualSystem
    $Result = $VMManagementService.ModifyVirtualSystem($VM.__PATH,$VMSystemGlobalSettingData.psbase.GetText(1))
    }

    # Turn off debugging
    if ($DebugOff -ne "false")
    {
    #Change the ElementName property
    $VMSystemGlobalSettingData.DebugPortEnabled = 0

    #Update the VM with ModifyVirtualSystem
    $Result = $VMManagementService.ModifyVirtualSystem($VM.__PATH,$VMSystemGlobalSettingData.psbase.GetText(1))
    }



    $VMSystemGlobalSettingData

    exit



    -------------------------------------------------------------------------


    From: [email protected] [mailto:[email protected]] On Behalf Of Petr Kurtin
    Sent: Tuesday, November 6, 2012 4:59 AM
    To: Windows System Software Devs Interest List
    Subject: RE: [ntdev] Hyper-V Kernel Debugging
    please read new windbg help topic for Hyper-V role: "Setting Up Network Debugging of a Virtual Machine Host"


    From: [email protected] [mailto:[email protected]] On Behalf Of Brandon Falk
    Sent: Monday, November 05, 2012 7:18 PM
    To: Windows System Software Devs Interest List
    Subject: [ntdev] Hyper-V Kernel Debugging

    I've decided to try out Hyper-V this week, and I've heard here and there that Hyper-V allows for really quick kernel debugging. Is this true? How do I go about kernel debugging 'properly' on Hyper-V?

    -Brandon
    --- NTDEV is sponsored by OSR 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

    ---
    NTDEV is sponsored by OSR

    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


    ---
    NTDEV is sponsored by OSR

    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
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    Am having trouble getting Hyper-V debugging to work after following Jake's setup prescription, all I ever see is

    "Microsoft (R) Windows Debugger Version 6.2.9200.16384 AMD64
    Copyright (c) Microsoft Corporation. All rights reserved.

    Using NET for debugging
    Opened WinSock 2.0
    Waiting to reconnect."

    has anyone been successful in getting this to work?
  • Maxim_S._ShatskihMaxim_S._Shatskih Member Posts: 10,396
    Use emulated serial port instead of net, it works fine.

    --
    Maxim S. Shatskih
    Windows DDK MVP
    [email protected]
    http://www.storagecraft.com

    <[email protected]> wrote in message news:[email protected]
    > Am having trouble getting Hyper-V debugging to work after following Jake's setup prescription, all I ever see is
    >
    > "Microsoft (R) Windows Debugger Version 6.2.9200.16384 AMD64
    > Copyright (c) Microsoft Corporation. All rights reserved.
    >
    > Using NET for debugging
    > Opened WinSock 2.0
    > Waiting to reconnect."
    >
    > has anyone been successful in getting this to work?
    >
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    I got it working and it is much faster than serial port debugging.


    On Fri, Dec 28, 2012 at 10:54 AM, Maxim S. Shatskih
    wrote:

    > Use emulated serial port instead of net, it works fine.
    >
    > --
    > Maxim S. Shatskih
    > Windows DDK MVP
    > [email protected]
    > http://www.storagecraft.com
    >
    > wrote in message news:[email protected]
    > > Am having trouble getting Hyper-V debugging to work after following
    > Jake's setup prescription, all I ever see is
    > >
    > > "Microsoft (R) Windows Debugger Version 6.2.9200.16384 AMD64
    > > Copyright (c) Microsoft Corporation. All rights reserved.
    > >
    > > Using NET for debugging
    > > Opened WinSock 2.0
    > > Waiting to reconnect."
    > >
    > > has anyone been successful in getting this to work?
    > >
    >
    > ---
    > NTDEV is sponsored by OSR
    >
    > 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
    >
  • raj_rraj_r Member - All Emails Posts: 987
    On 12/29/12, Joseph Parness <[email protected]> wrote:
    > I got it working and it is much faster than serial port debugging.

    may we know why it wasn't working in the first place

    whose wand you got to make your spell

    what was the spell

    and what other Aramaic words did you uncover that "did what was said"
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    If people are interested I'll be happy to post what I learned.

    On Dec 28, 2012, at 9:00 PM, raj_r <[email protected]> wrote:

    > On 12/29/12, Joseph Parness <[email protected]> wrote:
    >> I got it working and it is much faster than serial port debugging.
    >
    > may we know why it wasn't working in the first place
    >
    > whose wand you got to make your spell
    >
    > what was the spell
    >
    > and what other Aramaic words did you uncover that "did what was said"
    >
    > ---
    > NTDEV is sponsored by OSR
    >
    > 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
  • Maxim_S._ShatskihMaxim_S._Shatskih Member Posts: 10,396
    >I got it working and it is much faster than serial port debugging.

    Then _emulated_ serial port? it is amazingly fast.

    --
    Maxim S. Shatskih
    Windows DDK MVP
    [email protected]
    http://www.storagecraft.com
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    From what I can tell there is no serial port emulation involved. I appears that the guys on the Hyper-V team installed hooks to allow for network emulation of some kind in conjunction with WMI, from what I have seen the speed is more like 1394 or faster.

    On Dec 29, 2012, at 5:22 AM, Maxim S. Shatskih <[email protected]> wrote:

    >> I got it working and it is much faster than serial port debugging.
    >
    > Then _emulated_ serial port? it is amazingly fast.
    >
    > --
    > Maxim S. Shatskih
    > Windows DDK MVP
    > [email protected]
    > http://www.storagecraft.com
    >
    >
    > ---
    > NTDEV is sponsored by OSR
    >
    > 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
  • Ken_JohnsonKen_Johnson Member - All Emails Posts: 1,559
    The emulated serial port transport is not particularly fast. All of the other transports are significantly higher performance, including in Hyper-V.

    - S (Msft)
    ________________________________
    From: Maxim S. Shatskih
    Sent: ?12/?29/?2012 5:23
    To: Windows System Software Devs Interest List
    Subject: Re:[ntdev] Hyper-V Kernel Debugging

    >I got it working and it is much faster than serial port debugging.

    Then _emulated_ serial port? it is amazingly fast.

    --
    Maxim S. Shatskih
    Windows DDK MVP
    [email protected]
    http://www.storagecraft.com


    ---
    NTDEV is sponsored by OSR

    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
  • KirillKirill Member Posts: 5
    Hi All.
    Jake Oshins, on what version of Hyper-V Server works yours script? I tried it on Hyper-V Server 2008 R2, but has no luck.

    D:\synthdebug.ps1:96 symbol:32
    + $VMSystemGlobalSettingData. <<<< DebugPort = $DebugPort
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

    Thanks.
  • Ken_JohnsonKen_Johnson Member - All Emails Posts: 1,559
    New to Win8/WS2012.

    - S (Msft)
    ________________________________
    From: [email protected]
    Sent: ?1/?16/?2013 23:55
    To: Windows System Software Devs Interest List
    Subject: RE:[ntdev] Hyper-V Kernel Debugging

    Hi All.
    Jake Oshins, on what version of Hyper-V Server works yours script? I tried it on Hyper-V Server 2008 R2, but has no luck.

    D:\synthdebug.ps1:96 symbol:32
    + $VMSystemGlobalSettingData. <<<< DebugPort = $DebugPort
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

    Thanks.

    ---
    NTDEV is sponsored by OSR

    OSR is HIRING!! See 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
  • KirillKirill Member Posts: 5
    That means that i can't use net debug thru Hyper-V feature because I am not able to set ports to use, using Hyper-V WMI interface? Or not?
  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    Server 2012.

    - Jake

    -----Original Message-----
    From: [email protected] [mailto:[email protected]] On Behalf Of [email protected]
    Sent: Wednesday, January 16, 2013 11:59 PM
    To: Windows System Software Devs Interest List
    Subject: RE:[ntdev] Hyper-V Kernel Debugging

    Hi All.
    Jake Oshins, on what version of Hyper-V Server works yours script? I tried it on Hyper-V Server 2008 R2, but has no luck.

    D:\synthdebug.ps1:96 symbol:32
    + $VMSystemGlobalSettingData. <<<< DebugPort = $DebugPort
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

    Thanks.

    ---
    NTDEV is sponsored by OSR

    OSR is HIRING!! See 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
  • Ken_JohnsonKen_Johnson Member - All Emails Posts: 1,559
    Not if you are using a host older than when the network debugging feature was invented, no.

    - S (Msft)
    ________________________________
    From: [email protected]
    Sent: ?1/?17/?2013 3:01
    To: Windows System Software Devs Interest List
    Subject: RE:[ntdev] Hyper-V Kernel Debugging

    That means that i can't use net debug thru Hyper-V feature because I am not able to set ports to use, using Hyper-V WMI interface? Or not?

    ---
    NTDEV is sponsored by OSR

    OSR is HIRING!! See 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
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Writing WDF Drivers 24 January 2022 Live, Online
Internals & Software Drivers 7 February 2022 Live, Online
Kernel Debugging 21 March 2022 Live, Online
Developing Minifilters 23 May 2022 Live, Online