diff mbox

Do not generate discriminator directive in strict mode

Message ID 201104191540.18889.ebotcazou@adacore.com
State New
Headers show

Commit Message

Eric Botcazou April 19, 2011, 1:40 p.m. UTC
Hi,

it appears that the (standard DWARF as of version 4) discriminator directive 
can confuse non-GDB DWARF 2/3 debuggers, so this patch changes the compiler 
to stop emitting it in strict mode.

Tested on i586-suse-linux, OK for the mainline?


2011-04-19  Eric Botcazou  <ebotcazou@adacore.com>

	* dwarf2out.c (dwarf2out_source_line): Emit "discriminator" directive
	only for version 4 or above, or else in non-strict mode.

Comments

Richard Henderson April 20, 2011, 5:50 p.m. UTC | #1
On 04/19/2011 06:40 AM, Eric Botcazou wrote:
> -      if (SUPPORTS_DISCRIMINATOR && discriminator != 0)
> +      if (SUPPORTS_DISCRIMINATOR
> +	  && discriminator != 0
> +	  && (dwarf_version >= 4 || !dwarf_strict))
>  	fprintf (asm_out_file, " discriminator %d", discriminator);

How is this not redundant with the existing

  /* The discriminator column was added in dwarf4.  Simplify the below
     by simply removing it if we're not supposed to output it.  */
  if (dwarf_version < 4 && dwarf_strict)
    discriminator = 0;

check near the top of the function?


r~
Eric Botcazou April 20, 2011, 7:09 p.m. UTC | #2
> How is this not redundant with the existing
>
>   /* The discriminator column was added in dwarf4.  Simplify the below
>      by simply removing it if we're not supposed to output it.  */
>   if (dwarf_version < 4 && dwarf_strict)
>     discriminator = 0;
>
> check near the top of the function?

Obviously I missed this recent change, sorry.  So the question is: would the 
change be appropriate for the release branches, where we emit the directive 
unconditionally, i.e 4.5 and 4.6 branches, or would mine be safer for them?  
This directive apparently confuses (some versions of) the Wind River debugger.
Richard Henderson April 20, 2011, 8:41 p.m. UTC | #3
On 04/20/2011 12:09 PM, Eric Botcazou wrote:
>> How is this not redundant with the existing
>>
>>   /* The discriminator column was added in dwarf4.  Simplify the below
>>      by simply removing it if we're not supposed to output it.  */
>>   if (dwarf_version < 4 && dwarf_strict)
>>     discriminator = 0;
>>
>> check near the top of the function?
> 
> Obviously I missed this recent change, sorry.  So the question is: would the 
> change be appropriate for the release branches, where we emit the directive 
> unconditionally, i.e 4.5 and 4.6 branches, or would mine be safer for them?

Let's try to keep the branches more similar than not.  It's just as safe, since
prior to mainline we ignore the discriminator when not emitting via gas directive.


r~
diff mbox

Patch

Index: dwarf2out.c
===================================================================
--- dwarf2out.c	(revision 172693)
+++ dwarf2out.c	(working copy)
@@ -22232,7 +22240,9 @@  dwarf2out_source_line (unsigned int line
       fprintf (asm_out_file, "\t.loc %d %d 0", file_num, line);
       if (is_stmt != table->is_stmt)
 	fprintf (asm_out_file, " is_stmt %d", is_stmt ? 1 : 0);
-      if (SUPPORTS_DISCRIMINATOR && discriminator != 0)
+      if (SUPPORTS_DISCRIMINATOR
+	  && discriminator != 0
+	  && (dwarf_version >= 4 || !dwarf_strict))
 	fprintf (asm_out_file, " discriminator %d", discriminator);
       fputc ('\n', asm_out_file);
     }