Hi,

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
http://gcc.gnu.org/ml/gcc/2013-04/msg00007.html and
http://gcc.gnu.org/ml/gcc/2013-03/msg00271.html) 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.

Regards
Senthil

gcc/ChangeLog

2013-04-10  Senthil Kumar Selvaraj  <senthil_kumar.selva...@atmel.com>
            Jason Merrill  <ja...@redhat.com>

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
 
 gcoff
-Common JoinedOrMissing Negative(gdwarf-)
+Common JoinedOrMissing Negative(gdwarf)
 Generate debug information in COFF format
 
+gdwarf
+Common JoinedOrMissing UInteger Negative(gdwarf-)
+Generate debug information in the default DWARF version format
+
 gdwarf-
 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);
       break;
 
+    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);

Reply via email to