public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb/arm: Don't rely on loop detection to stop unwinding
@ 2022-10-15  9:40 Torbjorn Svensson
  0 siblings, 0 replies; only message in thread
From: Torbjorn Svensson @ 2022-10-15  9:40 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=619cce4cac9b7ad5f4604cd5a63933e71515e16f

commit 619cce4cac9b7ad5f4604cd5a63933e71515e16f
Author: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Date:   Fri Oct 14 15:34:24 2022 +0200

    gdb/arm: Don't rely on loop detection to stop unwinding
    
    Setting SP of the next frame to the same address as the current frame
    is an ugly way to stop the unwinding.  A cleaner way is to rely on
    the frame_unwind_stop_reason function to return UNWIND_OUTERMOST.
    
    Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>

Diff:
---
 gdb/arm-tdep.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index fa6b08e4a54..b5facae8a5e 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -3356,7 +3356,6 @@ arm_m_exception_cache (frame_info_ptr this_frame)
      to the exception and if FPU is used (causing extended stack frame).  */
 
   CORE_ADDR lr = get_frame_register_unsigned (this_frame, ARM_LR_REGNUM);
-  CORE_ADDR sp = get_frame_register_unsigned (this_frame, ARM_SP_REGNUM);
 
   /* ARMv7-M Architecture Reference "A2.3.1 Arm core registers"
      states that LR is set to 0xffffffff on reset.  ARMv8-M Architecture
@@ -3364,8 +3363,8 @@ arm_m_exception_cache (frame_info_ptr this_frame)
      reset if Main Extension is implemented, otherwise the value is unknown.  */
   if (lr == 0xffffffff)
     {
-      /* Terminate any further stack unwinding by referring to self.  */
-      arm_cache_set_active_sp_value (cache, tdep, sp);
+      /* Terminate any further stack unwinding.  */
+      arm_cache_set_active_sp_value (cache, tdep, 0);
       return cache;
     }
 
@@ -3387,8 +3386,8 @@ arm_m_exception_cache (frame_info_ptr this_frame)
 	{
 	  warning (_("Non-secure to secure stack unwinding disabled."));
 
-	  /* Terminate any further stack unwinding by referring to self.  */
-	  arm_cache_set_active_sp_value (cache, tdep, sp);
+	  /* Terminate any further stack unwinding.  */
+	  arm_cache_set_active_sp_value (cache, tdep, 0);
 	  return cache;
 	}
 
@@ -3452,8 +3451,8 @@ arm_m_exception_cache (frame_info_ptr this_frame)
 	    {
 	      warning (_("Non-secure to secure stack unwinding disabled."));
 
-	      /* Terminate any further stack unwinding by referring to self.  */
-	      arm_cache_set_active_sp_value (cache, tdep, sp);
+	      /* Terminate any further stack unwinding.  */
+	      arm_cache_set_active_sp_value (cache, tdep, 0);
 	      return cache;
 	    }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-10-15  9:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-15  9:40 [binutils-gdb] gdb/arm: Don't rely on loop detection to stop unwinding Torbjorn Svensson

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