Posts Tagged ‘tool’

Setting break point where an exception is thrown

December 22nd, 2009

Caolan told me today that when debugging with gdb, you can actually set a break point right before an exception is thrown.

You can do

gdb ./soffice.bin
(gdb) catch throw
(gdb) run

and gdb breaks at every location where an exception is raised. Or, you can set a normal break point, run catch throw and cont, and gdb will break at the next exception throw event. This technique helps when an exception gets caught somewhere at higher level in the call stack and you are trying to find out where exactly it is thrown. Such task, without this technique, would be very time-consuming, tedious, boring, and at times frustrating especially when you’ve spent hours and still don’t have the location of the thrown exception.

Similarly, you can also break where an exception is caught, with catch catch command, or you can catch a whole set of other events with this construct.

The only drawback with this catch event construct is that, it breaks at every single exception raised or caught, which, inside OOo’s codebase can be quite substantial in some places. Nonetheless, this is a very useful technique to add to your debugging arsenal.

callcatcher

May 15th, 2008

I just had the chance to play with Caolan’s cool callcatcher program to search and destroy (or comment out rather) lots of unused methods in Calc’s code. It was surprisingly simple to install and use it. All I had to do after downloading the source package was to

tar xvf callcatcher-1.0.8.tar.gz
cd callcatcher-1.0.8
sudo ./setup.py install

then replace all gcc and g++ calls with callcatcher gcc and callcatcher g++, respectively, to catch all defined functions and their references (or lack thereof). That’s all. Once done, run callanalyse [executable or shared library] to generate the summary output of all unused methods. It was pretty accurate, and as he claims there was no false positives as far as I could tell.