Re: [PATCH] Fix compile warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

* Dave Anderson <anderson@xxxxxxxxxx> [2007-01-17 15:48]:
> 
> gdb-6.1.patch:
> 
>             else if (*augmentation == 'P')
>             {
>               /* Skip.  */
> -             buf += size_of_encoded_value (*buf++);
> +             buf += size_of_encoded_value (*buf);
>               augmentation++;
>             }
> 
> This patch makes me a litte nervous.  I see that gdb 6.5 does this:
> 
>           else if (*augmentation == 'P')
>             {
>               /* Skip.  Avoid indirection since we throw away the result.  */
>               gdb_byte encoding = (*buf++) & ~DW_EH_PE_indirect;
>               read_encoded_value (unit, encoding, buf, &bytes_read);
>               buf += bytes_read;
>               augmentation++;
>             }
> 
> Are they equivalent?

Of course not. :) After thinking a bit I think the correct fix would
be:

        buf += size_of_encoded_value(*buf);
        buf++;

Do you aggree?

Attached I have some more fixes for the GDB patch (so this is no patch
for crash but should be added to gdb-6.1.patch). I saw that there's
some internal memset() with different paramter order in GDB [1], but
that's not taken in the gdb/ subdirectory because if you compile the
whole GDB with -D_FORTIFY_SOURCE=2, you get a linker (and not
compiler) warning. And the linker should know about it.


Regards,
Bernhard

[1] libiberty/memset.c
Index: gdb-6.1/gdb/remote.c
===================================================================
--- gdb-6.1.orig/gdb/remote.c
+++ gdb-6.1/gdb/remote.c
@@ -3445,7 +3445,7 @@ remote_store_registers (int regnum)
   {
     int i;
     regs = alloca (rs->sizeof_g_packet);
-    memset (regs, rs->sizeof_g_packet, 0);
+    memset (regs, 0, rs->sizeof_g_packet);
     for (i = 0; i < NUM_REGS + NUM_PSEUDO_REGS; i++)
       {
 	struct packet_reg *r = &rs->regs[i];
Index: gdb-6.1/gdb/std-regs.c
===================================================================
--- gdb-6.1.orig/gdb/std-regs.c
+++ gdb-6.1/gdb/std-regs.c
@@ -61,7 +61,7 @@ value_of_builtin_frame_reg (struct frame
   val = allocate_value (builtin_type_frame_reg);
   VALUE_LVAL (val) = not_lval;
   buf = VALUE_CONTENTS_RAW (val);
-  memset (buf, TYPE_LENGTH (VALUE_TYPE (val)), 0);
+  memset (buf, 0, TYPE_LENGTH (VALUE_TYPE (val)));
   /* frame.base.  */
   if (frame != NULL)
     ADDRESS_TO_POINTER (builtin_type_void_data_ptr, buf,
@@ -87,7 +87,7 @@ value_of_builtin_frame_fp_reg (struct fr
       struct value *val = allocate_value (builtin_type_void_data_ptr);
       char *buf = VALUE_CONTENTS_RAW (val);
       if (frame == NULL)
-	memset (buf, TYPE_LENGTH (VALUE_TYPE (val)), 0);
+	memset (buf, 0, TYPE_LENGTH (VALUE_TYPE (val)));
       else
 	ADDRESS_TO_POINTER (builtin_type_void_data_ptr, buf,
 			    get_frame_base_address (frame));
@@ -105,7 +105,7 @@ value_of_builtin_frame_pc_reg (struct fr
       struct value *val = allocate_value (builtin_type_void_data_ptr);
       char *buf = VALUE_CONTENTS_RAW (val);
       if (frame == NULL)
-	memset (buf, TYPE_LENGTH (VALUE_TYPE (val)), 0);
+	memset (buf, 0, TYPE_LENGTH (VALUE_TYPE (val)));
       else
 	ADDRESS_TO_POINTER (builtin_type_void_data_ptr, buf,
 			    get_frame_pc (frame));

Attachment: pgpY2Wgc1xQX1.pgp
Description: PGP signature

--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility

[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux