Bug 10220 - attribute DW_AT_calling_convention not correct for fortran
Summary: attribute DW_AT_calling_convention not correct for fortran
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Francois-Xavier Coudert
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: patch, wrong-debug
Depends on:
Blocks: 24546
  Show dependency treegraph
 
Reported: 2003-03-26 11:16 UTC by sana
Modified: 2007-11-04 14:46 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-10-25 16:06:49


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description sana 2003-03-26 11:16:00 UTC
Fortran compiler (f77) does not emit attribute DW_AT_calling_convention with value DW_CC_program for fortran main subprogram (with name MAIN__).

As result there are problems with setting of breakpoints in the start of debugging:
GNU gdb 5.3
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
(gdb) b 15
No line 15 in file "init.c".
(gdb) 

The reason of it is absence of debug information for file, which contains 'main'. That is why GDB tries to use debug information form file crt1.o and reports about file init.c.

Problem is the same when other debug format is used.

Besides there are no information about original name of main fortran subprogram at all

(gdb) b bcommon
Function "bcommon" not defined.
(gdb) q
 
Debug information is 

 <1><84>: Abbrev Number: 2 (DW_TAG_subprogram)
     DW_AT_sibling     : <190>  
     DW_AT_external    : 1      
     DW_AT_name        : MAIN__ 
     DW_AT_decl_file   : 1      
     DW_AT_decl_line   : 2      
     DW_AT_low_pc      : 0x8048e90 134516368    
     DW_AT_high_pc     : 0x8048fc0 134516672    
     DW_AT_frame_base  : 1 byte block: 55       (DW_OP_reg5)

Release:
unknown

Environment:
f77 on RH7.2,RH8.0

How-To-Repeat:

Test is other fortran test.
For example
c This routine tests blank common blocks
      program bcommon
      integer fun
      common ivo1,ivo2,ivo3
      common /a/a1(3)
      data a1/4,5,6/
      ivo1 = 0
      ivo2 = 1
      ivo3 = 2
      call sub1
      print *,ivo1,ivo2,ivo3
      print *,a1
      m=fun()
      print *,ivo1,ivo2,ivo3
      end
      subroutine sub1
      common ivo4,ivo5,ivo6
      ivo4=ivo4+1
      ivo5=ivo5+1
      ivo6=ivo6+1
      print *,ivo4,ivo5,ivo6
      end

      integer function fun()
      common ivo7,ivo8,ivo9
      common /a/b(3)
      ivo7=ivo7+b(1)
      ivo8=ivo8+b(2)
      ivo9=ivo9+b(3)
      fun=ivo8
      return
      end
Comment 1 Andrew Pinski 2003-08-07 17:58:24 UTC
I can confirm this on the mainline.
Comment 2 Andrew Pinski 2004-03-12 06:50:55 UTC
I think this is also true on the tree-ssa with gfortran too.
Comment 3 Francois-Xavier Coudert 2007-07-28 21:01:58 UTC
There's a thread about it starting at http://gcc.gnu.org/ml/gcc-patches/2005-11/msg01501.html and with a summary of the consensus at http://gcc.gnu.org/ml/gcc-patches/2005-11/msg01572.html (although no further action was actually taken).
Comment 4 Francois-Xavier Coudert 2007-10-25 16:06:49 UTC
Apparently, it has been decided that DW_AT_calling_convention should be set to DW_CC_program, because it's already done by other compilers (IBM, Sun, Intel):
http://www.sourceware.org/ml/gdb/2007-10/msg00205.html

Maybe that's not the ultimate Right Thing to do, but it sounds like the way to go for now.
Comment 5 Francois-Xavier Coudert 2007-11-04 14:44:00 UTC
Subject: Bug 10220

Author: fxcoudert
Date: Sun Nov  4 14:43:45 2007
New Revision: 129882

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129882
Log:
	PR fortran/10220
	* dwarf2out.c (add_calling_convention_attribute): Change
	second argument. Set calling convention to DW_CC_program for
	Fortran main program.
	(gen_subprogram_die): Adjust to new prototype for
	add_calling_convention_attribute.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/dwarf2out.c

Comment 6 Francois-Xavier Coudert 2007-11-04 14:46:24 UTC
Fixed.