Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional Breakpoints on Call Stack

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 most 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.

like image 210
Adam Houldsworth Avatar asked Apr 04 '11 15:04

Adam Houldsworth


People also ask

What are conditional breakpoints?

Conditional breakpoints allow you to break inside a code block when a defined expression evaluates to true. Conditional breakpoints highlight as orange instead of blue. Add a conditional breakpoint by right clicking a line number, selecting Add Conditional Breakpoint , and entering an expression.

How do you set a conditional breakpoint?

To set a conditional breakpoint, activate the context menu in the source pane, on the line where you want the breakpoint, and select “Add Conditional Breakpoint”. You'll then see a textbox where you can enter the expression. Press Return to finish.

How do you set a conditional breakpoint in WinDbg?

Conditional Breakpoints in WinDbg In WinDbg, you can create a conditional breakpoint by clicking Breakpoints from the Edit menu, entering a new breakpoint address into the Command box, and entering a condition into the Condition box.

How do I apply a conditional breakpoint in Visual Studio?

Right-click the breakpoint symbol and select Conditions (or press Alt + F9, C). Or hover over the breakpoint symbol, select the Settings icon, and then select Conditions in the Breakpoint Settings window.


1 Answers

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

new System.Diagnostics.StackTrace().ToString().Contains("YourMethodName")
like image 159
František Žiačik Avatar answered Sep 21 '22 10:09

František Žiačik