借助VMware实现单机使用WinDbg进行调试的方法。
安裝VMware Workstation 6.0, WinDbg。
具体步骤如下:
1 设置 VMware 的虚拟com
1.1 运行 VMware ,点击 "Edit virtual machine settings"
1.2 点击 "Add..." 来运行 VMware 的 Hardware Wizard

1.3 选择 "Serial Port",点 "下一步"

1.4 选择 "Output to named pipe",点 "下一步"

1.5 第一框里保持默认的 \\.\pipe\com_1 <==== 此可為任何名
第二框里选"This end is the server."
第三框里选"The other end is an application."
选中 "Connect at power on"
然后点击 "Advanced>>"

1.6 选中 "Yield CPU on poll"(VMware Support 中提到了这一点),然后点完成。

1.7 这样就完成了虚拟com的设置。

1.8 重新启动 VM。
2 设置 VMware 虚拟出来的 guest os
现在 power on 虚拟出来的 guest os
2.1 设置boot.ini
在c:\下,可以找到boot.ini,可以用记事本打开它。我们需要在 guest os 的启动项上加些参数,才能够使用WinDbg调试它。我们可以在现有的行后面直接加参数,不过强烈推荐复制一个新行,在新行的后面加参数。这样在调试启动有问题的时候,我们可以方便的换回原来的启动方式。下面就是我改好的boot.ini。
其中 " multi(0)disk(0)rdisk(0)partition(1)\WINNT="Microsoft Windows XP Professional" /fastdetect "
是原来的行。
" multi(0)disk(0)rdisk(0)partition(1)\WINNT="Microsoft Windows XP Professional - debug" /fastdetect /noguiboot/debug /debugport=com1 /baudrate=115200" 新加為用于 WinDbg 调试的行。
------------------------------------------------------------------------------------------
[boot loader]
timeout=10
default=multi(0)disk(0)rdisk(0)partition(1)\WINNT
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINNT="Microsoft Windows XP Professional" /fastdetect
multi(0)disk(0)rdisk(0)partition(1)\WINNT="Microsoft Windows XP Professional - debug" /fastdetect /debug /debugport=com1 /baudrate=115200
-------------------------------------------------------------------------------------------
这里还要注意的是,timeout不要为0,否则直接启动默认的项。新行后面加上了参数 /debug /debugport=com1 /baudrate=115200 ,可以看到 debugport=com1 ,baudrate=115200 。参数的具体作用,可以参考 WinDbg 的帮助文件。
2.2 设置com1端口的速度
在 guest os 的设备管理器中把com1端口的速度也就是"每秒位数"项,设为和上面一样的115200。
3 设置 WinDbg
我们需要告诉WinDbg通过pipe进行连接和连接的速度。可以在命令提示符(cmd.exe)下加参数
-b -k com:port=\\.\pipe\com_1,baud=11520,pipe 运行WinDbg(VMware Support 中没有提到 baud=11520 这个参数,其实这是个比较重要的参数)。更方便的方法是在桌面建立一个WinDbg的快捷方式,在该快捷方式的属性,"目标"框中,加上参数 -k com:port=\\.\pipe\com_1,baud=11520,pipe 。这样运行这个快捷方式启动的WinDbg就完成了设置。参数的具体作用,可以参考 WinDbg 的帮助文件。