[compiler-rt] b0fbfbb - [compiler-rt]: DumpAllRegs on NetBSD arm64. (#102826)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 26 02:07:04 PDT 2024


Author: David CARLIER
Date: 2024-08-26T10:07:01+01:00
New Revision: b0fbfbb6f33f20ef6b72ab003740f8f96efedd7e

URL: https://github.com/llvm/llvm-project/commit/b0fbfbb6f33f20ef6b72ab003740f8f96efedd7e
DIFF: https://github.com/llvm/llvm-project/commit/b0fbfbb6f33f20ef6b72ab003740f8f96efedd7e.diff

LOG: [compiler-rt]: DumpAllRegs on NetBSD arm64. (#102826)

all 35 registers are stored in one unique array. for simplicity sake, we
do not bother using _REG_X* constants.

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Removed: 
    


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