Loading debuggerd/backtrace.cpp +6 −0 Original line number Original line Diff line number Diff line Loading @@ -14,6 +14,8 @@ * limitations under the License. * limitations under the License. */ */ #define LOG_TAG "DEBUG" #include <stddef.h> #include <stddef.h> #include <stdlib.h> #include <stdlib.h> #include <string.h> #include <string.h> Loading @@ -27,6 +29,8 @@ #include <sys/ptrace.h> #include <sys/ptrace.h> #include <backtrace/Backtrace.h> #include <backtrace/Backtrace.h> #include <log/log.h> #include <UniquePtr.h> #include <UniquePtr.h> #include "backtrace.h" #include "backtrace.h" Loading Loading @@ -95,6 +99,8 @@ static void dump_thread( UniquePtr<Backtrace> backtrace(Backtrace::Create(tid, BACKTRACE_CURRENT_THREAD)); UniquePtr<Backtrace> backtrace(Backtrace::Create(tid, BACKTRACE_CURRENT_THREAD)); if (backtrace->Unwind(0)) { if (backtrace->Unwind(0)) { dump_backtrace_to_log(backtrace.get(), log, " "); dump_backtrace_to_log(backtrace.get(), log, " "); } else { ALOGE("Unwind failed: tid = %d", tid); } } if (!attached && ptrace(PTRACE_DETACH, tid, 0, 0) != 0) { if (!attached && ptrace(PTRACE_DETACH, tid, 0, 0) != 0) { Loading debuggerd/tombstone.cpp +7 −1 Original line number Original line Diff line number Diff line Loading @@ -448,6 +448,8 @@ static bool dump_sibling_thread_report( UniquePtr<Backtrace> backtrace(Backtrace::Create(pid, new_tid, map)); UniquePtr<Backtrace> backtrace(Backtrace::Create(pid, new_tid, map)); if (backtrace->Unwind(0)) { if (backtrace->Unwind(0)) { dump_backtrace_and_stack(backtrace.get(), log); dump_backtrace_and_stack(backtrace.get(), log); } else { ALOGE("Unwind of sibling failed: pid = %d, tid = %d", pid, new_tid); } } log->current_tid = log->crashed_tid; log->current_tid = log->crashed_tid; Loading Loading @@ -650,9 +652,13 @@ static bool dump_crash(log_t* log, pid_t pid, pid_t tid, int signal, int si_code dump_registers(log, tid); dump_registers(log, tid); if (backtrace->Unwind(0)) { if (backtrace->Unwind(0)) { dump_backtrace_and_stack(backtrace.get(), log); dump_backtrace_and_stack(backtrace.get(), log); } else { ALOGE("Unwind failed: pid = %d, tid = %d", pid, tid); } } dump_memory_and_code(log, tid); dump_memory_and_code(log, tid); if (map.get() != nullptr) { dump_all_maps(backtrace.get(), map.get(), log, tid); dump_all_maps(backtrace.get(), map.get(), log, tid); } if (want_logs) { if (want_logs) { dump_logs(log, pid, 5); dump_logs(log, pid, 5); Loading libbacktrace/Backtrace.cpp +3 −1 Original line number Original line Diff line number Diff line Loading @@ -114,8 +114,10 @@ std::string Backtrace::FormatFrameData(const backtrace_frame_data_t* frame) { } } void Backtrace::FillInMap(uintptr_t pc, backtrace_map_t* map) { void Backtrace::FillInMap(uintptr_t pc, backtrace_map_t* map) { if (map_ != nullptr) { map_->FillIn(pc, map); map_->FillIn(pc, map); } } } Backtrace* Backtrace::Create(pid_t pid, pid_t tid, BacktraceMap* map) { Backtrace* Backtrace::Create(pid_t pid, pid_t tid, BacktraceMap* map) { if (pid == BACKTRACE_CURRENT_PROCESS) { if (pid == BACKTRACE_CURRENT_PROCESS) { Loading libbacktrace/BacktraceCurrent.cpp +5 −0 Original line number Original line Diff line number Diff line Loading @@ -65,6 +65,11 @@ size_t BacktraceCurrent::Read(uintptr_t addr, uint8_t* buffer, size_t bytes) { } } bool BacktraceCurrent::Unwind(size_t num_ignore_frames, ucontext_t* ucontext) { bool BacktraceCurrent::Unwind(size_t num_ignore_frames, ucontext_t* ucontext) { if (GetMap() == nullptr) { // Without a map object, we can't do anything. return false; } if (ucontext) { if (ucontext) { return UnwindFromContext(num_ignore_frames, ucontext); return UnwindFromContext(num_ignore_frames, ucontext); } } Loading libbacktrace/UnwindPtrace.cpp +5 −0 Original line number Original line Diff line number Diff line Loading @@ -48,6 +48,11 @@ UnwindPtrace::~UnwindPtrace() { } } bool UnwindPtrace::Unwind(size_t num_ignore_frames, ucontext_t* ucontext) { bool UnwindPtrace::Unwind(size_t num_ignore_frames, ucontext_t* ucontext) { if (GetMap() == nullptr) { // Without a map object, we can't do anything. return false; } if (ucontext) { if (ucontext) { BACK_LOGW("Unwinding from a specified context not supported yet."); BACK_LOGW("Unwinding from a specified context not supported yet."); return false; return false; Loading Loading
debuggerd/backtrace.cpp +6 −0 Original line number Original line Diff line number Diff line Loading @@ -14,6 +14,8 @@ * limitations under the License. * limitations under the License. */ */ #define LOG_TAG "DEBUG" #include <stddef.h> #include <stddef.h> #include <stdlib.h> #include <stdlib.h> #include <string.h> #include <string.h> Loading @@ -27,6 +29,8 @@ #include <sys/ptrace.h> #include <sys/ptrace.h> #include <backtrace/Backtrace.h> #include <backtrace/Backtrace.h> #include <log/log.h> #include <UniquePtr.h> #include <UniquePtr.h> #include "backtrace.h" #include "backtrace.h" Loading Loading @@ -95,6 +99,8 @@ static void dump_thread( UniquePtr<Backtrace> backtrace(Backtrace::Create(tid, BACKTRACE_CURRENT_THREAD)); UniquePtr<Backtrace> backtrace(Backtrace::Create(tid, BACKTRACE_CURRENT_THREAD)); if (backtrace->Unwind(0)) { if (backtrace->Unwind(0)) { dump_backtrace_to_log(backtrace.get(), log, " "); dump_backtrace_to_log(backtrace.get(), log, " "); } else { ALOGE("Unwind failed: tid = %d", tid); } } if (!attached && ptrace(PTRACE_DETACH, tid, 0, 0) != 0) { if (!attached && ptrace(PTRACE_DETACH, tid, 0, 0) != 0) { Loading
debuggerd/tombstone.cpp +7 −1 Original line number Original line Diff line number Diff line Loading @@ -448,6 +448,8 @@ static bool dump_sibling_thread_report( UniquePtr<Backtrace> backtrace(Backtrace::Create(pid, new_tid, map)); UniquePtr<Backtrace> backtrace(Backtrace::Create(pid, new_tid, map)); if (backtrace->Unwind(0)) { if (backtrace->Unwind(0)) { dump_backtrace_and_stack(backtrace.get(), log); dump_backtrace_and_stack(backtrace.get(), log); } else { ALOGE("Unwind of sibling failed: pid = %d, tid = %d", pid, new_tid); } } log->current_tid = log->crashed_tid; log->current_tid = log->crashed_tid; Loading Loading @@ -650,9 +652,13 @@ static bool dump_crash(log_t* log, pid_t pid, pid_t tid, int signal, int si_code dump_registers(log, tid); dump_registers(log, tid); if (backtrace->Unwind(0)) { if (backtrace->Unwind(0)) { dump_backtrace_and_stack(backtrace.get(), log); dump_backtrace_and_stack(backtrace.get(), log); } else { ALOGE("Unwind failed: pid = %d, tid = %d", pid, tid); } } dump_memory_and_code(log, tid); dump_memory_and_code(log, tid); if (map.get() != nullptr) { dump_all_maps(backtrace.get(), map.get(), log, tid); dump_all_maps(backtrace.get(), map.get(), log, tid); } if (want_logs) { if (want_logs) { dump_logs(log, pid, 5); dump_logs(log, pid, 5); Loading
libbacktrace/Backtrace.cpp +3 −1 Original line number Original line Diff line number Diff line Loading @@ -114,8 +114,10 @@ std::string Backtrace::FormatFrameData(const backtrace_frame_data_t* frame) { } } void Backtrace::FillInMap(uintptr_t pc, backtrace_map_t* map) { void Backtrace::FillInMap(uintptr_t pc, backtrace_map_t* map) { if (map_ != nullptr) { map_->FillIn(pc, map); map_->FillIn(pc, map); } } } Backtrace* Backtrace::Create(pid_t pid, pid_t tid, BacktraceMap* map) { Backtrace* Backtrace::Create(pid_t pid, pid_t tid, BacktraceMap* map) { if (pid == BACKTRACE_CURRENT_PROCESS) { if (pid == BACKTRACE_CURRENT_PROCESS) { Loading
libbacktrace/BacktraceCurrent.cpp +5 −0 Original line number Original line Diff line number Diff line Loading @@ -65,6 +65,11 @@ size_t BacktraceCurrent::Read(uintptr_t addr, uint8_t* buffer, size_t bytes) { } } bool BacktraceCurrent::Unwind(size_t num_ignore_frames, ucontext_t* ucontext) { bool BacktraceCurrent::Unwind(size_t num_ignore_frames, ucontext_t* ucontext) { if (GetMap() == nullptr) { // Without a map object, we can't do anything. return false; } if (ucontext) { if (ucontext) { return UnwindFromContext(num_ignore_frames, ucontext); return UnwindFromContext(num_ignore_frames, ucontext); } } Loading
libbacktrace/UnwindPtrace.cpp +5 −0 Original line number Original line Diff line number Diff line Loading @@ -48,6 +48,11 @@ UnwindPtrace::~UnwindPtrace() { } } bool UnwindPtrace::Unwind(size_t num_ignore_frames, ucontext_t* ucontext) { bool UnwindPtrace::Unwind(size_t num_ignore_frames, ucontext_t* ucontext) { if (GetMap() == nullptr) { // Without a map object, we can't do anything. return false; } if (ucontext) { if (ucontext) { BACK_LOGW("Unwinding from a specified context not supported yet."); BACK_LOGW("Unwinding from a specified context not supported yet."); return false; return false; Loading