Skip to content

Commit

Permalink
Add minimal line tables at -g1.
Browse files Browse the repository at this point in the history
    
2013-11-21  Cary Coutant  <ccoutant@google.com>

gcc/
	* dwarf2out.c (want_pubnames): Don't do pubnames for -g1.
	(add_linkage_name): Don't add linkage name for -g1.
	(decls_for_scope): Process subblocks for -g1.
	(dwarf2out_source_line): Output line tables for -g1.
	(dwarf2out_finish): Likewise.
	* tree-ssa-live.c (remove_unused_scope_block_p): Don't prune
	unused scopes for -g1.
	* opts.c (common_handle_option): Handle -g same as -g2.
	* doc/invoke.texi: Update description for -g1.

gcc/testsuite/
	* gcc.dg/debug/dwarf2/mlt1.c: New test.
	* gcc.dg/debug/dwarf2/mlt2.c: New test.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205235 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
ccoutant committed Nov 21, 2013
1 parent d0e91c2 commit 7fa9fa1
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 25 deletions.
12 changes: 12 additions & 0 deletions gcc/ChangeLog
@@ -1,3 +1,15 @@
2013-11-21 Cary Coutant <ccoutant@google.com>

* dwarf2out.c (want_pubnames): Don't do pubnames for -g1.
(add_linkage_name): Don't add linkage name for -g1.
(decls_for_scope): Process subblocks for -g1.
(dwarf2out_source_line): Output line tables for -g1.
(dwarf2out_finish): Likewise.
* tree-ssa-live.c (remove_unused_scope_block_p): Don't prune
unused scopes for -g1.
* opts.c (common_handle_option): Handle -g same as -g2.
* doc/invoke.texi: Update description for -g1.

2013-11-21 Peter Bergner <bergner@vnet.ibm.com>

* doc/extend.texi: Document htm builtins.
Expand Down
4 changes: 2 additions & 2 deletions gcc/doc/invoke.texi
Expand Up @@ -5233,8 +5233,8 @@ Level 0 produces no debug information at all. Thus, @option{-g0} negates

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
Expand Down
40 changes: 23 additions & 17 deletions gcc/dwarf2out.c
Expand Up @@ -8849,6 +8849,8 @@ output_comp_unit (dw_die_ref die, int output_if_empty)
static inline bool
want_pubnames (void)
{
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;
Expand Down Expand Up @@ -16563,11 +16565,12 @@ add_src_coords_attributes (dw_die_ref die, tree decl)
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))
Expand Down Expand Up @@ -19963,16 +19966,19 @@ decls_for_scope (tree stmt, dw_die_ref context_die, int depth)
/* 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. */
Expand Down Expand Up @@ -21381,7 +21387,7 @@ dwarf2out_source_line (unsigned int line, const char *filename,
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
Expand Down Expand Up @@ -24073,7 +24079,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);

Expand Down Expand Up @@ -24130,7 +24136,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
Expand Down
9 changes: 7 additions & 2 deletions gcc/opts.c
Expand Up @@ -1807,8 +1807,13 @@ common_handle_option (struct gcc_options *opts,
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:
Expand Down
5 changes: 5 additions & 0 deletions gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
2013-11-21 Cary Coutant <ccoutant@google.com>

* gcc.dg/debug/dwarf2/mlt1.c: New test.
* gcc.dg/debug/dwarf2/mlt2.c: New test.

2013-11-21 Jeff Law <law@redhat.com>

PR tree-optimization/59221
Expand Down
8 changes: 4 additions & 4 deletions gcc/tree-ssa-live.c
Expand Up @@ -599,11 +599,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))
Expand Down

0 comments on commit 7fa9fa1

Please sign in to comment.