diff mbox

PR debug/61013: Change -g so that it will override -g1 but not -g3

Message ID 20140514213622.478F2160416@ccoutant.mtv.corp.google.com
State New
Headers show

Commit Message

Cary Coutant May 14, 2014, 9:36 p.m. UTC
This patch partially reverts a change in how a bare -g option was parsed
in a previous commit.  Originally, -g would set the debug level to 2
only if debug was off.  The previous commit changed that so that -g
would set the debug level to 2 unconditionally.  This patch changes
it so that -g sets the debug level to 2 if it was either off or at
level 1 before.

OK to commit?

-cary


2014-05-14  Cary Coutant  <ccoutant@google.com>

gcc/
        PR debug/61013
	* opts.c (common_handle_option): Don't special-case "-g".
	(set_debug_level): Default to at least level 2 with "-g".

Comments

Richard Henderson May 14, 2014, 9:45 p.m. UTC | #1
On 05/14/2014 02:36 PM, Cary Coutant wrote:
>         PR debug/61013
> 	* opts.c (common_handle_option): Don't special-case "-g".
> 	(set_debug_level): Default to at least level 2 with "-g".

Ok.  Thanks,


r~
Cary Coutant May 14, 2014, 9:47 p.m. UTC | #2
>>         PR debug/61013
>>       * opts.c (common_handle_option): Don't special-case "-g".
>>       (set_debug_level): Default to at least level 2 with "-g".
>
> Ok.  Thanks,

Forgot to ask -- OK to backport to the 4.9 branch?

-cary
Richard Henderson May 14, 2014, 9:49 p.m. UTC | #3
On 05/14/2014 02:47 PM, Cary Coutant wrote:
>>>         PR debug/61013
>>>       * opts.c (common_handle_option): Don't special-case "-g".
>>>       (set_debug_level): Default to at least level 2 with "-g".
>>
>> Ok.  Thanks,
> 
> Forgot to ask -- OK to backport to the 4.9 branch?

Yes please.


r~
diff mbox

Patch

Index: gcc/opts.c
===================================================================
--- gcc/opts.c	(revision 210437)
+++ gcc/opts.c	(working copy)
@@ -1814,13 +1814,8 @@  common_handle_option (struct gcc_options
       break;
 
     case OPT_g:
-      /* -g by itself should force -g2.  */
-      if (*arg == '\0')
-	set_debug_level (NO_DEBUG, DEFAULT_GDB_EXTENSIONS, "2", opts, opts_set,
-			 loc);
-      else
-	set_debug_level (NO_DEBUG, DEFAULT_GDB_EXTENSIONS, arg, opts, opts_set,
-			 loc);
+      set_debug_level (NO_DEBUG, DEFAULT_GDB_EXTENSIONS, arg, opts, opts_set,
+                       loc);
       break;
 
     case OPT_gcoff:
@@ -2070,10 +2065,12 @@  set_debug_level (enum debug_info_type ty
       opts_set->x_write_symbols = type;
     }
 
-  /* A debug flag without a level defaults to level 2.  */
+  /* A debug flag without a level defaults to level 2.
+     If off or at level 1, set it to level 2, but if already
+     at level 3, don't lower it.  */ 
   if (*arg == '\0')
     {
-      if (!opts->x_debug_info_level)
+      if (opts->x_debug_info_level < DINFO_LEVEL_NORMAL)
 	opts->x_debug_info_level = DINFO_LEVEL_NORMAL;
     }
   else