[英]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. 我希望Visual Studio调试器仅在调用来自特定调用者序列时才在函数内中断。 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. 我在本机(C ++)以及托管(C#)代码的上下文中问这个问题。
I think you could set a conditional breakpoint that utilizes the System.Diagnostics.StackTrace class. 我认为您可以设置一个利用System.Diagnostics.StackTrace类的条件断点 。
EDIT : GrayWizardx has pointed out in a comment that this may not be possible. 编辑 :GrayWizardx在评论中指出这可能是不可能的。 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.