From patchwork Thu Mar 26 15:51:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 455093 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 D04CC14009B for ; Fri, 27 Mar 2015 02:52:08 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=GyL17X0H; 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=Q6XS8/46P5O2EXavcKN8rtNRrqwZ6eCxH74Wu/aBM1qnUC PZwARp81ZAc+733Z/zNvcdnZmKMc4RLkSlAmMQ7+zWn6Y3Hw4G9bZNs01+76CA4P k3/UQl4463BqYCDeBie/DqJp5HTveFHofsgeHrsSl7JyHMH4VDe4Mxe7RQZrA= 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=dwCRsjuK1WYwhPXeWNC6S1Ky0bs=; b=GyL17X0H9CXdh4n6Y6AU yBrHtL/wCCalaNe2A7OXNDXkGY2/rH4MTYtKWOa1vzvYm2wsM2vjufLX79U7BwGH aTZtZVXQlFechF6W3hPrgcSbEudm6mV0bYx+d/w5Gxg4fJKs/r9GHvWVszPzciGi aEOfH42OeoY8/rx6RUY/dm4= Received: (qmail 89265 invoked by alias); 26 Mar 2015 15:52:01 -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 88159 invoked by uid 89); 26 Mar 2015 15:52:00 -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; Thu, 26 Mar 2015 15:51:59 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 896D8C1F19 for ; Thu, 26 Mar 2015 15:51:58 +0000 (UTC) Received: from reynosa.quesejoda.com (vpn-57-62.rdu2.redhat.com [10.10.57.62]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2QFpvOD023100 for ; Thu, 26 Mar 2015 11:51:57 -0400 Message-ID: <55142B1C.4030101@redhat.com> Date: Thu, 26 Mar 2015 08:51:56 -0700 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: gcc-patches Subject: [debug-early] Fill in array bounds for variable-length typedefs The following GDB test is failing because typedef's are being marked as completed after their type DIEs are generated in early debug: FAIL: gdb.base/vla-ptr.exp: print td_vla We need to revisit the partially created DIE in late debug and fill in the bound information when available. We were already doing this for variable-length arrays, but not for the variable-length arrays within a typedef. Fixed thus. Committed to mainline. One more gdb regression down. Oh yeah, I also abstracted some of the common code out. Aldy commit 826cf908f550484c0b3d972668a0a98fcf6c659b Author: Aldy Hernandez Date: Thu Mar 26 08:47:34 2015 -0700 Fill in array bounds for variable-length typedefs. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 4bc945f..1928846 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -17623,6 +17623,26 @@ decl_start_label (tree decl) } #endif +/* For variable-length arrays that have been previously generated, but + may be incomplete due to missing subscript info, fill the subscript + info. Return TRUE if this is one of those cases. */ +static bool +fill_variable_array_bounds (tree type) +{ + if (TREE_ASM_WRITTEN (type) + && TREE_CODE (type) == ARRAY_TYPE + && TYPE_SIZE (type) + && TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST) + { + dw_die_ref array_die = lookup_type_die (type); + if (!array_die) + return false; + add_subscript_info (array_die, type, !is_ada ()); + return true; + } + return false; +} + /* These routines generate the internal representation of the DIE's for the compilation unit. Debugging information is collected by walking the declaration trees passed in from dwarf2out_decl(). */ @@ -17644,22 +17664,8 @@ gen_array_type_die (tree type, dw_die_ref context_die) bool collapse_nested_arrays = !is_ada (); - /* For variable-length arrays that have been previously generated, - just fill in the possibly missing subscript info. */ - if (TREE_ASM_WRITTEN (type) - && TREE_CODE (type) == ARRAY_TYPE - && TYPE_SIZE (type) - && TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST) - { - array_die = lookup_type_die (type); - gcc_assert (array_die); - /* We could avoid calling add_subscript_info if - DW_AT_{upper,lower}_bound is already present, though it's - probably not worth it since we'll have to recurse through the - DW_TAG_subrange_type anyhow. */ - add_subscript_info (array_die, type, collapse_nested_arrays); - return; - } + if (fill_variable_array_bounds (type)) + return; dw_die_ref scope_die = scope_die_for (type, context_die); tree element_type; @@ -20583,7 +20589,11 @@ gen_typedef_die (tree decl, dw_die_ref context_die) tree origin; if (TREE_ASM_WRITTEN (decl)) - return; + { + if (DECL_ORIGINAL_TYPE (decl)) + fill_variable_array_bounds (DECL_ORIGINAL_TYPE (decl)); + return; + } TREE_ASM_WRITTEN (decl) = 1; type_die = new_die (DW_TAG_typedef, context_die, decl);