Windbg条件断点不会断?

Windbg conditional breakpoint won't break?

使用 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

我的断点有什么问题?

编辑

看了官方的docohere,我的断点看起来很准,但还是没断

您失败了,因为您将 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>

这是我的示例 src:

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>