From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15040 invoked by alias); 13 Dec 2014 14:23:54 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 15029 invoked by uid 89); 13 Dec 2014 14:23:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Sat, 13 Dec 2014 14:23:52 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id B60C9116476; Sat, 13 Dec 2014 09:23:50 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id eEim+34OPnEu; Sat, 13 Dec 2014 09:23:50 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id A65FF116474; Sat, 13 Dec 2014 09:23:50 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 6FF8240164; Sat, 13 Dec 2014 09:23:51 -0500 (EST) Date: Sat, 13 Dec 2014 14:23:00 -0000 From: Joel Brobecker To: Jan Kratochvil Cc: gdb-patches@sourceware.org Subject: Re: [patch+7.8] Fix 7.8 regression: resolve_dynamic_struct: Assertion `TYPE_NFIELDS (type) > 0' (PR 17642) Message-ID: <20141213142351.GG5457@adacore.com> References: <20141125195444.GA3400@host2.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20141125195444.GA3400@host2.jankratochvil.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2014-12/txt/msg00311.txt.bz2 > It is another missing check_typedef(). > gdb/ > 2014-11-25 Jan Kratochvil > > Fix internal error on stubs of dynamic types. > * gdbtypes.c (resolve_dynamic_type_internal): Apply check_typedef to > TYPE if not TYPE_CODE_TYPEDEF. > > gdb/testsuite/ > 2014-11-25 Jan Kratochvil > > Fix internal error on stubs of dynamic types. > * gdb.base/vla-stub-define.c: New file. > * gdb.base/vla-stub.c: New file. > * gdb.base/vla-stub.exp: New file. Pre-approved with the following comments. Ok for 7.8 as well, although the chances of a 7.8.2 are getting slimmer, and you'll need also to create a PR. > diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c > index 61d259d..aa76604 100644 > --- a/gdb/gdbtypes.c > +++ b/gdb/gdbtypes.c > @@ -1875,41 +1875,48 @@ resolve_dynamic_type_internal (struct type *type, CORE_ADDR addr, > if (!is_dynamic_type_internal (real_type, top_level)) > return type; > > - switch (TYPE_CODE (type)) > + if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF) > { > - case TYPE_CODE_TYPEDEF: > resolved_type = copy_type (type); > TYPE_TARGET_TYPE (resolved_type) > = resolve_dynamic_type_internal (TYPE_TARGET_TYPE (type), addr, > top_level); > - break; > + } > + else Trailing space here... > + { > + /* Typedefs do not need to be preserved here but we need > + to resolve any possible stub types. */ > + type = real_type; It took me a moment, despite your added comment, to understand that it was not so much about TYPE_CODE_TYPEDEF but about stubs! I keep forgetting that check_typedef does more than unwrapping typedef layers. We know that type isn't a typedef here, so mentioning typedefs is a bit confusing, IMO. How about we adjust the comment to say, for instance: /* Before trying to resolve TYPE, make sure it is not a stub. */ This is only a suggestion, and it's subjective, so feel free to ignore. Thank you, -- Joel