Skip to content
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

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]+}}
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member Author

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..

// CHECK-NODUMP-NOT: Register values
return 0;
}
Loading