我希望 Visual Studio 调试器仅在调用来自特定的调用者序列时在函数内中断。有没有办法设置这样的断点?或者也许是一些替代黑客?
我在 native (C++) 和托管 (C#) 代码的上下文中问这个问题。
最佳答案
我想你可以设置一个 conditional breakpoint利用 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
关于c# - 执行路径特定断点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1932061/