Force crash with stack trace?

1,415 views
Skip to first unread message

Bryan Ashby

unread,
Oct 20, 2010, 1:22:18 PM10/20/10
to android-ndk
I have a native piece of code that appears to be hanging. The code is
multi threaded so I can't really debug it very easily either. I am
aware of using the Git gdbserver, copy of libc.so, etc. to use gdb/
gdbserver with NDK threads... This has issues with the particular
piece of code as well + I'm not always in the position to do this when
the hang occurs).

What I'm after is a way to force the application to crash (e.g. a
unhandled signal or such) that will then dump a stack trace to logcat.
Is this possible?

kill -l in adb shell only lists [1] Terminated as a valid signal --
and is the only one I have got to do *anything*. Of course, this
doesn't cause a crash/stacktrace.

Any tips appreciated!

fadden

unread,
Oct 20, 2010, 1:39:24 PM10/20/10
to android-ndk
On Oct 20, 10:22 am, Bryan Ashby <nuskoo...@gmail.com> wrote:
> What I'm after is a way to force the application to crash (e.g. a
> unhandled signal or such) that will then dump a stack trace to logcat.
> Is this possible?

Hit the process with the same signal twice. Signal 6 (SIGABRT) will
work for this.

The first signal causes the signal handler in the process to wake up
debuggerd, which attaches with ptrace. The second signal causes a
ptrace event that results in debuggerd logging the stacks. (The log
will only show the main thread; look in /data/tombstones for the
rest.)

Bryan Ashby

unread,
Oct 20, 2010, 5:18:56 PM10/20/10
to android-ndk
On Oct 20, 11:39 am, fadden <fad...@android.com> wrote:
> Hit the process with the same signal twice.  Signal 6 (SIGABRT) will
> work for this.

Thanks a ton for this. This has saved me a lot of headache!
Reply all
Reply to author
Forward
0 new messages