0

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

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

4

1 回答 1

4

我认为您可以设置一个利用System.Diagnostics.StackTrace类的条件断点。

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

#if DEBUG
    // Use StackTrace class in this conditional to determine whether or not to break:
    if (yourConditionIsTrue)
    {
        System.Diagnostics.Debugger.Break();
    }
#endif
于 2009-12-19T05:37:04.950 回答