From ca09ce902c17c2bffc02bfafaf0844204ac13333 Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Tue, 31 Mar 2015 17:28:22 -0700 Subject: Discards frames for code within library. When doing a local unwind, do not include the frames that come from either libunwind or libbacktrace. Bug: 11518609 Change-Id: I0ec8d823aebbfa0903e61b16b7e5663f3fd65e78 --- libbacktrace/BacktraceCurrent.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libbacktrace/BacktraceCurrent.cpp') diff --git a/libbacktrace/BacktraceCurrent.cpp b/libbacktrace/BacktraceCurrent.cpp index b7190e256..fd1f4da7b 100644 --- a/libbacktrace/BacktraceCurrent.cpp +++ b/libbacktrace/BacktraceCurrent.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#define _GNU_SOURCE 1 #include #include #include @@ -73,6 +74,16 @@ bool BacktraceCurrent::Unwind(size_t num_ignore_frames, ucontext_t* ucontext) { return UnwindFromContext(num_ignore_frames, nullptr); } +bool BacktraceCurrent::DiscardFrame(const backtrace_frame_data_t& frame) { + if (BacktraceMap::IsValid(frame.map)) { + const std::string library = basename(frame.map.name.c_str()); + if (library == "libunwind.so" || library == "libbacktrace.so") { + return true; + } + } + return false; +} + static pthread_mutex_t g_sigaction_mutex = PTHREAD_MUTEX_INITIALIZER; static void SignalHandler(int, siginfo_t*, void* sigcontext) { -- cgit v1.2.3