From patchwork Fri Feb 28 17:20:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Neyman X-Patchwork-Id: 1246710 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-520335-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=att.net Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=sqSCtyKO; dkim=pass (1024-bit key; unprotected) header.d=att.net header.i=@att.net header.a=rsa-sha256 header.s=s1024 header.b=i7G06wIT; dkim-atps=neutral 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 48Tbs96N2Qz9sQt for ; Sat, 29 Feb 2020 04:20:28 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=p4ielswldkYF8Kq3x uE4P54y1ExNaGTbLROcT1xTnP5RDTa3b9IO9SeE7JKeAtgEIOBUAyzG9osPUtqm5 8YwkItWtMR4W17wDN46avDhXpJAy+gAjq2dGlGqmg/ElqCEVtFCc+ea234oUck1s j9BZv94KkkaMChtQ9X7Ir5ZMnw= 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 :subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=Q+BZZF8jUWCG1+gULu/S+45 SGU0=; b=sqSCtyKOYTa+XU3WJl0ghySizvNAu4akXxmEZq6IYT9BJzwjqQjmHBN 4uwSc6BJ/oWZkZSUUGYusZTdFMy43qW5keD+DMkjYisvjTfLny5lxHkp2tnSmynE ovwm9MV75q7g9RzufAeEiP054c7Sb7bzO6jT/+atJ3QoKFGqw68g= Received: (qmail 76457 invoked by alias); 28 Feb 2020 17:20:20 -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 76445 invoked by uid 89); 28 Feb 2020 17:20:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=H*RU:sk:sonic30, HX-Spam-Relays-External:sk:sonic30, H*r:sk:sonic30, H*r:sk:sonic.g X-HELO: sonic309-24.consmr.mail.ne1.yahoo.com Received: from sonic309-24.consmr.mail.ne1.yahoo.com (HELO sonic309-24.consmr.mail.ne1.yahoo.com) (66.163.184.150) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 28 Feb 2020 17:20:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=att.net; s=s1024; t=1582910416; bh=AvFCaQnU9Oi2bt6whQhVq0FdDbHrqt+plPedJIwAu/E=; h=Subject:To:References:From:Date:In-Reply-To:From:Subject; b=i7G06wITsvZ0Oq8NGzGTkZ9CGQv1p57WKbj49HJb1G3B0y8ijYZJabQHJSCHSKbqPCjXPvlNLKbn2LK6tGhABo7+EwAyMG6ZP6969c9UTn8lj09vFWpHIuyDsEQURYzLRVhtJDOvcCtjxaiWaM/XGvB9irndHPOu44B931K4PEo= Received: from sonic.gate.mail.ne1.yahoo.com by sonic309.consmr.mail.ne1.yahoo.com with HTTP; Fri, 28 Feb 2020 17:20:16 +0000 Received: by smtp431.mail.gq1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 561e9290c1b1f19d5deb18115d3a9d10; Fri, 28 Feb 2020 17:20:14 +0000 (UTC) Subject: [PATCH v3] debug/93751 Option to generate DIEs for external variables - ping To: Richard Biener , gcc-patches@gcc.gnu.org, Alexander Monakov , Jason Merrill References: <94e5ba1e-bf3c-c238-1019-58178542a8d0@redhat.com> <7E07E811-19FF-4635-8772-F826D04B3BE7@gmail.com> From: Alexey Neyman Message-ID: <03029d14-d76a-8bf7-0f07-56ba5dab6330@att.net> Date: Fri, 28 Feb 2020 09:20:09 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <7E07E811-19FF-4635-8772-F826D04B3BE7@gmail.com> On 2/26/20 11:40 AM, Richard Biener wrote: > On February 26, 2020 8:26:06 PM GMT+01:00, Alexander Monakov wrote: >> On Wed, 26 Feb 2020, Jason Merrill wrote: >> >>> Don't we want to fix the DWARF behavior to match the documentation? >> +1 - I think Alexey correctly pointed out in the Bugzilla that >> debuginfo >> growth from this change would be minimal (usually the number of global >> variables is very small compared to number of functions (and linemap >> info). > +1 from me as well > > Richard. Attached is a revised patch that enables DIE generation for external variables at -g1 without an additional option. Regards, Alexey. From eba778fd7c2489e2966c55bb8c11bdc48480fc52 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Thu, 13 Feb 2020 22:01:10 -0800 Subject: [PATCH] debug/93751 DWARF DIEs for external vars with -g1 -g1 is described in the manual to generate debug info for functions and external variables. It does that for older debugging formats but not for DWARF. This change brings DWARF in line with the rest of the debugging formats and with the manual. 2020-02-14 Alexey Neyman PR debug/93751 * dwarf2out.c (gen_decl_die): Proceed to generating the DIE if the debug level is terse and the declaration is public. (dwarf2out_decl): Same. * gcc/testsuite/gcc.dg/debug/dwarf2/pr93751-1: New test. * gcc/testsuite/gcc.dg/debug/dwarf2/pr93751-2: New test. * gcc/testsuite/gcc.dg/debug/dwarf2/pr93751-3: New test. Signed-off-by: Alexey Neyman --- gcc/dwarf2out.c | 12 ++++++++---- gcc/testsuite/gcc.dg/debug/dwarf2/pr93751-1.c | 6 ++++++ gcc/testsuite/gcc.dg/debug/dwarf2/pr93751-2.c | 6 ++++++ 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/pr93751-1.c create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/pr93751-2.c diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index fe46c7e1eee..4d9bfe3a68b 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -26354,8 +26354,10 @@ gen_decl_die (tree decl, tree origin, struct vlr_context *ctx, case VAR_DECL: case RESULT_DECL: /* If we are in terse mode, don't generate any DIEs to represent any - variable declarations or definitions. */ - if (debug_info_level <= DINFO_LEVEL_TERSE) + variable declarations or definitions unless it is external. */ + if (debug_info_level < DINFO_LEVEL_TERSE + || (debug_info_level == DINFO_LEVEL_TERSE + && !TREE_PUBLIC(decl_or_origin))) break; /* Avoid generating stray type DIEs during late dwarf dumping. @@ -26831,8 +26833,10 @@ dwarf2out_decl (tree decl) context_die = lookup_decl_die (DECL_CONTEXT (decl)); /* If we are in terse mode, don't generate any DIEs to represent any - variable declarations or definitions. */ - if (debug_info_level <= DINFO_LEVEL_TERSE) + variable declarations or definitions unless it is external. */ + if (debug_info_level < DINFO_LEVEL_TERSE + || (debug_info_level == DINFO_LEVEL_TERSE + && !TREE_PUBLIC(decl))) return; break; diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr93751-1.c b/gcc/testsuite/gcc.dg/debug/dwarf2/pr93751-1.c new file mode 100644 index 00000000000..4be170c57d6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/pr93751-1.c @@ -0,0 +1,6 @@ +// { dg-do compile } +// { dg-options "-O -gdwarf-2 -g1 -dA" } +static int bar; + +// Verify that with -g1 we still do not generate DIEs for static variables. +// { dg-final { scan-assembler-not " DW_TAG_variable" } } diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr93751-2.c b/gcc/testsuite/gcc.dg/debug/dwarf2/pr93751-2.c new file mode 100644 index 00000000000..3ee369bd99e --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/pr93751-2.c @@ -0,0 +1,6 @@ +// { dg-do compile } +// { dg-options "-O -gdwarf-2 -g1 -dA" } +int foo; + +// Verify that with -g1 we generate DIEs for external variables. +// { dg-final { scan-assembler " DW_TAG_variable" } } -- 2.20.1