This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, testsuite] Add missing -gdwarf-2 flag in debug/dwarf2 testcase
- From: Senthil Kumar Selvaraj <senthil_kumar dot selvaraj at atmel dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: Mike Stump <mikestump at comcast dot net>, "gcc at gcc dot gnu dot org List" <gcc at gcc dot gnu dot org>, "dodji at redhat dot com Seketeli" <dodji at redhat dot com>, "janisjo at codesourcery dot com Johnson" <janisjo at codesourcery dot com>
- Date: Thu, 4 Apr 2013 21:18:53 +0530
- Subject: Re: [Patch, testsuite] Add missing -gdwarf-2 flag in debug/dwarf2 testcase
- References: <20130328105752 dot GA887 at atmel dot com> <74DC064C-48E4-4462-A3EB-645F263A7FD4 at comcast dot net> <5155E199 dot 6070603 at redhat dot com> <20130330062307 dot GA13331 at atmel dot com> <515A37AA dot 1050702 at redhat dot com> <F1D390C2-2D95-48F2-AFB5-210F895FD80F at comcast dot net> <20130402130743 dot GA20532 at atmel dot com> <515AF498 dot 7000107 at redhat dot com> <20130402192420 dot GA23848 at atmel dot com> <515CEE58 dot 3010501 at redhat dot com>
On Wed, Apr 03, 2013 at 11:07:04PM -0400, Jason Merrill wrote:
> On 04/02/2013 03:25 PM, Senthil Kumar Selvaraj wrote:
> >+gdwarf
> >+Common UInteger Var(dwarf_default_version, 4) Negative(gdwarf-)
> >+Generate debug information in the default DWARF version format
>
> The Negative options need to form a circular chain, so gcoff should
> have Negative(gdwarf) and gdwarf should have Negative(gdwarf-).
>
> I don't think you need a dwarf_default_version variable since
> there's already dwarf_version.
>
Fixed those in the below patch.
> It would be nice to give a helpful diagnostic if people try to write
> -gdwarf2 to suggest that they either write -gdwarf-2 or -gdwarf -g2.
>
I wasn't able to get this done in a clean way. To make the gdwarf option
handling code detect this error, the only I found was to make it
JoinedOrMissing, and then raise the error if there was an argument
provided. Otherwise, I'd have to do it in the -g option case, which I
think is messy.
Regards
Senthil
diff --git gcc/common.opt gcc/common.opt
index e02e7ed..b9ba416 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 Var(dwarf_version, 4) 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..60f290d 100644
--- gcc/opts.c
+++ gcc/opts.c
@@ -1699,6 +1699,8 @@ common_handle_option (struct gcc_options *opts,
set_debug_level (SDB_DEBUG, false, arg, opts, opts_set, loc);
break;
+ case OPT_gdwarf:
+ value = opts->x_dwarf_version;
case OPT_gdwarf_:
if (value < 2 || value > 4)
error_at (loc, "dwarf version %d is not supported", value);