Is there a Visual Studio macro to set a breakpoint

2020-04-10 01:52发布

问题:

Is there a Visual Studio macro (either for version 2008 or 2010) to set a breakpoint on the start of every method in a class?

I've seen hints of references, but I've not been able to dig an actual one out.

回答1:

Wouldn't you be better off just single-stepping through your source code?

I can't imagine why a breakpoint at the start of every method would be any better than single-stepping. You're going to end up breaking everywhere anyway, and single-stepping provides the additional advantage of showing you the logical flow of your code paths.

You'll probably definitely want to learn the keyboard shortcut keys, but they can depend on how you have your VS environment set up. Look in your "Debug" menu for the "Step Over" and "Step Into" items. (Normally, Step Over is F10 and Step Into is F11.) The only difference is that, if the currently highlighted line contains a function call, Step Into will allow you to single-step through the code in the called function (this is probably most like what you want to do), while Step Over will simply call the function and stop on the next line in the current function.



回答2:

A Visual Studio extension named OzCode does have a feature to set/unset breakpoints on all members of a class. I use this extension a lot, as it has some very nice debugging enhancements.

Admittedly though, I haven't used the set/unset breakpoint feature much, but it's an option for you.



回答3:

There are some good ideas here: How to put breakpoint in every function of .cpp file?