diff options
author | Josh Gao <jmgao@google.com> | 2017-09-06 14:35:35 -0700 |
---|---|---|
committer | Josh Gao <jmgao@google.com> | 2017-10-20 13:52:56 -0700 |
commit | 45c4a56f1d484ce60390bf48ab55076d4d601c9d (patch) | |
tree | d6401f8b6a85858c91af46cb6b282f3f1ac8cc50 /libbacktrace | |
parent | d72d92aee2d125f6a8d26932e6482bea5398b92c (diff) | |
download | core-45c4a56f1d484ce60390bf48ab55076d4d601c9d.tar.gz core-45c4a56f1d484ce60390bf48ab55076d4d601c9d.tar.bz2 core-45c4a56f1d484ce60390bf48ab55076d4d601c9d.zip |
libbacktrace: expose libunwindstack Unwind routine.
Test: backtrace_test32/64 on hikey960
Change-Id: Iae6e342a8ffd13b4d5f76b39dd434c827f7a4d9e
Diffstat (limited to 'libbacktrace')
-rw-r--r-- | libbacktrace/UnwindStack.cpp | 8 | ||||
-rw-r--r-- | libbacktrace/include/backtrace/Backtrace.h | 7 |
2 files changed, 11 insertions, 4 deletions
diff --git a/libbacktrace/UnwindStack.cpp b/libbacktrace/UnwindStack.cpp index 41153ce19..0f6730c8b 100644 --- a/libbacktrace/UnwindStack.cpp +++ b/libbacktrace/UnwindStack.cpp @@ -66,8 +66,8 @@ static std::string GetFunctionName(BacktraceMap* back_map, uintptr_t pc, uintptr return name; } -static bool Unwind(unwindstack::Regs* regs, BacktraceMap* back_map, - std::vector<backtrace_frame_data_t>* frames, size_t num_ignore_frames) { +bool Backtrace::Unwind(unwindstack::Regs* regs, BacktraceMap* back_map, + std::vector<backtrace_frame_data_t>* frames, size_t num_ignore_frames) { static std::set<std::string> skip_names{"libunwindstack.so", "libbacktrace.so"}; UnwindStackMap* stack_map = reinterpret_cast<UnwindStackMap*>(back_map); auto process_memory = stack_map->process_memory(); @@ -127,7 +127,7 @@ bool UnwindStackCurrent::UnwindFromContext(size_t num_ignore_frames, ucontext_t* } error_ = BACKTRACE_UNWIND_NO_ERROR; - return ::Unwind(regs.get(), GetMap(), &frames_, num_ignore_frames); + return Backtrace::Unwind(regs.get(), GetMap(), &frames_, num_ignore_frames); } UnwindStackPtrace::UnwindStackPtrace(pid_t pid, pid_t tid, BacktraceMap* map) @@ -147,7 +147,7 @@ bool UnwindStackPtrace::Unwind(size_t num_ignore_frames, ucontext_t* context) { } error_ = BACKTRACE_UNWIND_NO_ERROR; - return ::Unwind(regs.get(), GetMap(), &frames_, num_ignore_frames); + return Backtrace::Unwind(regs.get(), GetMap(), &frames_, num_ignore_frames); } Backtrace* Backtrace::CreateNew(pid_t pid, pid_t tid, BacktraceMap* map) { diff --git a/libbacktrace/include/backtrace/Backtrace.h b/libbacktrace/include/backtrace/Backtrace.h index 289fd0cef..274c64bb6 100644 --- a/libbacktrace/include/backtrace/Backtrace.h +++ b/libbacktrace/include/backtrace/Backtrace.h @@ -77,6 +77,10 @@ struct backtrace_stackinfo_t { const uint8_t* data; }; +namespace unwindstack { +class Regs; +} + class Backtrace { public: // Create the correct Backtrace object based on what is to be unwound. @@ -106,6 +110,9 @@ public: // Get the current stack trace and store in the backtrace_ structure. virtual bool Unwind(size_t num_ignore_frames, ucontext_t* context = NULL) = 0; + static bool Unwind(unwindstack::Regs* regs, BacktraceMap* back_map, + std::vector<backtrace_frame_data_t>* frames, size_t num_ignore_frames); + // Get the function name and offset into the function given the pc. // If the string is empty, then no valid function name was found, // or the pc is not in any valid map. |