This is sources Bugzilla
Bugzilla Version 2.17.5
Bugzilla Bug 7927
  Finding 'main' in languages other than C/C++ Last modified: 2009-03-22 00:22:36
Bug List: First Last (This bug is not in your list)   Show list      Query page      Enter new bug
Bug#: 7927   Hardware:   Reporter: E. Zannoni <ezannoni@redhat.com>
Host: Target: Build:
Product:     Add CC:
Component:   Version:   CC:
Remove selected CCs
Status: ASSIGNED   Priority:  
Resolution:   Severity:  
Assigned To: Not yet assigned to anyone <unassigned@sourceware.org>   Target Milestone:  
Summary:
Keywords:

Attachment Description Type Created Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 7927 depends on: Show dependency tree
Show dependency graph
Bug 7927 blocks:

Additional Comments:


Leave as ASSIGNED 
Mark bug as waiting for feedback
Mark bug as suspended
Resolve bug, changing resolution to
Resolve bug, mark it as duplicate of bug #
Reassign bug to
Reassign bug to owner of selected component

View Bug Activity   |   Format For Printing


Description:   Last confirmed: 0000-00-00 00:00 Opened: 2002-11-12 15:08
[Converted from Gnats 822]

there is no mechanism in gdb to identify at startup the
entry point of the program. gdb knows only about 'main'.

Some time ago the set_main_name function was added to gdb,
to use the N_MAIN stab directive which identifies the entry
point of the program.  Dwarf doesn't really have such a 
thing, but somethng that can be used for the purpose. 
g77 doesn't emit it however.

the dwarf specs says:

"If the semantics of the language  of  the  compilation  unit
 containing   the   subroutine  entry  distinguishes  between
 ordinary subroutines and subroutines that can serve  as  the
 ``main program,'' that is, subroutines that cannot be called
 directly following the ordinary  calling  conventions,  then
 the  debugging  information  entry for such a subroutine may
 have a calling  convention  attribute  whose  value  is  the
 constant DW_CC_program.
 The  DW_CC_program value is intended to support Fortran main
 programs.  It is not intended as a way of finding the  entry
 address for the program."

I guess that Java and maybe Ada have the same problem.

Release:
unknown

How-To-Repeat:
teg@halden teg]$ cat hello.f 
       PROGRAM hello

       print *,"Hello, world!"

       END 
 [teg@halden teg]$ g77 -g hello.f -o hello
 [teg@halden teg]$ gdb hello
 GNU gdb Red Hat Linux 7.x (5.0rh-10)
 Copyright 2001 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 "i386-redhat-linux"...
 (gdb) list 
 1       init.c: No such file or directory.
         in init.c
 (gdb) b MAIN__
 Breakpoint 1 at 0x8048e96: file hello.f, line 3.
 (gdb) l
 1       in init.c
 (gdb) r
 Starting program: /home/devel/teg/hello 

 Breakpoint 1, MAIN__ () at hello.f:3
 3             print *,"Hello, world!"
 Current language:  auto; currently fortran
 (gdb) l
 1             PROGRAM hello
 2
 3             print *,"Hello, world!"
 4
 5             END 
 (gdb) The program is running.  Exit anyway? (y or n) y

------- Additional Comment #1 From E. Zannoni 2002-11-12 23:08 -------
Fix:
Elena,

I had an initial patch to set the main function in Fortran programs to "MAIN__".  Although it can't resolve this totally.  But it at least could let gdb recognize that the language is Fortran after just loading the fortran code.   Would you like to have a look?  I am very happy to get any comments from you on this?  Thanks.  Here is the link to the original patch:  http://sources.redhat.com/ml/gdb-patches/2005-07/msg00220.html

------- Additional Comment #2 From Tom Tromey 2009-03-22 00:22 -------
*** Bug 8257 has been marked as a duplicate of this bug. ***

------- Additional Comment #3 From Tom Tromey 2009-03-22 00:22 -------
*** Bug 8672 has been marked as a duplicate of this bug. ***

Bug List: First Last (This bug is not in your list)   Show list      Query page      Enter new bug
Actions: New | Query | bug # | Reports | Requests   New Account | Log In