diff options
author | Josh Gao <jmgao@google.com> | 2017-10-25 15:21:45 -0700 |
---|---|---|
committer | Josh Gao <jmgao@google.com> | 2017-10-26 14:19:49 -0700 |
commit | cd546c11d679288d552d80b3e6caf965a9094c63 (patch) | |
tree | 3e78e02b3af17a345e0ae63f776d20ec954a6f99 /libbacktrace | |
parent | 972753e09411ab223d2ed5a70a2a99938f2785b1 (diff) | |
download | core-cd546c11d679288d552d80b3e6caf965a9094c63.tar.gz core-cd546c11d679288d552d80b3e6caf965a9094c63.tar.bz2 core-cd546c11d679288d552d80b3e6caf965a9094c63.zip |
libbacktrace: correctly number frames when skipping.
Correct for the number of skipped frames when unwinding with
libunwindstack.
Test: backtrace_test32 --gtest_filter="unwind_frame_skip_*"
Change-Id: I9528977104fde3c4ec792a6db1ada24ed571b867
Diffstat (limited to 'libbacktrace')
-rw-r--r-- | libbacktrace/UnwindStack.cpp | 2 | ||||
-rw-r--r-- | libbacktrace/backtrace_test.cpp | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/libbacktrace/UnwindStack.cpp b/libbacktrace/UnwindStack.cpp index c3f08c81c..62e453fb8 100644 --- a/libbacktrace/UnwindStack.cpp +++ b/libbacktrace/UnwindStack.cpp @@ -64,7 +64,7 @@ bool Backtrace::Unwind(unwindstack::Regs* regs, BacktraceMap* back_map, auto frame = &unwinder_frames[i]; backtrace_frame_data_t* back_frame = &frames->at(cur_frame); - back_frame->num = frame->num; + back_frame->num = frame->num - num_ignore_frames; back_frame->rel_pc = frame->rel_pc; back_frame->pc = frame->pc; diff --git a/libbacktrace/backtrace_test.cpp b/libbacktrace/backtrace_test.cpp index e5eb9e34e..c3e5da09b 100644 --- a/libbacktrace/backtrace_test.cpp +++ b/libbacktrace/backtrace_test.cpp @@ -1844,6 +1844,22 @@ TEST(libbacktrace, unwind_remote_through_signal_using_action_new) { UnwindThroughSignal(true, Backtrace::CreateNew, BacktraceMap::CreateNew); } +static void TestFrameSkipNumbering(create_func_t create_func, map_create_func_t map_create_func) { + std::unique_ptr<BacktraceMap> map(map_create_func(getpid(), false)); + std::unique_ptr<Backtrace> backtrace(create_func(getpid(), gettid(), map.get())); + backtrace->Unwind(1); + ASSERT_NE(0U, backtrace->NumFrames()); + ASSERT_EQ(0U, backtrace->GetFrame(0)->num); +} + +TEST(libbacktrace, unwind_frame_skip_numbering) { + TestFrameSkipNumbering(Backtrace::Create, BacktraceMap::Create); +} + +TEST(libbacktrace, unwind_frame_skip_numbering_new) { + TestFrameSkipNumbering(Backtrace::CreateNew, BacktraceMap::CreateNew); +} + #if defined(ENABLE_PSS_TESTS) #include "GetPss.h" |