diff mbox

Add -gdwarf option to make gcc generate DWARF with the default version

Message ID 20130410132502.GA28317@atmel.com
State New
Headers show

Commit Message

Senthil Kumar Selvaraj April 10, 2013, 1:25 p.m. UTC
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.selvaraj@atmel.com>
            Jason Merrill  <jason@redhat.com>

Comments

Jason Merrill April 11, 2013, 2:13 a.m. UTC | #1
Applied, thanks.

Jason
Jakub Jelinek April 11, 2013, 7:08 a.m. UTC | #2
On Wed, Apr 10, 2013 at 06:55:10PM +0530, Senthil Kumar Selvaraj wrote:
> --- 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)

The formatting is wrong.  Space before ( above missing.

> +        {
> +          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;
> +        }

A single line statement shouldn't be surrounded inside { }.

ALso, if the OPT_gdwarf case is meant to fallthru into OPT_gdwarf_,
there should be /* FALLTHRU */ or similar comment.

>      case OPT_gdwarf_:
>        if (value < 2 || value > 4)
>  	error_at (loc, "dwarf version %d is not supported", value);

	Jakub
diff mbox

Patch

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);