Use new unwinder for offline in libbacktrace.
libbbacktrace changes:
- Completely rewrite the BacktraceOffline class to use the new unwinder.
- Modify the test data to save ucontext_t data instead of unw_context data.
- Convert the previous tests from unw_context data to ucontext_t data.
Bug: 65682279
Test: New unit tests pass in libunwindstack.
Test: All offline tests continue to pass.
Change-Id: I540345c304b20199d46deeb0349a0638a0f3ab2f
diff --git a/libbacktrace/UnwindStack.h b/libbacktrace/UnwindStack.h
index 498ad4e..33c4282 100644
--- a/libbacktrace/UnwindStack.h
+++ b/libbacktrace/UnwindStack.h
@@ -34,7 +34,7 @@
std::string GetFunctionNameRaw(uint64_t pc, uint64_t* offset) override;
- bool UnwindFromContext(size_t num_ignore_frames, ucontext_t* ucontext) override;
+ bool UnwindFromContext(size_t num_ignore_frames, void* ucontext) override;
};
class UnwindStackPtrace : public BacktracePtrace {
@@ -42,9 +42,9 @@
UnwindStackPtrace(pid_t pid, pid_t tid, BacktraceMap* map);
virtual ~UnwindStackPtrace() = default;
- bool Unwind(size_t num_ignore_frames, ucontext_t* context) override;
+ bool Unwind(size_t num_ignore_frames, void* context) override;
- std::string GetFunctionNameRaw(uint64_t pc, uint64_t* offset);
+ std::string GetFunctionNameRaw(uint64_t pc, uint64_t* offset) override;
size_t Read(uint64_t addr, uint8_t* buffer, size_t bytes) override;
@@ -52,4 +52,20 @@
unwindstack::MemoryRemote memory_;
};
+class UnwindStackOffline : public Backtrace {
+ public:
+ UnwindStackOffline(ArchEnum arch, pid_t pid, pid_t tid, BacktraceMap* map, bool map_shared);
+
+ bool Unwind(size_t num_ignore_frames, void* context) override;
+
+ std::string GetFunctionNameRaw(uint64_t pc, uint64_t* offset);
+
+ size_t Read(uint64_t addr, uint8_t* buffer, size_t bytes) override;
+
+ bool ReadWord(uint64_t ptr, word_t* out_value) override;
+
+ private:
+ ArchEnum arch_;
+};
+
#endif // _LIBBACKTRACE_UNWIND_STACK_H