This is the mail archive of the
gdb-prs@sources.redhat.com
mailing list for the GDB project.
gdb/822: Finding 'main' in languages other than C/C++
- From: ezannoni at redhat dot com
- To: gdb-gnats at sources dot redhat dot com
- Date: 12 Nov 2002 22:59:47 -0000
- Subject: gdb/822: Finding 'main' in languages other than C/C++
- Reply-to: ezannoni at redhat dot com
>Number: 822
>Category: gdb
>Synopsis: Finding 'main' in languages other than C/C++
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Nov 12 15:08:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: ezannoni@redhat.com
>Release: unknown-1.0
>Organization:
>Environment:
>Description:
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.
>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
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: