[binutils-gdb] gdb/m68hc11: fix for M68HC12 pseudo $pc accesses
Andrew Burgess
aburgess@sourceware.org
Tue Dec 1 16:31:28 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1689c4ebd1629c770ac21d1d39fd6f9b3b850669
commit 1689c4ebd1629c770ac21d1d39fd6f9b3b850669
Author: Joel Linn <j.linn@ecom.de>
Date: Tue Dec 1 16:22:20 2026 +0000
gdb/m68hc11: fix for M68HC12 pseudo $pc accesses
On M68HC12, when using the banked memory model (the executable has the
E_M68HC12_BANKS flag set in its ELF header), reading the $pc triggers
this error:
regcache.c:810: internal-error: cooked_read: Assertion \
`regnum >= 0 && regnum < m_descr->nr_cooked_registers' failed.
The problem is M68HC12_NUM_PSEUDO_REGS value, which has been unchanged
since it was added in commit 548bcbeca813f4c0:
#define M68HC12_NUM_PSEUDO_REGS ((M68HC11_MAX_SOFT_REGS+5)+1-1)
It's unclear what the '+1-1' is for here. The 'M68HC11_MAX_SOFT_REGS+5'
part matches this line:
#define M68HC11_NUM_PSEUDO_REGS (M68HC11_MAX_SOFT_REGS+5)
But this doesn't make sense as the $pc is an extra pseudo for M68HC12,
but the two values are the same. I suspect the '-1' might be a mistake.
Rewrite M68HC12_NUM_PSEUDO_REGS in terms of M68HC11_NUM_PSEUDO_REGS,
like this:
#define M68HC12_NUM_PSEUDO_REGS (M68HC11_NUM_PSEUDO_REGS + 1)
Which should resolve the above error. This fix was originally posted
combined with another fix here:
https://inbox.sourceware.org/gdb-patches/5fbef3b4-7117-439b-a870-aed245091455@ecom.de
Diff:
---
gdb/m68hc11-tdep.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c
index 982bfd62b5f..bcde8225ebc 100644
--- a/gdb/m68hc11-tdep.c
+++ b/gdb/m68hc11-tdep.c
@@ -120,7 +120,9 @@ enum insn_return_kind {
#define M68HC11_REG_SIZE (2)
#define M68HC12_NUM_REGS (9)
-#define M68HC12_NUM_PSEUDO_REGS ((M68HC11_MAX_SOFT_REGS+5)+1-1)
+/* One extra pseudo register for the 32-bit virtual PC
+ (M68HC12_HARD_PC_REGNUM). */
+#define M68HC12_NUM_PSEUDO_REGS (M68HC11_NUM_PSEUDO_REGS + 1)
#define M68HC12_HARD_PC_REGNUM (SOFT_D32_REGNUM+1)
struct insn_sequence;
More information about the Gdb-cvs
mailing list