public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Philipp Rudo <prudo@linux.vnet.ibm.com>
To: gdb-patches@sourceware.org
Cc: Andreas Arnez <arnez@linux.vnet.ibm.com>,
	       Ulrich Weigand <uweigand@de.ibm.com>,
	Yao Qi <qiyaoltc@gmail.com>
Subject: [PATCH v3 06/10] s390: if -> gdb_assert for tdesc_has_registers check
Date: Fri, 08 Dec 2017 11:05:00 -0000	[thread overview]
Message-ID: <20171208110436.30199-7-prudo@linux.vnet.ibm.com> (raw)
In-Reply-To: <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

  parent reply	other threads:[~2017-12-08 11:04 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-08 11:04 [PATCH v3 00/10] Split up s390-linux-tdep.c Philipp Rudo
2017-12-08 11:04 ` [PATCH v3 08/10] s390: gdbarch_tdep add hook for syscall record Philipp Rudo
2017-12-08 11:04 ` [PATCH v3 05/10] s390: Move tdesc validation to separate function Philipp Rudo
2017-12-08 11:04 ` [PATCH v3 01/10] s390: Remove duplicate checks for cached gdbarch at init Philipp Rudo
2017-12-08 11:04 ` [PATCH v3 03/10] s390: gdbarch_tdep.have_* int -> bool Philipp Rudo
2017-12-08 11:04 ` [PATCH v3 07/10] s390: Hook s390 into OSABI mechanism Philipp Rudo
2017-12-13 18:42   ` Ulrich Weigand
2017-12-14 12:08     ` Philipp Rudo
2017-12-14 15:45       ` Ulrich Weigand
2017-12-15 16:19         ` Philipp Rudo
2017-12-08 11:05 ` [PATCH v3 10/10] s390: Clean up s390-linux-tdep.c Philipp Rudo
2017-12-08 11:05 ` [PATCH v3 02/10] s390: Allocate gdbarch & tdep at start of gdbarch init Philipp Rudo
2017-12-08 11:05 ` [PATCH v3 04/10] s390: gdbarch_tdep add field tdesc Philipp Rudo
2017-12-08 11:05 ` Philipp Rudo [this message]
2017-12-08 11:56 ` [PATCH v3 09/10] s390: Split up s390-linux-tdep.c into two files Philipp Rudo
2017-12-08 11:56   ` [PATCH v3 09/10 b] " Philipp Rudo
2017-12-08 11:56   ` [PATCH v3 09/10 a] " Philipp Rudo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171208110436.30199-7-prudo@linux.vnet.ibm.com \
    --to=prudo@linux.vnet.ibm.com \
    --cc=arnez@linux.vnet.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=qiyaoltc@gmail.com \
    --cc=uweigand@de.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).