Skip to content
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
40 changes: 39 additions & 1 deletion compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,45 @@ SignalContext::WriteFlag SignalContext::GetWriteFlag() const {
}

void SignalContext::DumpAllRegisters(void *context) {
// FIXME: Implement this.
CONTEXT *ctx = (CONTEXT *)context;
# if defined(__M_X64)
Report("Register values:\n");
Printf("rax = %llx ", ctx->Rax);
Printf("rbx = %llx ", ctx->Rbx);
Printf("rcx = %llx ", ctx->Rcx);
Printf("rdx = %llx ", ctx->Rdx);
Printf("\n");
Printf("rdi = %llx ", ctx->Rdi);
Printf("rsi = %llx ", ctx->Rsi);
Printf("rbp = %llx ", ctx->Rbp);
Printf("rsp = %llx ", ctx->Rsp);
Printf("\n");
Printf("r8 = %llx ", ctx->R8);
Printf("r9 = %llx ", ctx->R9);
Printf("r10 = %llx ", ctx->R10);
Printf("r11 = %llx ", ctx->R11);
Printf("\n");
Printf("r12 = %llx ", ctx->R12);
Printf("r13 = %llx ", ctx->R13);
Printf("r14 = %llx ", ctx->R14);
Printf("r15 = %llx ", ctx->R15);
Printf("\n");
# elif defined(_M_IX86)
Report("Register values:\n");
Printf("eax = %lx ", ctx->Eax);
Printf("ebx = %lx ", ctx->Ebx);
Printf("ecx = %lx ", ctx->Ecx);
Printf("edx = %lx ", ctx->Edx);
Printf("\n");
Printf("edi = %lx ", ctx->Edi);
Printf("esi = %lx ", ctx->Esi);
Printf("ebp = %lx ", ctx->Ebp);
Printf("esp = %lx ", ctx->Esp);
Printf("\n");
# else
// TODO
(void)ctx;
# endif
}

int SignalContext::GetType() const {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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-prefixes=CHECK-NODUMP --strict-whitespace
// RUN: not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK-DUMP --strict-whitespace
//
// REQUIRES: i386-pc-windows-msvc

#include <windows.h>

int main() {
RaiseException(EXCEPTION_ACCESS_VIOLATION, 0, 0, NULL);
// CHECK-DUMP: Register values
// CHECK-DUMP-NEXT: eax = {{0x[0-9a-f]+}} ebx = {{0x[0-9a-f]+}} ecx = {{0x[0-9a-f]+}} edx = {{0x[0-9a-f]+}}
// CHECK-DUMP-NEXT: edi = {{0x[0-9a-f]+}} esi = {{0x[0-9a-f]+}} ebp = {{0x[0-9a-f]+}} esp = {{0x[0-9a-f]+}}
// CHECK-NODUMP-NOT: Register values
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// 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-prefixes=CHECK-NODUMP --strict-whitespace
// RUN: not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK-DUMP --strict-whitespace
//
// REQUIRES: x86_64-pc-windows-msvc

#include <windows.h>

int main() {
RaiseException(EXCEPTION_ACCESS_VIOLATION, 0, 0, NULL);
// CHECK-DUMP: Register values
// CHECK-DUMP-NEXT: rax = {{0x[0-9a-f]+}} rbx = {{0x[0-9a-f]+}} rcx = {{0x[0-9a-f]+}} rdx = {{0x[0-9a-f]+}}
// CHECK-DUMP-NEXT: rdi = {{0x[0-9a-f]+}} rsi = {{0x[0-9a-f]+}} rbp = {{0x[0-9a-f]+}} rsp = {{0x[0-9a-f]+}}
// CHECK-DUMP-NEXT: r8 = {{0x[0-9a-f]+}} r9 = {{0x[0-9a-f]+}} r10 = {{0x[0-9a-f]+}} r11 = {{0x[0-9a-f]+}}
// CHECK-DUMP-NEXT: r12 = {{0x[0-9a-f]+}} r13 = {{0x[0-9a-f]+}} r14 = {{0x[0-9a-f]+}} r15 = {{0x[0-9a-f]+}}
// CHECK-NODUMP-NOT: Register values
return 0;
}
Loading