This is the mail archive of the 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] Add -gdwarf option to make gcc generate DWARF with the default version


This patch adds a -gdwarf option to make gcc generate DWARF with the
default version (currently 4).

A bunch of tests in the dejagnu dwarf test suite fail right now if gcc
is configured/built with support for multiple debugging formats and
DWARF is not the default. The failing tests don't explicitly specify
-gdwarf-<version> but check for DWARF data. 

The tests need a way to ask gcc to generate the latest DWARF version supported.
Instead of hardcoding a specific version, adding this option allows the
tests to run against the latest supported DWARF version. Version specific 
DWARF tests can of course use the -gdwarf-<version> option.  There was a 
discussion on this in the mailing list previously (see and and Jason was ok with a
modified version of the patch.

The patch merely forwards control to  gdwarf- option handling, setting
value to the Init value set in common.opt for gdwarf-. In addition, it
raises an error if the user specifies a version with the option.

If ok, could someone apply please (I don't have commit access) ?
Once comitted, I'll send another patch for the failing tests with the -gdwarf
option added to dg-options.



2013-04-10  Senthil Kumar Selvaraj  <>
            Jason Merrill  <>

diff --git gcc/common.opt gcc/common.opt
index e02e7ed..e3645c3 100644
--- gcc/common.opt
+++ gcc/common.opt
@@ -2308,9 +2308,13 @@ Common JoinedOrMissing
 Generate debug information in default format
-Common JoinedOrMissing Negative(gdwarf-)
+Common JoinedOrMissing Negative(gdwarf)
 Generate debug information in COFF format
+Common JoinedOrMissing UInteger Negative(gdwarf-)
+Generate debug information in the default DWARF version format
 Common Joined UInteger Var(dwarf_version) Init(4) Negative(gstabs)
 Generate debug information in DWARF v2 (or later) format
diff --git gcc/opts.c gcc/opts.c
index 45b12fe..f96ed16 100644
--- gcc/opts.c
+++ gcc/opts.c
@@ -1699,6 +1699,18 @@ common_handle_option (struct gcc_options *opts,
       set_debug_level (SDB_DEBUG, false, arg, opts, opts_set, loc);
+    case OPT_gdwarf:
+      if (arg && strlen(arg) != 0)
+        {
+          error_at (loc, "%<-gdwarf%s%> is ambiguous; "
+                    "use %<-gdwarf-%s%> for DWARF version "
+                    "or %<-gdwarf -g%s%> for debug level", arg, arg, arg);
+          break;
+        }
+      else
+        {
+          value = opts->x_dwarf_version;
+        }
     case OPT_gdwarf_:
       if (value < 2 || value > 4)
 	error_at (loc, "dwarf version %d is not supported", value);

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