From patchwork Sat Feb 15 00:36:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexey Neyman X-Patchwork-Id: 1238446 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-519579-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=d8t8cmZp; dkim=pass (1024-bit key; unprotected) header.d=att.net header.i=@att.net header.a=rsa-sha256 header.s=s1024 header.b=6PtOEBzO; 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 48KBCW2jgmz9sRG for ; Sat, 15 Feb 2020 11:37:09 +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:to :from:subject:message-id:date:mime-version:content-type :references; q=dns; s=default; b=dpgZ0VNEcHK6WtvA4Pkuh31f1+I5bpo Ce6p6LUBdA4eCDyXpeJRf3bKIWJi6dVfx8p8IJ2Q3hSJP4b+xXGT7kT6OHjftl5N B2p/saOpdnET2VvrX4y264+rAYL9amlOloqIteTKft9MaEfwG9+tTl4dVjiE1DjQ /CX0zkBCuuNU= 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:to :from:subject:message-id:date:mime-version:content-type :references; s=default; bh=7ev/C9A73FRbZeKymfRZSdSqgLc=; b=d8t8c mZp+JP6cWzeY5eBDrXkNmfHlS7BV2AHZxjpNjeRdduxcd6u1Va90/8VAHPS5gG6s 35OYUE73u6xNDJXmNRhkrUbDU1k7r0Dk4CFsxFp/wqqwA9uyOTvBbWyJWN+ibKc/ HDotXA9NkZM2M9I9HfusAKtkPyI+eDS2PLnBjE= Received: (qmail 101845 invoked by alias); 15 Feb 2020 00:37: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 101780 invoked by uid 89); 15 Feb 2020 00:36:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=Proceed X-HELO: sonic308-13.consmr.mail.ne1.yahoo.com Received: from sonic308-13.consmr.mail.ne1.yahoo.com (HELO sonic308-13.consmr.mail.ne1.yahoo.com) (66.163.187.36) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 15 Feb 2020 00:36:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=att.net; s=s1024; t=1581727010; bh=p8iovcOCD0SsC8p8POOqtfXZalPN6VDtIFVzLlvDOVQ=; h=To:From:Subject:Date:References:From:Subject; b=6PtOEBzOBIMMc1hTrWrINHM77RzFlPOH3kgWz190FVHtqpaYoZKXSLAo8tj2wRAbiloXeX9wEw6y7BJ363N9kQwHc5stKhf0vU96S8t9EP5hVRIGjIRYg2m5zZJRogMVxaMmwaXl/Hh7PtyT5BzAX/DqJDBl+ShwAiPh/TDA1NU= Received: from sonic.gate.mail.ne1.yahoo.com by sonic308.consmr.mail.ne1.yahoo.com with HTTP; Sat, 15 Feb 2020 00:36:50 +0000 Received: by smtp404.mail.ne1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 99536687194c03c663105eee9fdfd981; Sat, 15 Feb 2020 00:36:47 +0000 (UTC) To: gcc-patches@gcc.gnu.org From: Alexey Neyman Subject: [PATCH] debug/93751 Generate DIEs for external variables with -g1 Message-ID: Date: Fri, 14 Feb 2020 16:36:45 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 References: Hi all, As reported here, https://gcc.gnu.org/ml/gcc-help/2020-02/msg00062.html, GCC does not behave according to manual when `-gdwarf -g1` options are used; it does not generate the debugging information for external variables even though it is supposed to (and it does so for other debugging formats): aneyman@supox:/tmp$ cat foo.c int foo __attribute__((externally_visible)); aneyman@supox:/tmp$ gcc -c -O2 -gdwarf -g1 foo.c aneyman@supox:/tmp$ readelf -wi foo.o aneyman@supox:/tmp$ gcc -c -O2 -gdwarf -g2 foo.c aneyman@supox:/tmp$ readelf -wi foo.o ... <1><1d>: Abbrev Number: 2 (DW_TAG_variable)     <1e>   DW_AT_name        : foo The attached patch fixes this issue. Regards, Alexey. From a4cdccf633c83746481daac5da088b07843c6c38 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Thu, 13 Feb 2020 22:01:10 -0800 Subject: [PATCH] debug/93751 Create 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 aligns the behavior of `-gdwarf -g1` with the description in 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. Signed-off-by: Alexey Neyman --- gcc/dwarf2out.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index fe46c7e1eee..5f9e82a8da2 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 except for public ones. */ + 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 except public ones. */ + if (debug_info_level < DINFO_LEVEL_TERSE + || (debug_info_level == DINFO_LEVEL_TERSE + && !TREE_PUBLIC(decl))) return; break; -- 2.20.1