From: Alexey Lapshin <alexey.lapshin@espressif.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: Alexey Gerenkov <alexey.gerenkov@espressif.com>,
"tom@tromey.com" <tom@tromey.com>,
Anton Maklakov <anton.maklakov@espressif.com>,
Ivan Grokhotkov <ivan@espressif.com>,
"jcmvbkbc@gmail.com" <jcmvbkbc@gmail.com>
Subject: [PATCH v2] gdb: xtensa: don't supply registers if they are not present
Date: Fri, 24 Feb 2023 06:28:08 +0000 [thread overview]
Message-ID: <026589bb5fd46e8811b0909d048307261a8165b7.camel@espressif.com> (raw)
When parsing a core file on hardware configurations without the
zero-overhead loop option (e.g. ESP32-S2 chip), GDB used to assert
while trying to call 'raw_supply' for lbeg, lend, lcount registers,
even though they were not set.
This was because:
regnum == -1 was used to indicate "supply all registers"
lbeg_regnum == -1 was used to indicate "lbeg register not present"
regnum == lbeg_regnum check was considered successful
---
gdb/xtensa-tdep.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
index 092ae088932..66e5baae7a5 100644
--- a/gdb/xtensa-tdep.c
+++ b/gdb/xtensa-tdep.c
@@ -801,6 +801,11 @@ xtensa_register_reggroup_p (struct gdbarch
*gdbarch,
return 1;
}
+static inline bool
+is_reg_raw_supplied (int check_regnum, int regnum)
+{
+ return check_regnum > 0 && (regnum == check_regnum || regnum == -1);
+}
/* Supply register REGNUM from the buffer specified by GREGS and LEN
in the general-purpose register set REGSET to register cache
@@ -824,22 +829,22 @@ xtensa_supply_gregset (const struct regset
*regset,
rc->raw_supply (gdbarch_pc_regnum (gdbarch), (char *) ®s->pc);
if (regnum == gdbarch_ps_regnum (gdbarch) || regnum == -1)
rc->raw_supply (gdbarch_ps_regnum (gdbarch), (char *) ®s->ps);
- if (regnum == tdep->wb_regnum || regnum == -1)
+ if (is_reg_raw_supplied (tdep->wb_regnum, regnum))
rc->raw_supply (tdep->wb_regnum,
(char *) ®s->windowbase);
- if (regnum == tdep->ws_regnum || regnum == -1)
+ if (is_reg_raw_supplied (tdep->ws_regnum, regnum))
rc->raw_supply (tdep->ws_regnum,
(char *) ®s->windowstart);
- if (regnum == tdep->lbeg_regnum || regnum == -1)
+ if (is_reg_raw_supplied (tdep->lbeg_regnum, regnum))
rc->raw_supply (tdep->lbeg_regnum,
(char *) ®s->lbeg);
- if (regnum == tdep->lend_regnum || regnum == -1)
+ if (is_reg_raw_supplied (tdep->lend_regnum, regnum))
rc->raw_supply (tdep->lend_regnum,
(char *) ®s->lend);
- if (regnum == tdep->lcount_regnum || regnum == -1)
+ if (is_reg_raw_supplied (tdep->lcount_regnum, regnum))
rc->raw_supply (tdep->lcount_regnum,
(char *) ®s->lcount);
- if (regnum == tdep->sar_regnum || regnum == -1)
+ if (is_reg_raw_supplied (tdep->sar_regnum, regnum))
rc->raw_supply (tdep->sar_regnum,
(char *) ®s->sar);
if (regnum >=tdep->ar_base
--
2.34.1
next reply other threads:[~2023-02-24 6:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-24 6:28 Alexey Lapshin [this message]
2023-02-24 19:55 ` Tom Tromey
2023-05-16 4:17 ` [PATCH v3] gdb: xtensa: fix registers supply if they " Alexey Lapshin
2024-04-03 14:49 ` Alexey Lapshin
2024-04-09 17:59 ` John Baldwin
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=026589bb5fd46e8811b0909d048307261a8165b7.camel@espressif.com \
--to=alexey.lapshin@espressif.com \
--cc=alexey.gerenkov@espressif.com \
--cc=anton.maklakov@espressif.com \
--cc=gdb-patches@sourceware.org \
--cc=ivan@espressif.com \
--cc=jcmvbkbc@gmail.com \
--cc=tom@tromey.com \
/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).