开发者

Execution Path Specific Breakpoint

开发者 https://www.devze.com 2022-12-14 22:03 出处:网络
I would like Visual Studio debugger to break within a 开发者_运维知识库function only when the call is from a specific sequence of callers. Is there a way to set such a breakpoint? Or perhaps some alte

I would like Visual Studio debugger to break within a 开发者_运维知识库function only when the call is from a specific sequence of callers. Is there a way to set such a breakpoint? Or perhaps some alternative hack?

I ask this in the context of native (C++) as well as managed (C#) code.


I think you could set a conditional breakpoint that utilizes the System.Diagnostics.StackTrace class.

EDIT: GrayWizardx has pointed out in a comment that this may not be possible. In that case you could cause your code to break programmatically:

#if DEBUG
    // Use StackTrace class in this conditional to determine whether or not to break:
    if (yourConditionIsTrue)
    {
        System.Diagnostics.Debugger.Break();
    }
#endif
0

精彩评论

暂无评论...
验证码 换一张
取 消