dladdr alternative for static "t" symbols?

Carlos O'Donell carlos@systemhalted.org
Tue Aug 11 14:50:00 GMT 2009


On Mon, Aug 10, 2009 at 8:51 PM, Brendan Miller<catphive@catphive.net> wrote:
> I'm trying to build a better backtrace. Is there an alternative to
> dladdr that can get symbol information on static symbols?
>
> Also, what's the easiest way to get the line number from the
> instruction pointer?
>
> I'm on ELF with DWARF debugging symbols.
>
> Sorry if these are big questions, or out of the scope of glibc. Any
> pointers in the right direction, or the right place to ask would be
> appreciated.

You will end up duplicating much of the functionality in gdb.

GDB does not use dladdr, it reads and understands the ELF file format.

GDB parses the DWARF2 debug information to determine PC<->Source Line mappings.

If you want to recreate this, you have a lot of work ahead of you, and
I would suggest the following alternative. There was, at one point in
the past, talk about enhancing gdb such that you could invoke the
debugger as a library call to perform a backtrace for your program. I
think that would be cool. It wouldn't be fast but it would be
*extremely* accurate, and it would get better as gdb got better.

Hope that helps.

Cheers,
Carlos.



More information about the Libc-help mailing list