diff options
author | Christopher Ferris <cferris@google.com> | 2022-03-05 00:25:45 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-03-05 00:25:45 +0000 |
commit | 6bc511ae96f8dd0547714d08d2637dcfff729d92 (patch) | |
tree | a65dc2cb2649cf88eaa1ccaabac51a6092583b69 | |
parent | a65d8a7e3bd61eb5958d4b8378e592f208a7dbbd (diff) | |
parent | 241d3b8bd95debba314fcf1ec7138aca160aaa9f (diff) | |
download | gwp_asan-6bc511ae96f8dd0547714d08d2637dcfff729d92.tar.gz |
Update for removal of LocalUnwinder object. am: ebd75f4048 am: 5278c55d55 am: 1c4b08efa7 am: 241d3b8bd9
Original change: https://android-review.googlesource.com/c/platform/external/gwp_asan/+/2007514
Change-Id: I8b39756c75b50770961aaa279cd6c239bd88855a
-rw-r--r-- | android/test_backtrace.cpp | 23 |
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 |