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] s390: if -> gdb_assert for tdesc_has_registers check


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

commit 650f5e137006fb7aea98e33d2ca9c6ac6712334c
Author: Philipp Rudo <prudo@linux.vnet.ibm.com>
Date:   Tue Jan 23 13:37:43 2018 +0100

    s390: if -> gdb_assert for tdesc_has_registers check
    
    Before doing the tdesc validation there is a check whether the tdesc has
    registers or not.  This check is not only unnecessary but wrong.
    
    First the check is done after a default tdesc is assigned if the original
    tdesc has no registers.  These default tdescs always have registers so the
    check alway returns true.
    
    Second if the default tdesc would not have registers the check only skips
    the tdesc validation instead of returning an error.  This would trigger a
    gdb_assert later on in tdesc_use_registers.
    
    gdb/ChangeLog:
    
    	* s390-linux-tdep.c (s390_gdbarch_init): Use gdb_assert for
    	tdesc_has_registers check

Diff:
---
 gdb/ChangeLog         |  5 +++++
 gdb/s390-linux-tdep.c | 14 ++++++--------
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 055b295..282ea37 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2018-01-23  Philipp Rudo  <prudo@linux.vnet.ibm.com>
 
+	* s390-linux-tdep.c (s390_gdbarch_init): Use gdb_assert for
+	tdesc_has_registers check
+
+2018-01-23  Philipp Rudo  <prudo@linux.vnet.ibm.com>
+
 	* s390-linux-tdep.c (s390_tdesc_valid): New function.
 	(s390_validate_reg_range): New macro.
 	(s390_gdbarch_init): Adjust.
diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c
index 054eb60..3869171 100644
--- a/gdb/s390-linux-tdep.c
+++ b/gdb/s390-linux-tdep.c
@@ -8045,15 +8045,13 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   tdep->tdesc = tdesc;
 
   /* Check any target description for validity.  */
-  if (tdesc_has_registers (tdesc))
+  gdb_assert (tdesc_has_registers (tdep->tdesc));
+  if (!s390_tdesc_valid (tdep, tdesc_data))
     {
-      if (!s390_tdesc_valid (tdep, tdesc_data))
-	{
-	  tdesc_data_cleanup (tdesc_data);
-	  xfree (tdep);
-	  gdbarch_free (gdbarch);
-	  return NULL;
-	}
+      tdesc_data_cleanup (tdesc_data);
+      xfree (tdep);
+      gdbarch_free (gdbarch);
+      return NULL;
     }
 
   /* Determine vector ABI.  */


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