From c56a499422a7d85999babecfb0e7b8a7d0b42adc Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Thu, 2 Nov 2017 16:19:56 -0700 Subject: [PATCH] Only skip frames for local unwinds. When doing a remote unwind, and there is a crash in the unwind stack code or in libbacktrace, the old version would skip those frames. This makes debugging crashes in those libraries a bit difficult. Bug: 68820611 Test: Ran unit tests. Test: kill -3 a zygote process and verify no frames in Test: libunwindstack.so/libbacktrace.so. Test: Forced a crash in libunwindstack.so and verified the tombstone Test: contains the full crash. Change-Id: I297e5b3775c87c0dddf57ebb423bd72ba1baf193 --- libbacktrace/UnwindStack.cpp | 11 ++++++----- libbacktrace/include/backtrace/Backtrace.h | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libbacktrace/UnwindStack.cpp b/libbacktrace/UnwindStack.cpp index d17c211d0..3a3883902 100644 --- a/libbacktrace/UnwindStack.cpp +++ b/libbacktrace/UnwindStack.cpp @@ -44,13 +44,13 @@ #include "UnwindStackMap.h" bool Backtrace::Unwind(unwindstack::Regs* regs, BacktraceMap* back_map, - std::vector* frames, size_t num_ignore_frames) { - std::vector skip_names{"libunwindstack.so", "libbacktrace.so"}; + std::vector* frames, size_t num_ignore_frames, + std::vector* skip_names) { UnwindStackMap* stack_map = reinterpret_cast(back_map); auto process_memory = stack_map->process_memory(); unwindstack::Unwinder unwinder(MAX_BACKTRACE_FRAMES + num_ignore_frames, stack_map->stack_maps(), regs, stack_map->process_memory()); - unwinder.Unwind(&skip_names, &stack_map->GetSuffixesToIgnore()); + unwinder.Unwind(skip_names, &stack_map->GetSuffixesToIgnore()); if (num_ignore_frames >= unwinder.NumFrames()) { frames->resize(0); @@ -104,7 +104,8 @@ bool UnwindStackCurrent::UnwindFromContext(size_t num_ignore_frames, ucontext_t* } error_ = BACKTRACE_UNWIND_NO_ERROR; - return Backtrace::Unwind(regs.get(), GetMap(), &frames_, num_ignore_frames); + std::vector skip_names{"libunwindstack.so", "libbacktrace.so"}; + return Backtrace::Unwind(regs.get(), GetMap(), &frames_, num_ignore_frames, &skip_names); } UnwindStackPtrace::UnwindStackPtrace(pid_t pid, pid_t tid, BacktraceMap* map) @@ -124,5 +125,5 @@ bool UnwindStackPtrace::Unwind(size_t num_ignore_frames, ucontext_t* context) { } error_ = BACKTRACE_UNWIND_NO_ERROR; - return Backtrace::Unwind(regs.get(), GetMap(), &frames_, num_ignore_frames); + return Backtrace::Unwind(regs.get(), GetMap(), &frames_, num_ignore_frames, nullptr); } diff --git a/libbacktrace/include/backtrace/Backtrace.h b/libbacktrace/include/backtrace/Backtrace.h index 73a58b5ee..e07353346 100644 --- a/libbacktrace/include/backtrace/Backtrace.h +++ b/libbacktrace/include/backtrace/Backtrace.h @@ -109,7 +109,8 @@ public: virtual bool Unwind(size_t num_ignore_frames, ucontext_t* context = NULL) = 0; static bool Unwind(unwindstack::Regs* regs, BacktraceMap* back_map, - std::vector* frames, size_t num_ignore_frames); + std::vector* frames, size_t num_ignore_frames, + std::vector* skip_names); // Get the function name and offset into the function given the pc. // If the string is empty, then no valid function name was found,