diff options
author | Michael Snyder <msnyder@vmware.com> | 2002-06-06 18:47:35 +0000 |
---|---|---|
committer | Michael Snyder <msnyder@vmware.com> | 2002-06-06 18:47:35 +0000 |
commit | 3d79a47c75ac0cb5c8d78dfc15f6b8e5b3bfc4b4 (patch) | |
tree | 875a11d011c7fd54f8737e0c22d6a69970736544 /gdb/d10v-tdep.c | |
parent | 9691d64f9a558a599867a6528db1908e4c5bc63f (diff) | |
download | gdb-3d79a47c75ac0cb5c8d78dfc15f6b8e5b3bfc4b4.zip gdb-3d79a47c75ac0cb5c8d78dfc15f6b8e5b3bfc4b4.tar.gz gdb-3d79a47c75ac0cb5c8d78dfc15f6b8e5b3bfc4b4.tar.bz2 |
2002-06-06 Michael Snyder <msnyder@redhat.com>
* d10v-tdep.c (d10v_store_return_value): Char return values
must be shifted over by one byte in R0.
(d10v_extract_return_value): Delete extra braces, re-indent.
Diffstat (limited to 'gdb/d10v-tdep.c')
-rw-r--r-- | gdb/d10v-tdep.c | 59 |
1 files changed, 38 insertions, 21 deletions
diff --git a/gdb/d10v-tdep.c b/gdb/d10v-tdep.c index cb2ce47..97562b7 100644 --- a/gdb/d10v-tdep.c +++ b/gdb/d10v-tdep.c @@ -482,9 +482,20 @@ d10v_store_struct_return (CORE_ADDR addr, CORE_ADDR sp) static void d10v_store_return_value (struct type *type, char *valbuf) { - write_register_bytes (REGISTER_BYTE (RET1_REGNUM), - valbuf, - TYPE_LENGTH (type)); + char tmp = 0; + /* Only char return values need to be shifted right within R0. */ + if (TYPE_LENGTH (type) == 1 + && TYPE_CODE (type) == TYPE_CODE_INT) + { + write_register_bytes (REGISTER_BYTE (RET1_REGNUM), + &tmp, 1); /* zero the high byte */ + write_register_bytes (REGISTER_BYTE (RET1_REGNUM) + 1, + valbuf, 1); /* copy the low byte */ + } + else + write_register_bytes (REGISTER_BYTE (RET1_REGNUM), + valbuf, + TYPE_LENGTH (type)); } /* Extract from an array REGBUF containing the (raw) register state @@ -1137,25 +1148,31 @@ d10v_extract_return_value (struct type *type, char regbuf[REGISTER_BYTES], char *valbuf) { int len; - /* printf("RET: TYPE=%d len=%d r%d=0x%x\n", TYPE_CODE (type), TYPE_LENGTH (type), RET1_REGNUM - R0_REGNUM, (int) extract_unsigned_integer (regbuf + REGISTER_BYTE(RET1_REGNUM), REGISTER_RAW_SIZE (RET1_REGNUM))); */ +#if 0 + printf("RET: TYPE=%d len=%d r%d=0x%x\n", TYPE_CODE (type), + TYPE_LENGTH (type), RET1_REGNUM - R0_REGNUM, + (int) extract_unsigned_integer (regbuf + REGISTER_BYTE(RET1_REGNUM), + REGISTER_RAW_SIZE (RET1_REGNUM))); +#endif + len = TYPE_LENGTH (type); + if (len == 1) { - len = TYPE_LENGTH (type); - if (len == 1) - { - unsigned short c = extract_unsigned_integer (regbuf + REGISTER_BYTE (RET1_REGNUM), REGISTER_RAW_SIZE (RET1_REGNUM)); - store_unsigned_integer (valbuf, 1, c); - } - else if ((len & 1) == 0) - memcpy (valbuf, regbuf + REGISTER_BYTE (RET1_REGNUM), len); - else - { - /* For return values of odd size, the first byte is in the - least significant part of the first register. The - remaining bytes in remaining registers. Interestingly, - when such values are passed in, the last byte is in the - most significant byte of that same register - wierd. */ - memcpy (valbuf, regbuf + REGISTER_BYTE (RET1_REGNUM) + 1, len); - } + unsigned short c; + + c = extract_unsigned_integer (regbuf + REGISTER_BYTE (RET1_REGNUM), + REGISTER_RAW_SIZE (RET1_REGNUM)); + store_unsigned_integer (valbuf, 1, c); + } + else if ((len & 1) == 0) + memcpy (valbuf, regbuf + REGISTER_BYTE (RET1_REGNUM), len); + else + { + /* For return values of odd size, the first byte is in the + least significant part of the first register. The + remaining bytes in remaining registers. Interestingly, + when such values are passed in, the last byte is in the + most significant byte of that same register - wierd. */ + memcpy (valbuf, regbuf + REGISTER_BYTE (RET1_REGNUM) + 1, len); } } |