none
How to debug windows device driver and what to debug if driver is installed on VM? RRS feed

  • Question

  • I'm using VS 2012 and VM on same machine.

    Host Win7_x64 and VM on same machine is again Win7_x64

    Debug using VS 2012, i.e using VS and pipe serial connection on VM.

    Everything is proper. I'm able to load driver on VM using VS's in built process to attach.

    I've build, link and install KmdfSmall driver given on microsoft website onto VM

    I've build, link and install another very small test driver onto VM.

    Yes, all drivers are showing very properly into device manager of VM.

    When ever I'm pressing break all onto host in debug mode into VS; all break points are also becoming read on .c and .cpp files.

    But the question comes here when I pressed f10 for checking code flow "No Source Code Available " window is getting open.

    Actually I'm not very much familiar that how and where it should go but as in normal C program case in VS during debug the pointer go ahead in source file so here in window device driver where it should go.

    thus how to debug driver here and what should I check to understand that driver is installed properly and working fine.

    Attaching few images to get better idea. It will let you know that how much I reached.

    Here I'm trying to debug NOTHING driver of OSR online

    http://www.osronline.com/article.cfm?article=390

    Kindly guide me to the best direction of what to debug and how in this windows device driver.

    One image is of host having VS and another image is of VM where driver has been installed.

    Please help me to debug the driver and understand its working.

    • Changed type Beginner15 Thursday, June 13, 2013 9:18 AM
    Wednesday, June 12, 2013 3:38 PM

Answers

  • Okay Sir,

    I think I got what you want to convey me.

    So, could you please provide me some code example or simply guide to the link which can give any practical feel that debug is going on i.e some source code of any driver which is not idle, any memory operation or any read or write operation.

    I mean to say I would like to know how does it works?. Means, if I begins debug what should come on Host machine and what should come on Client. Means any msg of debug.

    How do professional get to know either they are going into right direction of driver debug or not?

    Means any msg that driver has been install properly or driver is running or driver is asking some data or driver is giving any data.

    Kindly provide any pointer to get to know that how to debug and how to know debug is began and driver is working fine.

    Regards

    Matt

    • Marked as answer by Beginner15 Friday, June 14, 2013 6:53 AM
    Wednesday, June 12, 2013 11:47 PM
  • There is already quite a lot of sample sources, besides of the driver you already have. Just set the breakpoints on the paths that are going to be exercised. For this you should know what the driver does, but generally most of them have DriverEntry or AddDevice functions. May the Source be with you.

    How do professional get to know either they are going into right direction of driver debug or not?

    Test-driven development. Assume what the code should do (=design a test set) then write code that works correctly for this test set. Example scenario: installation of the driver. Expected outcome: the device shows up in the dev. manager, the machine does not crash. Another scenario: usermode app sends some ioctl and gets expected result. And so on.

    Good luck,

    -- pa

    Thursday, June 13, 2013 4:48 PM
  • Hello,

    On target, disable the driver meanwhile keep the VS into running debug mode onto host.
    Then restart the target, enable the driver as soon as enable the driver onto target  
    it will jump to VS running into debug mode onto host at the already settled breakpoint. then after just press F5 and go ahead.

    regards
    matt
    • Marked as answer by Beginner15 Sunday, June 16, 2013 4:08 AM
    Sunday, June 16, 2013 4:08 AM

All replies

  • Okay Sir,

    I think I got what you want to convey me.

    So, could you please provide me some code example or simply guide to the link which can give any practical feel that debug is going on i.e some source code of any driver which is not idle, any memory operation or any read or write operation.

    I mean to say I would like to know how does it works?. Means, if I begins debug what should come on Host machine and what should come on Client. Means any msg of debug.

    How do professional get to know either they are going into right direction of driver debug or not?

    Means any msg that driver has been install properly or driver is running or driver is asking some data or driver is giving any data.

    Kindly provide any pointer to get to know that how to debug and how to know debug is began and driver is working fine.

    Regards

    Matt

    • Marked as answer by Beginner15 Friday, June 14, 2013 6:53 AM
    Wednesday, June 12, 2013 11:47 PM
  • Hello,

    On target, disable the driver meanwhile keep the VS into running debug mode onto host.
    Then restart the target, enable the driver as soon as enable the driver onto target  
    it will jump to VS running into debug mode onto host at the already settled breakpoint. then after just press F5 and go ahead.

    regards
    matt
    • Marked as answer by Beginner15 Sunday, June 16, 2013 4:08 AM
    Sunday, June 16, 2013 4:08 AM
  • check this post  : Good article

    Debugging Windows Kernel/Device Drivers with Virtual machine from host machine


    MS Technologies Professional

    Sunday, June 16, 2013 3:27 PM
  • Really thanks MSProf,

    though article is good & old but still concepts lies into the same plate of basics and for that really thank you.

    regards

    matt

    Sunday, June 16, 2013 4:04 PM