[compiler-rt] [compiler-rt]: DumpAllRegs on NetBSD arm64. (PR #102826)
David CARLIER via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 11 12:41:19 PDT 2024
https://github.com/devnexen created https://github.com/llvm/llvm-project/pull/102826
all 35 registers are stored in one unique array. for simplicity sake, we do not bother using _REG_X* constants.
>From 525bfa5218c81431bc1b449a297826311bd3a1d7 Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen at gmail.com>
Date: Sun, 11 Aug 2024 20:39:02 +0100
Subject: [PATCH] [compiler-rt]: DumpAllRegs on NetBSD arm64.
all 35 registers are stored in one unique array. for simplicity
sake, we do not bother using _REG_X* constants.
---
compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
index 73f07c7b22dc5a..16d06c69a38f32 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -2312,11 +2312,11 @@ static const char *RegNumToRegName(int reg) {
return NULL;
}
-# if SANITIZER_LINUX && SANITIZER_GLIBC && \
+# if ((SANITIZER_LINUX && SANITIZER_GLIBC) || SANITIZER_NETBSD) && \
(defined(__arm__) || defined(__aarch64__))
static uptr GetArmRegister(ucontext_t *ctx, int RegNum) {
switch (RegNum) {
-# if defined(__arm__)
+# if defined(__arm__) && !SANITIZER_NETBSD
# ifdef MAKE_CASE
# undef MAKE_CASE
# endif
@@ -2345,10 +2345,15 @@ static uptr GetArmRegister(ucontext_t *ctx, int RegNum) {
case REG_R15:
return ctx->uc_mcontext.arm_pc;
# elif defined(__aarch64__)
+# if SANITIZER_LINUX
case 0 ... 30:
return ctx->uc_mcontext.regs[RegNum];
case 31:
return ctx->uc_mcontext.sp;
+# elif SANITIZER_NETBSD
+ case 0 ... 31:
+ return ctx->uc_mcontext.__gregs[RegNum];
+# endif
# endif
default:
return 0;
@@ -2456,7 +2461,7 @@ void SignalContext::DumpAllRegisters(void *context) {
DumpSingleReg(ucontext, REG_R14);
DumpSingleReg(ucontext, REG_R15);
Printf("\n");
-# elif defined(__aarch64__) && !SANITIZER_NETBSD
+# elif defined(__aarch64__)
Report("Register values:\n");
for (int i = 0; i <= 31; ++i) {
DumpSingleReg(ucontext, i);
More information about the llvm-commits
mailing list