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: Mike Stump <mikestump at comcast dot net>
- Cc: Jason Merrill <jason at redhat dot com>, "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: Tue, 2 Apr 2013 18:37:44 +0530
- Subject: Re: [Patch, testsuite] Add missing -gdwarf-2 flag in debug/dwarf2 testcase
- References: <20130327080214 dot GA7422 at atmel dot com> <57AC2D0F-7AB7-46A0-BA38-6BC66B876838 at comcast dot net> <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>
On Mon, Apr 01, 2013 at 06:46:29PM -0700, Mike Stump wrote:
> On Apr 1, 2013, at 6:43 PM, Jason Merrill <jason@redhat.com> 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-<default_version> */
+ 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,