Getting a backtrace/callstack in android, what is meant to work?

849 views
Skip to first unread message

Viserys T

unread,
Jun 15, 2014, 7:22:04 AM6/15/14
to andro...@googlegroups.com
After searching this mailing list (and stackoverflow etc), it seems that there are many ways to get the stack backtrace in android NDK.

However, I found none of these works.

ndk-gdb can't seem to even attach to my process, giving a "Application GL2JNI (process com.android.gl2jni) is waiting for the debugger to attach

ndk-stack doesn't do it, because somehow the stack trace is incomplete and only really shows the last two lines

I/DEBUG   (  179): backtrace:
I/DEBUG   (  179):     #00  pc 00021f90  /system/lib/libc.so (tgkill+12)
I/DEBUG   (  179):     #01  pc 00012fe1  /system/lib/libc.so (pthread_kill+48)
I/DEBUG   (  179):     #02  pc 000131f5  /system/lib/libc.so (raise+10)
I/DEBUG   (  179):     #03  pc 00d7c674  /data/app-lib/com.android.gl2jni-2/libgl2jni.so (Shing::reportAssert(char const*, int, char const*, char const*, char const*, std::string const&)+2956)

there are mentions of "CallStack" but I can't really find the headers anywhere in the android r9 distribution I have. Is that some sort of external code?

Thanks in advance if anybody could point me to the right direction. My head have been melting trying to find the solution, unfortunately I don't think I'm striking gold anytime soon.

Cheers

Alex Cohn

unread,
Jul 14, 2014, 6:56:04 PM7/14/14
to andro...@googlegroups.com
Have you tried 

 ${TOOLCHAIN}/bin/addr2line -c -f -e obj/local/$(ABI}/libgl2jni.so d7c674

BR,
Alex Cohn

Chris Varnz

unread,
Jul 21, 2014, 6:56:01 AM7/21/14
to andro...@googlegroups.com
I had the most luck using _Unwind_Backtrace to get the program counters, and then dladdr to get the name of the function and the library it was in. This is as far as I got as I then swapped to using VisualGDB to actually debug the native code (it works a dream), but my next steps would have been to demangle C++ names with abi::__cxa_demangle().

Hope this helps someone else out there.
Reply all
Reply to author
Forward
0 new messages