diff options
author | Christopher Ferris <cferris@google.com> | 2015-03-31 17:28:22 -0700 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2015-04-01 15:58:20 -0700 |
commit | ca09ce902c17c2bffc02bfafaf0844204ac13333 (patch) | |
tree | b2e3d6aee81be584523cc67b8117edb28276e961 /libbacktrace/UnwindCurrent.cpp | |
parent | 9dc41d5d34c792e7a05e1ddfeea99c6cfc02fffd (diff) | |
download | core-ca09ce902c17c2bffc02bfafaf0844204ac13333.tar.gz core-ca09ce902c17c2bffc02bfafaf0844204ac13333.tar.bz2 core-ca09ce902c17c2bffc02bfafaf0844204ac13333.zip |
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
Diffstat (limited to 'libbacktrace/UnwindCurrent.cpp')
-rw-r--r-- | libbacktrace/UnwindCurrent.cpp | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/libbacktrace/UnwindCurrent.cpp b/libbacktrace/UnwindCurrent.cpp index 12e289095..67e583f08 100644 --- a/libbacktrace/UnwindCurrent.cpp +++ b/libbacktrace/UnwindCurrent.cpp @@ -99,25 +99,30 @@ bool UnwindCurrent::UnwindFromContext(size_t num_ignore_frames, ucontext_t* ucon break; } - if (num_ignore_frames == 0) { - frames_.resize(num_frames+1); - backtrace_frame_data_t* frame = &frames_.at(num_frames); - frame->num = num_frames; - frame->pc = static_cast<uintptr_t>(pc); - frame->sp = static_cast<uintptr_t>(sp); - frame->stack_size = 0; + frames_.resize(num_frames+1); + backtrace_frame_data_t* frame = &frames_.at(num_frames); + frame->num = num_frames; + frame->pc = static_cast<uintptr_t>(pc); + frame->sp = static_cast<uintptr_t>(sp); + frame->stack_size = 0; - if (num_frames > 0) { - // Set the stack size for the previous frame. - backtrace_frame_data_t* prev = &frames_.at(num_frames-1); - prev->stack_size = frame->sp - prev->sp; + FillInMap(frame->pc, &frame->map); + // Check to see if we should skip this frame because it's coming + // from within the library, and we are doing a local unwind. + if (ucontext != nullptr || num_frames != 0 || !DiscardFrame(*frame)) { + if (num_ignore_frames == 0) { + // GetFunctionName is an expensive call, only do it if we are + // keeping the frame. + frame->func_name = GetFunctionName(frame->pc, &frame->func_offset); + if (num_frames > 0) { + // Set the stack size for the previous frame. + backtrace_frame_data_t* prev = &frames_.at(num_frames-1); + prev->stack_size = frame->sp - prev->sp; + } + num_frames++; + } else { + num_ignore_frames--; } - - frame->func_name = GetFunctionName(frame->pc, &frame->func_offset); - FillInMap(frame->pc, &frame->map); - num_frames++; - } else { - num_ignore_frames--; } ret = unw_step (cursor.get()); } while (ret > 0 && num_frames < MAX_BACKTRACE_FRAMES); |