Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a breakpoint in every method in VS2010

I have a bigger (c#) WPF application with n-classes and m-methods. I would like to place in every single method a breakpoint, so everytime i press a button in my application or any method gets called, i would like the application in VS2010 to hit that breakpoint. I want to understand the flow/progress of the application.

And since i have many methods i would rather not place manually in every and each of them a breakpoint.

Is there any command or tool to place everywhere in my VS2010 solution a breakpoint?

edit: maybe something like the following addin: http://weblogs.asp.net/uruit/archive/2011/08/04/visual-studio-2010-addin-setting-a-class-breakpoint.aspx

edit2: there are some answers but none of them seems like the straight forward easy solution. Anything else?

like image 631
Gero Avatar asked Feb 07 '13 12:02

Gero


People also ask

How do you put breakpoint on all of the methods in a class?

Press F3 and then press F9 to add a breakpoint.

How do you create a breakpoint in a method?

Set breakpoints in source code To set a breakpoint in source code: Click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint.

How do you set a breakpoint within your code?

It's easy to set a breakpoint in Python code to i.e. inspect the contents of variables at a given line. Add import pdb; pdb. set_trace() at the corresponding line in the Python code and execute it. The execution will stop at the breakpoint.


1 Answers

EDIT: tested only with C++

I came across this article that shows how to set a breakpoint at the beginning of every method in a class. I've tested it with VS 2010. The basic process (when using Visual C++) is:

  1. Go to Debug > New Breakpoint > Breakpoint at Function (Ctrl + B).
  2. In the Function field, insert MyClass::*
  3. This will show up as a single breakpoint in the Breakpoints window, but as soon as one of MyClass's methods is hit, you'll see a breakpoint at the beginning of every function in MyClass, and all of these will be "children" of the original breakpoint in the Breakpoints window.

I imagine this works with C# as well.

like image 186
Vicky Chijwani Avatar answered Oct 13 '22 00:10

Vicky Chijwani