Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* RFA: Fix compile time warnings building iq2000-tdep.c
@ 2006-11-28 16:41 Nick Clifton
  2006-11-28 16:56 ` Daniel Jacobowitz
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Clifton @ 2006-11-28 16:41 UTC (permalink / raw)
  To: gdb-patches; +Cc: kevinb

Hi Guys,

  The iq2000 port of GDB currently fails to build on the 6.6 branch
  and mainline because of compile time warnings triggered in
  iq2000-tdep.c, (which are now being treated as errors).  The
  patch below fixes them by changing various void* variables into
  gdb_byte*.

  May I apply the patch please ? 

Cheers
  Nick Clifton

gdb/ChangeLog
2006-11-28  Nick Clifton  <nickc@redhat.com>

	* iq2000-tdep.c: Fix compile time warnings:
	(iq2000_pointer_to_address): Change type of buf	parameter to
	gdb_byte*.
	(iq2000_address_to_pointer): Likewise.
	(iq2000_frame_prev_register): Likewise.
	(iq2000_extract_return_value): Change type of return_buffer to
	gdb_byte.
	(iq2000_return_value): Change type of readbuf and writebuf to
	gdb_byte.

Index: gdb/iq2000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/iq2000-tdep.c,v
retrieving revision 1.2
diff -c -3 -p -r1.2 iq2000-tdep.c
*** gdb/iq2000-tdep.c	17 Dec 2005 22:34:01 -0000	1.2
--- gdb/iq2000-tdep.c	28 Nov 2006 16:08:04 -0000
*************** insn_addr_from_ptr (CORE_ADDR ptr)	/* ta
*** 88,94 ****
     Convert a target pointer to an address in host (CORE_ADDR) format. */
  
  static CORE_ADDR
! iq2000_pointer_to_address (struct type * type, const void * buf)
  {
    enum type_code target = TYPE_CODE (TYPE_TARGET_TYPE (type));
    CORE_ADDR addr = extract_unsigned_integer (buf, TYPE_LENGTH (type));
--- 88,94 ----
     Convert a target pointer to an address in host (CORE_ADDR) format. */
  
  static CORE_ADDR
! iq2000_pointer_to_address (struct type * type, const gdb_byte * buf)
  {
    enum type_code target = TYPE_CODE (TYPE_TARGET_TYPE (type));
    CORE_ADDR addr = extract_unsigned_integer (buf, TYPE_LENGTH (type));
*************** iq2000_pointer_to_address (struct type *
*** 105,111 ****
     Convert a host-format address (CORE_ADDR) into a target pointer.  */
  
  static void
! iq2000_address_to_pointer (struct type *type, void *buf, CORE_ADDR addr)
  {
    enum type_code target = TYPE_CODE (TYPE_TARGET_TYPE (type));
  
--- 105,111 ----
     Convert a host-format address (CORE_ADDR) into a target pointer.  */
  
  static void
! iq2000_address_to_pointer (struct type *type, gdb_byte *buf, CORE_ADDR addr)
  {
    enum type_code target = TYPE_CODE (TYPE_TARGET_TYPE (type));
  
*************** static void
*** 395,401 ****
  iq2000_frame_prev_register (struct frame_info *next_frame, void **this_cache,
  			    int regnum, int *optimizedp,
  			    enum lval_type *lvalp, CORE_ADDR *addrp,
! 			    int *realnump, void *valuep)
  {
    struct iq2000_frame_cache *cache = iq2000_frame_cache (next_frame, this_cache);
    if (regnum == E_SP_REGNUM && cache->saved_sp)
--- 395,401 ----
  iq2000_frame_prev_register (struct frame_info *next_frame, void **this_cache,
  			    int regnum, int *optimizedp,
  			    enum lval_type *lvalp, CORE_ADDR *addrp,
! 			    int *realnump, gdb_byte *valuep)
  {
    struct iq2000_frame_cache *cache = iq2000_frame_cache (next_frame, this_cache);
    if (regnum == E_SP_REGNUM && cache->saved_sp)
*************** 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))
*************** iq2000_extract_return_value (struct type
*** 592,598 ****
  static enum return_value_convention
  iq2000_return_value (struct gdbarch *gdbarch, struct type *type,
  		     struct regcache *regcache,
! 		     void *readbuf, const void *writebuf)
  {
    if (iq2000_use_struct_convention (type))
      return RETURN_VALUE_STRUCT_CONVENTION;
--- 592,598 ----
  static enum return_value_convention
  iq2000_return_value (struct gdbarch *gdbarch, struct type *type,
  		     struct regcache *regcache,
! 		     gdb_byte *readbuf, const gdb_byte *writebuf)
  {
    if (iq2000_use_struct_convention (type))
      return RETURN_VALUE_STRUCT_CONVENTION;


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: RFA: Fix compile time warnings building iq2000-tdep.c
  2006-11-28 16:41 RFA: Fix compile time warnings building iq2000-tdep.c Nick Clifton
@ 2006-11-28 16:56 ` Daniel Jacobowitz
  2006-11-28 17:12   ` Nick Clifton
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2006-11-28 16:56 UTC (permalink / raw)
  To: Nick Clifton; +Cc: gdb-patches, kevinb

On Tue, Nov 28, 2006 at 04:43:46PM +0000, Nick Clifton wrote:
> Hi Guys,
> 
>   The iq2000 port of GDB currently fails to build on the 6.6 branch
>   and mainline because of compile time warnings triggered in
>   iq2000-tdep.c, (which are now being treated as errors).  The
>   patch below fixes them by changing various void* variables into
>   gdb_byte*.
> 
>   May I apply the patch please ? 

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?

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: RFA: Fix compile time warnings building iq2000-tdep.c
  2006-11-28 16:56 ` Daniel Jacobowitz
@ 2006-11-28 17:12   ` Nick Clifton
  2006-11-28 17:17     ` Daniel Jacobowitz
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Clifton @ 2006-11-28 17:12 UTC (permalink / raw)
  To: Nick Clifton, gdb-patches, kevinb

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: RFA: Fix compile time warnings building iq2000-tdep.c
  2006-11-28 17:12   ` Nick Clifton
@ 2006-11-28 17:17     ` Daniel Jacobowitz
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2006-11-28 17:17 UTC (permalink / raw)
  To: Nick Clifton; +Cc: gdb-patches, kevinb

On Tue, Nov 28, 2006 at 05:02:59PM +0000, Nick Clifton wrote:
> +       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).

If your host and target have different endianness, this isn't going to
work so well.  And CORE_ADDR may be 32-bit or 64-bit.

I suspect that what you really want is extract_typed_address; and to
size the buffer according to a target pointer, not according to a
CORE_ADDR.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-11-28 17:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-28 16:41 RFA: Fix compile time warnings building iq2000-tdep.c Nick Clifton
2006-11-28 16:56 ` Daniel Jacobowitz
2006-11-28 17:12   ` Nick Clifton
2006-11-28 17:17     ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox