qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] gdbstub: allow byte swapping for reading/writin


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH] gdbstub: allow byte swapping for reading/writing registers
Date: Tue, 14 Jan 2014 22:20:36 +0000

On 14 January 2014 22:06, Thomas Falcon <address@hidden> wrote:
> 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.  It accomplishes this goal by byte swapping the values of
> any registers only if the MSR:LE value is set and if the host machine
> is big endian.

Since this patch only affects ppc targets it would be helpful if the
subject line had an appropriate prefix indicating that.

>
> Signed-off-by: Thomas Falcon<address@hidden>
> ---
>  target-ppc/gdbstub.c | 50
> ++++++++++++++++++++++++++++++++------------------
>  1 file changed, 32 insertions(+), 18 deletions(-)
>
> diff --git a/target-ppc/gdbstub.c b/target-ppc/gdbstub.c
> index 1c91090..eba501a 100644
> --- a/target-ppc/gdbstub.c
> +++ b/target-ppc/gdbstub.c
> @@ -21,6 +21,19 @@
>  #include "qemu-common.h"
>  #include "exec/gdbstub.h"
>
> +/* The following macros are used to ensure the correct
> + * transfer of registers between a little endian ppc target
> + * and a big endian host by checking the LE bit in the Machine State
> Register
> + */
> +
> +#define end_swap64(x) (msr_le && HOST_WORDS_BIGENDIAN) ? bswap64(x) : x
> +#define end_swap32(x) (msr_le && HOST_WORDS_BIGENDIAN) ? bswap32(x) : x

Surely we need to swap if the host is little endian and the target
is bigendian, as well as if the host is bigendian and the target
little endian?

Also, it seems a bit dubious to switch the endianness of words
based on a runtime flag in the guest CPU -- I'm pretty sure a
connected gdb won't be able to cope with that. On the other
hand, gdb's pretty bad at dealing with the kind of thing real
CPUs can do with switching endianness or word size at run
time, so maybe this is just better than the alternatives...

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]