diff --git a/debuggerd/crasher/crasher.cpp b/debuggerd/crasher/crasher.cpp index 4b32b9d36..f31337d70 100644 --- a/debuggerd/crasher/crasher.cpp +++ b/debuggerd/crasher/crasher.cpp @@ -197,6 +197,7 @@ static int usage() { fprintf(stderr, " LOG-FATAL call libbase LOG(FATAL)\n"); fprintf(stderr, "\n"); fprintf(stderr, " SIGFPE cause a SIGFPE\n"); + fprintf(stderr, " SIGILL cause a SIGILL\n"); fprintf(stderr, " SIGSEGV cause a SIGSEGV at address 0x0 (synonym: crash)\n"); fprintf(stderr, " SIGSEGV-non-null cause a SIGSEGV at a non-zero address\n"); fprintf(stderr, " SIGSEGV-unmapped mmap/munmap a region of memory and then attempt to access it\n"); @@ -268,6 +269,16 @@ noinline int do_action(const char* arg) { } else if (!strcasecmp(arg, "SIGFPE")) { raise(SIGFPE); return EXIT_SUCCESS; + } else if (!strcasecmp(arg, "SIGILL")) { +#if defined(__aarch64__) + __asm__ volatile(".word 0\n"); +#elif defined(__arm__) + __asm__ volatile(".word 0xe7f0def0\n"); +#elif defined(__i386__) || defined(__x86_64__) + __asm__ volatile("ud2\n"); +#else +#error +#endif } else if (!strcasecmp(arg, "SIGTRAP")) { raise(SIGTRAP); return EXIT_SUCCESS; diff --git a/debuggerd/libdebuggerd/tombstone.cpp b/debuggerd/libdebuggerd/tombstone.cpp index e11be1ea7..433bb4657 100644 --- a/debuggerd/libdebuggerd/tombstone.cpp +++ b/debuggerd/libdebuggerd/tombstone.cpp @@ -102,10 +102,17 @@ static void dump_probable_cause(log_t* log, const siginfo_t* si) { if (!cause.empty()) _LOG(log, logtype::HEADER, "Cause: %s\n", cause.c_str()); } -static void dump_signal_info(log_t* log, const ThreadInfo& thread_info) { - char addr_desc[32]; // ", fault addr 0x1234" +static void dump_signal_info(log_t* log, const ThreadInfo& thread_info, Memory* process_memory) { + char addr_desc[64]; // ", fault addr 0x1234" if (signal_has_si_addr(thread_info.siginfo)) { - snprintf(addr_desc, sizeof(addr_desc), "%p", thread_info.siginfo->si_addr); + void* addr = thread_info.siginfo->si_addr; + if (thread_info.siginfo->si_signo == SIGILL) { + uint32_t instruction = {}; + process_memory->Read(reinterpret_cast(addr), &instruction, sizeof(instruction)); + snprintf(addr_desc, sizeof(addr_desc), "%p (*pc=%#08x)", addr, instruction); + } else { + snprintf(addr_desc, sizeof(addr_desc), "%p", addr); + } } else { snprintf(addr_desc, sizeof(addr_desc), "--------"); } @@ -418,7 +425,7 @@ static bool dump_thread(log_t* log, BacktraceMap* map, Memory* process_memory, dump_thread_info(log, thread_info); if (thread_info.siginfo) { - dump_signal_info(log, thread_info); + dump_signal_info(log, thread_info, process_memory); } if (primary_thread) {