windbg 源码调试的必要条件:
1. 源代码的路路径,可以通过Ctrl + P快捷键或通过.srcpath 命令来设置。
2. 符号路径, 可以通过Ctrl + S快捷键或通过.sympath 命令来设置。
3. imagePath, 可以通过Ctrl + S快捷键或.exepath命令来设置。
c++源码说明:
#include <windows.h>
int main ()
{
printf ("debug ok.");
}
cl /c /Zi xxx.cpp
link /subsystem:console /DEBUG xxx.obj
其中 /Zi 编译选项和 /DEBUG 链接选项是必须的,切忌。
asm 源码说明:
.386
.model flat, stdcall
option casemap :none case sensitive
include windows.inc
include user32.inc
includelib user32.lib
include kernel32.inc
includelib kernel32.lib
.data
szCaption db 'A MessageBox', 0
szTest db 'debug ok.', 0
.code
start
invoke MessageBox, NULL, offset szText, offset szCaption, MB_OK
invoke ExitProcess, NULL
end start
ml /c /coff /Zi xxx.asm
link /subsystem:windows /DEBUG xxx.obj
其中 /Zi 编译选项和 /DEBUG 链接选项是必须的,切忌。
这样就可以通过windbg 来进行win32 汇编程序和 c++ 程序的调试了。