This is the mail archive of the gdb-cvs@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]

[binutils-gdb] Fix build breakage on GNU/Linux AArch64, take 2


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a059f00c857d088a7fe55d2dbded9d3210af4989

commit a059f00c857d088a7fe55d2dbded9d3210af4989
Author: Sergio Durigan Junior <sergiodj@redhat.com>
Date:   Sun Sep 10 17:50:29 2017 -0400

    Fix build breakage on GNU/Linux AArch64, take 2
    
    The last commit unfortunately was not enough to fix the build breakage
    on AArch64.  I made a mistake and did not test it alone on BuildBot,
    but along with another patch that was responsible for fixing the
    breakage.
    
    The failure is:
    
      In file included from /usr/include/string.h:640:0,
    		   from build-gnulib-gdbserver/import/string.h:41,
    		   from ../../../binutils-gdb/gdb/gdbserver/../common/common-defs.h:56,
    		   from ../../../binutils-gdb/gdb/gdbserver/server.h:22,
    		   from ../../../binutils-gdb/gdb/gdbserver/regcache.c:19:
      In function â??void* memset(void*, int, size_t)â??,
          inlined from â??regcache* init_register_cache(regcache*, const target_desc*, unsigned char*)â?? at ../../../binutils-gdb/gdb/gdbserver/regcache.c:150:50:
      /usr/include/aarch64-linux-gnu/bits/string3.h:81:32: error: call to â??__warn_memset_zero_lenâ?? declared with attribute warning: memset used with constant zero length parameter; this could be due to transposed parameters [-Werror]
    	 __warn_memset_zero_len ();
    				  ^
      In function â??void* memset(void*, int, size_t)â??,
          inlined from â??regcache* get_thread_regcache(thread_info*, int)â?? at ../../../binutils-gdb/gdb/gdbserver/regcache.c:57:60:
      /usr/include/aarch64-linux-gnu/bits/string3.h:81:32: error: call to â??__warn_memset_zero_lenâ?? declared with attribute warning: memset used with constant zero length parameter; this could be due to transposed parameters [-Werror]
    	 __warn_memset_zero_len ();
    
    This is likely due to a GCC bug, because for some reason the compiler
    assumes that the third argument to the memset:
    
      memset (regcache->register_status, REG_UNAVAILABLE,
    	  VEC_length (tdesc_reg_p, regcache->tdesc->reg_defs));
    
    is always zero, which is not always true.
    
    Anyway, the simple fix for this is to guard the memset calls with:
    
      if (!VEC_empty (tdesc_reg_p, regcache->tdesc->reg_defs))
    
    This time, I made sure to regtest only this patch on BuildBot, and it
    finally solved the breakage.
    
    gdb/gdbserver/ChangeLog:
    2017-09-10  Sergio Durigan Junior  <sergiodj@redhat.com>
    
    	* regcache.c (get_thread_regcache): Guard calls to "memset"
              with "!VEC_empty".

Diff:
---
 gdb/gdbserver/ChangeLog  |  5 +++++
 gdb/gdbserver/regcache.c | 10 ++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 345abb3..d9f80c9 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,10 @@
 2017-09-10  Sergio Durigan Junior  <sergiodj@redhat.com>
 
+	* regcache.c (get_thread_regcache): Guard calls to "memset"
+          with "!VEC_empty".
+
+2017-09-10  Sergio Durigan Junior  <sergiodj@redhat.com>
+
 	* linux-low.c (handle_extended_wait): Use
 	"allocate_target_description" instead of "XNEW".
 	* linux-x86-low.c (initialize_low_arch): Likewise.
diff --git a/gdb/gdbserver/regcache.c b/gdb/gdbserver/regcache.c
index 43e78a5..d1a534c 100644
--- a/gdb/gdbserver/regcache.c
+++ b/gdb/gdbserver/regcache.c
@@ -53,8 +53,9 @@ get_thread_regcache (struct thread_info *thread, int fetch)
 
       current_thread = thread;
       /* Invalidate all registers, to prevent stale left-overs.  */
-      memset (regcache->register_status, REG_UNAVAILABLE,
-	      VEC_length (tdesc_reg_p, regcache->tdesc->reg_defs));
+      if (!VEC_empty (tdesc_reg_p, regcache->tdesc->reg_defs))
+	memset (regcache->register_status, REG_UNAVAILABLE,
+		VEC_length (tdesc_reg_p, regcache->tdesc->reg_defs));
       fetch_inferior_registers (regcache, -1);
       current_thread = saved_thread;
       regcache->registers_valid = 1;
@@ -146,8 +147,9 @@ init_register_cache (struct regcache *regcache,
       regcache->registers_owned = 1;
       regcache->register_status
 	= (unsigned char *) xmalloc (VEC_length (tdesc_reg_p, tdesc->reg_defs));
-      memset ((void *) regcache->register_status, REG_UNAVAILABLE,
-	      VEC_length (tdesc_reg_p, tdesc->reg_defs));
+      if (!VEC_empty (tdesc_reg_p, tdesc->reg_defs))
+	memset ((void *) regcache->register_status, REG_UNAVAILABLE,
+		VEC_length (tdesc_reg_p, tdesc->reg_defs));
 #else
       gdb_assert_not_reached ("can't allocate memory from the heap");
 #endif


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