* [RFC]: set the main function in Fortran programs to "MAIN__"
@ 2005-07-28 5:23 Wu Zhou
2005-07-28 12:57 ` Daniel Jacobowitz
0 siblings, 1 reply; 2+ messages in thread
From: Wu Zhou @ 2005-07-28 5:23 UTC (permalink / raw)
To: gdb-patches; +Cc: drow
Daniel,
Although the proper way of adding case insensitivity to symbol lookup is
still under discussion, I think it might be desirable to set the main
function of Fortran programs to "MAIN__" first. Because it can at least
let GDB recognize that the language is Fortran after loading a Fortran
executable only. What is your idea on this? Please comments. TIA!
Here is the patch to set the main function in Fortran programs to
"MAIN__". And followed is a patch to verify this. Tested with g77 and
gfortran on x86, and g77 on ppc64. With the first patch, it reported
PASS; without, report FAIL. No regression is found in gdb.fortran
testcases.
P.S: if there is a symbol named "MAIN__" in sources of other languages, it
might disturb the debugging. But I am not sure how much it is.
Index: gdb/symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.145
diff -c -p -r1.145 symtab.c
*** gdb/symtab.c 8 Mar 2005 04:34:44 -0000 1.145
--- gdb/symtab.c 28 Jul 2005 03:16:48 -0000
*************** find_main_name (void)
*** 4125,4132 ****
}
/* The languages above didn't identify the name of the main procedure.
! Fallback to "main". */
! set_main_name ("main");
}
char *
--- 4125,4136 ----
}
/* The languages above didn't identify the name of the main procedure.
! Fallback to "MAIN__" (g77 and gfortran) if we can find it in the
! minimal symtab, to "main" otherwise. */
! if (lookup_minimal_symbol ("MAIN__", NULL, NULL))
! set_main_name ("MAIN__");
! else
! set_main_name ("main");
}
char *
Testcase lang.exp to verify the above patch:
===========================================================
*** /dev/null Mon Jul 25 13:51:17 2005
--- gdb/testsuite/gdb.fortran/lang.exp Mon Jul 25 06:50:20 2005
***************
*** 0 ****
--- 1,40 ----
+ # Copyright 2005 Free Software Foundation, Inc.
+
+ # This program is free software; you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License as published by
+ # the Free Software Foundation; either version 2 of the License, or
+ # (at your option) any later version.
+ #
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ # GNU General Public License for more details.
+ #
+ # You should have received a copy of the GNU General Public License
+ # along with this program; if not, write to the Free Software
+ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ # This file was written by Wu Zhou. (woodzltc@cn.ibm.com)
+
+ # This file is part of the gdb testsuite. It is intended to test that gdb
+ # could recognize the Fortran language after loading the binary
+
+ if $tracelevel then {
+ strace $tracelevel
+ }
+
+ set testfile "array-element"
+ set srcfile ${srcdir}/${subdir}/${testfile}.f
+ set binfile ${objdir}/${subdir}/${testfile}
+
+ if { [gdb_compile "${srcfile}" "${binfile}" executable {debug f77}] != "" } {
+ untested "Couldn't compile ${srcfile}"
+ return -1
+ }
+
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+ gdb_load ${binfile}
+
+ gdb_test "show language" ".*currently fortran.*" "show language(fortran)"
Regards
- Wu Zhou
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [RFC]: set the main function in Fortran programs to "MAIN__"
2005-07-28 5:23 [RFC]: set the main function in Fortran programs to "MAIN__" Wu Zhou
@ 2005-07-28 12:57 ` Daniel Jacobowitz
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Jacobowitz @ 2005-07-28 12:57 UTC (permalink / raw)
To: Wu Zhou; +Cc: gdb-patches, Elena Zannoni
On Thu, Jul 28, 2005 at 07:41:56AM +0800, Wu Zhou wrote:
> Daniel,
>
> Although the proper way of adding case insensitivity to symbol lookup is
> still under discussion, I think it might be desirable to set the main
> function of Fortran programs to "MAIN__" first. Because it can at least
> let GDB recognize that the language is Fortran after loading a Fortran
> executable only. What is your idea on this? Please comments. TIA!
>
> Here is the patch to set the main function in Fortran programs to
> "MAIN__". And followed is a patch to verify this. Tested with g77 and
> gfortran on x86, and g77 on ppc64. With the first patch, it reported
> PASS; without, report FAIL. No regression is found in gdb.fortran
> testcases.
>
> P.S: if there is a symbol named "MAIN__" in sources of other languages, it
> might disturb the debugging. But I am not sure how much it is.
I have no fundamental objection to this patch, although it is adding to
a bit of a hack already present for Ada - the same reasons that made
this acceptable to Ada make it acceptable for Fortran, I think. Elena,
is this OK, with proper ChangeLog?
> Index: gdb/symtab.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/symtab.c,v
> retrieving revision 1.145
> diff -c -p -r1.145 symtab.c
> *** gdb/symtab.c 8 Mar 2005 04:34:44 -0000 1.145
> --- gdb/symtab.c 28 Jul 2005 03:16:48 -0000
> *************** find_main_name (void)
> *** 4125,4132 ****
> }
>
> /* The languages above didn't identify the name of the main procedure.
> ! Fallback to "main". */
> ! set_main_name ("main");
> }
>
> char *
> --- 4125,4136 ----
> }
>
> /* The languages above didn't identify the name of the main procedure.
> ! Fallback to "MAIN__" (g77 and gfortran) if we can find it in the
> ! minimal symtab, to "main" otherwise. */
> ! if (lookup_minimal_symbol ("MAIN__", NULL, NULL))
> ! set_main_name ("MAIN__");
> ! else
> ! set_main_name ("main");
> }
>
> char *
>
> Testcase lang.exp to verify the above patch:
> ===========================================================
> *** /dev/null Mon Jul 25 13:51:17 2005
> --- gdb/testsuite/gdb.fortran/lang.exp Mon Jul 25 06:50:20 2005
> ***************
> *** 0 ****
> --- 1,40 ----
> + # Copyright 2005 Free Software Foundation, Inc.
> +
> + # This program is free software; you can redistribute it and/or modify
> + # it under the terms of the GNU General Public License as published by
> + # the Free Software Foundation; either version 2 of the License, or
> + # (at your option) any later version.
> + #
> + # This program is distributed in the hope that it will be useful,
> + # but WITHOUT ANY WARRANTY; without even the implied warranty of
> + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + # GNU General Public License for more details.
> + #
> + # You should have received a copy of the GNU General Public License
> + # along with this program; if not, write to the Free Software
> + # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
> +
> + # This file was written by Wu Zhou. (woodzltc@cn.ibm.com)
> +
> + # This file is part of the gdb testsuite. It is intended to test that gdb
> + # could recognize the Fortran language after loading the binary
> +
> + if $tracelevel then {
> + strace $tracelevel
> + }
> +
> + set testfile "array-element"
> + set srcfile ${srcdir}/${subdir}/${testfile}.f
> + set binfile ${objdir}/${subdir}/${testfile}
> +
> + if { [gdb_compile "${srcfile}" "${binfile}" executable {debug f77}] != "" } {
> + untested "Couldn't compile ${srcfile}"
> + return -1
> + }
> +
> + gdb_exit
> + gdb_start
> + gdb_reinitialize_dir $srcdir/$subdir
> + gdb_load ${binfile}
> +
> + gdb_test "show language" ".*currently fortran.*" "show language(fortran)"
>
>
> Regards
> - Wu Zhou
>
--
Daniel Jacobowitz
CodeSourcery, LLC
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-07-28 12:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-28 5:23 [RFC]: set the main function in Fortran programs to "MAIN__" Wu Zhou
2005-07-28 12:57 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox