[PATCH 4/5] Support backtracing through elfutils (#70746)

Jan Kratochvil jan.kratochvil at redhat.com
Wed Oct 30 08:58:00 CET 2013


On Wed, 30 Oct 2013 07:31:19 +0100, Jasper St. Pierre wrote:
> Whoops, I misspoke when I talked about libbacktrace. I meant libunwind all
> throughout, since that's what Xorg uses right now.

I see now the libunwind support has been already upstreamed; I saw it before
only as a Fedora-only downstream patch so I did not have concerns for example
about the non-Linux OSes and I contacted Peter Hutterer only wrt the
downstream Fedora patch. The xorg-upstreamed libunwind support was:
	commit e21e183059df5975e7086850d1931edb2c1bbd06
	Author: Marcin Slusarz <marcin.slusarz at gmail.com>
	Date:   Thu Feb 21 09:02:44 2013 +1000
	os: use libunwind to generate backtraces
	http://cgit.freedesktop.org/xorg/xserver/commit/?id=e21e183059df5975e7086850d1931edb2c1bbd06


> Should we work on making the elfutils backtrace API more like libunwind /
> libbacktrace,

libunwind and libbacktrace have different API.  Besides that their
functionality is almost disjunct (they just both contain the tiny
addr->elfsymbol part xorg needs).


> Should we focus on porting libbacktrace / libunwind to elfutils, and have
> one simple API for this?

I do not understand what you are proposing.  This is the current situation:

elfutils:      addr->elfsymbol  (file:lineno) (inlines)
elfutils next: addr->elfsymbol  (file:lineno) (inlines) unwinding
backtrace():                                            unwinding
libbacktrace:  addr->elfsymbol   file:lineno   inlines 
libunwind:     addr->elfsymbol                          unwinding
GDB:           addr->elfsymbol   file:lineno   inlines  unwinding parameters

elfutils "(file:lineno)" and "(inlines)" means the DWARF reader is there for
it but the current xorg patch does not implement them the parsed DWARF.
Therefore implementable without too much effort but not there right now.

libgcc backtrace_symbols() can do some "addr->elfsymbol" but it resolves only
symbols in .dynsym (exported ones), not from .symtab, therefore also not from
separate .debug files.  In Fedora backtrace_symbols() does everything it can
if you do not have xorg-x11-server-debuginfo.rpm installed.

Currently xorg uses just the "addr->elfsymbol" part above.


You have an interesting idea the elfutils API could be simplified for the API
use like xorg does, dwfl_get() is needlessly long.  Currently elfutils
simplifies commandline utilities where the dwfl_get() part is done by
dwfl_standard_argp(), argp_parse() and dwfl_report_end() calls like in:
	https://git.fedorahosted.org/cgit/elfutils.git/tree/src/stack.c?h=jankratochvil/unwindx86

If you do not like the callbacks my original implementation did use iterators
(like libunwind uses).  Mark Wielaard has changed it to callbacks now during
upstreaming to elfutils.


Regards,
Jan


More information about the xorg-devel mailing list