[compiler-rt] [compiler-rt] DumpAllRegisters implementation for windows arm64. (PR #112254)
David CARLIER via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 14 13:04:39 PDT 2024
https://github.com/devnexen created https://github.com/llvm/llvm-project/pull/112254
None
>From 93715821735437ba2b4951b88a2857d4b0b6d11c Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen at gmail.com>
Date: Mon, 14 Oct 2024 21:02:24 +0100
Subject: [PATCH] [compiler-rt] DumpAllRegisters implementation for windows
arm64.
---
.../lib/sanitizer_common/sanitizer_win.cpp | 37 ++++++++++++++++++-
.../Windows/dump_registers_aarch64.cpp | 23 ++++++++++++
2 files changed, 59 insertions(+), 1 deletion(-)
create mode 100644 compiler-rt/test/sanitizer_common/TestCases/Windows/dump_registers_aarch64.cpp
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
index 832682772950e9..838b14d3cc559d 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
@@ -1034,7 +1034,7 @@ SignalContext::WriteFlag SignalContext::GetWriteFlag() const {
void SignalContext::DumpAllRegisters(void *context) {
CONTEXT *ctx = (CONTEXT *)context;
-# if defined(__M_X64)
+# if defined(_M_X64)
Report("Register values:\n");
Printf("rax = %llx ", ctx->Rax);
Printf("rbx = %llx ", ctx->Rbx);
@@ -1068,6 +1068,41 @@ void SignalContext::DumpAllRegisters(void *context) {
Printf("ebp = %lx ", ctx->Ebp);
Printf("esp = %lx ", ctx->Esp);
Printf("\n");
+# elif defined(_M_ARM64)
+ Report("Register values:\n");
+ Printf("x0 = %llx ", ctx->X0);
+ Printf("x1 = %llx ", ctx->X1);
+ Printf("x2 = %llx ", ctx->X2);
+ Printf("x3 = %llx ", ctx->X3);
+ Printf("x4 = %llx ", ctx->X4);
+ Printf("x5 = %llx ", ctx->X5);
+ Printf("x6 = %llx ", ctx->X6);
+ Printf("x7 = %llx ", ctx->X7);
+ Printf("x8 = %llx ", ctx->X8);
+ Printf("x9 = %llx ", ctx->X9);
+ Printf("x10 = %llx ", ctx->X10);
+ Printf("x11 = %llx ", ctx->X11);
+ Printf("x12 = %llx ", ctx->X12);
+ Printf("x13 = %llx ", ctx->X13);
+ Printf("x14 = %llx ", ctx->X14);
+ Printf("x15 = %llx ", ctx->X15);
+ Printf("x16 = %llx ", ctx->X16);
+ Printf("x17 = %llx ", ctx->X17);
+ Printf("x18 = %llx ", ctx->X18);
+ Printf("x19 = %llx ", ctx->X19);
+ Printf("x20 = %llx ", ctx->X20);
+ Printf("x21 = %llx ", ctx->X21);
+ Printf("x22 = %llx ", ctx->X22);
+ Printf("x23 = %llx ", ctx->X23);
+ Printf("x24 = %llx ", ctx->X24);
+ Printf("x25 = %llx ", ctx->X25);
+ Printf("x26 = %llx ", ctx->X26);
+ Printf("x27 = %llx ", ctx->X27);
+ Printf("x28 = %llx ", ctx->X28);
+ Printf("x29 = %llx ", ctx->X29);
+ Printf("x30 = %llx ", ctx->X30);
+ Printf("x31 = %llx ", ctx->X31);
+ Printf("\n");
# else
// TODO
(void)ctx;
diff --git a/compiler-rt/test/sanitizer_common/TestCases/Windows/dump_registers_aarch64.cpp b/compiler-rt/test/sanitizer_common/TestCases/Windows/dump_registers_aarch64.cpp
new file mode 100644
index 00000000000000..f4805640d682b0
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/TestCases/Windows/dump_registers_aarch64.cpp
@@ -0,0 +1,23 @@
+// Check that sanitizer prints registers dump_registers on dump_registers=1
+// RUN: %clangxx %s -o %t
+// RUN: %env_tool_opts=dump_registers=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NODUMP
+// RUN: not %run %t 2>&1 | FileCheck %s --strict-whitespace --check-prefix=CHECK-DUMP
+//
+// REQUIRES: aarch64-pc-windows-msvc
+
+#include <windows.h>
+
+int main() {
+ RaiseException(EXCEPTION_ACCESS_VIOLATION, 0, 0, NULL);
+ // CHECK-DUMP: Register values
+ // CHECK-DUMP-NEXT: x0 = {{0x[0-9a-f]+}} x1 = {{0x[0-9a-f]+}} x2 = {{0x[0-9a-f]+}} x3 = {{0x[0-9a-f]+}}
+ // CHECK-DUMP-NEXT: x4 = {{0x[0-9a-f]+}} x5 = {{0x[0-9a-f]+}} x6 = {{0x[0-9a-f]+}} x7 = {{0x[0-9a-f]+}}
+ // CHECK-DUMP-NEXT: x8 = {{0x[0-9a-f]+}} x9 = {{0x[0-9a-f]+}} x10 = {{0x[0-9a-f]+}} x11 = {{0x[0-9a-f]+}}
+ // CHECK-DUMP-NEXT:x12 = {{0x[0-9a-f]+}} x13 = {{0x[0-9a-f]+}} x14 = {{0x[0-9a-f]+}} x15 = {{0x[0-9a-f]+}}
+ // CHECK-DUMP-NEXT:x16 = {{0x[0-9a-f]+}} x17 = {{0x[0-9a-f]+}} x18 = {{0x[0-9a-f]+}} x19 = {{0x[0-9a-f]+}}
+ // CHECK-DUMP-NEXT:x20 = {{0x[0-9a-f]+}} x21 = {{0x[0-9a-f]+}} x22 = {{0x[0-9a-f]+}} x23 = {{0x[0-9a-f]+}}
+ // CHECK-DUMP-NEXT:x24 = {{0x[0-9a-f]+}} x25 = {{0x[0-9a-f]+}} x26 = {{0x[0-9a-f]+}} x27 = {{0x[0-9a-f]+}}
+ // CHECK-DUMP-NEXT:x28 = {{0x[0-9a-f]+}} fp = {{0x[0-9a-f]+}} lr = {{0x[0-9a-f]+}} sp = {{0x[0-9a-f]+}}
+ // CHECK-NODUMP-NOT: Register values
+ return 0;
+}
More information about the llvm-commits
mailing list