Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug code that uses boost w/o losing sanity?

Boost is a great set of libraries and it really boosts productivity. But debugging code that uses it is a total nightmare. Sure, stepping through twenty thousand header files can be a valuable intellectual exercise, but what if you need to do it over and over again?

Is there a developer-friendly way of just skipping the boost portion and having the debugger go straight to my code?

Visual Studio has a DebuggerStepThroughAttribute for .NET framework. Is there anything similar for native C++?

like image 489
Filip Frącz Avatar asked Nov 18 '08 06:11

Filip Frącz


2 Answers

There's no platform/compiler independent way, but I've been told that you can tell the debugger to not "step into" certain functions or classes. You should look up the registry key: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\NativeDE\StepOver] and create a string value named as a number in the order the rules should apply (I'm a bit confused about it too, but I guess that the rules are simply ordered in the (possibly reverse) way they should be applied) and set it to something like: "boost::.*=NoStepInto". E.g.:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\NativeDE\StepOver]
"10"="boost\:\:.*=NoStepInto"

You can read a little bit more here.

like image 88
Andreas Magnusson Avatar answered Oct 19 '22 00:10

Andreas Magnusson


You can skip the boost namespace entirely by using the techniques described here. Just use something like:

boost\:\:.*=NoStepInto

... in the relevant registry entry.

However if your code gets called from within boost (e.g. through a boost::function or similar) then your code will be skipped as well! I'll be interested if someone can come up with a good solution for that problem...

like image 22
Alastair Avatar answered Oct 18 '22 23:10

Alastair