Re: [Patch, testsuite] Add missing -gdwarf-2 flag in debug/dwarf2 testcase

2013-04-02 Thread Senthil Kumar Selvaraj
On Mon, Apr 01, 2013 at 06:46:29PM -0700, Mike Stump wrote:
> On Apr 1, 2013, at 6:43 PM, Jason Merrill  wrote:
> > On 03/30/2013 02:23 AM, Senthil Kumar Selvaraj wrote:
> >> I couldn't find a way to ask gcc to just generate DWARF (default
> >> version) either. How should this be fixed?
> > 
> > Maybe we could use -gdwarf for that now, since we stopped using it for 
> > DWARF 1 in GCC 3.4.
> 
> I like that.
> 
Ok, how about the following (tentative) patch? If -gdwarf- is
specified without any argument, it picks DWARF 4 as the default.

Regards
Senthil


diff --git gcc/common.opt gcc/common.opt
index bdbd3b6..58311e7 100644
--- gcc/common.opt
+++ gcc/common.opt
@@ -2307,7 +2307,7 @@ Common JoinedOrMissing Negative(gdwarf-)
 Generate debug information in COFF format
 
 gdwarf-
-Common Joined UInteger Var(dwarf_version) Init(4) Negative(gstabs)
+Common JoinedOrMissing UInteger Var(dwarf_version) Init(4) Negative(gstabs)
 Generate debug information in DWARF v2 (or later) format
 
 ggdb
diff --git gcc/opts.c gcc/opts.c
index 45b12fe..336554b 100644
--- gcc/opts.c
+++ gcc/opts.c
@@ -1700,12 +1700,24 @@ common_handle_option (struct gcc_options *opts,
   break;
 
 case OPT_gdwarf_:
-  if (value < 2 || value > 4)
-   error_at (loc, "dwarf version %d is not supported", value);
-  else
-   opts->x_dwarf_version = value;
-  set_debug_level (DWARF2_DEBUG, false, "", opts, opts_set, loc);
-  break;
+  {
+/* Treat -gdwarf- without any argument (dwarf version) as equivalent to
+   -gdwarf- */
+const int max_dwarf_version = 4;
+if (strlen (arg) == 0)
+  {
+opts->x_dwarf_version = max_dwarf_version;
+  }
+else
+  {
+if (value < 2 || value > max_dwarf_version)
+  error_at (loc, "dwarf version %d is not supported", value);
+else
+  opts->x_dwarf_version = value;
+  }
+set_debug_level (DWARF2_DEBUG, false, "", opts, opts_set, loc);
+break;
+  }
 
 case OPT_gsplit_dwarf:
   set_debug_level (NO_DEBUG, DEFAULT_GDB_EXTENSIONS, "", opts, opts_set,


Re: [Patch, testsuite] Add missing -gdwarf-2 flag in debug/dwarf2 testcase

2013-04-02 Thread Jason Merrill

On 04/02/2013 09:07 AM, Senthil Kumar Selvaraj wrote:

Ok, how about the following (tentative) patch? If -gdwarf- is
specified without any argument, it picks DWARF 4 as the default.


-gdwarf- looks a bit odd to me; I was thinking -gdwarf without the 
trailing -.


Jason




Re: [Patch, testsuite] Add missing -gdwarf-2 flag in debug/dwarf2 testcase

2013-04-02 Thread Senthil Kumar Selvaraj
On Tue, Apr 02, 2013 at 11:09:12AM -0400, Jason Merrill wrote:
> On 04/02/2013 09:07 AM, Senthil Kumar Selvaraj wrote:
> >Ok, how about the following (tentative) patch? If -gdwarf- is
> >specified without any argument, it picks DWARF 4 as the default.
> 
> -gdwarf- looks a bit odd to me; I was thinking -gdwarf without the
> trailing -.

Does the below patch look good?

Regards
Senthil


diff --git gcc/common.opt gcc/common.opt
index bdbd3b6..5af41d9 100644
--- gcc/common.opt
+++ gcc/common.opt
@@ -2306,8 +2306,12 @@ gcoff
 Common JoinedOrMissing Negative(gdwarf-)
 Generate debug information in COFF format
 
+gdwarf
+Common UInteger Var(dwarf_default_version, 4) Negative(gdwarf-)
+Generate debug information in the default DWARF version format
+
 gdwarf-
-Common Joined UInteger Var(dwarf_version) Init(4) Negative(gstabs)
+Common Joined UInteger Var(dwarf_version) Init(4) Negative(gstabs) 
Negative(gdwarf)
 Generate debug information in DWARF v2 (or later) format
 
 ggdb
diff --git gcc/opts.c gcc/opts.c
index 45b12fe..c6823a6 100644
--- gcc/opts.c
+++ gcc/opts.c
@@ -1698,7 +1698,9 @@ common_handle_option (struct gcc_options *opts,
 case OPT_gcoff:
   set_debug_level (SDB_DEBUG, false, arg, opts, opts_set, loc);
   break;
-
+  
+case OPT_gdwarf:
+  value = opts->x_dwarf_default_version;
 case OPT_gdwarf_:
   if (value < 2 || value > 4)
error_at (loc, "dwarf version %d is not supported", value);