Add support for using the new unwinder.
This adds a new option backtrace_full, when it is set, then it will use
libunwindstack.
Modify the dump to file data to dump the extra information from libunwindstack.
Along with the new dump file format, change the version to v1.1.
Updated document for new format of file data.
Add unit tests for the new functionality.
Bug: 74361929
Test: Ran unit tests.
Change-Id: I40fff795f5346bba7b9d7fde2e04f269ff4eb7f1
diff --git a/libc/malloc_debug/tests/backtrace_fake.cpp b/libc/malloc_debug/tests/backtrace_fake.cpp
index db542e5..ad16c02 100644
--- a/libc/malloc_debug/tests/backtrace_fake.cpp
+++ b/libc/malloc_debug/tests/backtrace_fake.cpp
@@ -20,6 +20,8 @@
#include <vector>
#include <utility>
+#include <unwindstack/LocalUnwinder.h>
+
#include "backtrace.h"
#include "backtrace_fake.h"
#include "debug_log.h"
@@ -57,3 +59,31 @@
error_log(" #%02zd pc %p", i, reinterpret_cast<void*>(frames[i]));
}
}
+
+static std::deque<std::vector<unwindstack::LocalFrameData>> g_fake_local_frame_data;
+
+void BacktraceUnwindFakeClearAll() {
+ g_fake_local_frame_data.clear();
+}
+
+void BacktraceUnwindFake(const std::vector<unwindstack::LocalFrameData>& frames) {
+ g_fake_local_frame_data.push_back(frames);
+}
+
+bool Unwind(std::vector<uintptr_t>* frames, std::vector<unwindstack::LocalFrameData>* info, size_t) {
+ if (g_fake_local_frame_data.empty()) {
+ return false;
+ }
+
+ *info = g_fake_local_frame_data.front();
+ g_fake_local_frame_data.pop_front();
+ frames->clear();
+ for (const auto& frame : *info) {
+ frames->push_back(frame.pc);
+ }
+
+ return true;
+}
+
+void UnwindLog(const std::vector<unwindstack::LocalFrameData>& /*frame_info*/) {
+}