This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH v3 06/10] s390: if -> gdb_assert for tdesc_has_registers check
- From: Philipp Rudo <prudo at linux dot vnet dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Cc: Andreas Arnez <arnez at linux dot vnet dot ibm dot com>, Ulrich Weigand <uweigand at de dot ibm dot com>, Yao Qi <qiyaoltc at gmail dot com>
- Date: Fri, 8 Dec 2017 12:04:32 +0100
- Subject: [PATCH v3 06/10] s390: if -> gdb_assert for tdesc_has_registers check
- Authentication-results: sourceware.org; auth=none
- References: <20171208110436.30199-1-prudo@linux.vnet.ibm.com>
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
---
gdb/s390-linux-tdep.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c
index f0bdc72301..bae3b52808 100644
--- a/gdb/s390-linux-tdep.c
+++ b/gdb/s390-linux-tdep.c
@@ -8047,15 +8047,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. */
--
2.13.5