This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Default to -gdwarf-4


Hi!

For reasonable debugging experience recent GCC versions need
GDB >= 7.0 for quite some time, and DWARF4 is almost 2 years old now,
and offers lots of improvements over DWARF2 we still default to.

So, I'd like to make -gdwarf-4 (just the version, of course -g
is needed to enable debug info generation) the default, together
with -fno-debug-types-section (as .debug_types isn't right now always a win,
see the data in the dwz-0.1 announcement plus not all DWARF consumers can
handle it yet or are gaining support only very recently (e.g. valgrind))
and -grecord-gcc-switches which is IMHO worth the few extra bytes per CU
(unless every CU is compiled with different code generation affecting
options usually just 4 extra bytes).  In Fedora we default to this combo
already for some time.  Targets that have tools that are upset by
any extensions that defaulted to -gno-strict-dwarf previously will now
default to -gdwarf-2 as before.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2012-04-25  Jakub Jelinek  <jakub@redhat.com>

	* common.opt (flag_debug_types_section): Default to 0.
	(dwarf_version): Default to 4.
	(dwarf_record_gcc_switches): Default to 1.
	(dwarf_strict): Default to 0.
	* toplev.c (process_options): Don't handle dwarf_strict
	or dwarf_version here.
	* config/vxworks.c (vxworks_override_options): Don't
	test whether dwarf_strict or dwarf_version are negative,
	instead test !global_options_set.x_dwarf_*.
	* config/darwin.c (darwin_override_options): Default to
	dwarf_version 2.
	* doc/invoke.texi: Note that -gdwarf-4, -grecord-gcc-switches
	and -fno-debug-types-section are now the default.

--- gcc/common.opt.jj	2012-04-25 12:14:55.000000000 +0200
+++ gcc/common.opt	2012-04-25 12:35:33.944460663 +0200
@@ -967,7 +967,7 @@ Common Joined RejectNegative Var(common_
 Map one directory name to another in debug information
 
 fdebug-types-section
-Common Report Var(flag_debug_types_section) Init(1)
+Common Report Var(flag_debug_types_section) Init(0)
 Output .debug_types section when using DWARF v4 debuginfo.
 
 ; Nonzero for -fdefer-pop: don't pop args after each function call
@@ -2212,7 +2212,7 @@ Common JoinedOrMissing Negative(gdwarf-)
 Generate debug information in COFF format
 
 gdwarf-
-Common Joined UInteger Var(dwarf_version) Init(-1) Negative(gstabs)
+Common Joined UInteger Var(dwarf_version) Init(4) Negative(gstabs)
 Generate debug information in DWARF v2 (or later) format
 
 ggdb
@@ -2220,7 +2220,7 @@ Common JoinedOrMissing
 Generate debug information in default extended format
 
 gno-record-gcc-switches
-Common RejectNegative Var(dwarf_record_gcc_switches,0) Init(0)
+Common RejectNegative Var(dwarf_record_gcc_switches,0) Init(1)
 Don't record gcc command line switches in DWARF DW_AT_producer.
 
 grecord-gcc-switches
@@ -2236,7 +2236,7 @@ Common JoinedOrMissing Negative(gvms)
 Generate debug information in extended STABS format
 
 gno-strict-dwarf
-Common RejectNegative Var(dwarf_strict,0) Init(-1)
+Common RejectNegative Var(dwarf_strict,0) Init(0)
 Emit DWARF additions beyond selected version
 
 gstrict-dwarf
--- gcc/toplev.c.jj	2012-04-25 12:14:55.000000000 +0200
+++ gcc/toplev.c	2012-04-25 12:34:38.016819701 +0200
@@ -1375,15 +1375,6 @@ process_options (void)
 	}
     }
 
-  /* Unless over-ridden for the target, assume that all DWARF levels
-     may be emitted, if DWARF2_DEBUG is selected.  */
-  if (dwarf_strict < 0)
-    dwarf_strict = 0;
-
-  /* And select a default dwarf level.  */
-  if (dwarf_version < 0)
-    dwarf_version = 2;
-
   /* A lot of code assumes write_symbols == NO_DEBUG if the debugging
      level is 0.  */
   if (debug_info_level == DINFO_LEVEL_NONE)
--- gcc/config/vxworks.c.jj	2012-04-25 12:14:55.000000000 +0200
+++ gcc/config/vxworks.c	2012-04-25 12:34:04.868027337 +0200
@@ -1,5 +1,5 @@
 /* Common VxWorks target definitions for GNU compiler.
-   Copyright (C) 2007, 2008, 2010
+   Copyright (C) 2007, 2008, 2010, 2012
    Free Software Foundation, Inc.
    Contributed by CodeSourcery, Inc.
 
@@ -147,9 +147,9 @@ vxworks_override_options (void)
 
   /* Default to strict dwarf-2 to prevent potential difficulties observed with
      non-gdb debuggers on extensions > 2.  */
-  if (dwarf_strict < 0)
+  if (!global_options_set.x_dwarf_strict)
     dwarf_strict = 1;
 
-  if (dwarf_version < 0)
+  if (!global_options_set.x_dwarf_version)
     dwarf_version = 2;
 }
--- gcc/config/darwin.c.jj	2011-12-01 11:45:06.000000000 +0100
+++ gcc/config/darwin.c	2012-04-25 12:21:03.965982850 +0200
@@ -1,6 +1,6 @@
 /* Functions for generic Darwin as target machine for GNU C compiler.
    Copyright (C) 1989, 1990, 1991, 1992, 1993, 2000, 2001, 2002, 2003, 2004,
-   2005, 2006, 2007, 2008, 2009, 2010, 2011
+   2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
    Contributed by Apple Computer Inc.
 
@@ -2973,6 +2973,8 @@ darwin_override_options (void)
      workaround for tool bugs.  */
   if (!global_options_set.x_dwarf_strict) 
     dwarf_strict = 1;
+  if (!global_options_set.x_dwarf_version)
+    dwarf_version = 2;
 
   /* Do not allow unwind tables to be generated by default for m32.  
      fnon-call-exceptions will override this, regardless of what we do.  */
--- gcc/doc/invoke.texi.jj	2012-04-23 11:11:18.000000000 +0200
+++ gcc/doc/invoke.texi	2012-04-25 12:39:49.934839228 +0200
@@ -4781,14 +4781,16 @@ normally emits debugging information for
 option increases the size of debugging information by as much as a
 factor of two.
 
-@item -fno-debug-types-section
-@opindex fno-debug-types-section
+@item -fdebug-types-section
 @opindex fdebug-types-section
-By default when using DWARF Version 4 or higher, type DIEs are put into
+@opindex fno-debug-types-section
+When using DWARF Version 4 or higher, type DIEs can be put into
 their own @code{.debug_types} section instead of making them part of the
 @code{.debug_info} section.  It is more efficient to put them in a separate
 comdat sections since the linker can then remove duplicates.
-But not all DWARF consumers support @code{.debug_types} sections yet.
+But not all DWARF consumers support @code{.debug_types} sections yet
+and on some objects @code{.debug_types} produces larger instead of smaller
+debugging information.
 
 @item -gstabs+
 @opindex gstabs+
@@ -4819,7 +4821,8 @@ assembler (GAS) to fail with an error.
 @item -gdwarf-@var{version}
 @opindex gdwarf-@var{version}
 Produce debugging information in DWARF format (if that is supported).
-The value of @var{version} may be either 2, 3 or 4; the default version is 2.
+The value of @var{version} may be either 2, 3 or 4; the default version
+for most targets is 4.
 
 Note that with DWARF Version 2, some ports require and always
 use some non-conflicting DWARF 3 extensions in the unwind tables.
@@ -4834,12 +4837,12 @@ compiler that may affect code generation
 DW_AT_producer attribute in DWARF debugging information.  The options
 are concatenated with spaces separating them from each other and from
 the compiler version.  See also @option{-frecord-gcc-switches} for another
-way of storing compiler options into the object file.
+way of storing compiler options into the object file.  This is the default.
 
 @item -gno-record-gcc-switches
 @opindex gno-record-gcc-switches
 Disallow appending command-line options to the DW_AT_producer attribute
-in DWARF debugging information.  This is the default.
+in DWARF debugging information.
 
 @item -gstrict-dwarf
 @opindex gstrict-dwarf

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]