This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: dladdr alternative for static "t" symbols?
- From: "Carlos O'Donell" <carlos at systemhalted dot org>
- To: Brendan Miller <catphive at catphive dot net>
- Cc: libc-help at sourceware dot org
- Date: Tue, 11 Aug 2009 10:50:07 -0400
- Subject: Re: dladdr alternative for static "t" symbols?
- References: <ef38762f0908101751k3ba646b1kc3ad8d7282c5c74b@mail.gmail.com>
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.