Skip to content

Commit

Permalink
[compiler-rt] DumpAllRegisters implementation for windows arm64. (llv…
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen authored and EricWF committed Oct 22, 2024
1 parent 93b980a commit 8dec14d
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
37 changes: 36 additions & 1 deletion compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 8dec14d

Please sign in to comment.