[libunwind] [libunwind][X86-64] Handle Linux sigreturn trampoline when DWARF info is missing (PR #103473)

via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 29 06:30:41 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 101acff2e5df21378b5764660afc0ec84ce6a1a6 f3e4787973daf1cd278a9615960bbb4b31d3c0c0 --extensions hpp -- libunwind/src/UnwindCursor.hpp
``````````

</details>

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

``````````diff
diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index 02cbd9891e..ff518b1eb1 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -2932,8 +2932,8 @@ bool UnwindCursor<A, R>::setInfoForSigReturn(Registers_x86_64 &) {
   // This special code path is a fallback that is only used if the trampoline
   // lacks proper (e.g. DWARF) unwind info.
   const uint8_t amd64_linux_sigtramp_code[9] = {
-    0x48, 0xc7, 0xc0, 0x0f, 0x00, 0x00, 0x00, // mov rax, 15
-    0x0f, 0x05                                // syscall
+      0x48, 0xc7, 0xc0, 0x0f, 0x00, 0x00, 0x00, // mov rax, 15
+      0x0f, 0x05                                // syscall
   };
   const size_t code_size = sizeof(amd64_linux_sigtramp_code);
 
@@ -2943,7 +2943,8 @@ bool UnwindCursor<A, R>::setInfoForSigReturn(Registers_x86_64 &) {
   if (!isReadableAddr(pc))
     return false;
   // If near page boundary, check the next page too.
-  if (((pc + code_size - 1) & 4095) != (pc & 4095) && !isReadableAddr(pc + code_size - 1))
+  if (((pc + code_size - 1) & 4095) != (pc & 4095) &&
+      !isReadableAddr(pc + code_size - 1))
     return false;
 
   const uint8_t *pc_ptr = reinterpret_cast<const uint8_t *>(pc);
@@ -2991,7 +2992,8 @@ int UnwindCursor<A, R>::stepThroughSigReturn(Registers_x86_64 &) {
   //     __u64 ip;  // 16
   //     ...
   //   };
-  const size_t idx_map[17] = {13, 12, 14, 11, 9, 8, 10, 15, 0, 1, 2, 3, 4, 5, 6, 7, 16};
+  const size_t idx_map[17] = {13, 12, 14, 11, 9, 8, 10, 15, 0,
+                              1,  2,  3,  4,  5, 6, 7,  16};
 
   for (int i = 0; i < 17; ++i) {
     uint64_t value = _addressSpace.get64(sigctx + idx_map[i] * 8);
@@ -2999,9 +3001,10 @@ int UnwindCursor<A, R>::stepThroughSigReturn(Registers_x86_64 &) {
   }
 
   // The +1 story is the same as in DwarfInstructions::stepWithDwarf()
-  // (search for "returnAddress + cieInfo.isSignalFrame" or "Return address points to the next instruction").
-  // This is probably not the right place for this because this function is not necessarily used
-  // with DWARF. Need to research whether the other unwind methods have the same +-1 situation or
+  // (search for "returnAddress + cieInfo.isSignalFrame" or "Return address
+  // points to the next instruction"). This is probably not the right place for
+  // this because this function is not necessarily used with DWARF. Need to
+  // research whether the other unwind methods have the same +-1 situation or
   // are off by one.
   _registers.setIP(_registers.getIP() + 1);
 

``````````

</details>


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


More information about the cfe-commits mailing list