diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2008-10-21 07:00:00 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2008-10-21 07:00:00 -0700 |
commit | a27d2baa0c1a2ec70f47ea9199b1dd6762c8a349 (patch) | |
tree | defd1cc07d16ad2f3b21154114e092d11c94c5bb /linker/debugger.c | |
download | bionic-a27d2baa0c1a2ec70f47ea9199b1dd6762c8a349.zip bionic-a27d2baa0c1a2ec70f47ea9199b1dd6762c8a349.tar.gz bionic-a27d2baa0c1a2ec70f47ea9199b1dd6762c8a349.tar.bz2 |
Initial Contributionandroid-1.0
Diffstat (limited to 'linker/debugger.c')
-rw-r--r-- | linker/debugger.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/linker/debugger.c b/linker/debugger.c new file mode 100644 index 0000000..68997c5 --- /dev/null +++ b/linker/debugger.c @@ -0,0 +1,52 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <ctype.h> +#include <signal.h> +#include <sys/mman.h> + +#include "linker.h" + +#include <sys/socket.h> +#include <cutils/sockets.h> + +void notify_gdb_of_libraries(); + +void debugger_signal_handler(int n) +{ + unsigned tid; + int s; + + /* avoid picking up GC interrupts */ + signal(SIGUSR1, SIG_IGN); + + tid = gettid(); + s = socket_local_client("android:debuggerd", + ANDROID_SOCKET_NAMESPACE_ABSTRACT, SOCK_STREAM); + + if(s >= 0) { + /* debugger knows our pid from the credentials on the + ** local socket but we need to tell it our tid. It + ** is paranoid and will verify that we are giving a tid + ** that's actually in our process + */ + write(s, &tid, sizeof(unsigned)); + + read(s, &tid, 1); + notify_gdb_of_libraries(); + close(s); + } + + /* remove our net so we fault for real when we return */ + signal(n, SIG_IGN); +} + +void debugger_init() +{ + signal(SIGILL, debugger_signal_handler); + signal(SIGABRT, debugger_signal_handler); + signal(SIGBUS, debugger_signal_handler); + signal(SIGFPE, debugger_signal_handler); + signal(SIGSEGV, debugger_signal_handler); + signal(SIGSTKFLT, debugger_signal_handler); +} |