开发者

Conditional Breakpoints on Call Stack

开发者 https://www.devze.com 2023-02-22 12:28 出处:网络
Is it possible to specify a breakpoint in Visual Studio 2010 that hits only if the calling methods up the call stack meet some specific condition?For example, and mos开发者_开发技巧t likely, method na

Is it possible to specify a breakpoint in Visual Studio 2010 that hits only if the calling methods up the call stack meet some specific condition? For example, and mos开发者_开发技巧t likely, method name.

I am ideally looking for a solution in Visual Studio itself such as the conditional breakpoint, but I'll settle for testing method names up the stack in code and having a coded breakpoint.

What I'm trying to achieve is to cut out calls from a specific caller.


Right click the breakpoint, choose "Condition" and use something like this:

new System.Diagnostics.StackTrace().ToString().Contains("YourMethodName")


The StackTrace class should give you what you need.

StackTrace stackTrace = new StackTrace();           
StackFrame[] stackFrames = stackTrace.GetFrames(); 
0

精彩评论

暂无评论...
验证码 换一张
取 消