summaryrefslogtreecommitdiffstats
path: root/target-ppc
diff options
context:
space:
mode:
authorThomas Falcon <tlfalcon@linux.vnet.ibm.com>2014-04-07 17:41:00 -0400
committerAlexander Graf <agraf@suse.de>2014-06-16 13:24:27 +0200
commit8a286ce4502356ce0b97a2424a2cb7dfb31567f2 (patch)
tree72862d582c6086889b1ad8c972224a71a9ded158 /target-ppc
parentc46e98310608b806382b036d973e2ada8e7275c3 (diff)
downloadhqemu-8a286ce4502356ce0b97a2424a2cb7dfb31567f2.zip
hqemu-8a286ce4502356ce0b97a2424a2cb7dfb31567f2.tar.gz
target-ppc: gdbstub allow byte swapping for reading/writing registers
This patch allows registers to be properly read from and written to when using the gdbstub to debug a ppc guest running in little endian mode. Reviewed-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'target-ppc')
-rw-r--r--target-ppc/gdbstub.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/target-ppc/gdbstub.c b/target-ppc/gdbstub.c
index 0740af8..381a3c7 100644
--- a/target-ppc/gdbstub.c
+++ b/target-ppc/gdbstub.c
@@ -59,6 +59,17 @@ static int ppc_gdb_register_len(int n)
}
+static void ppc_gdb_swap_register(uint8_t *mem_buf, int n, int len)
+{
+ if (len == 4) {
+ bswap32s((uint32_t *)mem_buf);
+ } else if (len == 8) {
+ bswap64s((uint64_t *)mem_buf);
+ } else {
+ g_assert_not_reached();
+ }
+}
+
/* Old gdb always expects FP registers. Newer (xml-aware) gdb only
* expects whatever the target description contains. Due to a
* historical mishap the FP registers appear in between core integer
@@ -114,6 +125,10 @@ int ppc_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n)
break;
}
}
+ if (msr_le) {
+ /* If cpu is in LE mode, convert memory contents to LE. */
+ ppc_gdb_swap_register(mem_buf, n, r);
+ }
return r;
}
@@ -126,6 +141,10 @@ int ppc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
if (!r) {
return r;
}
+ if (msr_le) {
+ /* If cpu is in LE mode, convert memory contents to LE. */
+ ppc_gdb_swap_register(mem_buf, n, r);
+ }
if (n < 32) {
/* gprs */
env->gpr[n] = ldtul_p(mem_buf);
OpenPOWER on IntegriCloud