This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA] A few sh fixes
- From: Elena Zannoni <ezannoni at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Fri, 27 Sep 2002 14:04:20 -0400
- Subject: Re: [RFA] A few sh fixes
- References: <20020927160439.Y1519@cygbert.vinschen.de>
Corinna Vinschen writes:
> Hi,
>
> the below patch contains the following fixes for sh:
>
> - Add some missing big/little endian stuff
> - Try to match sh_use_struct_convention() more closely to the ABI.
Thanks. Any difference in test results with this fixes? They are
better right? :)
Elena
>
> Corinna
>
> * sh-tdep.c (sh_use_struct_convention): Use definition according to ABI.
> (sh_push_arguments): Store in register with correct endianess.
> (sh_default_store_return_value): Ditto.
>
> Index: sh-tdep.c
> ===================================================================
> RCS file: /cvs/cvsfiles/devo/gdb/sh-tdep.c,v
> retrieving revision 2.125.2.2
> diff -u -p -r2.125.2.2 sh-tdep.c
> --- sh-tdep.c 2002/09/26 13:57:06 2.125.2.2
> +++ sh-tdep.c 2002/09/27 11:46:07
> @@ -906,7 +906,14 @@ sh_saved_pc_after_call (struct frame_inf
> static int
> sh_use_struct_convention (int gcc_p, struct type *type)
> {
> +#if 0
> return (TYPE_LENGTH (type) > 1);
> +#else
> + int len = TYPE_LENGTH (type);
> + int nelem = TYPE_NFIELDS (type);
> + return ((len != 1 && len != 2 && len != 4 && len != 8) || nelem != 1) &&
> + (len != 8 || TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0)) != 4);
> +#endif
> }
>
> static int
> @@ -2067,8 +2074,11 @@ sh_push_arguments (int nargs, struct val
> if (len < 4)
> {
> /* value gets right-justified in the register or stack word */
> - memcpy (valbuf + (4 - len),
> - (char *) VALUE_CONTENTS (args[argnum]), len);
> + if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
> + memcpy (valbuf + (4 - len),
> + (char *) VALUE_CONTENTS (args[argnum]), len);
> + else
> + memcpy (valbuf, (char *) VALUE_CONTENTS (args[argnum]), len);
> val = valbuf;
> }
> else
> @@ -2479,8 +2489,11 @@ sh_default_store_return_value (struct ty
> {
> /* Add leading zeros to the value. */
> memset (buf, 0, REGISTER_RAW_SIZE (R0_REGNUM));
> - memcpy (buf + REGISTER_RAW_SIZE (R0_REGNUM) - TYPE_LENGTH (type),
> - valbuf, TYPE_LENGTH (type));
> + if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
> + memcpy (buf + REGISTER_RAW_SIZE (R0_REGNUM) - TYPE_LENGTH (type),
> + valbuf, TYPE_LENGTH (type));
> + else
> + memcpy (buf, valbuf, TYPE_LENGTH (type));
> write_register_bytes (REGISTER_BYTE (R0_REGNUM), buf,
> REGISTER_RAW_SIZE (R0_REGNUM));
> }
>
> --
> Corinna Vinschen
> Cygwin Developer
> Red Hat, Inc.
> mailto:vinschen@redhat.com