* [RFC] Use DW_CC_program to indicate Fortran main subroutine
@ 2005-11-21 7:28 Wu Zhou
2005-11-21 14:14 ` Daniel Jacobowitz
0 siblings, 1 reply; 10+ messages in thread
From: Wu Zhou @ 2005-11-21 7:28 UTC (permalink / raw)
To: gcc-patches, gdb-patches; +Cc: drow, pinskia
Hello GCC and GDB maintainers,
We ever discussed about how to indicate the main subroutine of fortran
and java code with DWARF info (GCC PR 23280, 1427 and 10220; GDB PR 822).
My point is that DW_CC_program might be the final solution. Here is what
DWARF standard said about this:
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 according to 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.
Following this, I am doing some experiment with both gfortran and gdb. And
I found it does works. The problems stated in GDB PR 822, GCC 10220 are
all gone. So I think this might be the proper way. And I post my patches
here for review. Any comments and suggestion are highly appreciated.
Below is the patch to gcc-4.0.2. I think this method might also work well
with gcj, but I am not sure.
2005-11-21 Wu Zhou <woodzltc@cn.ibm.com>
* dwarf2out.c (add_calling_convention_attribute): If the function
name is MAIN__, add a DW_AT_calling_convention attribute with the
value being DW_CC_program.
--- dwarf2out.c.orig 2005-11-21 17:37:34.000000000 +0800
+++ dwarf2out.c 2005-11-21 17:37:53.000000000 +0800
@@ -10755,6 +10755,13 @@ add_calling_convention_attribute (dw_die
value = targetm.dwarf_calling_convention (type);
+ /* DWARF standard suggests to use DW_CC_program value to indicate Fortran
+ main programs. Do this when we find the name is 'MAIN__'.
+ FIXME: Maybe it is better to do this in other way. But I don't figure
+ out the better way yet. */
+ if (!strncmp (get_AT_string (subr_die, DW_AT_name), "MAIN__", 6))
+ add_AT_unsigned (subr_die, DW_AT_calling_convention, DW_CC_program);
+
/* Only add the attribute if the backend requests it, and
is not DW_CC_normal. */
if (value && (value != DW_CC_normal))
This is the patch to gdb mainline source. I ever thought of adding these
code into read_subroutine_type, but it seems that is too late for setting
main name. So I am now adding them into read_partial_die.
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.184.2.2
diff -u -p -r1.184.2.2 dwarf2read.c
--- dwarf2read.c 4 Nov 2005 02:58:31 -0000 1.184.2.2
+++ dwarf2read.c 21 Nov 2005 04:11:35 -0000
@@ -5432,6 +5432,13 @@ read_partial_die (struct partial_die_inf
part_die->has_stmt_list = 1;
part_die->line_offset = DW_UNSND (&attr);
break;
+ case DW_AT_calling_convention:
+ /* DWARF standard suggests to use value DW_CC_program of attribute
+ DW_AT_calling_convention to indicate the Fortran main program.
+ The following code is to check this. */
+ if (DW_UNSND (&attr) == DW_CC_program)
+ set_main_name (part_die->name);
+ break;
default:
break;
}
Regards
- Wu Zhou
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC] Use DW_CC_program to indicate Fortran main subroutine
2005-11-21 7:28 [RFC] Use DW_CC_program to indicate Fortran main subroutine Wu Zhou
@ 2005-11-21 14:14 ` Daniel Jacobowitz
2005-11-21 14:58 ` Jim Blandy
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Daniel Jacobowitz @ 2005-11-21 14:14 UTC (permalink / raw)
To: Wu Zhou; +Cc: gcc-patches, gdb-patches, pinskia
On Mon, Nov 21, 2005 at 12:44:33PM +0800, Wu Zhou wrote:
> Hello GCC and GDB maintainers,
>
> We ever discussed about how to indicate the main subroutine of fortran
> and java code with DWARF info (GCC PR 23280, 1427 and 10220; GDB PR 822).
> My point is that DW_CC_program might be the final solution. Here is what
> DWARF standard said about this:
>
> 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 according to 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.
The compiler patch I can't comment on...
As for calling set_main_name, I don't know if this is right or not. I
guess it depends what the DWARF folks meant by "not intended as a way
of finding the entry address for the program". Can a Fortran binary
have more than one "main program"?
If they only meant "it does not indicate the address you can jump to in
order to start", then this seems quite reasonable.
If that's the case then it should work for gcj too. You'll have a
function named main, with no special debug info, and also a function
with DW_CC_program at the real entry point.
--
Daniel Jacobowitz
CodeSourcery, LLC
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC] Use DW_CC_program to indicate Fortran main subroutine
2005-11-21 14:14 ` Daniel Jacobowitz
@ 2005-11-21 14:58 ` Jim Blandy
2005-11-21 16:37 ` Daniel Berlin
2005-11-21 18:10 ` Daniel Berlin
2005-11-21 22:02 ` Jason Merrill
2 siblings, 1 reply; 10+ messages in thread
From: Jim Blandy @ 2005-11-21 14:58 UTC (permalink / raw)
To: Wu Zhou, gcc-patches, gdb-patches, pinskia
I don't want to stand in the way of solving the Java and Fortran "find
the main program" problems, but when you look at the description of
DW_AT_calling_convention, it seems to me like that attribute is more
concerned with telling you how to assemble arguments to pass to the
function, and not so much with describing the overall structure of the
executable.
I don't see any other attribute that is more appropriate.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC] Use DW_CC_program to indicate Fortran main subroutine
2005-11-21 14:58 ` Jim Blandy
@ 2005-11-21 16:37 ` Daniel Berlin
0 siblings, 0 replies; 10+ messages in thread
From: Daniel Berlin @ 2005-11-21 16:37 UTC (permalink / raw)
To: Jim Blandy; +Cc: Wu Zhou, gcc-patches, gdb-patches, pinskia
On Sun, 2005-11-20 at 23:28 -0800, Jim Blandy wrote:
> I don't want to stand in the way of solving the Java and Fortran "find
> the main program" problems, but when you look at the description of
> DW_AT_calling_convention, it seems to me like that attribute is more
> concerned with telling you how to assemble arguments to pass to the
> function, and not so much with describing the overall structure of the
> executable.
Exactly.
>
> I don't see any other attribute that is more appropriate.
Hence, we should make one, as we've done in other cases.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC] Use DW_CC_program to indicate Fortran main subroutine
2005-11-21 14:14 ` Daniel Jacobowitz
2005-11-21 14:58 ` Jim Blandy
@ 2005-11-21 18:10 ` Daniel Berlin
2005-11-21 22:02 ` Jason Merrill
2 siblings, 0 replies; 10+ messages in thread
From: Daniel Berlin @ 2005-11-21 18:10 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Wu Zhou, gcc-patches, gdb-patches, pinskia
On Mon, 2005-11-21 at 00:10 -0500, Daniel Jacobowitz wrote:
> On Mon, Nov 21, 2005 at 12:44:33PM +0800, Wu Zhou wrote:
> > Hello GCC and GDB maintainers,
> >
> > We ever discussed about how to indicate the main subroutine of fortran
> > and java code with DWARF info (GCC PR 23280, 1427 and 10220; GDB PR 822).
> > My point is that DW_CC_program might be the final solution. Here is what
> > DWARF standard said about this:
> >
> > 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 according to 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.
>
> The compiler patch I can't comment on...
>
> As for calling set_main_name, I don't know if this is right or not. I
> guess it depends what the DWARF folks meant by "not intended as a way
> of finding the entry address for the program".
It means it wasn't intended to be reused for this purpose, AFAIK.
:)
> Can a Fortran binary
> have more than one "main program"?
>
> If they only meant "it does not indicate the address you can jump to in
> order to start", then this seems quite reasonable.
>
> If that's the case then it should work for gcj too. You'll have a
> function named main, with no special debug info, and also a function
> with DW_CC_program at the real entry point.
I remember asking Wu to file an issue with the dwarf working group, and
that issue was resolved by deferring to DWARF 4 for now.
See
http://dwarf.freestandards.org/ShowIssue.php?issue=050808.2&type=closed
For now, why don't we just add a new vendor attribute?
DW_AT_GNU_main
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC] Use DW_CC_program to indicate Fortran main subroutine
2005-11-21 14:14 ` Daniel Jacobowitz
2005-11-21 14:58 ` Jim Blandy
2005-11-21 18:10 ` Daniel Berlin
@ 2005-11-21 22:02 ` Jason Merrill
2005-11-21 22:03 ` Daniel Jacobowitz
2 siblings, 1 reply; 10+ messages in thread
From: Jason Merrill @ 2005-11-21 22:02 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Wu Zhou, gcc-patches, gdb-patches, pinskia
Daniel Jacobowitz wrote:
> As for calling set_main_name, I don't know if this is right or not. I
> guess it depends what the DWARF folks meant by "not intended as a way
> of finding the entry address for the program". Can a Fortran binary
> have more than one "main program"?
>
> If they only meant "it does not indicate the address you can jump to in
> order to start", then this seems quite reasonable.
This makes sense to me. The "entry address" sounds like _start, not main.
It does seem a bit odd to put this under the calling convention
attribute, though, as the main function might be callable using the
normal calling convention in some languages. Java, for instance.
Jason
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC] Use DW_CC_program to indicate Fortran main subroutine
2005-11-21 22:02 ` Jason Merrill
@ 2005-11-21 22:03 ` Daniel Jacobowitz
2005-11-22 8:15 ` Wu Zhou
0 siblings, 1 reply; 10+ messages in thread
From: Daniel Jacobowitz @ 2005-11-21 22:03 UTC (permalink / raw)
To: Jason Merrill; +Cc: Wu Zhou, gcc-patches, gdb-patches, pinskia
On Mon, Nov 21, 2005 at 11:34:15AM -0500, Jason Merrill wrote:
> Daniel Jacobowitz wrote:
> >As for calling set_main_name, I don't know if this is right or not. I
> >guess it depends what the DWARF folks meant by "not intended as a way
> >of finding the entry address for the program". Can a Fortran binary
> >have more than one "main program"?
> >
> >If they only meant "it does not indicate the address you can jump to in
> >order to start", then this seems quite reasonable.
>
> This makes sense to me. The "entry address" sounds like _start, not main.
>
> It does seem a bit odd to put this under the calling convention
> attribute, though, as the main function might be callable using the
> normal calling convention in some languages. Java, for instance.
Right - and it might not be, e.g. DW_CC_GNU_renesas_sh. I think Dan's
got the right idea; we should just make up a tag for this, and submit
it for dwarf4.
--
Daniel Jacobowitz
CodeSourcery, LLC
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC] Use DW_CC_program to indicate Fortran main subroutine
2005-11-21 22:03 ` Daniel Jacobowitz
@ 2005-11-22 8:15 ` Wu Zhou
2006-02-20 17:22 ` Daniel Jacobowitz
0 siblings, 1 reply; 10+ messages in thread
From: Wu Zhou @ 2005-11-22 8:15 UTC (permalink / raw)
To: Daniel Jacobowitz
Cc: Jason Merrill, gcc-patches, gdb-patches, pinskia, dberlin, jimb
Hi,
Thank you all for your kind input. I had a look at all your comments. It
seems that no one is 100% convinced that DW_CC_program is the proper
solution. In fact I am also a little odd about the usage of DW_CC_program
to indicate the main function. But the text in DWARF 3.3.1 really induce
me to think that it is currently the only feasible solution.
Now that most of you concur to make up a new attribute or tag for this. I
think it is more correct too. Maybe it is time for us to discuss the
detail of this new tag or attribute?
My vote is to use a new attribute Dan Berlin proposed: DW_AT_GNU_main. We
can use it in GNU toolchain first, gcc, gdb, binutils and so on. If the
DWARF committee can reach agreement on the final name, we can switch to
it then. What is your point on this? Thanks.
Regards
- Wu Zhou
On Mon, 21 Nov 2005, Daniel Jacobowitz wrote:
> On Mon, Nov 21, 2005 at 11:34:15AM -0500, Jason Merrill wrote:
> > Daniel Jacobowitz wrote:
> > >As for calling set_main_name, I don't know if this is right or not. I
> > >guess it depends what the DWARF folks meant by "not intended as a way
> > >of finding the entry address for the program". Can a Fortran binary
> > >have more than one "main program"?
> > >
> > >If they only meant "it does not indicate the address you can jump to in
> > >order to start", then this seems quite reasonable.
> >
> > This makes sense to me. The "entry address" sounds like _start, not main.
> >
> > It does seem a bit odd to put this under the calling convention
> > attribute, though, as the main function might be callable using the
> > normal calling convention in some languages. Java, for instance.
>
> Right - and it might not be, e.g. DW_CC_GNU_renesas_sh. I think Dan's
> got the right idea; we should just make up a tag for this, and submit
> it for dwarf4.
>
> --
> Daniel Jacobowitz
> CodeSourcery, LLC
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC] Use DW_CC_program to indicate Fortran main subroutine
2005-11-22 8:15 ` Wu Zhou
@ 2006-02-20 17:22 ` Daniel Jacobowitz
2006-02-24 4:42 ` Wu Zhou
0 siblings, 1 reply; 10+ messages in thread
From: Daniel Jacobowitz @ 2006-02-20 17:22 UTC (permalink / raw)
To: Wu Zhou; +Cc: Jason Merrill, gcc-patches, gdb-patches, pinskia, dberlin, jimb
On Tue, Nov 22, 2005 at 10:34:01AM +0800, Wu Zhou wrote:
> Hi,
>
> Thank you all for your kind input. I had a look at all your comments. It
> seems that no one is 100% convinced that DW_CC_program is the proper
> solution. In fact I am also a little odd about the usage of DW_CC_program
> to indicate the main function. But the text in DWARF 3.3.1 really induce
> me to think that it is currently the only feasible solution.
>
> Now that most of you concur to make up a new attribute or tag for this. I
> think it is more correct too. Maybe it is time for us to discuss the
> detail of this new tag or attribute?
>
> My vote is to use a new attribute Dan Berlin proposed: DW_AT_GNU_main. We
> can use it in GNU toolchain first, gcc, gdb, binutils and so on. If the
> DWARF committee can reach agreement on the final name, we can switch to
> it then. What is your point on this? Thanks.
Since we had this conversation DWARF-3 was published; did you want to
reopen this with the DWARF working group?
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC] Use DW_CC_program to indicate Fortran main subroutine
2006-02-20 17:22 ` Daniel Jacobowitz
@ 2006-02-24 4:42 ` Wu Zhou
0 siblings, 0 replies; 10+ messages in thread
From: Wu Zhou @ 2006-02-24 4:42 UTC (permalink / raw)
To: Daniel Jacobowitz
Cc: Jason Merrill, gcc-patches, gdb-patches, pinskia, dberlin, jimb
On Mon, 20 Feb 2006, Daniel Jacobowitz wrote:
> On Tue, Nov 22, 2005 at 10:34:01AM +0800, Wu Zhou wrote:
> > Hi,
> >
> > Thank you all for your kind input. I had a look at all your comments. It
> > seems that no one is 100% convinced that DW_CC_program is the proper
> > solution. In fact I am also a little odd about the usage of DW_CC_program
> > to indicate the main function. But the text in DWARF 3.3.1 really induce
> > me to think that it is currently the only feasible solution.
> >
> > Now that most of you concur to make up a new attribute or tag for this. I
> > think it is more correct too. Maybe it is time for us to discuss the
> > detail of this new tag or attribute?
> >
> > My vote is to use a new attribute Dan Berlin proposed: DW_AT_GNU_main. We
> > can use it in GNU toolchain first, gcc, gdb, binutils and so on. If the
> > DWARF committee can reach agreement on the final name, we can switch to
> > it then. What is your point on this? Thanks.
>
> Since we had this conversation DWARF-3 was published; did you want to
> reopen this with the DWARF working group?
Yes. Good point. It is time to do that. But I am not sure how to
re-open the deferred issue with the DWARF group. I just sent out a mail
to ask how. Hopefully someone can reply quickly.
BTW. Anyone have any comments about using DW_AT_GNU_main first in GNU
tools? I still like this idea. We don't need to wait for DWARF group's
decision, which might be long.
Regards
- Wu Zhou
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2006-02-24 2:34 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-21 7:28 [RFC] Use DW_CC_program to indicate Fortran main subroutine Wu Zhou
2005-11-21 14:14 ` Daniel Jacobowitz
2005-11-21 14:58 ` Jim Blandy
2005-11-21 16:37 ` Daniel Berlin
2005-11-21 18:10 ` Daniel Berlin
2005-11-21 22:02 ` Jason Merrill
2005-11-21 22:03 ` Daniel Jacobowitz
2005-11-22 8:15 ` Wu Zhou
2006-02-20 17:22 ` Daniel Jacobowitz
2006-02-24 4:42 ` Wu Zhou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox