* [Bug java/1427] gcj should generate N_MAIN stab or DW_AT_entry_point dwarf2 debug info
[not found] <bug-1427-360@http.gcc.gnu.org/bugzilla/>
@ 2005-11-15 3:04 ` woodzltc at sources dot redhat dot com
2006-10-14 14:17 ` steven at gcc dot gnu dot org
2006-10-17 2:40 ` [Bug java/1427] gcc should allow gcj and gfortran to " drow at false dot org
2 siblings, 0 replies; 3+ messages in thread
From: woodzltc at sources dot redhat dot com @ 2005-11-15 3:04 UTC (permalink / raw)
To: java-prs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1866 bytes --]
------- Comment #18 from woodzltc at sources dot redhat dot com 2005-11-15 03:04 -------
Hi Andrew,
(In reply to comment #8)
> Dwarf2 has DW_AT_entry_point for the same thing as the stabs N_MAIN.
I am now believing that DW_CC_program is for this purpose in DWARF. Please
have a look at the following two excerpted paragraphs in section 3.3.1 of DWARF
standard:
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.
==== End of the excerpt ====
Although it is intended to support Fortran main programs. But I think that it
might also be ok for java as well.
If my understanding is right, I think the fix is not that hard (at least for
gfortran). Here is my thought: when gfortran trying to emit symbol MAIN__, we
can add an extra attribute DW_AT_calling_convention and set it to
DW_CC_program. Then in gdb's dwarf2reader, we can add a routine to find out
the symbol whose DW_AT_calling_convention is DW_CC_program, and set it to the
main function.
I am not familar with the gfortran code, if anyone could code the above patch
in gfortran's side, I could try to code in the gdb's side. But if anyone is
willing to point out where to emit DWARF debuginfo for MAIN__ in gfortran's
source, I am very happy to have a try in gfortran.
For java, the process might be the same.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=1427
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug java/1427] gcj should generate N_MAIN stab or DW_AT_entry_point dwarf2 debug info
[not found] <bug-1427-360@http.gcc.gnu.org/bugzilla/>
2005-11-15 3:04 ` [Bug java/1427] gcj should generate N_MAIN stab or DW_AT_entry_point dwarf2 debug info woodzltc at sources dot redhat dot com
@ 2006-10-14 14:17 ` steven at gcc dot gnu dot org
2006-10-17 2:40 ` [Bug java/1427] gcc should allow gcj and gfortran to " drow at false dot org
2 siblings, 0 replies; 3+ messages in thread
From: steven at gcc dot gnu dot org @ 2006-10-14 14:17 UTC (permalink / raw)
To: java-prs
------- Comment #19 from steven at gcc dot gnu dot org 2006-10-14 14:17 -------
Someone should make gdb understand the DW_AT_calling_convention attribute.
This is the bit necessary to make it work for Fortran. I considered stealing a
bit on FUNCTION_DECL to mark it as the main program but it seems to me that
this hard-coded solution should be acceptable as well (but, your thoughts?).
Index: dwarf2out.c
===================================================================
--- dwarf2out.c (revision 117672)
+++ dwarf2out.c (working copy)
@@ -11105,11 +11105,18 @@ add_calling_convention_attribute (dw_die
{
enum dwarf_calling_convention value = DW_CC_normal;
- value = targetm.dwarf_calling_convention (type);
+ if (is_fortran ())
+ {
+ /* The subroutine named MAIN__ is the main program for Fortran. */
+ const char *subroutine_name = get_AT_string (subr_die, DW_AT_name);
+ if (strcmp (subroutine_name, "MAIN__") == 0)
+ value = DW_CC_program;
+ }
+ else
+ value = targetm.dwarf_calling_convention (type);
- /* Only add the attribute if the backend requests it, and
- is not DW_CC_normal. */
- if (value && (value != DW_CC_normal))
+ /* Only add the attribute if it is not DW_CC_normal. */
+ if (value != DW_CC_normal)
add_AT_unsigned (subr_die, DW_AT_calling_convention, value);
}
--
steven at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |steven at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=1427
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug java/1427] gcc should allow gcj and gfortran to generate N_MAIN stab or DW_AT_entry_point dwarf2 debug info
[not found] <bug-1427-360@http.gcc.gnu.org/bugzilla/>
2005-11-15 3:04 ` [Bug java/1427] gcj should generate N_MAIN stab or DW_AT_entry_point dwarf2 debug info woodzltc at sources dot redhat dot com
2006-10-14 14:17 ` steven at gcc dot gnu dot org
@ 2006-10-17 2:40 ` drow at false dot org
2 siblings, 0 replies; 3+ messages in thread
From: drow at false dot org @ 2006-10-17 2:40 UTC (permalink / raw)
To: java-prs
------- Comment #20 from drow at gcc dot gnu dot org 2006-10-17 02:40 -------
Subject: Re: gcj should generate N_MAIN stab or DW_AT_entry_point dwarf2
debug info
On Sat, Oct 14, 2006 at 02:17:32PM -0000, steven at gcc dot gnu dot org wrote:
> Someone should make gdb understand the DW_AT_calling_convention attribute.
> This is the bit necessary to make it work for Fortran. I considered stealing a
> bit on FUNCTION_DECL to mark it as the main program but it seems to me that
> this hard-coded solution should be acceptable as well (but, your thoughts?).
I don't remember the discussion entirely, and can't find it now, but I
thought that the conclusion was that DW_AT_calling_convention was not
appropriate for this purpose? In gfortran, main-ness doesn't affect
whether the function can be called or not, or how to call it, I don't
think.
Compare to DW_CC_GNU_renesas_sh, indicating a different ABI. A flag
for i386 regparm could also go here.
I guess the language in the standard allows this usage, but it would
make it impossible to mark a main routine as obeying a particular ABI.
Ah, here:
http://dwarf.freestandards.org/ShowIssue.php?issue=050808.2&type=closed
Maybe someone out to poke the committee again.
> - value = targetm.dwarf_calling_convention (type);
> + if (is_fortran ())
> + {
> + /* The subroutine named MAIN__ is the main program for Fortran. */
> + const char *subroutine_name = get_AT_string (subr_die, DW_AT_name);
> + if (strcmp (subroutine_name, "MAIN__") == 0)
> + value = DW_CC_program;
> + }
> + else
> + value = targetm.dwarf_calling_convention (type);
Probably ought to call the target hook in the fortran case
eventually...
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=1427
^ permalink raw reply [flat|nested] 3+ messages in thread