【问题标题】:Windbg conditional breakpoint won't break?Windbg条件断点不会中断?
【发布时间】:2019-01-27 20:07:31
【问题描述】:

使用 Windbg,我正在尝试使用以下 src 文件有条件地中断:basic_thread.cpp

9:  void __stdcall process()
10: {
11:    unsigned int count = 100000000;
12:    unsigned int hits = 0;
13:    for(unsigned int i = 0; i < count; i++)
14:    {
15:        // Not much to look at.
16:        hits++;
17:    }
18: }

我的断点是这样设置的:

bu `basic_thread.cpp:12` 
    ".if (poi(count)==0n100000000){.echo 'count==100000000'} .else {gc}"
bu `basic_thread.cpp:16` 
    ".if (poi(hits)==0n500){.echo 'hits==500'} .else {gc}"

设置后,我重新启动程序并运行,但断点从未实现?

.restart

g

我的断点有什么问题?

编辑

我已经阅读了官方文档here,我的断点看起来准确,但它们仍然没有中断。

【问题讨论】:

  • 你试过把断点放在不同的行吗? hits 不在第 11 行的范围内,我也不确定 count 是否在这一点上。
  • 对不起,你是对的。该示例应读取第 12 行和第 16 行...但是,它仍然没有中断。
  • 不知道为什么这会被否决...

标签: c debugging windbg


【解决方案1】:

您失败了,因为您将 c++ 表达式与 MASM 表达式混合在一起。 MASM 引擎不理解您的hitscounts。您必须使用 @@c++() 语法对它们进行限定。

我刚刚编译并运行了一个简单的测试来模拟你想要的问题:

:\>ls
windbp.cpp

:\>cl /Zi /W4 /Od /analyze /EHsc /nologo windbp.cpp /link /release /nologo
windbp.cpp

:\>cdb -c ".lines;bp `windbp.cpp:16` \".if( @@c++(hits) != 500 ) { gc }\";g" windbp.exe

结果是:

Microsoft (R) Windows Debugger Version 10.0.17763.132 X86

ntdll!LdrpDoDebuggerBreak+0x2c:
773005a6 cc              int     3

0:000> cdb: Reading initial command '.lines;bp `windbp.cpp:16` ".if( @@c++(hits) != 500 ) { gc }";g'
Line number information will be loaded
ModLoad: 6d300000 6d303000   C:\Windows\system32\api-ms-win-core-synch-l1-2-0.DLL
eax=00000500 ebx=7ffd6000 ecx=00000500 edx=00000500 esi=009c8648 edi=00349098
eip=0098102e esp=0028f838 ebp=0028f844 iopl=0         nv up ei ng nz na pe cy
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000287
windbp!process+0x2e:
0098102e 8b55f8          mov     edx,dword ptr [ebp-8] ss:0023:0028f83c=00000500
0:000> ?? hits
unsigned int 0x500
0:000>

这是我的示例源代码:

0:000> lsa .
     8: //space filler
     9: void __stdcall process()
    10: {
    11:    unsigned int count = 100000000;
    12:    unsigned int hits = 0;
    13:    for(unsigned int i = 0; i < count; i++)
    14:    {
    15:        // Not much to look at.
>   16:        hits++;
    17:    }
    18: }
    19:
    20: int main(void) {
    21:     process();
    22:     return 0;
    23: }
0:000>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多