public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libsanitizer: Fix SPARC stacktraces
@ 2023-08-07  9:13 Rainer Orth
  2023-08-07  9:19 ` Jakub Jelinek
  0 siblings, 1 reply; 2+ messages in thread
From: Rainer Orth @ 2023-08-07  9:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jakub Jelinek

[-- Attachment #1: Type: text/plain, Size: 785 bytes --]

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.

Ok for trunk and the gcc-13 branch?

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sparc-libsanitizer-stacktrace.patch --]
[-- Type: text/x-patch, Size: 1742 bytes --]

# HG changeset patch
# Parent  cc61fd6b33c37b7a2a1415e0ed02f75dd8a21110
Fix SPARC stacktraces in sanitizers

diff --git a/libsanitizer/sanitizer_common/sanitizer_stacktrace_sparc.cpp b/libsanitizer/sanitizer_common/sanitizer_stacktrace_sparc.cpp
--- a/libsanitizer/sanitizer_common/sanitizer_stacktrace_sparc.cpp
+++ b/libsanitizer/sanitizer_common/sanitizer_stacktrace_sparc.cpp
@@ -30,13 +30,7 @@ void BufferedStackTrace::UnwindFast(uptr
   // 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
diff --git a/libsanitizer/sanitizer_common/sanitizer_unwind_linux_libcdep.cpp b/libsanitizer/sanitizer_common/sanitizer_unwind_linux_libcdep.cpp
--- a/libsanitizer/sanitizer_common/sanitizer_unwind_linux_libcdep.cpp
+++ b/libsanitizer/sanitizer_common/sanitizer_unwind_linux_libcdep.cpp
@@ -139,13 +139,7 @@ void BufferedStackTrace::UnwindSlow(uptr
   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) {

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] libsanitizer: Fix SPARC stacktraces
  2023-08-07  9:13 [PATCH] libsanitizer: Fix SPARC stacktraces Rainer Orth
@ 2023-08-07  9:19 ` Jakub Jelinek
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2023-08-07  9:19 UTC (permalink / raw)
  To: Rainer Orth; +Cc: gcc-patches

On Mon, Aug 07, 2023 at 11:13:10AM +0200, Rainer Orth wrote:
> 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.
> 
> Ok for trunk and the gcc-13 branch?

Ok, thanks.

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

	Jakub


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-07  9:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-07  9:13 [PATCH] libsanitizer: Fix SPARC stacktraces Rainer Orth
2023-08-07  9:19 ` Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).