Loading debuggerd/crash_dump.cpp +8 −8 Original line number Diff line number Diff line Loading @@ -51,12 +51,9 @@ #define ATRACE_TAG ATRACE_TAG_BIONIC #include <utils/Trace.h> #include <unwindstack/DexFiles.h> #include <unwindstack/JitDebug.h> #include <unwindstack/Maps.h> #include <unwindstack/Memory.h> #include <unwindstack/AndroidUnwinder.h> #include <unwindstack/Error.h> #include <unwindstack/Regs.h> #include <unwindstack/Unwinder.h> #include "libdebuggerd/backtrace.h" #include "libdebuggerd/tombstone.h" Loading Loading @@ -623,9 +620,12 @@ int main(int argc, char** argv) { } // TODO: Use seccomp to lock ourselves down. unwindstack::UnwinderFromPid unwinder(256, vm_pid, unwindstack::Regs::CurrentArch()); if (!unwinder.Init()) { LOG(FATAL) << "Failed to init unwinder object."; unwindstack::AndroidRemoteUnwinder unwinder(vm_pid, unwindstack::Regs::CurrentArch()); unwindstack::ErrorData error_data; if (!unwinder.Initialize(error_data)) { LOG(FATAL) << "Failed to initialize unwinder object: " << unwindstack::GetErrorCodeString(error_data.code); } std::string amfd_data; Loading debuggerd/handler/debuggerd_fallback.cpp +3 −6 Original line number Diff line number Diff line Loading @@ -31,12 +31,9 @@ #include <android-base/unique_fd.h> #include <async_safe/log.h> #include <bionic/reserved_signals.h> #include <unwindstack/DexFiles.h> #include <unwindstack/JitDebug.h> #include <unwindstack/Maps.h> #include <unwindstack/AndroidUnwinder.h> #include <unwindstack/Memory.h> #include <unwindstack/Regs.h> #include <unwindstack/Unwinder.h> #include "debuggerd/handler.h" #include "handler/fallback.h" Loading Loading @@ -75,11 +72,11 @@ static void debuggerd_fallback_trace(int output_fd, ucontext_t* ucontext) { // Do not use the thread cache here because it will call pthread_key_create // which doesn't work in linker code. See b/189803009. // Use a normal cached object because the process is stopped, and there // Use a normal cached object because the thread is stopped, and there // is no chance of data changing between reads. auto process_memory = unwindstack::Memory::CreateProcessMemoryCached(getpid()); // TODO: Create this once and store it in a global? unwindstack::UnwinderFromPid unwinder(kMaxFrames, getpid(), process_memory); unwindstack::AndroidLocalUnwinder unwinder(process_memory); dump_backtrace_thread(output_fd, &unwinder, thread); } __linker_disable_fallback_allocator(); Loading debuggerd/libdebuggerd/backtrace.cpp +8 −11 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ #include <android-base/strings.h> #include <android-base/unique_fd.h> #include <log/log.h> #include <unwindstack/AndroidUnwinder.h> #include <unwindstack/Unwinder.h> #include "libdebuggerd/types.h" Loading @@ -57,7 +58,7 @@ static void dump_process_footer(log_t* log, pid_t pid) { _LOG(log, logtype::BACKTRACE, "\n----- end %d -----\n", pid); } void dump_backtrace_thread(int output_fd, unwindstack::Unwinder* unwinder, void dump_backtrace_thread(int output_fd, unwindstack::AndroidUnwinder* unwinder, const ThreadInfo& thread) { log_t log; log.tfd = output_fd; Loading @@ -65,21 +66,17 @@ void dump_backtrace_thread(int output_fd, unwindstack::Unwinder* unwinder, _LOG(&log, logtype::BACKTRACE, "\n\"%s\" sysTid=%d\n", thread.thread_name.c_str(), thread.tid); unwinder->SetRegs(thread.registers.get()); unwinder->Unwind(); if (unwinder->NumFrames() == 0) { _LOG(&log, logtype::THREAD, "Unwind failed: tid = %d\n", thread.tid); if (unwinder->LastErrorCode() != unwindstack::ERROR_NONE) { _LOG(&log, logtype::THREAD, " Error code: %s\n", unwinder->LastErrorCodeString()); _LOG(&log, logtype::THREAD, " Error address: 0x%" PRIx64 "\n", unwinder->LastErrorAddress()); } unwindstack::AndroidUnwinderData data; if (!unwinder->Unwind(thread.registers.get(), data)) { _LOG(&log, logtype::THREAD, "Unwind failed: tid = %d: Error %s\n", thread.tid, data.GetErrorString().c_str()); return; } log_backtrace(&log, unwinder, " "); log_backtrace(&log, unwinder, data, " "); } void dump_backtrace(android::base::unique_fd output_fd, unwindstack::Unwinder* unwinder, void dump_backtrace(android::base::unique_fd output_fd, unwindstack::AndroidUnwinder* unwinder, const std::map<pid_t, ThreadInfo>& thread_info, pid_t target_thread) { log_t log; log.tfd = output_fd.get(); Loading debuggerd/libdebuggerd/gwp_asan.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -21,9 +21,8 @@ #include "gwp_asan/common.h" #include "gwp_asan/crash_handler.h" #include <unwindstack/Maps.h> #include <unwindstack/AndroidUnwinder.h> #include <unwindstack/Memory.h> #include <unwindstack/Regs.h> #include <unwindstack/Unwinder.h> #include "tombstone.pb.h" Loading Loading @@ -106,7 +105,8 @@ bool GwpAsanCrashData::CrashIsMine() const { constexpr size_t kMaxTraceLength = gwp_asan::AllocationMetadata::kMaxTraceLengthToCollect; void GwpAsanCrashData::AddCauseProtos(Tombstone* tombstone, unwindstack::Unwinder* unwinder) const { void GwpAsanCrashData::AddCauseProtos(Tombstone* tombstone, unwindstack::AndroidUnwinder* unwinder) const { if (!CrashIsMine()) { ALOGE("Internal Error: AddCauseProtos() on a non-GWP-ASan crash."); return; Loading Loading @@ -140,7 +140,6 @@ void GwpAsanCrashData::AddCauseProtos(Tombstone* tombstone, unwindstack::Unwinde heap_object->set_address(__gwp_asan_get_allocation_address(responsible_allocation_)); heap_object->set_size(__gwp_asan_get_allocation_size(responsible_allocation_)); unwinder->SetDisplayBuildID(true); std::unique_ptr<uintptr_t[]> frames(new uintptr_t[kMaxTraceLength]); Loading debuggerd/libdebuggerd/include/libdebuggerd/backtrace.h +3 −3 Original line number Diff line number Diff line Loading @@ -30,16 +30,16 @@ // Forward delcaration namespace unwindstack { class Unwinder; class AndroidUnwinder; } // Dumps a backtrace using a format similar to what Dalvik uses so that the result // can be intermixed in a bug report. void dump_backtrace(android::base::unique_fd output_fd, unwindstack::Unwinder* unwinder, void dump_backtrace(android::base::unique_fd output_fd, unwindstack::AndroidUnwinder* unwinder, const std::map<pid_t, ThreadInfo>& thread_info, pid_t target_thread); void dump_backtrace_header(int output_fd); void dump_backtrace_thread(int output_fd, unwindstack::Unwinder* unwinder, void dump_backtrace_thread(int output_fd, unwindstack::AndroidUnwinder* unwinder, const ThreadInfo& thread); void dump_backtrace_footer(int output_fd); Loading Loading
debuggerd/crash_dump.cpp +8 −8 Original line number Diff line number Diff line Loading @@ -51,12 +51,9 @@ #define ATRACE_TAG ATRACE_TAG_BIONIC #include <utils/Trace.h> #include <unwindstack/DexFiles.h> #include <unwindstack/JitDebug.h> #include <unwindstack/Maps.h> #include <unwindstack/Memory.h> #include <unwindstack/AndroidUnwinder.h> #include <unwindstack/Error.h> #include <unwindstack/Regs.h> #include <unwindstack/Unwinder.h> #include "libdebuggerd/backtrace.h" #include "libdebuggerd/tombstone.h" Loading Loading @@ -623,9 +620,12 @@ int main(int argc, char** argv) { } // TODO: Use seccomp to lock ourselves down. unwindstack::UnwinderFromPid unwinder(256, vm_pid, unwindstack::Regs::CurrentArch()); if (!unwinder.Init()) { LOG(FATAL) << "Failed to init unwinder object."; unwindstack::AndroidRemoteUnwinder unwinder(vm_pid, unwindstack::Regs::CurrentArch()); unwindstack::ErrorData error_data; if (!unwinder.Initialize(error_data)) { LOG(FATAL) << "Failed to initialize unwinder object: " << unwindstack::GetErrorCodeString(error_data.code); } std::string amfd_data; Loading
debuggerd/handler/debuggerd_fallback.cpp +3 −6 Original line number Diff line number Diff line Loading @@ -31,12 +31,9 @@ #include <android-base/unique_fd.h> #include <async_safe/log.h> #include <bionic/reserved_signals.h> #include <unwindstack/DexFiles.h> #include <unwindstack/JitDebug.h> #include <unwindstack/Maps.h> #include <unwindstack/AndroidUnwinder.h> #include <unwindstack/Memory.h> #include <unwindstack/Regs.h> #include <unwindstack/Unwinder.h> #include "debuggerd/handler.h" #include "handler/fallback.h" Loading Loading @@ -75,11 +72,11 @@ static void debuggerd_fallback_trace(int output_fd, ucontext_t* ucontext) { // Do not use the thread cache here because it will call pthread_key_create // which doesn't work in linker code. See b/189803009. // Use a normal cached object because the process is stopped, and there // Use a normal cached object because the thread is stopped, and there // is no chance of data changing between reads. auto process_memory = unwindstack::Memory::CreateProcessMemoryCached(getpid()); // TODO: Create this once and store it in a global? unwindstack::UnwinderFromPid unwinder(kMaxFrames, getpid(), process_memory); unwindstack::AndroidLocalUnwinder unwinder(process_memory); dump_backtrace_thread(output_fd, &unwinder, thread); } __linker_disable_fallback_allocator(); Loading
debuggerd/libdebuggerd/backtrace.cpp +8 −11 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ #include <android-base/strings.h> #include <android-base/unique_fd.h> #include <log/log.h> #include <unwindstack/AndroidUnwinder.h> #include <unwindstack/Unwinder.h> #include "libdebuggerd/types.h" Loading @@ -57,7 +58,7 @@ static void dump_process_footer(log_t* log, pid_t pid) { _LOG(log, logtype::BACKTRACE, "\n----- end %d -----\n", pid); } void dump_backtrace_thread(int output_fd, unwindstack::Unwinder* unwinder, void dump_backtrace_thread(int output_fd, unwindstack::AndroidUnwinder* unwinder, const ThreadInfo& thread) { log_t log; log.tfd = output_fd; Loading @@ -65,21 +66,17 @@ void dump_backtrace_thread(int output_fd, unwindstack::Unwinder* unwinder, _LOG(&log, logtype::BACKTRACE, "\n\"%s\" sysTid=%d\n", thread.thread_name.c_str(), thread.tid); unwinder->SetRegs(thread.registers.get()); unwinder->Unwind(); if (unwinder->NumFrames() == 0) { _LOG(&log, logtype::THREAD, "Unwind failed: tid = %d\n", thread.tid); if (unwinder->LastErrorCode() != unwindstack::ERROR_NONE) { _LOG(&log, logtype::THREAD, " Error code: %s\n", unwinder->LastErrorCodeString()); _LOG(&log, logtype::THREAD, " Error address: 0x%" PRIx64 "\n", unwinder->LastErrorAddress()); } unwindstack::AndroidUnwinderData data; if (!unwinder->Unwind(thread.registers.get(), data)) { _LOG(&log, logtype::THREAD, "Unwind failed: tid = %d: Error %s\n", thread.tid, data.GetErrorString().c_str()); return; } log_backtrace(&log, unwinder, " "); log_backtrace(&log, unwinder, data, " "); } void dump_backtrace(android::base::unique_fd output_fd, unwindstack::Unwinder* unwinder, void dump_backtrace(android::base::unique_fd output_fd, unwindstack::AndroidUnwinder* unwinder, const std::map<pid_t, ThreadInfo>& thread_info, pid_t target_thread) { log_t log; log.tfd = output_fd.get(); Loading
debuggerd/libdebuggerd/gwp_asan.cpp +3 −4 Original line number Diff line number Diff line Loading @@ -21,9 +21,8 @@ #include "gwp_asan/common.h" #include "gwp_asan/crash_handler.h" #include <unwindstack/Maps.h> #include <unwindstack/AndroidUnwinder.h> #include <unwindstack/Memory.h> #include <unwindstack/Regs.h> #include <unwindstack/Unwinder.h> #include "tombstone.pb.h" Loading Loading @@ -106,7 +105,8 @@ bool GwpAsanCrashData::CrashIsMine() const { constexpr size_t kMaxTraceLength = gwp_asan::AllocationMetadata::kMaxTraceLengthToCollect; void GwpAsanCrashData::AddCauseProtos(Tombstone* tombstone, unwindstack::Unwinder* unwinder) const { void GwpAsanCrashData::AddCauseProtos(Tombstone* tombstone, unwindstack::AndroidUnwinder* unwinder) const { if (!CrashIsMine()) { ALOGE("Internal Error: AddCauseProtos() on a non-GWP-ASan crash."); return; Loading Loading @@ -140,7 +140,6 @@ void GwpAsanCrashData::AddCauseProtos(Tombstone* tombstone, unwindstack::Unwinde heap_object->set_address(__gwp_asan_get_allocation_address(responsible_allocation_)); heap_object->set_size(__gwp_asan_get_allocation_size(responsible_allocation_)); unwinder->SetDisplayBuildID(true); std::unique_ptr<uintptr_t[]> frames(new uintptr_t[kMaxTraceLength]); Loading
debuggerd/libdebuggerd/include/libdebuggerd/backtrace.h +3 −3 Original line number Diff line number Diff line Loading @@ -30,16 +30,16 @@ // Forward delcaration namespace unwindstack { class Unwinder; class AndroidUnwinder; } // Dumps a backtrace using a format similar to what Dalvik uses so that the result // can be intermixed in a bug report. void dump_backtrace(android::base::unique_fd output_fd, unwindstack::Unwinder* unwinder, void dump_backtrace(android::base::unique_fd output_fd, unwindstack::AndroidUnwinder* unwinder, const std::map<pid_t, ThreadInfo>& thread_info, pid_t target_thread); void dump_backtrace_header(int output_fd); void dump_backtrace_thread(int output_fd, unwindstack::Unwinder* unwinder, void dump_backtrace_thread(int output_fd, unwindstack::AndroidUnwinder* unwinder, const ThreadInfo& thread); void dump_backtrace_footer(int output_fd); Loading