This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA] sh-tdep.c: Fix little endian problem with doubles
- From: Elena Zannoni <ezannoni at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Fri, 10 Oct 2003 17:47:20 -0400
- Subject: Re: [RFA] sh-tdep.c: Fix little endian problem with doubles
- References: <20031007164256.GO29063@cygbert.vinschen.de>
Corinna Vinschen writes:
> Hi,
>
> I missed to get little endian mode right when it comes to passing
> doubles in registers on FPU CPUs. The below patch fixes that.
> It's against the two patches I sent on Saturday.
>
> Corinna
>
> * sh-tdep.c (sh_push_dummy_call_fpu): Accomodate double passing
> in little endian mode.
> (sh3e_sh4_extract_return_value): Ditto.
>
> --- sh-tdep.c.INTERIM 2003-10-04 13:22:01.000000000 +0200
> +++ sh-tdep.c 2003-10-07 18:42:13.000000000 +0200
> @@ -846,6 +846,17 @@ sh_push_dummy_call_fpu (struct gdbarch *
> /* Argument goes in a float argument register. */
> reg_size = register_size (gdbarch, flt_argreg);
> regval = extract_unsigned_integer (val, reg_size);
> + /* A float type taking two registers must be handled
> + differently in LE mode. */
> + if (TARGET_BYTE_ORDER == BFD_ENDIAN_LITTLE
> + && len == 2 * reg_size)
> + {
> + regcache_cooked_write_unsigned (regcache, flt_argreg + 1,
> + regval);
> + val += reg_size;
> + len -= reg_size;
> + regval = extract_unsigned_integer (val, reg_size);
> + }
I'd prefer if there is an 'else if' clause just for the
doubles. I.e. don't use len in the test, but TYPE_LENGTH(type). This is
too confusing.
> regcache_cooked_write_unsigned (regcache, flt_argreg++, regval);
> }
> else if (!treat_as_flt && argreg <= ARGLAST_REGNUM)
> @@ -978,7 +989,10 @@ sh3e_sh4_extract_return_value (struct ty
> int len = TYPE_LENGTH (type);
> int i, regnum = FP0_REGNUM;
> for (i = 0; i < len; i += 4)
> - regcache_raw_read (regcache, regnum++, (char *) valbuf + i);
> + if (TARGET_BYTE_ORDER == BFD_ENDIAN_LITTLE)
> + regcache_raw_read (regcache, regnum++, (char *) valbuf + len - 4 - i);
> + else
> + regcache_raw_read (regcache, regnum++, (char *) valbuf + i);
> }
> else
> sh_default_extract_return_value (type, regcache, valbuf);
>
this one is fine.
elena
> --
> Corinna Vinschen
> Cygwin Developer
> Red Hat, Inc.