From patchwork Sun Jun 1 10:32:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Herman, Andrei" X-Patchwork-Id: 354588 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 5C493140092 for ; Sun, 1 Jun 2014 20:33:11 +1000 (EST) 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:cc:subject:content-type; q=dns; s=default; b=PyREtdyDveWheGUj7CdRVl2skyOQOIOAPNfZlEaKY1Y EsVryvkNtGVyQQmaUcfQ7j/Hvc3GBb82t7xVeqzOBa8QOid0mj0vYJMih57e6unu Fk3IbzI/nFWeRILsOhbrvvZU0IKzy0AOVfCBKIOQUI04ePuAboJABSpJ/Gc9huOg = 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:cc:subject:content-type; s=default; bh=kB3qWp0n91y7Srthfbdh48Hnf+Q=; b=xq/jY5wX6/QEI5MPu vPOTT1OB5PBtKeb47mMUl8iCiSuErACad47zcDEXbo6SJzc0qWDT6x7HQQiAGG7E aMaYLBRPElt5VHnr97YFH4ko2hjoRcISvmPrlY8x0yHAZDrlIlEy+mV3KeCIWzgA AZKkhob/isN4e6w72A7bagkIEo= Received: (qmail 31110 invoked by alias); 1 Jun 2014 10:33:03 -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 31046 invoked by uid 89); 1 Jun 2014 10:33:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 01 Jun 2014 10:32:57 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1Wr34O-0003OM-Kk from Andrei_Herman@mentor.com for gcc-patches@gcc.gnu.org; Sun, 01 Jun 2014 03:32:52 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Sun, 1 Jun 2014 03:32:52 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.2.247.3; Sun, 1 Jun 2014 11:32:50 +0100 Message-ID: <538B0151.5030404@codesourcery.com> Date: Sun, 1 Jun 2014 13:32:49 +0300 From: "Herman, Andrei" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Subject: [PATCH GCC]Add 'force-dwarf-lexical-blocks' command line option Hi, Currently GCC only emits DWARF debug information (DW_TAG_lexical_block DIEs) for compound statements containing significant local declarations. However, code coverage tools that process the DWARF debug information to implement block/path coverage need more complete lexical block information. This patch adds the necessary functionality under the control of a new command line argument: -fforce-dwarf-lexical-blocks. When this flag is set, a DW_TAG_lexical_block DIE will be emitted for every function body, loop body, switch body, case statement, if-then and if-else statement, even if the body is a single statement. Likewise, a lexical block will be emitted for the first label of a labeled statement. This block ends at the end of the current lexical scope, or when a break, continue, goto or return statement is encountered at the same lexical scope level. Consequently, any case in a switch statement that does not flow through to the next case, will have its own dwarf lexical block. The complete change proposal contains 3 patches (attached first 2): 1. Add command line option -fforce-dwarf-lexical-blocks 2. Use of flag_force_dwarf_blocks in C. Attached are the proposed ChangeLog additions, named according to the directory each one belongs to. A third patch, extending the proposed functionality to C++ will be submitted in a separate message. NOTE: This is a second submit, with changes made according to maintainer's sugestions. All check-c and check-c++ tests have been run for unix target. The only test that failed with the -fforce-dwarf-lexical-blocks set was: FAIL: gcc.dg/debug/dwarf2/inline2.c scan-assembler-times \\(DIE \\([^\n]*\\) DW_TAG_lexical_block 6 as expected. Best regards, Andrei Herman Mentor Graphics Corporation Israel branch From 6dd5796f04ca249e8e59026208e90e7619534a80 Mon Sep 17 00:00:00 2001 From: Andrei Herman Date: Sun, 1 Jun 2014 11:13:09 +0300 Subject: [PATCH 1/2] Add command line option -fforce-dwarf-lexical-blocks. * gcc/c-family/c.opt: Add -fforce-dwarf-lexical-blocks flag. * gcc/c-family/c-opts.c (c_common_post_options): Limit its use to dwarf4. * gcc/doc/invoke.texi: Document the new option. Signed-off-by: Andrei Herman --- gcc/c-family/c-opts.c | 13 +++++++++++++ gcc/c-family/c.opt | 4 ++++ gcc/doc/invoke.texi | 12 ++++++++++++ 3 files changed, 29 insertions(+), 0 deletions(-) diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 29e9a35..7c9dbfc 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -936,6 +936,19 @@ c_common_post_options (const char **pfilename) #endif } + /* The -fforce-dwarf-lexical-blocks option is only relevant when debug + info is in DWARF4 format */ + if (flag_force_dwarf_blocks) { + if (write_symbols != DWARF2_DEBUG) + flag_force_dwarf_blocks = 0; + if (write_symbols == DWARF2_DEBUG && dwarf_version < 4) { + inform (input_location, + "-fforce-dwarf-lexical-blocks is only supported with " + "DWARF4 debug format"); + flag_force_dwarf_blocks = 0; + } + } + if (flag_preprocess_only) { /* Open the output now. We must do so even if flag_no_output is diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index c586e65..b66389e 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -960,6 +960,10 @@ ffor-scope C++ ObjC++ Var(flag_new_for_scope) Init(1) Scope of for-init-statement variables is local to the loop +fforce-dwarf-lexical-blocks +C C++ Var(flag_force_dwarf_blocks) +Force generation of lexical blocks in dwarf output + ffreestanding C ObjC C++ ObjC++ Do not assume that standard C libraries and \"main\" exist diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 9475594..5bf154a 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -333,6 +333,7 @@ Objective-C and Objective-C++ Dialects}. -feliminate-unused-debug-symbols -femit-class-debug-always @gol -fenable-@var{kind}-@var{pass} @gol -fenable-@var{kind}-@var{pass}=@var{range-list} @gol +-fforce-dwarf-lexical-blocks @gol -fdebug-types-section -fmem-report-wpa @gol -fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report -fprofile-arcs @gol -fopt-info @gol @@ -5200,6 +5201,17 @@ normally emits debugging information for classes because using this option increases the size of debugging information by as much as a factor of two. +@item -fforce-dwarf-lexical-blocks +Produce debug information (a DW_TAG_lexical_block) for every function +body, loop body, switch body, case statement, if-then and if-else statement, +even if the body is a single statement. Likewise, a lexical block will be +emitted for the first label of a statement. This block ends at the end of the +current lexical scope, or when a break, continue, goto or return statement is +encountered at the same lexical scope level. This option is usefull for +coverage tools that utilize the dwarf debug information. +This option only applies to C/C++ code and is available when using DWARF +Version 4 or higher. + @item -fdebug-types-section @opindex fdebug-types-section @opindex fno-debug-types-section