diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 5e7ea108b5..3c554571fb 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,10 @@ +2018-05-21 Maciej W. Rozycki + + * linux-mips-low.c (mips_fetch_register): New function. Update + preceding comment. + (mips_store_gregset): Supply 0 rather than $restart for $zero. + (the_low_target): Wire `mips_fetch_register'. + 2018-05-10 Joel Brobecker * lynx-i386-low.c (LYNXOS_178): New macro. diff --git a/gdb/gdbserver/linux-mips-low.c b/gdb/gdbserver/linux-mips-low.c index d423633747..ff87dd77d3 100644 --- a/gdb/gdbserver/linux-mips-low.c +++ b/gdb/gdbserver/linux-mips-low.c @@ -198,8 +198,8 @@ struct arch_lwp_info /* Pseudo registers can not be read. ptrace does not provide a way to read (or set) PS_REGNUM, and there's no point in reading or setting - ZERO_REGNUM. We also can not set BADVADDR, CAUSE, or FCRIR via - ptrace(). */ + ZERO_REGNUM, it's always 0. We also can not set BADVADDR, CAUSE, + or FCRIR via ptrace(). */ static int mips_cannot_fetch_register (int regno) @@ -242,6 +242,20 @@ mips_cannot_store_register (int regno) return 0; } +static int +mips_fetch_register (struct regcache *regcache, int regno) +{ + const struct target_desc *tdesc = current_process ()->tdesc; + + if (find_regno (tdesc, "r0") == regno) + { + supply_register_zeroed (regcache, regno); + return 1; + } + + return 0; +} + static CORE_ADDR mips_get_pc (struct regcache *regcache) { @@ -750,7 +764,9 @@ mips_store_gregset (struct regcache *regcache, const void *buf) use_64bit = (register_size (regcache->tdesc, 0) == 8); - for (i = 0; i < 32; i++) + supply_register_by_name_zeroed (regcache, "r0"); + + for (i = 1; i < 32; i++) mips_supply_register (regcache, use_64bit, i, regset + i); mips_supply_register (regcache, use_64bit, @@ -879,7 +895,7 @@ struct linux_target_ops the_low_target = { mips_regs_info, mips_cannot_fetch_register, mips_cannot_store_register, - NULL, /* fetch_register */ + mips_fetch_register, mips_get_pc, mips_set_pc, NULL, /* breakpoint_kind_from_pc */