Debuggerd

723 views
Skip to first unread message

letsgo

unread,
Jul 8, 2009, 9:59:55 AM7/8/09
to android-platform
Hi,

When the app crashed, Android will print out the call stack dump
through debuggerd. My question is that how Android detect app crash
and then communicate with debuggerd through domain socket?
I'm interested because sometimes my app crash, the debuggerd has no
output for me. So that I cannot know what caused the crash.

fadden

unread,
Jul 8, 2009, 1:33:48 PM7/8/09
to android-platform
It's a tricky bit of fun involving signal handlers and ptrace. The
interesting files are:
system/core/debuggerd/debuggerd.c
bionic/linker/debugger.c

When a fatal signal hits (SIGILL, SIGABRT, SIGBUS, SIGFPE, SIGSEGV,
SIGSTKFLT, SIGPIPE), it's caught by a signal handler called
debugger_signal_handler(). This opens a UNIX-domain socket connection
to debuggerd and sends the thread ID over. After a little
housekeeping the signal handler for the signal is reset, and the
handler function returns. This causes the signal to be re-thrown, but
this time debuggerd is watching with ptrace and catches the break.

It doesn't always work, but it does 99% of the time.

If it's not working for you, attach gdb to your process before it dies
and try to catch it that way. (I believe the NDK has some
instructions for this.)
Reply all
Reply to author
Forward
0 new messages