summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2022-03-04 23:42:30 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-03-04 23:42:30 +0000
commit1c4b08efa7c75aca9df87970df7f5faa0bac39b8 (patch)
treea65dc2cb2649cf88eaa1ccaabac51a6092583b69
parentc1aa8d6fd898bb270009398f26b44b9398e39ce6 (diff)
parent5278c55d55814853f9824a99e44ad452b2609973 (diff)
downloadgwp_asan-1c4b08efa7c75aca9df87970df7f5faa0bac39b8.tar.gz
Update for removal of LocalUnwinder object. am: ebd75f4048 am: 5278c55d55
Original change: https://android-review.googlesource.com/c/platform/external/gwp_asan/+/2007514 Change-Id: Ia0aec88664c05577c59907a5ba4cd32099111429
-rw-r--r--android/test_backtrace.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/android/test_backtrace.cpp b/android/test_backtrace.cpp
index 4a6d20d..0d397fd 100644
--- a/android/test_backtrace.cpp
+++ b/android/test_backtrace.cpp
@@ -18,7 +18,10 @@
#include "gwp_asan/optional/backtrace.h"
#include "gwp_asan/optional/segv_handler.h"
-#include <unwindstack/LocalUnwinder.h>
+#include <unwindstack/Maps.h>
+#include <unwindstack/Memory.h>
+#include <unwindstack/Regs.h>
+#include <unwindstack/RegsGetLocal.h>
#include <unwindstack/Unwinder.h>
namespace {
@@ -32,19 +35,21 @@ namespace {
// potentially more detailed stack frames in the allocation/deallocation traces
// (as we don't use the production unwinder), but that's fine for test-only.
size_t BacktraceUnwindstack(uintptr_t *TraceBuffer, size_t Size) {
- unwindstack::LocalUnwinder unwinder;
- if (!unwinder.Init()) {
- return 0;
- }
- std::vector<unwindstack::LocalFrameData> frames;
- if (!unwinder.Unwind(&frames, Size)) {
+ unwindstack::LocalMaps maps;
+ if (!maps.Parse()) {
return 0;
}
- for (const auto &frame : frames) {
+
+ auto process_memory = unwindstack::Memory::CreateProcessMemoryThreadCached(getpid());
+ std::unique_ptr<unwindstack::Regs> regs(unwindstack::Regs::CreateFromLocal());
+ unwindstack::RegsGetLocal(regs.get());
+ unwindstack::Unwinder unwinder(Size, &maps, regs.get(), process_memory);
+ unwinder.Unwind();
+ for (const auto &frame : unwinder.frames()) {
*TraceBuffer = frame.pc;
TraceBuffer++;
}
- return frames.size();
+ return unwinder.NumFrames();
}
// We don't need any custom handling for the Segv backtrace - the unwindstack