Patchwork Add DW_AT_main_subprogram tag to Fortran main program

login
register
mail settings
Submitter FX
Date Oct. 3, 2010, 8:05 p.m.
Message ID <B6EA0D6B-87C2-4E49-9A93-D831248FB27C@gmail.com>
Download mbox | patch
Permalink /patch/66604/
State New
Headers show

Comments

FX - Oct. 3, 2010, 8:05 p.m.
> +      add_AT_flag (subr_die, DW_AT_main_subprogram, 1);
> 
> should be guarded by
>  if (dwarf_version >= 4 || !dwarf_strict)


Updated patch below, against regtested on x86_64-linux. OK to commit?

FX






2010-10-03  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

	* dwarf2out.c (add_calling_convention_attribute): Flag main
	Fortran subroutine with DW_AT_main_subprogram.
FX - Oct. 10, 2010, 9:49 a.m.
ping


> Updated patch below, against regtested on x86_64-linux. OK to commit?
> 
> 
> 
> 2010-10-03  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
> 
> 	* dwarf2out.c (add_calling_convention_attribute): Flag main
> 	Fortran subroutine with DW_AT_main_subprogram.
> 
> 
> 
> Index: gcc/dwarf2out.c
> ===================================================================
> --- gcc/dwarf2out.c	(revision 164914)
> +++ gcc/dwarf2out.c	(working copy)
> @@ -17841,14 +17841,21 @@ add_calling_convention_attribute (dw_die
>   value = ((enum dwarf_calling_convention)
> 	   targetm.dwarf_calling_convention (TREE_TYPE (decl)));
> 
> -  /* DWARF doesn't provide a way to identify a program's source-level
> -     entry point.  DW_AT_calling_convention attributes are only meant
> -     to describe functions' calling conventions.  However, lacking a
> -     better way to signal the Fortran main program, we use this for the
> -     time being, following existing custom.  */
>   if (is_fortran ()
>       && !strcmp (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), "MAIN__"))
> -    value = DW_CC_program;
> +    {
> +      /* DWARF 2 doesn't provide a way to identify a program's source-level
> +	entry point.  DW_AT_calling_convention attributes are only meant
> +	to describe functions' calling conventions.  However, lacking a
> +	better way to signal the Fortran main program, we used this for 
> +	a long time, following existing custom.  Now, DWARF 4 has 
> +	DW_AT_main_subprogram, which we add below, but some tools still
> +	rely on the old way, which we thus keep.  */
> +      value = DW_CC_program;
> +
> +      if (dwarf_version >= 4 || !dwarf_strict)
> +	add_AT_flag (subr_die, DW_AT_main_subprogram, 1);
> +    }
> 
>   /* Only add the attribute if the backend requests it, and
>      is not DW_CC_normal.  */
>
Tobias Burnus - Oct. 18, 2010, 12:18 p.m.
On 10/10/2010 11:49 AM, FX wrote:
> ping
>
>
>> Updated patch below, against regtested on x86_64-linux. OK to commit?
>>
>>
>>
>> 2010-10-03  Francois-Xavier Coudert<fxcoudert@gcc.gnu.org>
>>
>> 	* dwarf2out.c (add_calling_convention_attribute): Flag main
>> 	Fortran subroutine with DW_AT_main_subprogram.
>>
>>
>>
>> Index: gcc/dwarf2out.c
>> ===================================================================
>> --- gcc/dwarf2out.c	(revision 164914)
>> +++ gcc/dwarf2out.c	(working copy)
>> @@ -17841,14 +17841,21 @@ add_calling_convention_attribute (dw_die
>>    value = ((enum dwarf_calling_convention)
>> 	   targetm.dwarf_calling_convention (TREE_TYPE (decl)));
>>
>> -  /* DWARF doesn't provide a way to identify a program's source-level
>> -     entry point.  DW_AT_calling_convention attributes are only meant
>> -     to describe functions' calling conventions.  However, lacking a
>> -     better way to signal the Fortran main program, we use this for the
>> -     time being, following existing custom.  */
>>    if (is_fortran ()
>>        &&  !strcmp (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), "MAIN__"))
>> -    value = DW_CC_program;
>> +    {
>> +      /* DWARF 2 doesn't provide a way to identify a program's source-level
>> +	entry point.  DW_AT_calling_convention attributes are only meant
>> +	to describe functions' calling conventions.  However, lacking a
>> +	better way to signal the Fortran main program, we used this for
>> +	a long time, following existing custom.  Now, DWARF 4 has
>> +	DW_AT_main_subprogram, which we add below, but some tools still
>> +	rely on the old way, which we thus keep.  */
>> +      value = DW_CC_program;
>> +
>> +      if (dwarf_version>= 4 || !dwarf_strict)
>> +	add_AT_flag (subr_die, DW_AT_main_subprogram, 1);
>> +    }
>>
>>    /* Only add the attribute if the backend requests it, and
>>       is not DW_CC_normal.  */
>>
>
>
FX - Oct. 18, 2010, 5:11 p.m.
I now remember someone told me to CC Jason for such patches... Please, Jason, can you review?

Thanks,
FX


Le 18 oct. 2010 à 14:18, Tobias Burnus a écrit :

> On 10/10/2010 11:49 AM, FX wrote:
>> ping
>> 
>> 
>>> Updated patch below, against regtested on x86_64-linux. OK to commit?
>>> 
>>> 
>>> 
>>> 2010-10-03  Francois-Xavier Coudert<fxcoudert@gcc.gnu.org>
>>> 
>>> 	* dwarf2out.c (add_calling_convention_attribute): Flag main
>>> 	Fortran subroutine with DW_AT_main_subprogram.
>>> 
>>> 
>>> 
>>> Index: gcc/dwarf2out.c
>>> ===================================================================
>>> --- gcc/dwarf2out.c	(revision 164914)
>>> +++ gcc/dwarf2out.c	(working copy)
>>> @@ -17841,14 +17841,21 @@ add_calling_convention_attribute (dw_die
>>>   value = ((enum dwarf_calling_convention)
>>> 	   targetm.dwarf_calling_convention (TREE_TYPE (decl)));
>>> 
>>> -  /* DWARF doesn't provide a way to identify a program's source-level
>>> -     entry point.  DW_AT_calling_convention attributes are only meant
>>> -     to describe functions' calling conventions.  However, lacking a
>>> -     better way to signal the Fortran main program, we use this for the
>>> -     time being, following existing custom.  */
>>>   if (is_fortran ()
>>>       &&  !strcmp (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), "MAIN__"))
>>> -    value = DW_CC_program;
>>> +    {
>>> +      /* DWARF 2 doesn't provide a way to identify a program's source-level
>>> +	entry point.  DW_AT_calling_convention attributes are only meant
>>> +	to describe functions' calling conventions.  However, lacking a
>>> +	better way to signal the Fortran main program, we used this for
>>> +	a long time, following existing custom.  Now, DWARF 4 has
>>> +	DW_AT_main_subprogram, which we add below, but some tools still
>>> +	rely on the old way, which we thus keep.  */
>>> +      value = DW_CC_program;
>>> +
>>> +      if (dwarf_version>= 4 || !dwarf_strict)
>>> +	add_AT_flag (subr_die, DW_AT_main_subprogram, 1);
>>> +    }
>>> 
>>>   /* Only add the attribute if the backend requests it, and
>>>      is not DW_CC_normal.  */
>>> 
>> 
>> 
>
Richard Henderson - Oct. 18, 2010, 6:16 p.m.
On 10/18/2010 10:11 AM, FX wrote:
>>>> 2010-10-03  Francois-Xavier Coudert<fxcoudert@gcc.gnu.org>
>>>>
>>>> 	* dwarf2out.c (add_calling_convention_attribute): Flag main
>>>> 	Fortran subroutine with DW_AT_main_subprogram.

Ok, with

>>>> +      if (dwarf_version>= 4 || !dwarf_strict)

Fix whitespace around >=.


r~
FX - Oct. 19, 2010, 12:31 p.m.
> Ok, with
> 
>>>>> +      if (dwarf_version>= 4 || !dwarf_strict)
> 
> Fix whitespace around >=.

Thanks, committed as rev. 165699.

FX

Patch

Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c	(revision 164914)
+++ gcc/dwarf2out.c	(working copy)
@@ -17841,14 +17841,21 @@  add_calling_convention_attribute (dw_die
   value = ((enum dwarf_calling_convention)
 	   targetm.dwarf_calling_convention (TREE_TYPE (decl)));
 
-  /* DWARF doesn't provide a way to identify a program's source-level
-     entry point.  DW_AT_calling_convention attributes are only meant
-     to describe functions' calling conventions.  However, lacking a
-     better way to signal the Fortran main program, we use this for the
-     time being, following existing custom.  */
   if (is_fortran ()
       && !strcmp (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), "MAIN__"))
-    value = DW_CC_program;
+    {
+      /* DWARF 2 doesn't provide a way to identify a program's source-level
+	entry point.  DW_AT_calling_convention attributes are only meant
+	to describe functions' calling conventions.  However, lacking a
+	better way to signal the Fortran main program, we used this for 
+	a long time, following existing custom.  Now, DWARF 4 has 
+	DW_AT_main_subprogram, which we add below, but some tools still
+	rely on the old way, which we thus keep.  */
+      value = DW_CC_program;
+
+      if (dwarf_version >= 4 || !dwarf_strict)
+	add_AT_flag (subr_die, DW_AT_main_subprogram, 1);
+    }
 
   /* Only add the attribute if the backend requests it, and
      is not DW_CC_normal.  */