From: "Torbjörn SVENSSON" <torbjorn.svensson@foss.st.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH] gdb/arm: Stop unwinding on error, but do not assert
Date: Thu, 6 Oct 2022 16:15:56 +0200 [thread overview]
Message-ID: <20221006141556.300733-1-torbjorn.svensson@foss.st.com> (raw)
When it's impossible to read the FPCCR and XPSR, the unwinding is
unpredictable as the it's not possible to determine the correct
frame size or padding.
The only sane thing to do in this condition is to stop the unwinding.
Without this patch, gdb would assert if this errornous state was
detected.
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
---
gdb/arm-tdep.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index d357066653b..ce5c8c23fd4 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -3591,9 +3591,10 @@ arm_m_exception_cache (struct frame_info *this_frame)
ULONGEST fpcar;
/* Read FPCCR register. */
- gdb_assert (safe_read_memory_unsigned_integer (FPCCR,
- ARM_INT_REGISTER_SIZE,
- byte_order, &fpccr));
+ if (!safe_read_memory_unsigned_integer (FPCCR, ARM_INT_REGISTER_SIZE,
+ byte_order, &fpccr))
+ error (_("Could not fetch required FPCCR content. Further unwind "
+ "is impossible."));
/* Read FPCAR register. */
if (!safe_read_memory_unsigned_integer (FPCAR, ARM_INT_REGISTER_SIZE,
@@ -3669,9 +3670,11 @@ arm_m_exception_cache (struct frame_info *this_frame)
aligner between the top of the 32-byte stack frame and the
previous context's stack pointer. */
ULONGEST xpsr;
- gdb_assert (safe_read_memory_unsigned_integer (cache->saved_regs[
- ARM_PS_REGNUM].addr (), 4,
- byte_order, &xpsr));
+ if (!safe_read_memory_unsigned_integer (cache->saved_regs[ ARM_PS_REGNUM]
+ .addr (), 4, byte_order, &xpsr))
+ error (_("Could not fetch required XPSR content. Further unwind is "
+ "impossible."));
+
if (bit (xpsr, 9) != 0)
{
CORE_ADDR new_sp = arm_cache_get_prev_sp_value (cache, tdep) + 4;
--
2.25.1
reply other threads:[~2022-10-06 14:16 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=20221006141556.300733-1-torbjorn.svensson@foss.st.com \
--to=torbjorn.svensson@foss.st.com \
--cc=gdb-patches@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).