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)
+ && T