public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Yvan Roux <yroux@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] gdb/arm: Terminate unwinding when LR is 0xffffffff
Date: Thu,  9 Jun 2022 14:33:36 +0000 (GMT)	[thread overview]
Message-ID: <20220609143336.80AE63853547@sourceware.org> (raw)

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

commit 148ca9dd5cf96049c0db17c1230e4b96c0ac054a
Author: Yvan Roux <yvan.roux@foss.st.com>
Date:   Thu Jun 9 16:31:40 2022 +0200

    gdb/arm: Terminate unwinding when LR is 0xffffffff
    
    ARMv7-M Architecture Reference "A2.3.1 Arm core registers" states
    that LR is set to 0xffffffff on reset.
    
    ARMv8-M Architecture Reference "B3.3 Registers" states that LR is set
    to 0xffffffff on warm reset if Main Extension is implemented,
    otherwise the value is unknown.
    
    Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@st.com>
    Signed-off-by: Yvan Roux <yvan.roux@foss.st.com>

Diff:
---
 gdb/arm-tdep.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 591a2da99f2..09670b69a1d 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -3330,6 +3330,17 @@ arm_m_exception_cache (struct frame_info *this_frame)
   lr = get_frame_register_unsigned (this_frame, ARM_LR_REGNUM);
   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
+     Reference "B3.3 Registers" states that LR is set to 0xffffffff on warm
+     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);
+      return cache;
+    }
+
   fnc_return = ((lr & 0xfffffffe) == 0xfefffffe);
   if (tdep->have_sec_ext && fnc_return)
     {


                 reply	other threads:[~2022-06-09 14:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220609143336.80AE63853547@sourceware.org \
    --to=yroux@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).