Re: 用windbg调试一个简单的c++程序,bp设置断点不成功,很奇怪的错误提示
WinDbg
用windbg调试一个简单的c++程序,bp设置断点不成功,很奇怪的错误提示
初学
2014-06-28, 15:08 下午
我用visual c++2012写了个很简单的程序
int _tmain(int argc, _TCHAR* argv[])
{
int i=2;
++i;
int j=3;
++j;
return 0;
}
编译以后,debug版的exe和pdb目录都在这个目录:
C:\Users\a\Documents\Visual Studio 2012\Projects\ConsoleApplication1\Debug
然后我启动windbg(6.12.002.633.X86),Ctrl+E来打开一个可执行程序ConsoleApplication2.exe,然后观察.sympath/.srcpath都已经有了:
但是我试图设置断点的时候,就提示我Symbol文件找不到
CommandLine: "C:\Users\a\Documents\Visual Studio 2012\Projects\ConsoleApplication1\Debug\ConsoleApplication2.exe"
Symbol search path is: C:\Users\a\Documents\Visual Studio 2012\Projects\ConsoleApplication1\Debug
Executable search path is:
ModLoad: 012c0000 012e3000 ConsoleApplication2.exe
ModLoad: 77030000 7716c000 ntdll.dll
ModLoad: 75400000 754d4000 C:\Windows\system32\kernel32.dll
ModLoad: 750c0000 7510b000 C:\Windows\system32\KERNELBASE.dll
ModLoad: 56ad0000 56b9b000 C:\Windows\system32\MSVCP110D.dll
ModLoad: 0f0a0000 0f241000 C:\Windows\system32\MSVCR110D.dll
(8d0.a88): Break instruction exception - code 80000003 (first chance)
eax=00000000 ebx=00000000 ecx=002ff598 edx=770770f4 esi=fffffffe edi=00000000
eip=770d05a6 esp=002ff5b4 ebp=002ff5e0 iopl=0 nv up ei pl zr na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246
*** ERROR: Symbol file could not be found. Defaulted to export symbols for ntdll.dll -
ntdll!LdrVerifyImageMatchesChecksum+0x633:
770d05a6 cc int 3
0:000> .sympath
Symbol search path is: C:\Users\a\Documents\Visual Studio 2012\Projects\ConsoleApplication1\Debug
Expanded Symbol search path is: c:\users\a\documents\visual studio 2012\projects\consoleapplication1\debug
0:000> .srcpath
Source search path is: C:\Users\a\Documents\Visual Studio 2012\Projects\ConsoleApplication1\ConsoleApplication2
0:000> bp 'ConsoleApplication2:12'
0:000> g
Unable to insert breakpoint 1 at 323a3132, Win32 error 0n299
"仅完成部分的 ReadProcessMemory 或 WriteProcessMemory 请求。"
The breakpoint was set with BP. If you want breakpoints
to track module load/unload state you must use BU.
bp1 at 323a3132 failed
WaitForEvent failed
eax=00000000 ebx=00000000 ecx=002ff598 edx=770770f4 esi=fffffffe edi=00000000
eip=770d05a7 esp=002ff5b4 ebp=002ff5e0 iopl=0 nv up ei pl zr na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246
ntdll!LdrVerifyImageMatchesChecksum+0x634:
770d05a7 8975fc mov dword ptr [ebp-4],esi ss:0023:002ff5dc=00000000
看起来我的.sympath/.srcpath都没有错,为什么bp命令会失败?
提示的"仅完成部分的 ReadProcessMemory 或 WriteProcessMemory 请求。"是什么意思?
Re: 用windbg调试一个简单的c++程序,bp设置断点不成功,很奇怪的错误提示
初学
2014-06-29, 21:38 下午
求回答!
Re: 用windbg调试一个简单的c++程序,bp设置断点不成功,很奇怪的错误提示
格蠹老雷
2014-06-29, 21:52 下午
仔细看下帮助文件,或者找本书看看,注意bp的参数格式
Re: 用windbg调试一个简单的c++程序,bp设置断点不成功,很奇怪的错误提示
初学
2014-06-30, 22:49 下午
OK, 我给bp命令加上了单引号,但是还是不行:
(1)从lm命令的结果来看,ConsoleApplication2的start/end分别是00a80000/00aa3000
(2)bp命令成功执行了,但是bl命令列出的断点地址是703a3131,看起来这个无效地址。这是为什么呢?
源代码--------------------------------------------------------------------------------------------------------
// ConsoleApplication2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int i=2;
++i;
int j=3;
++j;
return 0;
}
Windbg-------------------------------------------------------------------------------------------------------
0:000> bp 'ConsoleApplication2.cpp:11'
0:000> bl
0 e 703a3131 0001 (0001) 0:****
0:000> lm
start end module name
00a80000 00aa3000 ConsoleApplication2 C (private pdb symbols) C:\Users\a\Documents\Visual Studio 2012\Projects\ConsoleApplication1\Debug\ConsoleApplication2.pdb
0f710000 0f8b1000 MSVCR110D (deferred)
0fb70000 0fc3b000 MSVCP110D (deferred)
751e0000 7522b000 KERNELBASE (deferred)
758c0000 75994000 kernel32 (deferred)
76f70000 770ac000 ntdll (pdb symbols) c:\symbols\ntdll.pdb\CD4062A231154A17A18DAE7D1A0FBACC2\ntdll.pdb
Re: 用windbg调试一个简单的c++程序,bp设置断点不成功,很奇怪的错误提示
格蠹老雷
2014-07-01, 17:57 下午
很好,有进步,估计是看过帮助文件了,但是看得不够仔细,睁大眼睛,那不是单引号,而是重音符号,通常在键盘的左上角,和~在一起的那个
我的书里介绍这个命令时是有特别提示过的,说明你没有读我的书