-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[compiler-rt] DumpAllRegisters implementation for windows arm64. #112254
Conversation
@llvm/pr-subscribers-compiler-rt-sanitizer Author: David CARLIER (devnexen) ChangesFull diff: https://github.com/llvm/llvm-project/pull/112254.diff 2 Files Affected:
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;
+}
|
This fails to build on downstream builders:
|
The winnt.h header in the windows 10 SDK 10.0.22621 has this:
|
Looking at it. thanks |
// 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]+}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test can't possibly succeed - as you're printing x29
etc above, while looking for the string fp
here?
Also even with #112305 when the code actually does compile, it still won't match this test.
Please make sure that you test compile code contributions, and for test additions, that you actually have tested running them and verified that they succeed. If you did try to run the test, was it executed, or was the REQUIRES
line not really matched?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact I do not have windows for arm64 just x86_64 but have access to the CONTEXT struct definitions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
going to fix the test..
No description provided.