From patchwork Tue Jan 9 12:01:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Rudo X-Patchwork-Id: 25289 Received: (qmail 61224 invoked by alias); 9 Jan 2018 12:02:01 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 61120 invoked by uid 89); 9 Jan 2018 12:02:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=alway X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 09 Jan 2018 12:01:59 +0000 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w09BxXq0140219 for ; Tue, 9 Jan 2018 07:01:57 -0500 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0b-001b2d01.pphosted.com with ESMTP id 2fcuy54n8t-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 09 Jan 2018 07:01:57 -0500 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 9 Jan 2018 12:01:55 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 9 Jan 2018 12:01:53 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w09C1qFf41877506; Tue, 9 Jan 2018 12:01:52 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B457FAE064; Tue, 9 Jan 2018 11:53:53 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 895F7AE059; Tue, 9 Jan 2018 11:53:53 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 9 Jan 2018 11:53:53 +0000 (GMT) From: Philipp Rudo To: gdb-patches@sourceware.org Cc: Andreas Arnez , Ulrich Weigand , Yao Qi Subject: [PATCH v4 06/11] s390: if -> gdb_assert for tdesc_has_registers check Date: Tue, 9 Jan 2018 13:01:39 +0100 In-Reply-To: <20180109120144.93854-1-prudo@linux.vnet.ibm.com> References: <20180109120144.93854-1-prudo@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18010912-0040-0000-0000-000004029A60 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18010912-0041-0000-0000-00002605EF86 Message-Id: <20180109120144.93854-7-prudo@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-09_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1801090169 X-IsSubscribed: yes 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 b70688b7ff..a4f64a37e9 100644 --- a/gdb/s390-linux-tdep.c +++ b/gdb/s390-linux-tdep.c @@ -8046,15 +8046,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. */