[Dwarf-discuss] DWARF Issue 050808.2&body=Re: <ahref=http://dwarf.freestandards.org/ShowIssue.php

Jim Blandy jimb
Thu Feb 23 20:53:05 GMT 2006


On 2/23/06, Daniel Berlin <dberlin at dberlin.org> wrote:
> Most C compiler assume the main function to be "main".  Other
> languages might have different names, or even allow it to have
> any name.  If we have an entry to tell what is the main function
> in a program, it will let the debugger to present this to users
> in an intelligent way.  Another debug-info format stabs could
> support this with N_MAIN stab type.
>
>
> Proposal:
>
> I propose we modify the definition of the DW_TAG_entry_point tag definition to state
> that it is also usable for specifying the main entry point to a program,
> not just fortran alternate entry points.
>
> In order to determine which of the DW_TAG_entry_point is the single main entry point to the program,
>  a flag attribute DW_AT_is_main(or something suitably named) should be added to the allowed attributes for DW_TAG_entry_point.

I think reusing tags this way is not a great idea.

In Fortran, an entry point is a very specific language feature that
one can attach to a subprogram.  "An ENTRY statement establishes an
alternate entry point for an external subprogram or a module
subprogram," says one language reference I found on the web
<http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=/com.ibm.xlf101l.doc/xlflr/entry.htm>
 So DW_TAG_entry_point in Dwarf describes an "ENTRY" statement in
Fortran, just as DW_TAG_try_block describes a "try" block in Java.

When similar features occur in languages, I think it makes very good
sense to use the same Dwarf tag to describe them all.  It's nice to
use DW_TAG_subprogram for both C functions and Pascal procedures and
functions, for example.

But it seems to me that Fortran subprogram entry points and the 'main
function' of an overall executable are not sufficiently analogous to
merit this kind of reuse.  The fact that it might be necessary to have
an attribute saying which sort of use is at hand reinforces my
misgivings.

Also --- in Java, if I remember correctly, it's not clear when you
compile a class whether that class is going to be the program's entry
point or not.  You need to pass a '--main=CLASSNAME' option to GCJ,
for example, to say that the 'main' method of the class named CLASS
will be the program's entry point.  So the compiler can't emit a
DW_TAG_entry_point child of the 'main' method as required by the
proposal, since the entry point hasn't been chosen yet.

I'd prefer adding a new attribute, DW_AT_program_entry_point, whose
value would be a reference to the die representing the program's main
function.  This would be an attribute of some DW_TAG_compile_unit die.
 It wouldn't necessarily need to refer to a die in that compilation
unit, so gcj could emit a dummy Dwarf compilation unit just to contain
the DW_AT_program_entry_point attribute at link time.

I'm shaky on the linking procedure for Java, so corrections and
clarifications are welcome, as always.



More information about the Dwarf-discuss mailing list