简体   繁体   中英

How do you add conditional breaking based on another breakpoint being hit? Visual C++

I have a bunch of generic code that is used a lot, which i'd like to poke into in order to deal with a bug in a certain specific case.

So I'd like to break on a set of breakpoints only if some other breakpoint has been hit. Is there a way to do this in Visual 2005? I'm using C++ code.

Thanks!

请记住,您可以禁用断点 - 禁用第二个断点可能更容易/更高效/更干净(然后将调试标志添加到您的代码并重新编译)您的断点窗口 - 每次调试时只需单击两次鼠标... :)

If the trigger logic is complex enough, sometimes I find it easier to just add a DebugBreak (); call into the source.

Have your first breakpoint change the value of some variable to a magic value (you can use a conditional breakpoint, with an expression which changed the variable and then returned true). Then, have the second breakpoint break when the variable is at that magic value. eg,

int debug_flag = 0;

First breakpoint condition:

debug_flag = 0xdeadbeef, true

Second breakpoint condition:

debug_flag == 0xdeadbeef

Ten years later...

An easy way to do what the OP wants would be to use the immediate window to define a global variable, and use it as suggested by @chris-jester-young in breakpoints conditions.

Did the trick for me anyway.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM