[英]Visual studio breakpoint conditional on the stack state
Visual Studio可以在断点命中时打印调用堆栈,并且可以在条件满足时停止,是否有任何方法可以组合它并在从另一个选定的函数调用函数时停止,并忽略所有其他调用?
我相信这样做的唯一方法是使用宏。 右键单击断点,选择“When Hit ..”,选择“Run a macro”,然后将其指向一个类似于的宏:
Sub ContinueUnlessCalledFromRightContext()
For Each frame As EnvDTE.StackFrame In DTE.Debugger.CurrentThread.StackFrames
If (frame.FunctionName.Contains("SomeOtherMethodsName") Then Exit Function
Next
DTE.Debugger.Go() ` we weren't called from the right context so continue execution.
End Sub
以上是半伪代码; 我实际上没有测试它,但应该使用一些小的编辑。
请注意,如果断点被多次击中,这将会很慢,因为从断点运行宏本身就非常慢。
顺便说一句,如果你问的是.NET / C#它会简单得多,你可能只是在做一个条件断点
new System.Diagnostics.StackTrace().ToString().Contains("SomeOtherMethodsName")
......并完成它。
不确定,但您可能能够使用Filtering或Conditions,尽管将断点放在调用进程上可能更容易
这是一个很好的资源: 在Visual Studio 2010中掌握调试 - 初学者指南
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.