This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFC] arm sim: Adjust return values in sim_{fetch,store}_register
- From: Kevin Buettner <kevinb at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 30 Jul 2012 13:49:26 -0700
- Subject: [RFC] arm sim: Adjust return values in sim_{fetch,store}_register
The change, below, to sim_store_register() fixes the following
GDB internal error for an arm-eabi target:
remote-sim.c:531: internal-error: Register 14 not updated
On the GDB side of things, remote-sim.c now requires that
sim_store_register() return the length of the register being stored.
(This requirement has been in place for quite a while now.) Returning
a value less than zero triggers an internal error. Returning 0
triggers a warning.
The change to sim_fetch_register() is not strictly required, though
the comments in remote-sim.c suggests that return of -1 might be
considered to be broken at some point too.
The include of libiberty.h fixes a warning regarding xstrdup() that I
noticed during a rebuild. I can post this separately if desired.
Comments?
Kevin
sim/arm/ChangeLog:
* wrapper.c (libiberty.h): Include.
(sim_store_register, sim_fetch_register): On success, return
length, instead of -1.
Index: arm/wrapper.c
===================================================================
RCS file: /cvs/src/src/sim/arm/wrapper.c,v
retrieving revision 1.45
diff -u -p -r1.45 wrapper.c
--- arm/wrapper.c 13 Jun 2012 10:07:11 -0000 1.45
+++ arm/wrapper.c 30 Jul 2012 20:32:00 -0000
@@ -37,6 +37,7 @@
#include "run-sim.h"
#include "gdb/sim-arm.h"
#include "gdb/signals.h"
+#include "libiberty.h"
host_callback *sim_callback;
@@ -443,7 +444,7 @@ sim_store_register (sd, rn, memory, leng
SIM_DESC sd ATTRIBUTE_UNUSED;
int rn;
unsigned char *memory;
- int length ATTRIBUTE_UNUSED;
+ int length;
{
init ();
@@ -544,7 +545,7 @@ sim_store_register (sd, rn, memory, leng
return 0;
}
- return -1;
+ return length;
}
int
@@ -552,9 +553,10 @@ sim_fetch_register (sd, rn, memory, leng
SIM_DESC sd ATTRIBUTE_UNUSED;
int rn;
unsigned char *memory;
- int length ATTRIBUTE_UNUSED;
+ int length;
{
ARMword regval;
+ int len = length;
init ();
@@ -657,16 +659,16 @@ sim_fetch_register (sd, rn, memory, leng
return 0;
}
- while (length)
+ while (len)
{
tomem (state, memory, regval);
- length -= 4;
+ len -= 4;
memory += 4;
regval = 0;
}
- return -1;
+ return length;
}
#ifdef SIM_TARGET_SWITCHES