From patchwork Fri Apr 10 18:25:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 460189 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1B9451401AF for ; Sat, 11 Apr 2015 04:25:26 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Qa62Wu8o; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=Ax1b+PkN19LOzqHoqTVjc+VAIv/xphCJZs959CWfIkB6Xa oVsEbfW2p3J9RcbZ4AaIAirnpajlYZNm9l0nDz7PnzkWF9PpEdLsDtB5sQiKkCaI RO5zp9s7AqyVAM8OlUoi6lcWnv2yHLsC676Z0ifbDjtXREV+zOFDRnOrN5RYY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=PSP+oY09ulVYuF1E5Lfz39VQHxg=; b=Qa62Wu8o/mtGbl6UPuIT H2F1SAKzEJ2HqhSHWEXmJs1gLV6zyCFavCgogl/nHnkyhmkIEusGybEeo3AcsMca kXWaNsG0zLk5aC/4HaftetdZA3y3ZgNEcUz7FAc1+hI82GB5AP34u7ZgGHY4aitc CBGz9KkkB2eOq0kD5T+B1pk= Received: (qmail 78592 invoked by alias); 10 Apr 2015 18:25:18 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 77042 invoked by uid 89); 10 Apr 2015 18:25:17 -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, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 10 Apr 2015 18:25:16 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id EBE958F303 for ; Fri, 10 Apr 2015 18:25:14 +0000 (UTC) Received: from reynosa.quesejoda.com (vpn-61-146.rdu2.redhat.com [10.10.61.146]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3AIPDDY030779 for ; Fri, 10 Apr 2015 14:25:14 -0400 Message-ID: <55281589.9010209@redhat.com> Date: Fri, 10 Apr 2015 11:25:13 -0700 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: gcc-patches Subject: [debug-early] handle objects containing variable-length members The attached patch handles late dwarf annotations to objects containing variable-length members. It fixes the following regressions in the gdb testsuite: > FAIL: gdb.base/vla-datatypes.exp: print vla_struct_object > FAIL: gdb.base/vla-datatypes.exp: print vla_union_object > FAIL: gdb.base/vla-datatypes.exp: ptype vla_struct_object > FAIL: gdb.base/vla-datatypes.exp: ptype vla_union_object > FAIL: gdb.base/vla-datatypes.exp: size of vla_struct_object > FAIL: gdb.base/vla-datatypes.exp: size of vla_union_object I am not convinced this is the last patch to variable-length variables, so it may require further refining, but it does get us down to ZERO gdb regressions which is A Good Thing (TM). The only differences I see for trunk and the debug-early branch wrt gdb regressions are: < KFAIL: gdb.cp/oranking.exp: p foo4(&a) (PRMS: gdb/12098) --- > KPASS: gdb.cp/oranking.exp: p foo4(&a) (PRMS gdb/12098) 20065c20065 < KFAIL: gdb.cp/oranking.exp: p foo101("abc") (PRMS: gdb/12098) --- > KPASS: gdb.cp/oranking.exp: p foo101("abc") (PRMS gdb/12098) 28222c28222 Plus some noise regarding threads. I don't know what KFAIL/KPASS are, having lived in GCC land too long, but I will take a look at those next. Committed to branch. Aldy commit b7cc4054654591a53e7dcc6a33f1ec35a3c5a7f9 Author: Aldy Hernandez Date: Fri Apr 10 11:16:46 2015 -0700 Handle late dwarf annotations to objects containing variable-length members. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 1928846..0976415 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -20470,6 +20470,16 @@ static void gen_struct_or_union_type_die (tree type, dw_die_ref context_die, enum debug_info_usage usage) { + /* Fill in the size of variable lengthed fields in late dwarf. */ + if (TREE_ASM_WRITTEN (type) + && !early_dwarf_dumping) + { + tree member; + for (member = TYPE_FIELDS (type); member; member = DECL_CHAIN (member)) + fill_variable_array_bounds (TREE_TYPE (member)); + return; + } + dw_die_ref type_die = lookup_type_die (type); dw_die_ref scope_die = 0; int nested = 0; @@ -20676,13 +20686,15 @@ gen_tagged_type_die (tree type, || !is_tagged_type (type)) return; + if (TREE_ASM_WRITTEN (type)) + need_pop = 0; /* If this is a nested type whose containing class hasn't been written out yet, writing it out will cover this one, too. This does not apply to instantiations of member class templates; they need to be added to the containing class as they are generated. FIXME: This hurts the idea of combining type decls from multiple TUs, since we can't predict what set of template instantiations we'll get. */ - if (TYPE_CONTEXT (type) + else if (TYPE_CONTEXT (type) && AGGREGATE_TYPE_P (TYPE_CONTEXT (type)) && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type))) { @@ -20810,11 +20822,14 @@ gen_type_die_with_usage (tree type, dw_die_ref context_die, if (TREE_ASM_WRITTEN (type)) { - /* Variabled-lengthed types may be incomplete even if + /* Variable-length types may be incomplete even if TREE_ASM_WRITTEN. For such types, fall through to gen_array_type_die() and possibly fill in DW_AT_{upper,lower}_bound attributes. */ - if (TREE_CODE (type) != ARRAY_TYPE + if ((TREE_CODE (type) != ARRAY_TYPE + && TREE_CODE (type) != RECORD_TYPE + && TREE_CODE (type) != UNION_TYPE + && TREE_CODE (type) != QUAL_UNION_TYPE) || (TYPE_SIZE (type) && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST)) return; @@ -20870,9 +20885,6 @@ gen_type_die_with_usage (tree type, dw_die_ref context_die, break; case ARRAY_TYPE: - gen_array_type_die (type, context_die); - break; - case VECTOR_TYPE: gen_array_type_die (type, context_die); break;