From patchwork Sat Feb 11 15:24:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxim Akhmedov X-Patchwork-Id: 19228 Received: (qmail 5908 invoked by alias); 11 Feb 2017 15:24:37 -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 4703 invoked by uid 89); 11 Feb 2017 15:24:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.8 required=5.0 tests=BAYES_50, SPF_PASS autolearn=ham version=3.3.2 spammy=iterating, H*x:yandex.ru, H*UA:yandex.ru, H*x:Yamail X-HELO: forwardcorp1o.cmail.yandex.net Received: from forwardcorp1o.cmail.yandex.net (HELO forwardcorp1o.cmail.yandex.net) (37.9.109.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 11 Feb 2017 15:24:04 +0000 Received: from mxbackcorp1o.mail.yandex.net (mxbackcorp1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::301]) by forwardcorp1o.cmail.yandex.net (Yandex) with ESMTP id 4AF2120BFB for ; Sat, 11 Feb 2017 18:24:01 +0300 (MSK) Received: from webcorp03f.yandex-team.ru (webcorp03f.yandex-team.ru [77.88.31.71]) by mxbackcorp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id hIMSq87swb-O0QuFa5q; Sat, 11 Feb 2017 18:24:01 +0300 Authentication-Results: mxbackcorp1o.mail.yandex.net; dkim=pass header.i=@yandex-team.com X-Yandex-Sender-Uid: 1120000000036182 Received: by webcorp03f.yandex-team.ru with HTTP; Sat, 11 Feb 2017 18:24:00 +0300 From: Maxim Akhmedov Envelope-From: max42@yandex-team.ru To: gdb-patches@sourceware.org Subject: [PATCH 2/2] Do not put {NULL, NULL} entries in a worklist when checking types for equality. MIME-Version: 1.0 Message-Id: <154181486826640@webcorp03f.yandex-team.ru> Date: Sat, 11 Feb 2017 18:24:00 +0300 If type1 and type2 are enumeration types, their fields (corresponding to the enum members) have their types set to NULL. I'm not sure whether this is a mistake of reading the DWARF2 information, or if this is an intended behavior, but the shortest way to fix that is to ensure that we do not put pairs consisting of NULLs into a worklist in the check_types_equal procedure when iterating over all fields. gdb/ChangeLog: 2017-02-11 Maxim Akhmedov * gdbtypes.c: do not put {NULL, NULL} entries in a worklist in check_types_equal. --- gdb/gdbtypes.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) --  2.11.0 diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 5e5db2776b..62bc3d752b 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -3364,6 +3364,8 @@ static int check_types_equal (struct type *type1, struct type *type2, VEC (type_equality_entry_d) **worklist) { + gdb_assert (type1 != NULL && type2 != NULL); + type1 = check_typedef (type1); type2 = check_typedef (type2); @@ -3448,9 +3450,17 @@ check_types_equal (struct type *type1, struct type *type2, FIELD_LOC_KIND (*field1)); } - entry.type1 = FIELD_TYPE (*field1); - entry.type2 = FIELD_TYPE (*field2); - VEC_safe_push (type_equality_entry_d, *worklist, &entry); + /* For some types fields may not have their own type specifications + like enum fields in C++. */ + if (FIELD_TYPE (*field1) != NULL && FIELD_TYPE (*field2) != NULL) + { + entry.type1 = FIELD_TYPE (*field1); + entry.type2 = FIELD_TYPE (*field2); + + VEC_safe_push (type_equality_entry_d, *worklist, &entry); + } + else if (FIELD_TYPE (*field1) != NULL || FIELD_TYPE (*field2) != NULL) + return 0; } }