summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-04-28 15:57:00 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-04-28 15:57:00 +0000
commit56ba3e0abc1ff9da3bbac28aad3acc48c783c417 (patch)
tree2552b2460f512b2a12eda5710d8a596f3dcb9b01
parentdd02cb60c2ca7664fab673389f0901b9a8980d71 (diff)
parent3a491726721f7b040d3b95c994fdab92dd6350ee (diff)
downloadgwp_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.bp5
-rw-r--r--android/test_backtrace.cpp23
-rw-r--r--gwp_asan/tests/iterate.cpp1
3 files changed, 16 insertions, 13 deletions
diff --git a/Android.bp b/Android.bp
index e45795f..5f8c925 100644
--- a/Android.bp
+++ b/Android.bp
@@ -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>