Kernel Debugging: WinDbg and Virtual PC
My new job has me doing a lot of device driver development, which naturally leads to quite a bit kernel debugging and system crashes. Thankfully, with WinDbg and Virtual PC it is simple to set up kernel debugging for a virtual machine. Since I am developing for a Windows environment, I am using Virtual PC 2007 and WinDbg. This process will also work for Virtual PC 2004. This is all probably possible with VMWare, Virtual Box, or any other virtual machine program out there, I am just not sure of the steps. The following steps are all you need to get debugging, assuming that you have a Windows virtual machine already set up:
Step 1: Edit the settings of you virtual machine to use a named pipe for a COM port
Step 2: Edit boot.ini file on the virtual machine.
Right-click on My Computer
Edit start-up file manually:
/DEBUG /DEBUGPORT = COM1 /BAUDRATE=115200
I like to add a second line here instead. Copy the last line, and append it with the above line:
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect
/DEBUG /DEBUGPORT=COM1 /BAUDRATE=115200
This will give you two different boot options, one for debugging and the other for normal use.
Step 3: Set up WinDbg for remote debugging over COM1.
This can be done through the File -> Kernel Debug menu, but I prefer to make a shortcut so I can have multiple different types of debugging environments.
Create a shortcut that points to WinDbg.exe and add the the necessary command-line arguments. Your shortcut target should look something like this:
"C:\Program Files\Debugging Tools for Windows\windbg.exe" -k com:pipe,port=\\.\pipe\vpcdebug,resets=10
This is all you need to do to set up kernel debugging. Be sure to start the VM before WinDbg so that it has a chance to create the named pipe. Also, make sure you download the correct symbols for your environment. For example: