Allow calling GetFunctionName before unwinding.
Some extra initialization needs to occur before calling the local/remote
GetFunctioneName.
Also, cleanup the test code a bit:
- Make all local functions static.
- Create a common function to create and finish remote processes.
- Remove unused function.
- Fix the formatting a bit by making it match clang format.
Test: Ran the unit tests.
Change-Id: I998bed1378d582df59fdf9263df6f208db5d795a
diff --git a/libbacktrace/UnwindCurrent.h b/libbacktrace/UnwindCurrent.h
index 3023996..3656104 100644
--- a/libbacktrace/UnwindCurrent.h
+++ b/libbacktrace/UnwindCurrent.h
@@ -32,18 +32,20 @@
#include <libunwind.h>
class UnwindCurrent : public BacktraceCurrent {
-public:
+ public:
UnwindCurrent(pid_t pid, pid_t tid, BacktraceMap* map) : BacktraceCurrent(pid, tid, map) {}
virtual ~UnwindCurrent() {}
std::string GetFunctionNameRaw(uintptr_t pc, uintptr_t* offset) override;
-private:
+ private:
void GetUnwContextFromUcontext(const ucontext_t* ucontext);
bool UnwindFromContext(size_t num_ignore_frames, ucontext_t* ucontext) override;
unw_context_t context_;
+
+ bool initialized_ = false;
};
#endif // _LIBBACKTRACE_UNWIND_CURRENT_H