* [PATCH] gdb: xtensa: don't supply registers if they are not present
@ 2022-11-09 19:15 Alexey Lapshin
2022-11-09 20:12 ` Tom Tromey
0 siblings, 1 reply; 2+ messages in thread
From: Alexey Lapshin @ 2022-11-09 19:15 UTC (permalink / raw)
To: gdb-patches; +Cc: Alexey Gerenkov, Anton Maklakov, Ivan Grokhotkov, jcmvbkbc
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 | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
index 685536c3b9e..65e159aa613 100644
--- a/gdb/xtensa-tdep.c
+++ b/gdb/xtensa-tdep.c
@@ -813,6 +813,12 @@ xtensa_register_reggroup_p (struct gdbarch
*gdbarch,
in the general-purpose register set REGSET to register cache
REGCACHE. If REGNUM is -1 do this for all registers in REGSET. */
+static inline bool
+is_reg_raw_supplied (int check_regnum, int regnum)
+{
+ return check_regnum > 0 && (regnum == check_regnum || regnum == -1);
+}
+
static void
xtensa_supply_gregset (const struct regset *regset,
struct regcache *rc,
@@ -831,22 +837,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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] gdb: xtensa: don't supply registers if they are not present
2022-11-09 19:15 [PATCH] gdb: xtensa: don't supply registers if they are not present Alexey Lapshin
@ 2022-11-09 20:12 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2022-11-09 20:12 UTC (permalink / raw)
To: Alexey Lapshin via Gdb-patches
Cc: Alexey Lapshin, Alexey Gerenkov, Anton Maklakov, Ivan Grokhotkov,
jcmvbkbc
>>>>> "Alexey" == Alexey Lapshin via Gdb-patches <gdb-patches@sourceware.org> writes:
Alexey> @@ -813,6 +813,12 @@ xtensa_register_reggroup_p (struct gdbarch
Alexey> *gdbarch,
Alexey> in the general-purpose register set REGSET to register cache
Alexey> REGCACHE. If REGNUM is -1 do this for all registers in REGSET. */
Alexey> +static inline bool
Alexey> +is_reg_raw_supplied (int check_regnum, int regnum)
Alexey> +{
This seems to insert the new function between a comment and the function
that comment describes.
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-09 20:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-09 19:15 [PATCH] gdb: xtensa: don't supply registers if they are not present Alexey Lapshin
2022-11-09 20:12 ` Tom Tromey
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).