开发者

Execution Path Specific Breakpoint

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜