From 70142c72b9571de6aae2a7d85ed63f905d37f6f9 Mon Sep 17 00:00:00 2001 From: skrll Date: Sat, 3 Nov 2012 15:06:55 +0000 Subject: [PATCH] Supply MIPS_ZERO_REGNUM and MIPS_UNUSED_REGNUM (as zero). Idea stolen from mips-linux-tdep.c --- external/gpl3/gdb/dist/gdb/mipsnbsd-tdep.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/external/gpl3/gdb/dist/gdb/mipsnbsd-tdep.c b/external/gpl3/gdb/dist/gdb/mipsnbsd-tdep.c index 3a7c8570e775..4318c235aa37 100644 --- a/external/gpl3/gdb/dist/gdb/mipsnbsd-tdep.c +++ b/external/gpl3/gdb/dist/gdb/mipsnbsd-tdep.c @@ -83,15 +83,23 @@ mipsnbsd_supply_gregset (const struct regset *regset, const void *gregs, size_t len) { size_t regsize = mips_isa_regsize (get_regcache_arch (regcache)); + char zerobuf[MAX_REGISTER_SIZE]; const char *regs = gregs; int i; + memset (zerobuf, 0, MAX_REGISTER_SIZE); + gdb_assert (len >= MIPSNBSD_NUM_GREGS * regsize); for (i = 0; i <= MIPS_PC_REGNUM; i++) { if (regnum == i || regnum == -1) - regcache_raw_supply (regcache, i, regs + i * regsize); + { + if (i == MIPS_ZERO_REGNUM || i == MIPS_UNUSED_REGNUM) + regcache_raw_supply (regcache, i, zerobuf); + else + regcache_raw_supply (regcache, i, regs + i * regsize); + } } if (len >= (MIPSNBSD_NUM_GREGS + MIPSNBSD_NUM_FPREGS) * regsize) @@ -144,13 +152,18 @@ void mipsnbsd_supply_reg (struct regcache *regcache, const char *regs, int regno) { struct gdbarch *gdbarch = get_regcache_arch (regcache); + char zerobuf[MAX_REGISTER_SIZE]; int i; + memset (zerobuf, 0, MAX_REGISTER_SIZE); + for (i = 0; i <= gdbarch_pc_regnum (gdbarch); i++) { if (regno == i || regno == -1) { - if (gdbarch_cannot_fetch_register (gdbarch, i)) + if (i == MIPS_ZERO_REGNUM || i == MIPS_UNUSED_REGNUM) + regcache_raw_supply (regcache, i, zerobuf); + else if (gdbarch_cannot_fetch_register (gdbarch, i)) regcache_raw_supply (regcache, i, NULL); else regcache_raw_supply (regcache, i,