This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH, RFC] Changes to sim_store_register API
- From: "Andrew Burgess" <aburgess at broadcom dot com>
- To: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Tue, 14 Dec 2010 09:13:30 +0000
- Subject: Re: [PATCH, RFC] Changes to sim_store_register API
- References: <89AE14E37D740B4796DC14566DF6325ECB7F5F6770@SJEXCHCCR02.corp.ad.broadcom.com> <89AE14E37D740B4796DC14566DF6325ECB7F8F13FA@SJEXCHCCR02.corp.ad.broadcom.com> <20101214064904.GM2596@adacore.com>
Joel,
Thanks for taking the time to review this patch.
On 14/12/2010 06:49, Joel Brobecker wrote:
>
> Overall, this seems OK to me. Can you make the adjustments requested
> above, and then resubmit?
>
I believe I have addressed all the issues raised.
Thanks,
Andrew
gdb/ChangeLog :
2010-11-16 Andrew Burgess <aburgess@broadcom.com>
* remote-sim.c (gdbsim_store_register): Update API to
sim_store_register to check more error conditions.
include/gdb/ChangeLog :
2010-11-16 Andrew Burgess <aburgess@broadcom.com>
* remote-sim.h (sim_store_register): Update the API
documentation for this function.
sim/erc32/ChangeLog :
2010-11-16 Andrew Burgess <aburgess@broadcom.com>
* interf.c (sim_store_register): Update return value to
match new API.
sim/h8300/ChangeLog :
2010-11-16 Andrew Burgess <aburgess@broadcom.com>
* compile.c (sim_store_register): Update return value to
match new API.
sim/m32c/ChangesLog :
2010-11-16 Andrew Burgess <aburgess@broadcom.com>
* gdb-if.c (sim_store_register): Update return value to
match new API.
sim/mn10300/ChangeLog :
2010-11-16 Andrew Burgess <aburgess@broadcom.com>
* interp.c (sim_store_register): Update return value to
match new API.
sim/ppc/ChangeLog :
2010-11-16 Andrew Burgess <aburgess@broadcom.com>
* gdb-sim.c (sim_store_register): Update return value to
match new API.
sim/rx/ChangeLog :
2010-11-16 Andrew Burgess <aburgess@broadcom.com>
* gdb-if.c (sim_store_register): Update return value to
match new API.
sim/v850/ChangeLog :
2010-11-16 Andrew Burgess <aburgess@broadcom.com>
* interp.c (sim_store_register): Update return value to
match new API.
diff -rwup clean/gdb-7.2.50.20101027/gdb/remote-sim.c working/gdb-7.2.50.20101027/gdb/remote-sim.c
--- clean/gdb-7.2.50.20101027/gdb/remote-sim.c 2010-08-10 05:39:26.000000000 +0100
+++ working/gdb-7.2.50.20101027/gdb/remote-sim.c 2010-11-16 11:07:54.398861201 +0000
@@ -527,9 +527,13 @@ gdbsim_store_register (struct target_ops
if (nr_bytes > 0 && nr_bytes != register_size (gdbarch, regno))
internal_error (__FILE__, __LINE__,
_("Register size different to expected"));
- /* FIXME: cagney/2002-05-27: Should check `nr_bytes == 0'
- indicating that GDB and the SIM have different ideas about
- which registers are fetchable. */
+ if (nr_bytes < 0)
+ internal_error (__FILE__, __LINE__,
+ _("Register %d not updated"), regno);
+ if (nr_bytes == 0)
+ warning (_("Register %s not updated"),
+ gdbarch_register_name (gdbarch, regno));
+
if (remote_debug)
{
printf_filtered ("gdbsim_store_register: %d", regno);
diff -rwup clean/gdb-7.2.50.20101027/include/gdb/remote-sim.h working/gdb-7.2.50.20101027/include/gdb/remote-sim.h
--- clean/gdb-7.2.50.20101027/include/gdb/remote-sim.h 2010-04-13 21:39:44.000000000 +0100
+++ working/gdb-7.2.50.20101027/include/gdb/remote-sim.h 2010-12-14 08:44:50.186806811 +0000
@@ -191,13 +191,15 @@ int sim_fetch_register (SIM_DESC sd, int
/* Store register REGNO from the raw (target endian) value in BUF.
- Return the actual size of the register or zero if REGNO is not
- applicable.
- Legacy implementations ignore LENGTH and always return -1.
+ Return the actual size of the register, any size not equal to
+ LENGTH indicates the register was not updated correctly.
- If LENGTH does not match the size of REGNO no data is transfered
- (the actual register size is still returned). */
+ Return a LENGTH of -1 to indicate the register was not updated
+ and an error has occurred.
+
+ Return a LENGTH of 0 to indicate the register was not updated
+ but no error has occurred. */
int sim_store_register (SIM_DESC sd, int regno, unsigned char *buf, int length);
diff -rwup clean/gdb-7.2.50.20101027/sim/erc32/interf.c working/gdb-7.2.50.20101027/sim/erc32/interf.c
--- clean/gdb-7.2.50.20101027/sim/erc32/interf.c 2010-05-11 15:18:20.000000000 +0100
+++ working/gdb-7.2.50.20101027/sim/erc32/interf.c 2010-10-27 16:56:12.607262027 +0100
@@ -330,7 +330,7 @@ sim_store_register(sd, regno, value, len
regval = (value[3] << 24) | (value[2] << 16)
| (value[1] << 8) | value[0];
set_regi(&sregs, regno, regval);
- return -1;
+ return length;
}
diff -rwup clean/gdb-7.2.50.20101027/sim/h8300/compile.c working/gdb-7.2.50.20101027/sim/h8300/compile.c
--- clean/gdb-7.2.50.20101027/sim/h8300/compile.c 2010-04-14 08:38:04.000000000 +0100
+++ working/gdb-7.2.50.20101027/sim/h8300/compile.c 2010-10-27 16:56:28.193119915 +0100
@@ -4715,7 +4715,7 @@ sim_store_register (SIM_DESC sd, int rn,
h8_set_ticks (sd, longval);
break;
}
- return -1;
+ return length;
}
int
diff -rwup clean/gdb-7.2.50.20101027/sim/m32c/gdb-if.c working/gdb-7.2.50.20101027/sim/m32c/gdb-if.c
--- clean/gdb-7.2.50.20101027/sim/m32c/gdb-if.c 2010-04-14 08:38:04.000000000 +0100
+++ working/gdb-7.2.50.20101027/sim/m32c/gdb-if.c 2010-12-14 08:46:04.058808380 +0000
@@ -405,7 +405,7 @@ sim_store_register (SIM_DESC sd, int reg
check_desc (sd);
if (!check_regno (regno))
- return 0;
+ return -1;
size = reg_size (regno);
@@ -502,7 +502,7 @@ sim_store_register (SIM_DESC sd, int reg
default:
fprintf (stderr, "m32c minisim: unrecognized register number: %d\n",
regno);
- return -1;
+ return 0;
}
}
diff -rwup clean/gdb-7.2.50.20101027/sim/mn10300/interp.c working/gdb-7.2.50.20101027/sim/mn10300/interp.c
--- clean/gdb-7.2.50.20101027/sim/mn10300/interp.c 2004-06-26 23:18:18.000000000 +0100
+++ working/gdb-7.2.50.20101027/sim/mn10300/interp.c 2010-10-27 16:59:00.810068620 +0100
@@ -410,7 +410,7 @@ sim_store_register (SIM_DESC sd,
int length)
{
State.regs[rn] = get_word (memory);
- return -1;
+ return length;
}
diff -rwup clean/gdb-7.2.50.20101027/sim/ppc/gdb-sim.c working/gdb-7.2.50.20101027/sim/ppc/gdb-sim.c
--- clean/gdb-7.2.50.20101027/sim/ppc/gdb-sim.c 2010-01-01 10:03:33.000000000 +0000
+++ working/gdb-7.2.50.20101027/sim/ppc/gdb-sim.c 2010-10-27 17:00:16.559040694 +0100
@@ -1289,7 +1289,7 @@ sim_store_register (SIM_DESC sd, int reg
const char *regname = regnum2name (regno);
if (simulator == NULL || regname == NULL)
- return -1;
+ return 0;
TRACE(trace_gdb, ("sim_store_register(regno=%d(%s), buf=0x%lx)\n",
regno, regname, (long)buf));
diff -rwup clean/gdb-7.2.50.20101027/sim/rx/gdb-if.c working/gdb-7.2.50.20101027/sim/rx/gdb-if.c
--- clean/gdb-7.2.50.20101027/sim/rx/gdb-if.c 2010-09-24 00:05:28.000000000 +0100
+++ working/gdb-7.2.50.20101027/sim/rx/gdb-if.c 2010-12-14 08:48:41.402812553 +0000
@@ -534,12 +534,12 @@ sim_store_register (SIM_DESC sd, int reg
check_desc (sd);
if (!check_regno (regno))
- return 0;
+ return -1;
size = reg_size (regno);
if (length != size)
- return 0;
+ return -1;
if (rx_big_endian)
val = get_be (buf, length);
@@ -630,7 +630,7 @@ sim_store_register (SIM_DESC sd, int reg
default:
fprintf (stderr, "rx minisim: unrecognized register number: %d\n",
regno);
- return -1;
+ return 0;
}
return size;
diff -rwup clean/gdb-7.2.50.20101027/sim/v850/interp.c working/gdb-7.2.50.20101027/sim/v850/interp.c
--- clean/gdb-7.2.50.20101027/sim/v850/interp.c 2010-03-31 00:43:03.000000000 +0100
+++ working/gdb-7.2.50.20101027/sim/v850/interp.c 2010-10-27 17:00:02.016083444 +0100
@@ -327,7 +327,7 @@ sim_store_register (sd, rn, memory, leng
int length;
{
State.regs[rn] = T2H_4 (*(unsigned32*)memory);
- return -1;
+ return length;
}
void