This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFA: Fix compile time warnings building iq2000-tdep.c


Hi Daniel,

Looks OK except...

*************** iq2000_extract_return_value (struct type
*** 558,564 ****
returned in a register, and if larger than 8 bytes, it is returned in a stack location which is pointed to by the same
register. */
! CORE_ADDR return_buffer;
int len = TYPE_LENGTH (type);
if (len <= (2 * 4))
--- 558,564 ----
returned in a register, and if larger than 8 bytes, it is returned in a stack location which is pointed to by the same
register. */
! gdb_byte return_buffer;
int len = TYPE_LENGTH (type);
if (len <= (2 * 4))

That? Aren't you going to run off the end of that if it's only a single byte?

Urk, yes. How about this version instead:


*************** iq2000_extract_return_value (struct type
*** 558,564 ****
       returned in a register, and if larger than 8 bytes, it is
       returned in a stack location which is pointed to by the same
       register.  */
-   CORE_ADDR return_buffer;
    int len = TYPE_LENGTH (type);

if (len <= (2 * 4))
--- 558,563 ----
*************** iq2000_extract_return_value (struct type
*** 582,598 ****
}
else
{
/* Return values > 8 bytes are returned in memory,
pointed to by FN_RETURN_REGNUM. */
! regcache_cooked_read (regcache, E_FN_RETURN_REGNUM, & return_buffer);
! read_memory (return_buffer, valbuf, TYPE_LENGTH (type));
}
}


--- 581,605 ----
}
else
{
+ CORE_ADDR dummy;
+ union
+ {
+ gdb_byte bytes[sizeof dummy];
+ CORE_ADDR addr;
+ }
+ return_buffer;
+
/* Return values > 8 bytes are returned in memory,
pointed to by FN_RETURN_REGNUM. */
! regcache_cooked_read (regcache, E_FN_RETURN_REGNUM, return_buffer.bytes);
! read_memory (return_buffer.addr, valbuf, TYPE_LENGTH (type));
}
}


(Rest of the patch as before).

This makes the puning of gdb_byte and CORE_ADDR explicit, which I think is a good thing, but maybe there is a preferred gdb way of doing this ? (Also I could not think of a clean way of obtaining the size of a CORE_ADDR without using a dummy variable).

Cheers
  Nick


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]