diff options
author | Elliott Hughes <enh@google.com> | 2014-04-25 16:05:34 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2014-04-25 20:20:39 -0700 |
commit | 855fcc3114c20ff9fd286fe1723d1413fec9685a (patch) | |
tree | 012f6de674c3ba210b9f1de42d9c7607a6e9862d /debuggerd/crasher.c | |
parent | 2317287d18fae3f9ae0f3beb7748a804f06b5720 (diff) | |
download | system_core-855fcc3114c20ff9fd286fe1723d1413fec9685a.zip system_core-855fcc3114c20ff9fd286fe1723d1413fec9685a.tar.gz system_core-855fcc3114c20ff9fd286fe1723d1413fec9685a.tar.bz2 |
Use the si_code value bionic passes us.
Bionic needs to re-raise various signals, which means the si_code
debuggerd sees has been clobbered. If bionic sends us the original
si_code value, we can use that instead of the one we see when the
ptrace the crashed process' siginfo.
Change-Id: If116a6bc667d55a6fb39b74f96673292af4e4c8c
Diffstat (limited to 'debuggerd/crasher.c')
-rw-r--r-- | debuggerd/crasher.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/debuggerd/crasher.c b/debuggerd/crasher.c index 9946faa..3e3ab5a 100644 --- a/debuggerd/crasher.c +++ b/debuggerd/crasher.c @@ -126,7 +126,7 @@ static int do_action(const char* arg) return ctest(); } else if (!strcmp(arg, "exit")) { exit(1); - } else if (!strcmp(arg, "crash")) { + } else if (!strcmp(arg, "crash") || !strcmp(arg, "SIGSEGV")) { return crash(42); } else if (!strcmp(arg, "abort")) { maybe_abort(); @@ -138,23 +138,32 @@ static int do_action(const char* arg) LOG_ALWAYS_FATAL("hello %s", "world"); } else if (!strcmp(arg, "LOG_ALWAYS_FATAL_IF")) { LOG_ALWAYS_FATAL_IF(true, "hello %s", "world"); + } else if (!strcmp(arg, "SIGPIPE")) { + int pipe_fds[2]; + pipe(pipe_fds); + close(pipe_fds[0]); + write(pipe_fds[1], "oops", 4); + return EXIT_SUCCESS; } else if (!strcmp(arg, "heap-usage")) { abuse_heap(); } fprintf(stderr, "%s OP\n", __progname); fprintf(stderr, "where OP is:\n"); - fprintf(stderr, " smash-stack overwrite a stack-guard canary\n"); - fprintf(stderr, " stack-overflow recurse until the stack overflows\n"); - fprintf(stderr, " heap-corruption cause a libc abort by corrupting the heap\n"); - fprintf(stderr, " heap-usage cause a libc abort by abusing a heap function\n"); - fprintf(stderr, " nostack crash with a NULL stack pointer\n"); - fprintf(stderr, " ctest (obsoleted by thread-crash?)\n"); - fprintf(stderr, " exit call exit(1)\n"); - fprintf(stderr, " crash cause a SIGSEGV\n"); - fprintf(stderr, " abort call abort()\n"); - fprintf(stderr, " assert call assert() without a function\n"); - fprintf(stderr, " assert2 call assert() with a function\n"); + fprintf(stderr, " smash-stack overwrite a stack-guard canary\n"); + fprintf(stderr, " stack-overflow recurse until the stack overflows\n"); + fprintf(stderr, " heap-corruption cause a libc abort by corrupting the heap\n"); + fprintf(stderr, " heap-usage cause a libc abort by abusing a heap function\n"); + fprintf(stderr, " nostack crash with a NULL stack pointer\n"); + fprintf(stderr, " ctest (obsoleted by thread-crash?)\n"); + fprintf(stderr, " exit call exit(1)\n"); + fprintf(stderr, " abort call abort()\n"); + fprintf(stderr, " assert call assert() without a function\n"); + fprintf(stderr, " assert2 call assert() with a function\n"); + fprintf(stderr, " LOG_ALWAYS_FATAL call LOG_ALWAYS_FATAL\n"); + fprintf(stderr, " LOG_ALWAYS_FATAL_IF call LOG_ALWAYS_FATAL\n"); + fprintf(stderr, " SIGPIPE cause a SIGPIPE\n"); + fprintf(stderr, " SIGSEGV cause a SIGSEGV (synonym: crash)\n"); fprintf(stderr, "prefix any of the above with 'thread-' to not run\n"); fprintf(stderr, "on the process' main thread.\n"); return EXIT_SUCCESS; |