Received: from eggs.gnu.org ([2001:4830:134:3::10]:52731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsAZ6-0007qf-6I for qemu-devel@nongnu.org; Wed, 04 Jun 2014 08:45:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WsAYw-0008F1-Dn for qemu-devel@nongnu.org; Wed, 04 Jun 2014 08:45:12 -0400 From: Alexander Graf Date: Wed, 4 Jun 2014 14:43:07 +0200 Message-Id: <1401885899-16524-7-git-send-email-agraf@suse.de> In-Reply-To: <1401885899-16524-1-git-send-email-agraf@suse.de> References: <1401885899-16524-1-git-send-email-agraf@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 006/118] target-ppc: gdbstub allow byte swapping for reading/writing registers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-ppc@nongnu.org Cc: Thomas Falcon , qemu-devel@nongnu.org From: Thomas Falcon 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=C3=A4rber Signed-off-by: Thomas Falcon Signed-off-by: Alexander Graf --- target-ppc/gdbstub.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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) } =20 =20 +static void ppc_gdb_swap_register(uint8_t *mem_buf, int n, int len) +{ + if (len =3D=3D 4) { + bswap32s((uint32_t *)mem_buf); + } else if (len =3D=3D 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; } =20 @@ -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] =3D ldtul_p(mem_buf); --=20 1.8.1.4