diff options
Diffstat (limited to 'debuggerd/crash_dump.cpp')
-rw-r--r-- | debuggerd/crash_dump.cpp | 62 |
1 files changed, 30 insertions, 32 deletions
diff --git a/debuggerd/crash_dump.cpp b/debuggerd/crash_dump.cpp index 3e998802b1..d7cb9725fb 100644 --- a/debuggerd/crash_dump.cpp +++ b/debuggerd/crash_dump.cpp @@ -254,9 +254,7 @@ static void ParseArgs(int argc, char** argv, pid_t* pseudothread_tid, DebuggerdD } static void ReadCrashInfo(unique_fd& fd, siginfo_t* siginfo, - std::unique_ptr<unwindstack::Regs>* regs, uintptr_t* abort_msg_address, - uintptr_t* fdsan_table_address, uintptr_t* gwp_asan_state, - uintptr_t* gwp_asan_metadata) { + std::unique_ptr<unwindstack::Regs>* regs, ProcessInfo* process_info) { std::aligned_storage<sizeof(CrashInfo) + 1, alignof(CrashInfo)>::type buf; CrashInfo* crash_info = reinterpret_cast<CrashInfo*>(&buf); ssize_t rc = TEMP_FAILURE_RETRY(read(fd.get(), &buf, sizeof(buf))); @@ -266,15 +264,13 @@ static void ReadCrashInfo(unique_fd& fd, siginfo_t* siginfo, ssize_t expected_size = 0; switch (crash_info->header.version) { case 1: - expected_size = sizeof(CrashInfoHeader) + sizeof(CrashInfoDataV1); - break; - case 2: - expected_size = sizeof(CrashInfoHeader) + sizeof(CrashInfoDataV2); + case 3: + expected_size = sizeof(CrashInfoHeader) + sizeof(CrashInfoDataStatic); break; - case 3: - expected_size = sizeof(CrashInfoHeader) + sizeof(CrashInfoDataV3); + case 4: + expected_size = sizeof(CrashInfoHeader) + sizeof(CrashInfoDataDynamic); break; default: @@ -282,28 +278,34 @@ static void ReadCrashInfo(unique_fd& fd, siginfo_t* siginfo, break; }; - if (rc != expected_size) { + if (rc < expected_size) { LOG(FATAL) << "read " << rc << " bytes when reading target crash information, expected " << expected_size; } } - *fdsan_table_address = 0; - *gwp_asan_state = 0; - *gwp_asan_metadata = 0; switch (crash_info->header.version) { - case 3: - *gwp_asan_state = crash_info->data.v3.gwp_asan_state; - *gwp_asan_metadata = crash_info->data.v3.gwp_asan_metadata; - FALLTHROUGH_INTENDED; - case 2: - *fdsan_table_address = crash_info->data.v2.fdsan_table_address; + case 4: + process_info->fdsan_table_address = crash_info->data.d.fdsan_table_address; + process_info->gwp_asan_state = crash_info->data.d.gwp_asan_state; + process_info->gwp_asan_metadata = crash_info->data.d.gwp_asan_metadata; + process_info->scudo_stack_depot = crash_info->data.d.scudo_stack_depot; + process_info->scudo_region_info = crash_info->data.d.scudo_region_info; FALLTHROUGH_INTENDED; case 1: - *abort_msg_address = crash_info->data.v1.abort_msg_address; - *siginfo = crash_info->data.v1.siginfo; + case 2: + case 3: + process_info->abort_msg_address = crash_info->data.s.abort_msg_address; + *siginfo = crash_info->data.s.siginfo; + if (signal_has_si_addr(siginfo)) { + // Make a copy of the ucontext field because otherwise it is not aligned enough (due to + // being in a packed struct) and clang complains about that. + ucontext_t ucontext = crash_info->data.s.ucontext; + process_info->has_fault_address = true; + process_info->fault_address = get_fault_address(siginfo, &ucontext); + } regs->reset(unwindstack::Regs::CreateFromUcontext(unwindstack::Regs::CurrentArch(), - &crash_info->data.v1.ucontext)); + &crash_info->data.s.ucontext)); break; default: @@ -425,10 +427,7 @@ int main(int argc, char** argv) { ATRACE_NAME("after reparent"); pid_t pseudothread_tid; DebuggerdDumpType dump_type; - uintptr_t abort_msg_address = 0; - uintptr_t fdsan_table_address = 0; - uintptr_t gwp_asan_state = 0; - uintptr_t gwp_asan_metadata = 0; + ProcessInfo process_info; Initialize(argv); ParseArgs(argc, argv, &pseudothread_tid, &dump_type); @@ -489,8 +488,7 @@ int main(int argc, char** argv) { if (thread == g_target_thread) { // Read the thread's registers along with the rest of the crash info out of the pipe. - ReadCrashInfo(input_pipe, &siginfo, &info.registers, &abort_msg_address, - &fdsan_table_address, &gwp_asan_state, &gwp_asan_metadata); + ReadCrashInfo(input_pipe, &siginfo, &info.registers, &process_info); info.siginfo = &siginfo; info.signo = info.siginfo->si_signo; } else { @@ -599,14 +597,14 @@ int main(int argc, char** argv) { } else { { ATRACE_NAME("fdsan table dump"); - populate_fdsan_table(&open_files, unwinder.GetProcessMemory(), fdsan_table_address); + populate_fdsan_table(&open_files, unwinder.GetProcessMemory(), + process_info.fdsan_table_address); } { ATRACE_NAME("engrave_tombstone"); - engrave_tombstone(std::move(g_output_fd), &unwinder, thread_info, g_target_thread, - abort_msg_address, &open_files, &amfd_data, gwp_asan_state, - gwp_asan_metadata); + engrave_tombstone(std::move(g_output_fd), &unwinder, thread_info, g_target_thread, process_info, + &open_files, &amfd_data); } } |