]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libsanitizer: Fix SPARC stacktraces
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Mon, 7 Aug 2023 09:29:02 +0000 (11:29 +0200)
committerRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Mon, 7 Aug 2023 09:29:02 +0000 (11:29 +0200)
As detailed in LLVM Issue #57624
(https://github.com/llvm/llvm-project/issues/57624), a patch to
sanitizer_internal_defs.h broke SPARC stacktraces in the sanitizers.
The issue has now been fixed upstream (https://reviews.llvm.org/D156504)
and I'd like to cherry-pick that patch.

Bootstrapped without regressions on sparc-sun-solaris2.11.

2023-07-27  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libsanitizer:
* sanitizer_common/sanitizer_stacktrace_sparc.cpp,
sanitizer_common/sanitizer_unwind_linux_libcdep.cpp: Cherry-pick
llvm-project revision 679c076ae446af81eba81ce9b94203a273d4b88a.

libsanitizer/sanitizer_common/sanitizer_stacktrace_sparc.cpp
libsanitizer/sanitizer_common/sanitizer_unwind_linux_libcdep.cpp

index 1e635a66978f36422335e70a65c4c217c24b4352..a2000798a3907de534dbcd60678fcac2cdc5726e 100644 (file)
@@ -30,13 +30,7 @@ void BufferedStackTrace::UnwindFast(uptr pc, uptr bp, uptr stack_top,
   // TODO(yln): add arg sanity check for stack_top/stack_bottom
   CHECK_GE(max_depth, 2);
   const uptr kPageSize = GetPageSizeCached();
-#if defined(__GNUC__)
-  // __builtin_return_address returns the address of the call instruction
-  // on the SPARC and not the return address, so we need to compensate.
-  trace_buffer[0] = GetNextInstructionPc(pc);
-#else
   trace_buffer[0] = pc;
-#endif
   size = 1;
   if (stack_top < 4096) return;  // Sanity check for stack top.
   // Flush register windows to memory
index 72f025a7d307adcd30fd000562c61bc923c5faf9..6a8e82e2e213c0d732bf289b071a93f96e5604e5 100644 (file)
@@ -139,13 +139,7 @@ void BufferedStackTrace::UnwindSlow(uptr pc, u32 max_depth) {
   if (to_pop == 0 && size > 1)
     to_pop = 1;
   PopStackFrames(to_pop);
-#if defined(__GNUC__) && defined(__sparc__)
-  // __builtin_return_address returns the address of the call instruction
-  // on the SPARC and not the return address, so we need to compensate.
-  trace_buffer[0] = GetNextInstructionPc(pc);
-#else
   trace_buffer[0] = pc;
-#endif
 }
 
 void BufferedStackTrace::UnwindSlow(uptr pc, void *context, u32 max_depth) {