[Libreoffice] gdb: catching exceptions...

Tom Tromey tromey at redhat.com
Tue Oct 18 07:02:31 PDT 2011

I'm re-sending this note... I sent it yesterday via gmane, but I guess
this list is configured for moderation even in that situation; so today
I joined.

Mark Wielaard pointed out this note to me.
Feel free to CC 'archer at sourceware.org' on hacks like this, we're
interested in hearing about them and to find out what developers need
from gdb.

Michael> since my smoketest failed again today, i've distracted myself a bit
Michael> with GDB Python scripting, the result of which is a command that can
Michael> break when an exception is thrown, but only if a certain function
Michael> (which is given as parameter) is on the stack.


Michael> seems to work, but it is quite slow: finding the smoketest exception
Michael> in SfxBaseModel::getTitle takes GDB 4 minutes of CPU time.

Michael> now probably somebody will tell me that i'm too stupid to RTFM and
Michael> there is a much simpler way to do this :)

There isn't a simpler way right now.  You could try to do it by having a
breakpoint on the function you care about that keeps a count of entries
and exits and enables the __cxa_throw breakpoint if this is nonzero.
However, this is hard to do reliably right now, because you have to do a
lot of manual management of return breakpoints.  I think this may get
simpler when the "finish breakpoint" feature goes in:


We're interested in hearing about real-life uses of exceptions and what
better functionality gdb could provide.  Freely file feature requests in
gdb bugzilla; enhancing C++ development is a primary goal of ours these


More information about the LibreOffice mailing list