Skip to content

Commit b8ee0aa

Browse files
authored
[compiler-rt] DumpAllRegisters implementation for windows arm64. (#112254)
1 parent d0d54fa commit b8ee0aa

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_win.cpp

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ SignalContext::WriteFlag SignalContext::GetWriteFlag() const {
10341034

10351035
void SignalContext::DumpAllRegisters(void *context) {
10361036
CONTEXT *ctx = (CONTEXT *)context;
1037-
# if defined(__M_X64)
1037+
# if defined(_M_X64)
10381038
Report("Register values:\n");
10391039
Printf("rax = %llx ", ctx->Rax);
10401040
Printf("rbx = %llx ", ctx->Rbx);
@@ -1068,6 +1068,41 @@ void SignalContext::DumpAllRegisters(void *context) {
10681068
Printf("ebp = %lx ", ctx->Ebp);
10691069
Printf("esp = %lx ", ctx->Esp);
10701070
Printf("\n");
1071+
# elif defined(_M_ARM64)
1072+
Report("Register values:\n");
1073+
Printf("x0 = %llx ", ctx->X0);
1074+
Printf("x1 = %llx ", ctx->X1);
1075+
Printf("x2 = %llx ", ctx->X2);
1076+
Printf("x3 = %llx ", ctx->X3);
1077+
Printf("x4 = %llx ", ctx->X4);
1078+
Printf("x5 = %llx ", ctx->X5);
1079+
Printf("x6 = %llx ", ctx->X6);
1080+
Printf("x7 = %llx ", ctx->X7);
1081+
Printf("x8 = %llx ", ctx->X8);
1082+
Printf("x9 = %llx ", ctx->X9);
1083+
Printf("x10 = %llx ", ctx->X10);
1084+
Printf("x11 = %llx ", ctx->X11);
1085+
Printf("x12 = %llx ", ctx->X12);
1086+
Printf("x13 = %llx ", ctx->X13);
1087+
Printf("x14 = %llx ", ctx->X14);
1088+
Printf("x15 = %llx ", ctx->X15);
1089+
Printf("x16 = %llx ", ctx->X16);
1090+
Printf("x17 = %llx ", ctx->X17);
1091+
Printf("x18 = %llx ", ctx->X18);
1092+
Printf("x19 = %llx ", ctx->X19);
1093+
Printf("x20 = %llx ", ctx->X20);
1094+
Printf("x21 = %llx ", ctx->X21);
1095+
Printf("x22 = %llx ", ctx->X22);
1096+
Printf("x23 = %llx ", ctx->X23);
1097+
Printf("x24 = %llx ", ctx->X24);
1098+
Printf("x25 = %llx ", ctx->X25);
1099+
Printf("x26 = %llx ", ctx->X26);
1100+
Printf("x27 = %llx ", ctx->X27);
1101+
Printf("x28 = %llx ", ctx->X28);
1102+
Printf("x29 = %llx ", ctx->X29);
1103+
Printf("x30 = %llx ", ctx->X30);
1104+
Printf("x31 = %llx ", ctx->X31);
1105+
Printf("\n");
10711106
# else
10721107
// TODO
10731108
(void)ctx;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Check that sanitizer prints registers dump_registers on dump_registers=1
2+
// RUN: %clangxx %s -o %t
3+
// RUN: %env_tool_opts=dump_registers=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NODUMP
4+
// RUN: not %run %t 2>&1 | FileCheck %s --strict-whitespace --check-prefix=CHECK-DUMP
5+
//
6+
// REQUIRES: aarch64-pc-windows-msvc
7+
8+
#include <windows.h>
9+
10+
int main() {
11+
RaiseException(EXCEPTION_ACCESS_VIOLATION, 0, 0, NULL);
12+
// CHECK-DUMP: Register values
13+
// CHECK-DUMP-NEXT: x0 = {{0x[0-9a-f]+}} x1 = {{0x[0-9a-f]+}} x2 = {{0x[0-9a-f]+}} x3 = {{0x[0-9a-f]+}}
14+
// CHECK-DUMP-NEXT: x4 = {{0x[0-9a-f]+}} x5 = {{0x[0-9a-f]+}} x6 = {{0x[0-9a-f]+}} x7 = {{0x[0-9a-f]+}}
15+
// CHECK-DUMP-NEXT: x8 = {{0x[0-9a-f]+}} x9 = {{0x[0-9a-f]+}} x10 = {{0x[0-9a-f]+}} x11 = {{0x[0-9a-f]+}}
16+
// CHECK-DUMP-NEXT:x12 = {{0x[0-9a-f]+}} x13 = {{0x[0-9a-f]+}} x14 = {{0x[0-9a-f]+}} x15 = {{0x[0-9a-f]+}}
17+
// CHECK-DUMP-NEXT:x16 = {{0x[0-9a-f]+}} x17 = {{0x[0-9a-f]+}} x18 = {{0x[0-9a-f]+}} x19 = {{0x[0-9a-f]+}}
18+
// CHECK-DUMP-NEXT:x20 = {{0x[0-9a-f]+}} x21 = {{0x[0-9a-f]+}} x22 = {{0x[0-9a-f]+}} x23 = {{0x[0-9a-f]+}}
19+
// CHECK-DUMP-NEXT:x24 = {{0x[0-9a-f]+}} x25 = {{0x[0-9a-f]+}} x26 = {{0x[0-9a-f]+}} x27 = {{0x[0-9a-f]+}}
20+
// CHECK-DUMP-NEXT:x28 = {{0x[0-9a-f]+}} fp = {{0x[0-9a-f]+}} lr = {{0x[0-9a-f]+}} sp = {{0x[0-9a-f]+}}
21+
// CHECK-NODUMP-NOT: Register values
22+
return 0;
23+
}

0 commit comments

Comments
 (0)