【问题标题】:Execution Path Specific Breakpoint执行路径特定断点
【发布时间】:2009-12-19 05:31:55
【问题描述】:

我希望 Visual Studio 调试器在调用来自特定调用者序列时在函数内中断。有没有办法设置这样的断点?或者也许是一些替代黑客?

我在本机 (C++) 和托管 (C#) 代码的上下文中问这个问题。

【问题讨论】:

    标签: c# c++ visual-studio breakpoints callstack


    【解决方案1】:

    我认为您可以设置一个使用System.Diagnostics.StackTrace 类的conditional breakpoint

    编辑:GrayWizardx 在评论中指出这可能是不可能的。在这种情况下,您可能会导致代码以编程方式中断:

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

    【讨论】:

    • 据我所知,CBP 需要在没有实例化的情况下评估为真正的内联(即基本上是静态的),更不用说编写 CBP 了。
    • @GrayWizardx:确实如此——它会很笨拙。希望我的新建议更好。
    猜你喜欢
    • 2022-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-04
    • 1970-01-01
    • 2010-12-21
    相关资源
    最近更新 更多