diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-09 05:58:26 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-09 05:58:26 +0000 |
commit | 41ebffe74f0534624cb0916d743ba777eb93f353 (patch) | |
tree | 2552b2460f512b2a12eda5710d8a596f3dcb9b01 | |
parent | 01ca8e414235ca216aabcefaaecb14806d14c099 (diff) | |
parent | 3a491726721f7b040d3b95c994fdab92dd6350ee (diff) | |
download | gwp_asan-android13-frc-ipsec-release.tar.gz |
Snap for 8558685 from 3a491726721f7b040d3b95c994fdab92dd6350ee to tm-frc-ipsec-releaset_frc_ips_330443010android13-frc-ipsec-release
Change-Id: Iaa224fed8015a23c49839dbd98a5e11a5f01ffe7
-rw-r--r-- | Android.bp | 5 | ||||
-rw-r--r-- | android/test_backtrace.cpp | 23 | ||||
-rw-r--r-- | gwp_asan/tests/iterate.cpp | 1 |
3 files changed, 16 insertions, 13 deletions
@@ -100,6 +100,7 @@ cc_library_headers { "com.android.art.debug", "com.android.media", "com.android.media.swcodec", + "com.android.virt", ], } @@ -225,9 +226,5 @@ cc_test { // Ensure that the helper functions in test/backtrace.cpp don't get // tail-call optimised, as this breaks the unwind chain. "-fno-optimize-sibling-calls", - - // The experimental pass manager seems to kill __attribute__((optnone)), - // and so we disable it (as we rely on optnone for tests/backtrace.cpp). - "-fno-experimental-new-pass-manager", ], } 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 diff --git a/gwp_asan/tests/iterate.cpp b/gwp_asan/tests/iterate.cpp index 2b8635d..49953f3 100644 --- a/gwp_asan/tests/iterate.cpp +++ b/gwp_asan/tests/iterate.cpp @@ -8,6 +8,7 @@ #include "gwp_asan/tests/harness.h" +#include <algorithm> #include <set> #include <vector> |