* amd64-tdep.c (amd64_return_value): Revert previous change

that used TYPE_LENGTH directly.
        * bfin-tdep.c (bfin_extract_return_value): Likewise.
        (bfin_store_return_value): Likewise.
        * cris-tdep.c (cris_store_return_value): Likewise.
        (cris_extract_return_value): Likewise.
        * h8300-tdep.c (h8300_extract_return_value): Likewise.
        * hppa-tdep.c (hppa64_return_value): Likewise.
        * lm32-tdep.c (lm32_store_return_value): Likewise.
        * microblaze-tdep.c (microblaze_store_return_value): Likewise.
        * spu-tdep.c (spu_value_from_register): Likewise.
        * vax-tdep.c (vax_return_value): Likewise.
This commit is contained in:
Siddhesh Poyarekar 2012-09-27 10:40:01 +00:00
parent 63375b7438
commit bad43aa52e
10 changed files with 51 additions and 34 deletions

View file

@ -1,3 +1,18 @@
2012-09-27 Siddhesh Poyarekar <siddhesh@redhat.com>
* amd64-tdep.c (amd64_return_value): Revert previous change
that used TYPE_LENGTH directly.
* bfin-tdep.c (bfin_extract_return_value): Likewise.
(bfin_store_return_value): Likewise.
* cris-tdep.c (cris_store_return_value): Likewise.
(cris_extract_return_value): Likewise.
* h8300-tdep.c (h8300_extract_return_value): Likewise.
* hppa-tdep.c (hppa64_return_value): Likewise.
* lm32-tdep.c (lm32_store_return_value): Likewise.
* microblaze-tdep.c (microblaze_store_return_value): Likewise.
* spu-tdep.c (spu_value_from_register): Likewise.
* vax-tdep.c (vax_return_value): Likewise.
2012-09-27 Siddhesh Poyarekar <siddhesh@redhat.com> 2012-09-27 Siddhesh Poyarekar <siddhesh@redhat.com>
* gdbtypes.c (lookup_array_range_type): Expand parameters * gdbtypes.c (lookup_array_range_type): Expand parameters

View file

@ -637,7 +637,7 @@ amd64_return_value (struct gdbarch *gdbarch, struct value *function,
} }
gdb_assert (class[1] != AMD64_MEMORY); gdb_assert (class[1] != AMD64_MEMORY);
gdb_assert (TYPE_LENGTH (type) <= 16); gdb_assert (len <= 16);
for (i = 0; len > 0; i++, len -= 8) for (i = 0; len > 0; i++, len -= 8)
{ {

View file

@ -615,7 +615,7 @@ bfin_extract_return_value (struct type *type,
ULONGEST tmp; ULONGEST tmp;
int regno = BFIN_R0_REGNUM; int regno = BFIN_R0_REGNUM;
gdb_assert (TYPE_LENGTH (type) <= 8); gdb_assert (len <= 8);
while (len > 0) while (len > 0)
{ {
@ -643,7 +643,7 @@ bfin_store_return_value (struct type *type,
int len = TYPE_LENGTH (type); int len = TYPE_LENGTH (type);
int regno = BFIN_R0_REGNUM; int regno = BFIN_R0_REGNUM;
gdb_assert (TYPE_LENGTH (type) <= 8); gdb_assert (len <= 8);
while (len > 0) while (len > 0)
{ {

View file

@ -1662,20 +1662,20 @@ cris_store_return_value (struct type *type, struct regcache *regcache,
struct gdbarch *gdbarch = get_regcache_arch (regcache); struct gdbarch *gdbarch = get_regcache_arch (regcache);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST val; ULONGEST val;
int len = TYPE_LENGTH (type);
if (TYPE_LENGTH (type) <= 4) if (len <= 4)
{ {
/* Put the return value in R10. */ /* Put the return value in R10. */
val = extract_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order); val = extract_unsigned_integer (valbuf, len, byte_order);
regcache_cooked_write_unsigned (regcache, ARG1_REGNUM, val); regcache_cooked_write_unsigned (regcache, ARG1_REGNUM, val);
} }
else if (TYPE_LENGTH (type) <= 8) else if (len <= 8)
{ {
/* Put the return value in R10 and R11. */ /* Put the return value in R10 and R11. */
val = extract_unsigned_integer (valbuf, 4, byte_order); val = extract_unsigned_integer (valbuf, 4, byte_order);
regcache_cooked_write_unsigned (regcache, ARG1_REGNUM, val); regcache_cooked_write_unsigned (regcache, ARG1_REGNUM, val);
val = extract_unsigned_integer ((char *)valbuf + 4, val = extract_unsigned_integer ((char *)valbuf + 4, len - 4, byte_order);
TYPE_LENGTH (type) - 4, byte_order);
regcache_cooked_write_unsigned (regcache, ARG2_REGNUM, val); regcache_cooked_write_unsigned (regcache, ARG2_REGNUM, val);
} }
else else
@ -1833,21 +1833,21 @@ cris_extract_return_value (struct type *type, struct regcache *regcache,
struct gdbarch *gdbarch = get_regcache_arch (regcache); struct gdbarch *gdbarch = get_regcache_arch (regcache);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST val; ULONGEST val;
int len = TYPE_LENGTH (type);
if (TYPE_LENGTH (type) <= 4) if (len <= 4)
{ {
/* Get the return value from R10. */ /* Get the return value from R10. */
regcache_cooked_read_unsigned (regcache, ARG1_REGNUM, &val); regcache_cooked_read_unsigned (regcache, ARG1_REGNUM, &val);
store_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order, val); store_unsigned_integer (valbuf, len, byte_order, val);
} }
else if (TYPE_LENGTH (type) <= 8) else if (len <= 8)
{ {
/* Get the return value from R10 and R11. */ /* Get the return value from R10 and R11. */
regcache_cooked_read_unsigned (regcache, ARG1_REGNUM, &val); regcache_cooked_read_unsigned (regcache, ARG1_REGNUM, &val);
store_unsigned_integer (valbuf, 4, byte_order, val); store_unsigned_integer (valbuf, 4, byte_order, val);
regcache_cooked_read_unsigned (regcache, ARG2_REGNUM, &val); regcache_cooked_read_unsigned (regcache, ARG2_REGNUM, &val);
store_unsigned_integer ((char *)valbuf + 4, TYPE_LENGTH (type) - 4, store_unsigned_integer ((char *)valbuf + 4, len - 4, byte_order, val);
byte_order, val);
} }
else else
error (_("cris_extract_return_value: type length too large")); error (_("cris_extract_return_value: type length too large"));

View file

@ -751,12 +751,12 @@ h8300_extract_return_value (struct type *type, struct regcache *regcache,
int len = TYPE_LENGTH (type); int len = TYPE_LENGTH (type);
ULONGEST c, addr; ULONGEST c, addr;
switch (TYPE_LENGTH (type)) switch (len)
{ {
case 1: case 1:
case 2: case 2:
regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &c); regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &c);
store_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order, c); store_unsigned_integer (valbuf, len, byte_order, c);
break; break;
case 4: /* Needs two registers on plain H8/300 */ case 4: /* Needs two registers on plain H8/300 */
regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &c); regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &c);
@ -768,9 +768,8 @@ h8300_extract_return_value (struct type *type, struct regcache *regcache,
if (TYPE_CODE (type) == TYPE_CODE_INT) if (TYPE_CODE (type) == TYPE_CODE_INT)
{ {
regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &addr); regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &addr);
c = read_memory_unsigned_integer ((CORE_ADDR) addr, c = read_memory_unsigned_integer ((CORE_ADDR) addr, len, byte_order);
TYPE_LENGTH (type), byte_order); store_unsigned_integer (valbuf, len, byte_order, c);
store_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order, c);
} }
else else
{ {

View file

@ -1160,7 +1160,7 @@ hppa64_return_value (struct gdbarch *gdbarch, struct value *function,
int len = TYPE_LENGTH (type); int len = TYPE_LENGTH (type);
int regnum, offset; int regnum, offset;
if (TYPE_LENGTH (type) > 16) if (len > 16)
{ {
/* All return values larget than 128 bits must be aggregate /* All return values larget than 128 bits must be aggregate
return values. */ return values. */

View file

@ -349,18 +349,18 @@ lm32_store_return_value (struct type *type, struct regcache *regcache,
struct gdbarch *gdbarch = get_regcache_arch (regcache); struct gdbarch *gdbarch = get_regcache_arch (regcache);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST val; ULONGEST val;
int len = TYPE_LENGTH (type);
if (TYPE_LENGTH (type) <= 4) if (len <= 4)
{ {
val = extract_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order); val = extract_unsigned_integer (valbuf, len, byte_order);
regcache_cooked_write_unsigned (regcache, SIM_LM32_R1_REGNUM, val); regcache_cooked_write_unsigned (regcache, SIM_LM32_R1_REGNUM, val);
} }
else if (TYPE_LENGTH (type) <= 8) else if (len <= 8)
{ {
val = extract_unsigned_integer (valbuf, 4, byte_order); val = extract_unsigned_integer (valbuf, 4, byte_order);
regcache_cooked_write_unsigned (regcache, SIM_LM32_R1_REGNUM, val); regcache_cooked_write_unsigned (regcache, SIM_LM32_R1_REGNUM, val);
val = extract_unsigned_integer (valbuf + 4, TYPE_LENGTH (type) - 4, val = extract_unsigned_integer (valbuf + 4, len - 4, byte_order);
byte_order);
regcache_cooked_write_unsigned (regcache, SIM_LM32_R2_REGNUM, val); regcache_cooked_write_unsigned (regcache, SIM_LM32_R2_REGNUM, val);
} }
else else

View file

@ -590,21 +590,22 @@ static void
microblaze_store_return_value (struct type *type, struct regcache *regcache, microblaze_store_return_value (struct type *type, struct regcache *regcache,
const gdb_byte *valbuf) const gdb_byte *valbuf)
{ {
int len = TYPE_LENGTH (type);
gdb_byte buf[8]; gdb_byte buf[8];
memset (buf, 0, sizeof(buf)); memset (buf, 0, sizeof(buf));
/* Integral and pointer return values. */ /* Integral and pointer return values. */
if (TYPE_LENGTH (type) > 4) if (len > 4)
{ {
gdb_assert (TYPE_LENGTH (type) == 8); gdb_assert (len == 8);
memcpy (buf, valbuf, 8); memcpy (buf, valbuf, 8);
regcache_cooked_write (regcache, MICROBLAZE_RETVAL_REGNUM+1, buf + 4); regcache_cooked_write (regcache, MICROBLAZE_RETVAL_REGNUM+1, buf + 4);
} }
else else
/* ??? Do we need to do any sign-extension here? */ /* ??? Do we need to do any sign-extension here? */
memcpy (buf + 4 - TYPE_LENGTH (type), valbuf, TYPE_LENGTH (type)); memcpy (buf + 4 - len, valbuf, len);
regcache_cooked_write (regcache, MICROBLAZE_RETVAL_REGNUM, buf); regcache_cooked_write (regcache, MICROBLAZE_RETVAL_REGNUM, buf);
} }

View file

@ -316,10 +316,11 @@ spu_value_from_register (struct type *type, int regnum,
struct frame_info *frame) struct frame_info *frame)
{ {
struct value *value = default_value_from_register (type, regnum, frame); struct value *value = default_value_from_register (type, regnum, frame);
int len = TYPE_LENGTH (type);
if (regnum < SPU_NUM_GPRS && TYPE_LENGTH (type) < 16) if (regnum < SPU_NUM_GPRS && len < 16)
{ {
int preferred_slot = TYPE_LENGTH (type) < 4 ? 4 - TYPE_LENGTH (type) : 0; int preferred_slot = len < 4 ? 4 - len : 0;
set_value_offset (value, preferred_slot); set_value_offset (value, preferred_slot);
} }

View file

@ -208,6 +208,7 @@ vax_return_value (struct gdbarch *gdbarch, struct value *function,
struct type *type, struct regcache *regcache, struct type *type, struct regcache *regcache,
gdb_byte *readbuf, const gdb_byte *writebuf) gdb_byte *readbuf, const gdb_byte *writebuf)
{ {
int len = TYPE_LENGTH (type);
gdb_byte buf[8]; gdb_byte buf[8];
if (TYPE_CODE (type) == TYPE_CODE_STRUCT if (TYPE_CODE (type) == TYPE_CODE_STRUCT
@ -223,7 +224,7 @@ vax_return_value (struct gdbarch *gdbarch, struct value *function,
ULONGEST addr; ULONGEST addr;
regcache_raw_read_unsigned (regcache, VAX_R0_REGNUM, &addr); regcache_raw_read_unsigned (regcache, VAX_R0_REGNUM, &addr);
read_memory (addr, readbuf, TYPE_LENGTH (type)); read_memory (addr, readbuf, len);
} }
return RETURN_VALUE_ABI_RETURNS_ADDRESS; return RETURN_VALUE_ABI_RETURNS_ADDRESS;
@ -233,16 +234,16 @@ vax_return_value (struct gdbarch *gdbarch, struct value *function,
{ {
/* Read the contents of R0 and (if necessary) R1. */ /* Read the contents of R0 and (if necessary) R1. */
regcache_cooked_read (regcache, VAX_R0_REGNUM, buf); regcache_cooked_read (regcache, VAX_R0_REGNUM, buf);
if (TYPE_LENGTH (type) > 4) if (len > 4)
regcache_cooked_read (regcache, VAX_R1_REGNUM, buf + 4); regcache_cooked_read (regcache, VAX_R1_REGNUM, buf + 4);
memcpy (readbuf, buf, TYPE_LENGTH (type)); memcpy (readbuf, buf, len);
} }
if (writebuf) if (writebuf)
{ {
/* Read the contents to R0 and (if necessary) R1. */ /* Read the contents to R0 and (if necessary) R1. */
memcpy (buf, writebuf, TYPE_LENGTH (type)); memcpy (buf, writebuf, len);
regcache_cooked_write (regcache, VAX_R0_REGNUM, buf); regcache_cooked_write (regcache, VAX_R0_REGNUM, buf);
if (TYPE_LENGTH (type) > 4) if (len > 4)
regcache_cooked_write (regcache, VAX_R1_REGNUM, buf + 4); regcache_cooked_write (regcache, VAX_R1_REGNUM, buf + 4);
} }