From patchwork Thu Feb 7 06:34:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cary Coutant X-Patchwork-Id: 218825 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]) by ozlabs.org (Postfix) with SMTP id 5C51A2C02A7 for ; Thu, 7 Feb 2013 17:35:13 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1360823714; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Date:Message-ID:Subject:From:To: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=grpH9t1 AjAbEn/7znQZj29ow8lM=; b=D9kQDHDPqo07bjGevkEmbNeR8sg3PENxYDFLvw8 tsPeG56PADgkFvSMRwtbziaEb50YT7EX3fvy1R7FOcBOkoM3nSUSf/+nHittQ0oZ G59qOjMX81HhRgLCMtO4gI6s15tauE4jYAOacuLMxPUyy5czJDTemx3t74rXVpFl xF+M= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:MIME-Version:X-Received:Received:Date:Message-ID:Subject:From:To:Content-Type:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=boScfpCM5TWesRdFTfjFqxxnSrzyHJXio98btJt3f3CivAWu839jPRTR6xtxM1 Nt1KA3FHwHsI/uzKJqRQzoj/TfhkPr9UmDpphHHF0xP7mzdgN7UDnkKNHwCAfTK+ wzpv0BZCSMcitYGlhKmRq/IGxGT3z6qo2pWKNzsUxxB8g=; Received: (qmail 14986 invoked by alias); 7 Feb 2013 06:35:03 -0000 Received: (qmail 14790 invoked by uid 22791); 7 Feb 2013 06:35:02 -0000 X-SWARE-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, TW_GD X-Spam-Check-By: sourceware.org Received: from mail-ve0-f171.google.com (HELO mail-ve0-f171.google.com) (209.85.128.171) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 07 Feb 2013 06:34:56 +0000 Received: by mail-ve0-f171.google.com with SMTP id b10so2001690vea.30 for ; Wed, 06 Feb 2013 22:34:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type:x-gm-message-state; bh=d+sQns4dHLKiuL8oligerUBQlThW+CVxp98DqzDct/8=; b=VGsv0FMF7z/C3wxSF5wg9UkvjFgWj2JpwLH2/Vt1cQEiur0QEJ9PyuGzCmEZrakd7d ZDD2DwVhZWeuyAHrGGAismflrZ7vPr7xpADj7JRPHxQORaeI7l0wCAUMcSTaQK3wr33a EWAmoQ4ktvxmyW/UBtiJS3wiWhrVn6aTMR5Pp1JHuzyOUchWE4wmauGVqUZfP3FuN/9G nVxkasFU5ptcEDMWJmJfOJGn5pSJBaKnUWIFolFSSKxArAlwANsHCdwBqCYoqaX/zN+Q UA/H1rNgwrOQbXXEimETZ566+Bk60NslKenYiSjAjjRpqqUGCYhj2Rv1XPxiWtrQMbhl i/Eg== MIME-Version: 1.0 X-Received: by 10.58.188.48 with SMTP id fx16mr237483vec.22.1360218895535; Wed, 06 Feb 2013 22:34:55 -0800 (PST) Received: by 10.220.247.71 with HTTP; Wed, 6 Feb 2013 22:34:55 -0800 (PST) Date: Wed, 6 Feb 2013 22:34:55 -0800 Message-ID: Subject: [google/main] Generate line tables at -g1 (aka -gmlt) From: Cary Coutant To: gcc-patches , Diego Novillo , Xinliang David Li X-Gm-Message-State: ALoCoQnPehIBWCTviWLTqhXd9C+jeiSy6mEvUkzC1EMKT95goSV3INL/cEdET8cDia3yEk8j4yxW9T+cDsb0bGgiMpD3EHOx8S61zxdVZ5aKY5gTcCSBwfh7PAL2CjXnRXfjAykAFYW5k494FxRxxvTdVBrfp3Ih8t6dymSxdkoUJ3bFPH06SOuR9oCSWeBe84H73p0D+mdQ X-IsSubscribed: yes 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 This patch is the google/main version of this pending patch for trunk: http://gcc.gnu.org/ml/gcc-patches/2013-02/msg00260.html I've modified GCC to generate line number tables at -g1, and we already have the -gmlt option in google/main as a synonym for -g1. The patch also changes -g so that it has the same behavior as -g2 -- "-g1 -g" is the same as "-g1 -g2". Tested with crosstool-validate.py. OK for google/main? -cary Index: doc/invoke.texi =================================================================== --- doc/invoke.texi (revision 195825) +++ doc/invoke.texi (working copy) @@ -5105,8 +5105,8 @@ Level 0 produces no debug information at Level 1 produces minimal information, enough for making backtraces in parts of the program that you don't plan to debug. This includes -descriptions of functions and external variables, but no information -about local variables and no line numbers. +descriptions of functions and external variables, and line number +tables, but no information about local variables. Level 3 includes extra information, such as all the macro definitions present in the program. Some debuggers support macro expansion when Index: common.opt =================================================================== --- common.opt (revision 195825) +++ common.opt (working copy) @@ -2456,6 +2456,10 @@ grecord-gcc-switches Common RejectNegative Var(dwarf_record_gcc_switches,1) Record gcc command line switches in DWARF DW_AT_producer. +gmlt +Common RejectNegative +Generate debug information at level 1 with minimal line table + gno-split-dwarf Common Driver RejectNegative Var(dwarf_split_debug_info,0) Init(0) Don't generate debug information in separate .dwo files Index: testsuite/gcc.dg/debug/dwarf2/mlt2.c =================================================================== --- testsuite/gcc.dg/debug/dwarf2/mlt2.c (revision 0) +++ testsuite/gcc.dg/debug/dwarf2/mlt2.c (revision 0) @@ -0,0 +1,31 @@ +/* Test that -g overrides -g1. */ +/* Origin: Cary Coutant */ +/* { dg-do compile } */ +/* { dg-options "-O2 -gdwarf-2 -dA -g1 -g" } */ +/* { dg-final { scan-assembler "DW_AT_stmt_list" } } */ +/* { dg-final { scan-assembler "DW_TAG_subprogram" } } */ +/* { dg-final { scan-assembler "DW_TAG_inlined_subroutine" } } */ +/* { dg-final { scan-assembler "DW_TAG_variable" } } */ +/* { dg-final { scan-assembler "DW_TAG_formal_parameter" } } */ +/* { dg-final { scan-assembler "DW_TAG_base_type" } } */ + +static inline __attribute__((always_inline)) int +a(int i, int j) +{ + return (i << 5) + j; +} + +int +b(int i, int j) +{ + return (i >> 5) + (j << 27); +} + +int +c(int i, int j) +{ + int r = a(i, j); + r = b(r, i); + r = b(r, j); + return r; +} Index: testsuite/gcc.dg/debug/dwarf2/mlt1.c =================================================================== --- testsuite/gcc.dg/debug/dwarf2/mlt1.c (revision 0) +++ testsuite/gcc.dg/debug/dwarf2/mlt1.c (revision 0) @@ -0,0 +1,32 @@ +/* Test that -g1 includes line tables and inlined subroutine entries, + and excludes types and variables. */ +/* Origin: Cary Coutant */ +/* { dg-do compile } */ +/* { dg-options "-O2 -gdwarf-2 -dA -g1" } */ +/* { dg-final { scan-assembler "DW_AT_stmt_list" } } */ +/* { dg-final { scan-assembler "DW_TAG_subprogram" } } */ +/* { dg-final { scan-assembler "DW_TAG_inlined_subroutine" } } */ +/* { dg-final { scan-assembler-not "DW_TAG_variable" } } */ +/* { dg-final { scan-assembler-not "DW_TAG_formal_parameter" } } */ +/* { dg-final { scan-assembler-not "DW_TAG_base_type" } } */ + +static inline __attribute__((always_inline)) int +a(int i, int j) +{ + return (i << 5) + j; +} + +int +b(int i, int j) +{ + return (i >> 5) + (j << 27); +} + +int +c(int i, int j) +{ + int r = a(i, j); + r = b(r, i); + r = b(r, j); + return r; +} Index: dwarf2out.c =================================================================== --- dwarf2out.c (revision 195825) +++ dwarf2out.c (working copy) @@ -8648,9 +8648,11 @@ output_comp_unit (dw_die_ref die, int ou static inline bool want_pubnames (void) { - return (debug_generate_pub_sections != -1 - ? debug_generate_pub_sections - : targetm.want_debug_pub_sections); + if (debug_info_level <= DINFO_LEVEL_TERSE) + return false; + if (debug_generate_pub_sections != -1) + return debug_generate_pub_sections; + return targetm.want_debug_pub_sections; } /* Add the DW_AT_GNU_pubnames and DW_AT_GNU_pubtypes attributes. */ @@ -16225,11 +16227,12 @@ add_src_coords_attributes (dw_die_ref di static void add_linkage_name (dw_die_ref die, tree decl) { - if ((TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == VAR_DECL) - && TREE_PUBLIC (decl) - && !DECL_ABSTRACT (decl) - && !(TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl)) - && die->die_tag != DW_TAG_member) + if (debug_info_level > DINFO_LEVEL_TERSE + && (TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == VAR_DECL) + && TREE_PUBLIC (decl) + && !DECL_ABSTRACT (decl) + && !(TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl)) + && die->die_tag != DW_TAG_member) { /* Defer until we have an assembler name set. */ if (!DECL_ASSEMBLER_NAME_SET_P (decl)) @@ -19611,16 +19614,19 @@ decls_for_scope (tree stmt, dw_die_ref c /* Output the DIEs to represent all of the data objects and typedefs declared directly within this block but not within any nested sub-blocks. Also, nested function and tag DIEs have been - generated with a parent of NULL; fix that up now. */ - for (decl = BLOCK_VARS (stmt); decl != NULL; decl = DECL_CHAIN (decl)) - process_scope_var (stmt, decl, NULL_TREE, context_die); - for (i = 0; i < BLOCK_NUM_NONLOCALIZED_VARS (stmt); i++) - process_scope_var (stmt, NULL, BLOCK_NONLOCALIZED_VAR (stmt, i), - context_die); + generated with a parent of NULL; fix that up now. We don't + have to do this if we're at -g1. */ + if (debug_info_level > DINFO_LEVEL_TERSE) + { + for (decl = BLOCK_VARS (stmt); decl != NULL; decl = DECL_CHAIN (decl)) + process_scope_var (stmt, decl, NULL_TREE, context_die); + for (i = 0; i < BLOCK_NUM_NONLOCALIZED_VARS (stmt); i++) + process_scope_var (stmt, NULL, BLOCK_NONLOCALIZED_VAR (stmt, i), + context_die); + } - /* If we're at -g1, we're not interested in subblocks. */ - if (debug_info_level <= DINFO_LEVEL_TERSE) - return; + /* Even if we're at -g1, we need to process the subblocks in order to get + inlined call information. */ /* Output the DIEs to represent all sub-blocks (and the items declared therein) of this block. */ @@ -20969,7 +20975,7 @@ dwarf2out_source_line (unsigned int line unsigned int file_num; dw_line_info_table *table; - if (debug_info_level < DINFO_LEVEL_NORMAL || line == 0) + if (debug_info_level < DINFO_LEVEL_TERSE || line == 0) return; /* The discriminator column was added in dwarf4. Simplify the below @@ -23452,7 +23458,7 @@ dwarf2out_finish (const char *filename) } } - if (debug_info_level >= DINFO_LEVEL_NORMAL) + if (debug_info_level >= DINFO_LEVEL_TERSE) add_AT_lineptr (main_comp_unit_die, DW_AT_stmt_list, debug_line_section_label); @@ -23500,7 +23506,7 @@ dwarf2out_finish (const char *filename) /* Add a pointer to the line table for the main compilation unit so that the debugger can make sense of DW_AT_decl_file attributes. */ - if (debug_info_level >= DINFO_LEVEL_NORMAL) + if (debug_info_level >= DINFO_LEVEL_TERSE) add_AT_lineptr (ctnode->root_die, DW_AT_stmt_list, (!dwarf_split_debug_info ? debug_line_section_label Index: tree-ssa-live.c =================================================================== --- tree-ssa-live.c (revision 195825) +++ tree-ssa-live.c (working copy) @@ -563,11 +563,11 @@ remove_unused_scope_block_p (tree scope) eliminated. */ else if (!nsubblocks) ; - /* For terse debug info we can eliminate info on unused variables. */ - else if (debug_info_level == DINFO_LEVEL_NONE - || debug_info_level == DINFO_LEVEL_TERSE) + /* When not generating debug info we can eliminate info on unused + variables. */ + else if (debug_info_level == DINFO_LEVEL_NONE) { - /* Even for -g0/-g1 don't prune outer scopes from artificial + /* Even for -g0 don't prune outer scopes from artificial functions, otherwise diagnostics using tree_nonartificial_location will not be emitted properly. */ if (inlined_function_outer_scope_p (scope)) Index: opts.c =================================================================== --- opts.c (revision 195825) +++ opts.c (working copy) @@ -1697,8 +1697,13 @@ common_handle_option (struct gcc_options break; case OPT_g: - set_debug_level (NO_DEBUG, DEFAULT_GDB_EXTENSIONS, arg, opts, opts_set, - loc); + /* -g by itself should force -g2. */ + if (*arg == '\0') + set_debug_level (NO_DEBUG, DEFAULT_GDB_EXTENSIONS, "2", opts, opts_set, + loc); + else + set_debug_level (NO_DEBUG, DEFAULT_GDB_EXTENSIONS, arg, opts, opts_set, + loc); break; case OPT_gcoff: @@ -1728,6 +1733,12 @@ common_handle_option (struct gcc_options loc); break; + case OPT_gmlt: + /* Synonym for -g1. */ + set_debug_level (NO_DEBUG, DEFAULT_GDB_EXTENSIONS, "1", opts, opts_set, + loc); + break; + case OPT_gvms: set_debug_level (VMS_DEBUG, false, arg, opts, opts_set, loc); break;