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
diff --git a/libbacktrace/BacktraceCurrent.cpp b/libbacktrace/BacktraceCurrent.cpp
index b7190e2..fd1f4da 100644
--- a/libbacktrace/BacktraceCurrent.cpp
+++ b/libbacktrace/BacktraceCurrent.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#define _GNU_SOURCE 1
#include <errno.h>
#include <stdint.h>
#include <string.h>
@@ -73,6 +74,16 @@
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) {