Setting break point where an exception is thrown

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /homepages/7/d105059906/htdocs/ on line 383

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.

3 thoughts on “Setting break point where an exception is thrown”

  1. Kohei, probably your blog is not the right place to ask this but couldn’t find a more accurate place to ask this (since you are heavily involved in Novell OpenOffice): Where can i find Novell roadmap regarding its flavour of OpenOffice? It seems there is no official roadmap available on web

  2. Hi Fernando,

    We normally share our roadmap only with our customers, so we don’t have one that’s publicly available, unfortunately. I wish I could give you a little more than that, but this is all I am able to provide at this point.

Comments are closed.