using backtrace() in exception throwing?

Tom Tromey tromey at redhat.com
Mon Feb 18 09:09:41 PST 2013


>>>>> "Lubos" == Lubos Lunak <l.lunak at suse.cz> writes:

Lubos>  This could be very useful ('catch throw' is so cumbersome in
Lubos> gdb),

Is there something we could do to improve it?

Lubos> but I think the first thing to check is if it would
Lubos> actually work. Last time I checked, "recent" features like
Lubos> -fvisibility make backtrace() very often generate call traces
Lubos> that are next to useless.

There are a few other approaches that are possible on Linux.

There is one that is part of GCC, libbacktrace.
It is its own library, but part of the GCC tree; so you'd have to
extract it.

Jan is also writing one based on elfutils.  It is in elfutils git but
not merged to master yet.

Also it can be done using the existing unwinder data, which already
exists for exception handling.  This is the approach libgcj took.
Specifically, it used this data to construct the list of PC values and
stash this in the exception; this was then transformed when actually
printing an exception.  The code in libgcj is a bit hairier than you
might need, since it had to handle interpreter and libffi frames
specially.  You could probably adapt it.

Tom


More information about the LibreOffice mailing list