dladdr() to resolve function name from a program counter address?

731 views
Skip to first unread message

Chris Peterson (Adobe)

unread,
Oct 14, 2009, 9:19:26 PM10/14/09
to android-ndk
I am trying to port some stack tracing code (for tracking memory
leaks) from Linux to Android. The original code used dladdr() to
resolve function names from program counter addresses.

I see that Android has some libdl functions, but not dladdr(). Is
there an Android alternative?

The android::CallStack class (in Android's base framework library) was
helpful, but it does not resolve function names, just program counter
addresses. If bionic's ELF linker.c can map symbol names to addresses
for dlsym(), it seems like the reverse mapping for dladdr() should be
possible.

thanks,
chris

fadden

unread,
Oct 15, 2009, 3:58:43 PM10/15/09
to android-ndk
On Oct 14, 6:19 pm, "Chris Peterson (Adobe)" <chris...@adobe.com>
wrote:
> I am trying to port some stack tracing code (for tracking memory
> leaks) from Linux to Android. The original code used dladdr() to
> resolve function names from program counter addresses.
>
> I see that Android has some libdl functions, but not dladdr(). Is
> there an Android alternative?

Most of the symbolic / debug information is stripped out of the
binaries that ship on the device. Conversion of addresses to names is
generally done on the host side, using a copy of the objects with
symbols (out/target/product/<name>/symbols/system/...).

http://groups.google.com/group/android-developers/browse_thread/thread/73f89bb8739c24bb/5228e7a5dcfff090

Some memory allocation tracking already exists in the sources; see
bionic/libc/bionic/malloc_leak.c. For this purpose, the raw values
are sent up to DDMS, which uses the "symbols" files and arm-eabi-
addr2line to convert values.
Reply all
Reply to author
Forward
0 new messages