[compiler-rt] [compiler-rt] SignalContext, attempt to implement ::DumpAllRegisters (PR #84413)
David CARLIER via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 8 05:09:23 PST 2024
https://github.com/devnexen updated https://github.com/llvm/llvm-project/pull/84413
>From c51e08db8bb91ebde807c122072fb98764c40723 Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen at gmail.com>
Date: Fri, 8 Mar 2024 00:57:04 +0000
Subject: [PATCH 1/2] [compiler-rt] SignalContext, attempt to implement
::DumpAllRegisters
---
.../lib/sanitizer_common/sanitizer_linux.cpp | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
index 5d2dd3a7a658fe..3c0e9248b9a66b 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -2106,7 +2106,24 @@ bool SignalContext::IsTrueFaultingAddress() const {
}
void SignalContext::DumpAllRegisters(void *context) {
- // FIXME: Implement this.
+# if SANITIZER_LINUX
+# if defined(__x86_64__)
+ ucontext_t *uc = static_cast<ucontext_t *>(context);
+ mcontext_t *mc = &uc->uc_mcontext;
+
+ Report(
+ "rax: %016lx rbx: %016lx rbp: %016lx rsp: %016lx\n"
+ "rdi: %016lx rsi: %016lx rdx: %016lx rcx: %016lx\n"
+ "r8: %016lx r9: %016lx r10: %016lx r11: %016lx\n"
+ "r12: %016lx r13: %016lx r14: %016lx r15: %016lx\n",
+ mc->gregs[REG_RAX], mc->gregs[REG_RBX], mc->gregs[REG_RBP], mc->gregs[REG_RSP],
+ mc->gregs[REG_RDI], mc->gregs[REG_RSI], mc->gregs[REG_RDX], mc->gregs[REG_RCX],
+ mc->gregs[REG_R8], mc->gregs[REG_R9], mc->gregs[REG_R10], mc->gregs[REG_R11],
+ mc->gregs[REG_R12], mc->gregs[REG_R13], mc->gregs[REG_R14], mc->gregs[REG_R15]
+ );
+# endif
+# endif
+ // FIXME: Implement for other platforms/archs.
}
static void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) {
>From c76177e6a93e63b98a264a80314c7f035663c844 Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen at gmail.com>
Date: Fri, 8 Mar 2024 13:09:01 +0000
Subject: [PATCH 2/2] arm64 linux
---
.../lib/sanitizer_common/sanitizer_linux.cpp | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
index 3c0e9248b9a66b..b0bf55d0e563f0 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -2107,9 +2107,9 @@ bool SignalContext::IsTrueFaultingAddress() const {
void SignalContext::DumpAllRegisters(void *context) {
# if SANITIZER_LINUX
-# if defined(__x86_64__)
ucontext_t *uc = static_cast<ucontext_t *>(context);
mcontext_t *mc = &uc->uc_mcontext;
+# if defined(__x86_64__)
Report(
"rax: %016lx rbx: %016lx rbp: %016lx rsp: %016lx\n"
@@ -2121,7 +2121,16 @@ void SignalContext::DumpAllRegisters(void *context) {
mc->gregs[REG_R8], mc->gregs[REG_R9], mc->gregs[REG_R10], mc->gregs[REG_R11],
mc->gregs[REG_R12], mc->gregs[REG_R13], mc->gregs[REG_R14], mc->gregs[REG_R15]
);
-# endif
+# elif defined(__aarch64__)
+ Report(
+ "x0: %016lx, x1: %016lx, x2: %016lx, x3: %016lx\n"
+ "x4: %016lx, x5: %016lx, x6: %016lx, x7: %016lx\n"
+ "x29: %016lx, x30: %016lx, x16: %016lx, x17: %016lx\n",
+ mc->regs[0], mc->regs[1], mc->regs[2], mc->regs[3],
+ mc->regs[4], mc->regs[5], mc->regs[6], mc->regs[7],
+ mc->regs[29], mc->regs[30], mc->regs[16], mc->regs[17]
+ );
+# endif
# endif
// FIXME: Implement for other platforms/archs.
}
More information about the llvm-commits
mailing list