[compiler-rt] [compiler-rt] Implement `DumpAllRegisters` for arm-linux and aarch64-linux (PR #99613)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 20 22:36:27 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff f1422a86c4a812a7ccd744082741841e596ccea0 9af8fb2959b3b8537f477cd9d649436529e61aae --extensions cpp -- compiler-rt/test/sanitizer_common/TestCases/Linux/dump_registers_aarch64.cpp compiler-rt/test/sanitizer_common/TestCases/Linux/dump_registers_arm.cpp compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
index 3b44a056e5..592172e665 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -2172,11 +2172,11 @@ static const char *RegNumToRegName(int reg) {
       return "ebp";
     case REG_ESP:
       return "esp";
-#  elif defined(__arm__)
-#    define REG_STR(reg) #reg
-#    define MAKE_CASE(N) \
-      case REG_R##N:     \
-        return REG_STR(r##N)
+#    elif defined(__arm__)
+#      define REG_STR(reg) #reg
+#      define MAKE_CASE(N) \
+        case REG_R##N:     \
+          return REG_STR(r##N)
     MAKE_CASE(0);
     MAKE_CASE(1);
     MAKE_CASE(2);
@@ -2196,11 +2196,11 @@ static const char *RegNumToRegName(int reg) {
       return "lr";
     case REG_R15:
       return "pc";
-#  elif defined(__aarch64__)
-#    define REG_STR(reg) #reg
-#    define MAKE_CASE(N) \
-      case N:            \
-        return REG_STR(x##N)
+#    elif defined(__aarch64__)
+#      define REG_STR(reg) #reg
+#      define MAKE_CASE(N) \
+        case N:            \
+          return REG_STR(x##N)
     MAKE_CASE(0);
     MAKE_CASE(1);
     MAKE_CASE(2);
@@ -2236,20 +2236,20 @@ static const char *RegNumToRegName(int reg) {
       return "lr";
     case 31:
       return "sp";
-#  endif
+#    endif
     default:
       return NULL;
   }
   return NULL;
 }
 
-#  if SANITIZER_LINUX && (defined(__arm__) || defined(__aarch64__))
+#    if SANITIZER_LINUX && (defined(__arm__) || defined(__aarch64__))
 static unsigned long GetArmRegister(ucontext_t *ctx, int RegNum) {
   switch (RegNum) {
-#    if defined(__arm__)
-#      define MAKE_CASE(N) \
-        case REG_R##N:     \
-          return ctx->uc_mcontext.arm_r##N
+#      if defined(__arm__)
+#        define MAKE_CASE(N) \
+          case REG_R##N:     \
+            return ctx->uc_mcontext.arm_r##N
     MAKE_CASE(0);
     MAKE_CASE(1);
     MAKE_CASE(2);
@@ -2271,18 +2271,18 @@ static unsigned long GetArmRegister(ucontext_t *ctx, int RegNum) {
       return ctx->uc_mcontext.arm_lr;
     case REG_R15:
       return ctx->uc_mcontext.arm_pc;
-#    elif defined(__aarch64__)
+#      elif defined(__aarch64__)
     case 0 ... 30:
       return ctx->uc_mcontext.regs[RegNum];
     case 31:
       return ctx->uc_mcontext.sp;
-#    endif
+#      endif
     default:
       return 0UL;
   }
   return 0UL;
 }
-#  endif  // SANITIZER_LINUX && (defined(__arm__) || defined(__aarch64__))
+#    endif  // SANITIZER_LINUX && (defined(__arm__) || defined(__aarch64__))
 
 UNUSED
 static void DumpSingleReg(ucontext_t *ctx, int RegNum) {
@@ -2292,13 +2292,13 @@ static void DumpSingleReg(ucontext_t *ctx, int RegNum) {
          RegName, ctx->uc_mcontext.gregs[RegNum]);
 #    elif defined(__i386__)
   Printf("%s = 0x%08x  ", RegName, ctx->uc_mcontext.gregs[RegNum]);
-#  elif defined(__arm__)
+#    elif defined(__arm__)
   Printf("%s%s = 0x%08lx  ", internal_strlen(RegName) == 2 ? " " : "", RegName,
          GetArmRegister(ctx, RegNum));
-#  elif defined(__aarch64__)
+#    elif defined(__aarch64__)
   Printf("%s%s = 0x%016llx  ", internal_strlen(RegName) == 2 ? " " : "",
          RegName, GetArmRegister(ctx, RegNum));
-#  else
+#    else
   (void)RegName;
 #    endif
 }

``````````

</details>


https://github.com/llvm/llvm-project/pull/99613


More information about the llvm-commits mailing list