diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-04-28 15:57:00 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-04-28 15:57:00 +0000 |
commit | 56ba3e0abc1ff9da3bbac28aad3acc48c783c417 (patch) | |
tree | 2552b2460f512b2a12eda5710d8a596f3dcb9b01 | |
parent | dd02cb60c2ca7664fab673389f0901b9a8980d71 (diff) | |
parent | 3a491726721f7b040d3b95c994fdab92dd6350ee (diff) | |
download | gwp_asan-android13-frc-media-release.tar.gz |
Snap for 8512216 from 3a491726721f7b040d3b95c994fdab92dd6350ee to tm-frc-media-releaset_frc_med_330443030android13-frc-media-release
Change-Id: I9ed6303a6a5d738c9df1f05414d8300f7422387a
-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> |