public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing
@ 2020-04-24  9:44 Sharma, Alok Kumar
  2020-04-24 10:17 ` Andrew Burgess
  0 siblings, 1 reply; 14+ messages in thread
From: Sharma, Alok Kumar @ 2020-04-24  9:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: George, Jini Susan, Achra, Nitika

[-- Attachment #1: Type: text/plain, Size: 3016 bytes --]

[AMD Official Use Only - Internal Distribution Only]

Hi all,

I request you all to please review this patch. Below are the details.

Problem Description:

Name of fortran main function for Flang compiler is MAIN_ while
for gfortran it is MAIN__ . In test cases MAIN__ is hardcoded for
the purpose of inserting breakpoint.
(please note the number of underscores after MAIN) 

Resolution:

New proc is added to detect main function name depending on the
compiler used. Which is used in testcases.

This commit adds support for Flang main function, there should be
no change for gfortran.

    gdb/testsuite/ChangeLog

            * gdb.dwarf2/dw2-common-block.exp: Skip test except for gfortran,
            as assembly file to be tested is generated by gfortran.
            * lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_.
            * gdb.fortran/array-bounds-high.exp: Handle flang MAIN_
            * gdb.fortran/array-bounds.exp: Likewise.
            * gdb.fortran/array-slices.exp: Likewise.
            * gdb.fortran/block-data.exp: Likewise.
            * gdb.fortran/charset.exp: Likewise.
            * gdb.fortran/common-block.exp: Likewise.
            * gdb.fortran/complex.exp: Likewise.
            * gdb.fortran/derived-type-function.exp: Likewise.
            * gdb.fortran/derived-type.exp: Likewise.
            * gdb.fortran/info-modules.exp: Likewise.
            * gdb.fortran/info-types.exp: Likewise.
            * gdb.fortran/intrinsics.exp: Likewise.
            * gdb.fortran/library-module.exp: Likewise.
            * gdb.fortran/logical.exp: Likewise.
            * gdb.fortran/max-depth.exp: Likewise.
            * gdb.fortran/module.exp: Likewise.
            * gdb.fortran/multi-dim.exp: Likewise.
            * gdb.fortran/nested-funcs.exp: Likewise.
            * gdb.fortran/print-formatted.exp: Likewise.
            * gdb.fortran/print_type.exp: Likewise.
            * gdb.fortran/printing-types.exp: Likewise.
            * gdb.fortran/ptr-indentation.exp: Likewise.
            * gdb.fortran/ptype-on-functions.exp: Likewise.
            * gdb.fortran/subarray.exp: Likewise.
            * gdb.fortran/vla-alloc-assoc.exp: Likewise.
            * gdb.fortran/vla-datatypes.exp: Likewise.
            * gdb.fortran/vla-history.exp: Likewise.
            * gdb.fortran/vla-ptr-info.exp: Likewise.
            * gdb.fortran/vla-ptype-sub.exp: Likewise.
            * gdb.fortran/vla-ptype.exp: Likewise.
            * gdb.fortran/vla-sizeof.exp: Likewise.
            * gdb.fortran/vla-type.exp: Likewise.
            * gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
            * gdb.fortran/vla-value-sub-finish.exp: Likewise.
            * gdb.fortran/vla-value-sub.exp: Likewise.
            * gdb.fortran/vla-value.exp: Likewise.
            * gdb.fortran/whatis_type.exp: Likewise.
            * gdb.mi/mi-var-child-f.exp: Likewise.

Please let me know your comments.

Regards,
Alok

[-- Attachment #2: 0001-gdb-fortran-Allow-Flang-MAIN_-in-Fortran-testing.patch --]
[-- Type: application/octet-stream, Size: 30204 bytes --]

From 7c1667f2e074dc1e0d9a0336d9ec07da59124a72 Mon Sep 17 00:00:00 2001
From: Alok Kumar Sharma <AlokKumar.Sharma@amd.com>
Date: Fri, 24 Apr 2020 14:46:09 +0530
Subject: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing

Name of fortran main function for Flang compiler is MAIN_ while
for gfortran it is MAIN__ . In test cases MAIN__ is hardcoded for
the purpose of inserting breakpoint.

New proc is added to detect main function name depending on the
compiler used. Which is used in testcases.

This commit adds support for Flang main function, there should be
no change for gfortran.

gdb/testsuite/ChangeLog

	* gdb.dwarf2/dw2-common-block.exp: Skip test except for gfortran,
	as assembly file to be tested is generated by gfortran.
	* lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_.
	* gdb.fortran/array-bounds-high.exp: Handle flang MAIN_
	* gdb.fortran/array-bounds.exp: Likewise.
	* gdb.fortran/array-slices.exp: Likewise.
	* gdb.fortran/block-data.exp: Likewise.
	* gdb.fortran/charset.exp: Likewise.
	* gdb.fortran/common-block.exp: Likewise.
	* gdb.fortran/complex.exp: Likewise.
	* gdb.fortran/derived-type-function.exp: Likewise.
	* gdb.fortran/derived-type.exp: Likewise.
	* gdb.fortran/info-modules.exp: Likewise.
	* gdb.fortran/info-types.exp: Likewise.
	* gdb.fortran/intrinsics.exp: Likewise.
	* gdb.fortran/library-module.exp: Likewise.
	* gdb.fortran/logical.exp: Likewise.
	* gdb.fortran/max-depth.exp: Likewise.
	* gdb.fortran/module.exp: Likewise.
	* gdb.fortran/multi-dim.exp: Likewise.
	* gdb.fortran/nested-funcs.exp: Likewise.
	* gdb.fortran/print-formatted.exp: Likewise.
	* gdb.fortran/print_type.exp: Likewise.
	* gdb.fortran/printing-types.exp: Likewise.
	* gdb.fortran/ptr-indentation.exp: Likewise.
	* gdb.fortran/ptype-on-functions.exp: Likewise.
	* gdb.fortran/subarray.exp: Likewise.
	* gdb.fortran/vla-alloc-assoc.exp: Likewise.
	* gdb.fortran/vla-datatypes.exp: Likewise.
	* gdb.fortran/vla-history.exp: Likewise.
	* gdb.fortran/vla-ptr-info.exp: Likewise.
	* gdb.fortran/vla-ptype-sub.exp: Likewise.
	* gdb.fortran/vla-ptype.exp: Likewise.
	* gdb.fortran/vla-sizeof.exp: Likewise.
	* gdb.fortran/vla-type.exp: Likewise.
	* gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
	* gdb.fortran/vla-value-sub-finish.exp: Likewise.
	* gdb.fortran/vla-value-sub.exp: Likewise.
	* gdb.fortran/vla-value.exp: Likewise.
	* gdb.fortran/whatis_type.exp: Likewise.
	* gdb.mi/mi-var-child-f.exp: Likewise.

Change-Id: I0a30f5dad684879b416f71d3d08c385c159325bf
---
 gdb/testsuite/ChangeLog                       | 44 +++++++++++++++++++
 gdb/testsuite/gdb.dwarf2/dw2-common-block.exp |  6 +++
 .../gdb.fortran/array-bounds-high.exp         |  5 ++-
 gdb/testsuite/gdb.fortran/array-bounds.exp    |  5 ++-
 gdb/testsuite/gdb.fortran/array-slices.exp    |  3 +-
 gdb/testsuite/gdb.fortran/block-data.exp      |  4 +-
 gdb/testsuite/gdb.fortran/charset.exp         |  6 ++-
 gdb/testsuite/gdb.fortran/common-block.exp    |  4 +-
 gdb/testsuite/gdb.fortran/complex.exp         |  5 ++-
 .../gdb.fortran/derived-type-function.exp     |  5 ++-
 gdb/testsuite/gdb.fortran/derived-type.exp    |  4 +-
 gdb/testsuite/gdb.fortran/info-modules.exp    |  4 +-
 gdb/testsuite/gdb.fortran/info-types.exp      |  4 +-
 gdb/testsuite/gdb.fortran/intrinsics.exp      |  4 +-
 gdb/testsuite/gdb.fortran/library-module.exp  |  5 ++-
 gdb/testsuite/gdb.fortran/logical.exp         |  5 ++-
 gdb/testsuite/gdb.fortran/max-depth.exp       |  4 +-
 gdb/testsuite/gdb.fortran/module.exp          |  6 +--
 gdb/testsuite/gdb.fortran/multi-dim.exp       |  4 +-
 gdb/testsuite/gdb.fortran/nested-funcs.exp    |  4 +-
 gdb/testsuite/gdb.fortran/print-formatted.exp |  4 +-
 gdb/testsuite/gdb.fortran/print_type.exp      |  2 +-
 gdb/testsuite/gdb.fortran/printing-types.exp  |  5 ++-
 gdb/testsuite/gdb.fortran/ptr-indentation.exp |  4 +-
 .../gdb.fortran/ptype-on-functions.exp        |  4 +-
 gdb/testsuite/gdb.fortran/subarray.exp        |  5 ++-
 gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp |  3 +-
 gdb/testsuite/gdb.fortran/vla-datatypes.exp   |  2 +-
 gdb/testsuite/gdb.fortran/vla-history.exp     |  3 +-
 gdb/testsuite/gdb.fortran/vla-ptr-info.exp    |  3 +-
 gdb/testsuite/gdb.fortran/vla-ptype-sub.exp   |  2 +-
 gdb/testsuite/gdb.fortran/vla-ptype.exp       |  2 +-
 gdb/testsuite/gdb.fortran/vla-sizeof.exp      |  3 +-
 gdb/testsuite/gdb.fortran/vla-type.exp        |  2 +-
 .../gdb.fortran/vla-value-sub-arbitrary.exp   |  3 +-
 .../gdb.fortran/vla-value-sub-finish.exp      |  3 +-
 gdb/testsuite/gdb.fortran/vla-value-sub.exp   |  3 +-
 gdb/testsuite/gdb.fortran/vla-value.exp       |  6 +--
 gdb/testsuite/gdb.fortran/whatis_type.exp     |  4 +-
 gdb/testsuite/gdb.mi/mi-var-child-f.exp       |  2 +-
 gdb/testsuite/lib/fortran.exp                 | 16 +++++++
 41 files changed, 148 insertions(+), 64 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 10683db566..e972f97fad 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,47 @@
+2020-04-24  Alok Kumar Sharma  <alokkumar.sharma@amd.com>
+
+	* gdb.dwarf2/dw2-common-block.exp: Skip test except for gfortran,
+	as assembly file to be tested is generated by gfortran.
+	* lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_.
+	* gdb.fortran/array-bounds-high.exp: Handle flang MAIN_
+	* gdb.fortran/array-bounds.exp: Likewise.
+	* gdb.fortran/array-slices.exp: Likewise.
+	* gdb.fortran/block-data.exp: Likewise.
+	* gdb.fortran/charset.exp: Likewise.
+	* gdb.fortran/common-block.exp: Likewise.
+	* gdb.fortran/complex.exp: Likewise.
+	* gdb.fortran/derived-type-function.exp: Likewise.
+	* gdb.fortran/derived-type.exp: Likewise.
+	* gdb.fortran/info-modules.exp: Likewise.
+	* gdb.fortran/info-types.exp: Likewise.
+	* gdb.fortran/intrinsics.exp: Likewise.
+	* gdb.fortran/library-module.exp: Likewise.
+	* gdb.fortran/logical.exp: Likewise.
+	* gdb.fortran/max-depth.exp: Likewise.
+	* gdb.fortran/module.exp: Likewise.
+	* gdb.fortran/multi-dim.exp: Likewise.
+	* gdb.fortran/nested-funcs.exp: Likewise.
+	* gdb.fortran/print-formatted.exp: Likewise.
+	* gdb.fortran/print_type.exp: Likewise.
+	* gdb.fortran/printing-types.exp: Likewise.
+	* gdb.fortran/ptr-indentation.exp: Likewise.
+	* gdb.fortran/ptype-on-functions.exp: Likewise.
+	* gdb.fortran/subarray.exp: Likewise.
+	* gdb.fortran/vla-alloc-assoc.exp: Likewise.
+	* gdb.fortran/vla-datatypes.exp: Likewise.
+	* gdb.fortran/vla-history.exp: Likewise.
+	* gdb.fortran/vla-ptr-info.exp: Likewise.
+	* gdb.fortran/vla-ptype-sub.exp: Likewise.
+	* gdb.fortran/vla-ptype.exp: Likewise.
+	* gdb.fortran/vla-sizeof.exp: Likewise.
+	* gdb.fortran/vla-type.exp: Likewise.
+	* gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
+	* gdb.fortran/vla-value-sub-finish.exp: Likewise.
+	* gdb.fortran/vla-value-sub.exp: Likewise.
+	* gdb.fortran/vla-value.exp: Likewise.
+	* gdb.fortran/whatis_type.exp: Likewise.
+	* gdb.mi/mi-var-child-f.exp: Likewise.
+
 2020-04-23  Tom de Vries  <tdevries@suse.de>
 
 	* gdb.base/decl-before-def.exp: Run to main and print a again.
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-common-block.exp b/gdb/testsuite/gdb.dwarf2/dw2-common-block.exp
index 9bcf06b17f..cf41c6833f 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-common-block.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-common-block.exp
@@ -30,6 +30,12 @@ if {[skip_fortran_tests]} {
     return 0
 }
 
+# Assembly file is generated using gfortran.
+# skip running for other compilers.
+if {![test_compiler_info {gcc-*}]} {
+    return 0
+}
+
 standard_testfile .S
 
 if { [prepare_for_testing "failed to prepare" "${testfile}" $srcfile \
diff --git a/gdb/testsuite/gdb.fortran/array-bounds-high.exp b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
index 81e2f87b89..f1945b4112 100644
--- a/gdb/testsuite/gdb.fortran/array-bounds-high.exp
+++ b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
@@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
 
 set testfile "array-bounds-high"
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
     return -1
 }
 
-if {![runto MAIN__]} {
-    perror "Could not run to breakpoint `MAIN__'."
+if {![runto $fmain]} {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/array-bounds.exp b/gdb/testsuite/gdb.fortran/array-bounds.exp
index 12bf5c2db3..be28ff6da9 100644
--- a/gdb/testsuite/gdb.fortran/array-bounds.exp
+++ b/gdb/testsuite/gdb.fortran/array-bounds.exp
@@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
 
 set testfile "array-bounds"
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
     return -1
 }
 
-if {![runto MAIN__]} {
-    perror "Could not run to breakpoint `MAIN__'."
+if {![runto $fmain]} {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp b/gdb/testsuite/gdb.fortran/array-slices.exp
index 11997f926a..e91db62aa1 100644
--- a/gdb/testsuite/gdb.fortran/array-slices.exp
+++ b/gdb/testsuite/gdb.fortran/array-slices.exp
@@ -21,13 +21,14 @@
 if {[skip_fortran_tests]} { return -1 }
 
 standard_testfile ".f90"
+load_lib fortran.exp
 
 if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
 	 {debug f90}]} {
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/block-data.exp b/gdb/testsuite/gdb.fortran/block-data.exp
index 292afe6c16..520f0d5d28 100644
--- a/gdb/testsuite/gdb.fortran/block-data.exp
+++ b/gdb/testsuite/gdb.fortran/block-data.exp
@@ -30,8 +30,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    untested "couldn't run to breakpoint MAIN__"
+if ![runto $fmain] then {
+    untested "couldn't run to breakpoint $fmain"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/charset.exp b/gdb/testsuite/gdb.fortran/charset.exp
index f0f62f8490..11ab9dfdf0 100644
--- a/gdb/testsuite/gdb.fortran/charset.exp
+++ b/gdb/testsuite/gdb.fortran/charset.exp
@@ -19,12 +19,14 @@
 if { [skip_fortran_tests] } { return -1 }
 
 standard_testfile .f90
+load_lib fortran.exp
+
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug additional_flags=-fbackslash f90}] } {
     return -1
 }
 
-if ![runto MAIN__] {
-    perror "Couldn't run to MAIN__"
+if ![runto $fmain] {
+    perror "Couldn't run to $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/common-block.exp b/gdb/testsuite/gdb.fortran/common-block.exp
index 19c1af0d81..2b74a18e75 100644
--- a/gdb/testsuite/gdb.fortran/common-block.exp
+++ b/gdb/testsuite/gdb.fortran/common-block.exp
@@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" ${testfile} \
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto $fmain] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/complex.exp b/gdb/testsuite/gdb.fortran/complex.exp
index c092ab29f1..8ac81c1fcb 100644
--- a/gdb/testsuite/gdb.fortran/complex.exp
+++ b/gdb/testsuite/gdb.fortran/complex.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "Couldn't run to MAIN__"
+if ![runto $fmain] then {
+    perror "Couldn't run to $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/derived-type-function.exp b/gdb/testsuite/gdb.fortran/derived-type-function.exp
index 1f0f957317..8a298f5f7b 100644
--- a/gdb/testsuite/gdb.fortran/derived-type-function.exp
+++ b/gdb/testsuite/gdb.fortran/derived-type-function.exp
@@ -21,13 +21,14 @@
 if { [skip_fortran_tests] } { return -1 }
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto $fmain] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/derived-type.exp b/gdb/testsuite/gdb.fortran/derived-type.exp
index f1705bffd8..eddd985e59 100644
--- a/gdb/testsuite/gdb.fortran/derived-type.exp
+++ b/gdb/testsuite/gdb.fortran/derived-type.exp
@@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto $fmain] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/info-modules.exp b/gdb/testsuite/gdb.fortran/info-modules.exp
index 0c3c6a58e1..9967803dcc 100644
--- a/gdb/testsuite/gdb.fortran/info-modules.exp
+++ b/gdb/testsuite/gdb.fortran/info-modules.exp
@@ -28,8 +28,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![runto $fmain] } {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/info-types.exp b/gdb/testsuite/gdb.fortran/info-types.exp
index 2138937782..7f58740ed8 100644
--- a/gdb/testsuite/gdb.fortran/info-types.exp
+++ b/gdb/testsuite/gdb.fortran/info-types.exp
@@ -27,8 +27,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![runto $fmain] } {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/intrinsics.exp b/gdb/testsuite/gdb.fortran/intrinsics.exp
index 504bce4138..dca2d98cf4 100644
--- a/gdb/testsuite/gdb.fortran/intrinsics.exp
+++ b/gdb/testsuite/gdb.fortran/intrinsics.exp
@@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![runto $fmain] } {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/library-module.exp b/gdb/testsuite/gdb.fortran/library-module.exp
index f25988e32c..eb26551f4d 100644
--- a/gdb/testsuite/gdb.fortran/library-module.exp
+++ b/gdb/testsuite/gdb.fortran/library-module.exp
@@ -40,9 +40,10 @@ if  { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list debug f90
 clean_restart $testfile
 
 gdb_load_shlib $libfile
+load_lib fortran.exp
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto $fmain] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/logical.exp b/gdb/testsuite/gdb.fortran/logical.exp
index 324714fa49..ef5954aaf9 100644
--- a/gdb/testsuite/gdb.fortran/logical.exp
+++ b/gdb/testsuite/gdb.fortran/logical.exp
@@ -16,13 +16,14 @@
 # This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![runto $fmain] } {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/max-depth.exp b/gdb/testsuite/gdb.fortran/max-depth.exp
index 262d0fdfa1..52b5a24b98 100644
--- a/gdb/testsuite/gdb.fortran/max-depth.exp
+++ b/gdb/testsuite/gdb.fortran/max-depth.exp
@@ -26,8 +26,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![runto $fmain] } {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/module.exp b/gdb/testsuite/gdb.fortran/module.exp
index 1c269e2fed..9f5c79fba2 100644
--- a/gdb/testsuite/gdb.fortran/module.exp
+++ b/gdb/testsuite/gdb.fortran/module.exp
@@ -29,8 +29,8 @@ gdb_test "p modmany::var_i" " = 14" "stopped language detection"
 
 gdb_test "print mod1::var_const" " = 20" "fully qualified name of DW_TAG_constant"
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto $fmain] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
@@ -123,7 +123,7 @@ complete "modmany::var" $modmany_list
 # Breakpoint would work in language "c".
 gdb_test "show language" {The current source language is "(auto; currently )?fortran".}
 
-# gcc-4.4.2: The main program is always MAIN__ in .symtab so "runto" above
+# gcc-4.4.2: The main program is always $fmain in .symtab so "runto" above
 # works.  But DWARF DW_TAG_subprogram contains the name specified by
 # the "program" Fortran statement.
 if [gdb_breakpoint "module"] {
diff --git a/gdb/testsuite/gdb.fortran/multi-dim.exp b/gdb/testsuite/gdb.fortran/multi-dim.exp
index 05590914df..2567f166e2 100644
--- a/gdb/testsuite/gdb.fortran/multi-dim.exp
+++ b/gdb/testsuite/gdb.fortran/multi-dim.exp
@@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug f90}
     return -1
 }
 
-if ![runto MAIN__] {
-    perror "Couldn't run to MAIN__"
+if ![runto $fmain] {
+    perror "Couldn't run to $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/nested-funcs.exp b/gdb/testsuite/gdb.fortran/nested-funcs.exp
index e4fc02ffa5..b68227cb5a 100755
--- a/gdb/testsuite/gdb.fortran/nested-funcs.exp
+++ b/gdb/testsuite/gdb.fortran/nested-funcs.exp
@@ -25,8 +25,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto $fmain] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/print-formatted.exp b/gdb/testsuite/gdb.fortran/print-formatted.exp
index 8c6529ce7f..cd12c6b3c4 100644
--- a/gdb/testsuite/gdb.fortran/print-formatted.exp
+++ b/gdb/testsuite/gdb.fortran/print-formatted.exp
@@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
     return -1
 }
 
-if { ![runto MAIN__] } {
-    fail "runto MAIN__"
+if { ![runto $fmain] } {
+    fail "runto $fmain"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/print_type.exp b/gdb/testsuite/gdb.fortran/print_type.exp
index 7d5915390d..615c2be226 100755
--- a/gdb/testsuite/gdb.fortran/print_type.exp
+++ b/gdb/testsuite/gdb.fortran/print_type.exp
@@ -24,7 +24,7 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/printing-types.exp b/gdb/testsuite/gdb.fortran/printing-types.exp
index 2c88f9e003..206cccd19b 100644
--- a/gdb/testsuite/gdb.fortran/printing-types.exp
+++ b/gdb/testsuite/gdb.fortran/printing-types.exp
@@ -16,13 +16,14 @@
 if {[skip_fortran_tests]} { return -1 }
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if {![runto MAIN__]} then {
-    untested "could not run to breakpoint MAIN__"
+if {![runto $fmain]} then {
+    untested "could not run to breakpoint $fmain"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/ptr-indentation.exp b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
index 285e24e2cc..bffd4983f0 100644
--- a/gdb/testsuite/gdb.fortran/ptr-indentation.exp
+++ b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
@@ -22,8 +22,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if {![runto MAIN__]} then {
-    untested "couldn't run to breakpoint MAIN__"
+if {![runto $fmain]} then {
+    untested "couldn't run to breakpoint $fmain"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
index d91e4bd48e..bf1f5d8637 100644
--- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
+++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
@@ -24,8 +24,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto $fmain] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/subarray.exp b/gdb/testsuite/gdb.fortran/subarray.exp
index 5e3e8c38cb..c8aa5fe829 100644
--- a/gdb/testsuite/gdb.fortran/subarray.exp
+++ b/gdb/testsuite/gdb.fortran/subarray.exp
@@ -21,6 +21,7 @@
 if { [skip_fortran_tests] } { return -1 }
 
 standard_testfile .f
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
@@ -31,8 +32,8 @@ gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_load ${binfile}
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto $fmain] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
index 5d8585c2ee..ba1ee8e58c 100644
--- a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
+++ b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-datatypes.exp b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
index 2db9b3e110..b4c4b198c3 100644
--- a/gdb/testsuite/gdb.fortran/vla-datatypes.exp
+++ b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
@@ -24,7 +24,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
 # check that all fortran standard datatypes will be
 # handled correctly when using as VLA's
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-history.exp b/gdb/testsuite/gdb.fortran/vla-history.exp
index 24bd945f4a..aa38d5288c 100644
--- a/gdb/testsuite/gdb.fortran/vla-history.exp
+++ b/gdb/testsuite/gdb.fortran/vla-history.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
index 24c7b45840..1538f689e2 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
index 09909e74b0..90455601e4 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-ptype.exp b/gdb/testsuite/gdb.fortran/vla-ptype.exp
index 22b2005317..39d00a32c2 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptype.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptype.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
index 8e7d36314e..c826d96eb9 100644
--- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp
+++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-type.exp b/gdb/testsuite/gdb.fortran/vla-type.exp
index 6d885e7889..d9b66ff395 100755
--- a/gdb/testsuite/gdb.fortran/vla-type.exp
+++ b/gdb/testsuite/gdb.fortran/vla-type.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
index ab61dde06f..a18b4e4209 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla-sub.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
index afd992cee4..a056fc2732 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla-sub.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub.exp b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
index 3311f6befa..e0a42260a4 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla-sub.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp
index 5af17b570c..994a5a3e7a 100644
--- a/gdb/testsuite/gdb.fortran/vla-value.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
@@ -129,8 +129,8 @@ gdb_test "print vla1(9, 9, 9)" "no such vector element \\\(vector not allocated\
 # Try to assign VLA to user variable
 clean_restart ${testfile}
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto $fmain] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
diff --git a/gdb/testsuite/gdb.fortran/whatis_type.exp b/gdb/testsuite/gdb.fortran/whatis_type.exp
index 6a9cc0a81e..8a9a1eb79f 100644
--- a/gdb/testsuite/gdb.fortran/whatis_type.exp
+++ b/gdb/testsuite/gdb.fortran/whatis_type.exp
@@ -23,8 +23,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
     return -1
 }
 
-if ![runto MAIN__] {
-    fail "run to MAIN__"
+if ![runto $fmain] {
+    fail "run to $fmain"
     return
 }
 
diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
index 8cfffa7c08..363da0b7ed 100644
--- a/gdb/testsuite/gdb.mi/mi-var-child-f.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
@@ -36,7 +36,7 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
 mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load ${binfile}
 
-mi_runto MAIN__
+mi_runto $fmain
 
 mi_create_varobj "array" "array" "create local variable array"
 
diff --git a/gdb/testsuite/lib/fortran.exp b/gdb/testsuite/lib/fortran.exp
index 549ed65790..0bd95504c8 100644
--- a/gdb/testsuite/lib/fortran.exp
+++ b/gdb/testsuite/lib/fortran.exp
@@ -18,6 +18,8 @@
 # Auxiliary function to set the language to fortran.
 # The result is 1 (true) for success, 0 (false) for failure.
 
+global fmain
+
 proc set_lang_fortran {} {
     if [gdb_test_no_output "set language fortran"] {
 	return 0
@@ -126,3 +128,17 @@ proc fortran_character1 {} {
 	return "unknown"
     }
 }
+
+proc fortran_main {} {
+    if {[test_compiler_info {gcc-4-[012]-*}]
+         || [test_compiler_info {gcc-*}]
+         || [test_compiler_info {icc-*}]} {
+	return "MAIN__"
+    } elseif {[test_compiler_info {clang-*}]} {
+	return "MAIN_"
+    } else {
+	return "unknown"
+    }
+}
+
+set fmain  [fortran_main]
-- 
2.17.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing
  2020-04-24  9:44 [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing Sharma, Alok Kumar
@ 2020-04-24 10:17 ` Andrew Burgess
  2020-04-24 11:48   ` Sharma, Alok Kumar
  2020-04-24 12:56   ` Tom Tromey
  0 siblings, 2 replies; 14+ messages in thread
From: Andrew Burgess @ 2020-04-24 10:17 UTC (permalink / raw)
  To: Sharma, Alok Kumar; +Cc: gdb-patches, George, Jini Susan, Achra, Nitika

Hi,

Thanks for look at this.

* Sharma, Alok Kumar <AlokKumar.Sharma@amd.com> [2020-04-24 09:44:18 +0000]:

> [AMD Official Use Only - Internal Distribution Only]

You may want to figure out how to disable this for external mail.

> 
> Hi all,
> 
> I request you all to please review this patch. Below are the details.
> 
> Problem Description:
> 
> Name of fortran main function for Flang compiler is MAIN_ while
> for gfortran it is MAIN__ . In test cases MAIN__ is hardcoded for
> the purpose of inserting breakpoint.
> (please note the number of underscores after MAIN) 
> 
> Resolution:
> 
> New proc is added to detect main function name depending on the
> compiler used. Which is used in testcases.
> 
> This commit adds support for Flang main function, there should be
> no change for gfortran.
> 
>     gdb/testsuite/ChangeLog
> 
>             * gdb.dwarf2/dw2-common-block.exp: Skip test except for gfortran,
>             as assembly file to be tested is generated by gfortran.
>             * lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_.
>             * gdb.fortran/array-bounds-high.exp: Handle flang MAIN_
>             * gdb.fortran/array-bounds.exp: Likewise.
>             * gdb.fortran/array-slices.exp: Likewise.
>             * gdb.fortran/block-data.exp: Likewise.
>             * gdb.fortran/charset.exp: Likewise.
>             * gdb.fortran/common-block.exp: Likewise.
>             * gdb.fortran/complex.exp: Likewise.
>             * gdb.fortran/derived-type-function.exp: Likewise.
>             * gdb.fortran/derived-type.exp: Likewise.
>             * gdb.fortran/info-modules.exp: Likewise.
>             * gdb.fortran/info-types.exp: Likewise.
>             * gdb.fortran/intrinsics.exp: Likewise.
>             * gdb.fortran/library-module.exp: Likewise.
>             * gdb.fortran/logical.exp: Likewise.
>             * gdb.fortran/max-depth.exp: Likewise.
>             * gdb.fortran/module.exp: Likewise.
>             * gdb.fortran/multi-dim.exp: Likewise.
>             * gdb.fortran/nested-funcs.exp: Likewise.
>             * gdb.fortran/print-formatted.exp: Likewise.
>             * gdb.fortran/print_type.exp: Likewise.
>             * gdb.fortran/printing-types.exp: Likewise.
>             * gdb.fortran/ptr-indentation.exp: Likewise.
>             * gdb.fortran/ptype-on-functions.exp: Likewise.
>             * gdb.fortran/subarray.exp: Likewise.
>             * gdb.fortran/vla-alloc-assoc.exp: Likewise.
>             * gdb.fortran/vla-datatypes.exp: Likewise.
>             * gdb.fortran/vla-history.exp: Likewise.
>             * gdb.fortran/vla-ptr-info.exp: Likewise.
>             * gdb.fortran/vla-ptype-sub.exp: Likewise.
>             * gdb.fortran/vla-ptype.exp: Likewise.
>             * gdb.fortran/vla-sizeof.exp: Likewise.
>             * gdb.fortran/vla-type.exp: Likewise.
>             * gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
>             * gdb.fortran/vla-value-sub-finish.exp: Likewise.
>             * gdb.fortran/vla-value-sub.exp: Likewise.
>             * gdb.fortran/vla-value.exp: Likewise.
>             * gdb.fortran/whatis_type.exp: Likewise.
>             * gdb.mi/mi-var-child-f.exp: Likewise.
> 
> Please let me know your comments.
> 
> Regards,
> Alok


> From 7c1667f2e074dc1e0d9a0336d9ec07da59124a72 Mon Sep 17 00:00:00 2001
> From: Alok Kumar Sharma <AlokKumar.Sharma@amd.com>
> Date: Fri, 24 Apr 2020 14:46:09 +0530
> Subject: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing
> 
> Name of fortran main function for Flang compiler is MAIN_ while
> for gfortran it is MAIN__ . In test cases MAIN__ is hardcoded for
> the purpose of inserting breakpoint.
> 
> New proc is added to detect main function name depending on the
> compiler used. Which is used in testcases.
> 
> This commit adds support for Flang main function, there should be
> no change for gfortran.
> 
> gdb/testsuite/ChangeLog
> 
> 	* gdb.dwarf2/dw2-common-block.exp: Skip test except for gfortran,
> 	as assembly file to be tested is generated by gfortran.
> 	* lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_.
> 	* gdb.fortran/array-bounds-high.exp: Handle flang MAIN_
> 	* gdb.fortran/array-bounds.exp: Likewise.
> 	* gdb.fortran/array-slices.exp: Likewise.
> 	* gdb.fortran/block-data.exp: Likewise.
> 	* gdb.fortran/charset.exp: Likewise.
> 	* gdb.fortran/common-block.exp: Likewise.
> 	* gdb.fortran/complex.exp: Likewise.
> 	* gdb.fortran/derived-type-function.exp: Likewise.
> 	* gdb.fortran/derived-type.exp: Likewise.
> 	* gdb.fortran/info-modules.exp: Likewise.
> 	* gdb.fortran/info-types.exp: Likewise.
> 	* gdb.fortran/intrinsics.exp: Likewise.
> 	* gdb.fortran/library-module.exp: Likewise.
> 	* gdb.fortran/logical.exp: Likewise.
> 	* gdb.fortran/max-depth.exp: Likewise.
> 	* gdb.fortran/module.exp: Likewise.
> 	* gdb.fortran/multi-dim.exp: Likewise.
> 	* gdb.fortran/nested-funcs.exp: Likewise.
> 	* gdb.fortran/print-formatted.exp: Likewise.
> 	* gdb.fortran/print_type.exp: Likewise.
> 	* gdb.fortran/printing-types.exp: Likewise.
> 	* gdb.fortran/ptr-indentation.exp: Likewise.
> 	* gdb.fortran/ptype-on-functions.exp: Likewise.
> 	* gdb.fortran/subarray.exp: Likewise.
> 	* gdb.fortran/vla-alloc-assoc.exp: Likewise.
> 	* gdb.fortran/vla-datatypes.exp: Likewise.
> 	* gdb.fortran/vla-history.exp: Likewise.
> 	* gdb.fortran/vla-ptr-info.exp: Likewise.
> 	* gdb.fortran/vla-ptype-sub.exp: Likewise.
> 	* gdb.fortran/vla-ptype.exp: Likewise.
> 	* gdb.fortran/vla-sizeof.exp: Likewise.
> 	* gdb.fortran/vla-type.exp: Likewise.
> 	* gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
> 	* gdb.fortran/vla-value-sub-finish.exp: Likewise.
> 	* gdb.fortran/vla-value-sub.exp: Likewise.
> 	* gdb.fortran/vla-value.exp: Likewise.
> 	* gdb.fortran/whatis_type.exp: Likewise.
> 	* gdb.mi/mi-var-child-f.exp: Likewise.
> 
> Change-Id: I0a30f5dad684879b416f71d3d08c385c159325bf
> ---
>  gdb/testsuite/ChangeLog                       | 44 +++++++++++++++++++
>  gdb/testsuite/gdb.dwarf2/dw2-common-block.exp |  6 +++
>  .../gdb.fortran/array-bounds-high.exp         |  5 ++-
>  gdb/testsuite/gdb.fortran/array-bounds.exp    |  5 ++-
>  gdb/testsuite/gdb.fortran/array-slices.exp    |  3 +-
>  gdb/testsuite/gdb.fortran/block-data.exp      |  4 +-
>  gdb/testsuite/gdb.fortran/charset.exp         |  6 ++-
>  gdb/testsuite/gdb.fortran/common-block.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/complex.exp         |  5 ++-
>  .../gdb.fortran/derived-type-function.exp     |  5 ++-
>  gdb/testsuite/gdb.fortran/derived-type.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/info-modules.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/info-types.exp      |  4 +-
>  gdb/testsuite/gdb.fortran/intrinsics.exp      |  4 +-
>  gdb/testsuite/gdb.fortran/library-module.exp  |  5 ++-
>  gdb/testsuite/gdb.fortran/logical.exp         |  5 ++-
>  gdb/testsuite/gdb.fortran/max-depth.exp       |  4 +-
>  gdb/testsuite/gdb.fortran/module.exp          |  6 +--
>  gdb/testsuite/gdb.fortran/multi-dim.exp       |  4 +-
>  gdb/testsuite/gdb.fortran/nested-funcs.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/print-formatted.exp |  4 +-
>  gdb/testsuite/gdb.fortran/print_type.exp      |  2 +-
>  gdb/testsuite/gdb.fortran/printing-types.exp  |  5 ++-
>  gdb/testsuite/gdb.fortran/ptr-indentation.exp |  4 +-
>  .../gdb.fortran/ptype-on-functions.exp        |  4 +-
>  gdb/testsuite/gdb.fortran/subarray.exp        |  5 ++-
>  gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp |  3 +-
>  gdb/testsuite/gdb.fortran/vla-datatypes.exp   |  2 +-
>  gdb/testsuite/gdb.fortran/vla-history.exp     |  3 +-
>  gdb/testsuite/gdb.fortran/vla-ptr-info.exp    |  3 +-
>  gdb/testsuite/gdb.fortran/vla-ptype-sub.exp   |  2 +-
>  gdb/testsuite/gdb.fortran/vla-ptype.exp       |  2 +-
>  gdb/testsuite/gdb.fortran/vla-sizeof.exp      |  3 +-
>  gdb/testsuite/gdb.fortran/vla-type.exp        |  2 +-
>  .../gdb.fortran/vla-value-sub-arbitrary.exp   |  3 +-
>  .../gdb.fortran/vla-value-sub-finish.exp      |  3 +-
>  gdb/testsuite/gdb.fortran/vla-value-sub.exp   |  3 +-
>  gdb/testsuite/gdb.fortran/vla-value.exp       |  6 +--
>  gdb/testsuite/gdb.fortran/whatis_type.exp     |  4 +-
>  gdb/testsuite/gdb.mi/mi-var-child-f.exp       |  2 +-
>  gdb/testsuite/lib/fortran.exp                 | 16 +++++++
>  41 files changed, 148 insertions(+), 64 deletions(-)
> 
> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
> index 10683db566..e972f97fad 100644
> --- a/gdb/testsuite/ChangeLog
> +++ b/gdb/testsuite/ChangeLog
> @@ -1,3 +1,47 @@
> +2020-04-24  Alok Kumar Sharma  <alokkumar.sharma@amd.com>
> +
> +	* gdb.dwarf2/dw2-common-block.exp: Skip test except for gfortran,
> +	as assembly file to be tested is generated by gfortran.
> +	* lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_.
> +	* gdb.fortran/array-bounds-high.exp: Handle flang MAIN_
> +	* gdb.fortran/array-bounds.exp: Likewise.
> +	* gdb.fortran/array-slices.exp: Likewise.
> +	* gdb.fortran/block-data.exp: Likewise.
> +	* gdb.fortran/charset.exp: Likewise.
> +	* gdb.fortran/common-block.exp: Likewise.
> +	* gdb.fortran/complex.exp: Likewise.
> +	* gdb.fortran/derived-type-function.exp: Likewise.
> +	* gdb.fortran/derived-type.exp: Likewise.
> +	* gdb.fortran/info-modules.exp: Likewise.
> +	* gdb.fortran/info-types.exp: Likewise.
> +	* gdb.fortran/intrinsics.exp: Likewise.
> +	* gdb.fortran/library-module.exp: Likewise.
> +	* gdb.fortran/logical.exp: Likewise.
> +	* gdb.fortran/max-depth.exp: Likewise.
> +	* gdb.fortran/module.exp: Likewise.
> +	* gdb.fortran/multi-dim.exp: Likewise.
> +	* gdb.fortran/nested-funcs.exp: Likewise.
> +	* gdb.fortran/print-formatted.exp: Likewise.
> +	* gdb.fortran/print_type.exp: Likewise.
> +	* gdb.fortran/printing-types.exp: Likewise.
> +	* gdb.fortran/ptr-indentation.exp: Likewise.
> +	* gdb.fortran/ptype-on-functions.exp: Likewise.
> +	* gdb.fortran/subarray.exp: Likewise.
> +	* gdb.fortran/vla-alloc-assoc.exp: Likewise.
> +	* gdb.fortran/vla-datatypes.exp: Likewise.
> +	* gdb.fortran/vla-history.exp: Likewise.
> +	* gdb.fortran/vla-ptr-info.exp: Likewise.
> +	* gdb.fortran/vla-ptype-sub.exp: Likewise.
> +	* gdb.fortran/vla-ptype.exp: Likewise.
> +	* gdb.fortran/vla-sizeof.exp: Likewise.
> +	* gdb.fortran/vla-type.exp: Likewise.
> +	* gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
> +	* gdb.fortran/vla-value-sub-finish.exp: Likewise.
> +	* gdb.fortran/vla-value-sub.exp: Likewise.
> +	* gdb.fortran/vla-value.exp: Likewise.
> +	* gdb.fortran/whatis_type.exp: Likewise.
> +	* gdb.mi/mi-var-child-f.exp: Likewise.
> +
>  2020-04-23  Tom de Vries  <tdevries@suse.de>
>  
>  	* gdb.base/decl-before-def.exp: Run to main and print a again.
> diff --git a/gdb/testsuite/gdb.dwarf2/dw2-common-block.exp b/gdb/testsuite/gdb.dwarf2/dw2-common-block.exp
> index 9bcf06b17f..cf41c6833f 100644
> --- a/gdb/testsuite/gdb.dwarf2/dw2-common-block.exp
> +++ b/gdb/testsuite/gdb.dwarf2/dw2-common-block.exp
> @@ -30,6 +30,12 @@ if {[skip_fortran_tests]} {
>      return 0
>  }
>  
> +# Assembly file is generated using gfortran.
> +# skip running for other compilers.
> +if {![test_compiler_info {gcc-*}]} {
> +    return 0
> +}


I don't think this change relates to the name of the main function,
right?  So it should be split into a separate patch.

> +
>  standard_testfile .S
>  
>  if { [prepare_for_testing "failed to prepare" "${testfile}" $srcfile \
> diff --git a/gdb/testsuite/gdb.fortran/array-bounds-high.exp b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
> index 81e2f87b89..f1945b4112 100644
> --- a/gdb/testsuite/gdb.fortran/array-bounds-high.exp
> +++ b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
> @@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
>  
>  set testfile "array-bounds-high"
>  standard_testfile .f90
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
>      return -1
>  }
>  
> -if {![runto MAIN__]} {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if {![runto $fmain]} {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/array-bounds.exp b/gdb/testsuite/gdb.fortran/array-bounds.exp
> index 12bf5c2db3..be28ff6da9 100644
> --- a/gdb/testsuite/gdb.fortran/array-bounds.exp
> +++ b/gdb/testsuite/gdb.fortran/array-bounds.exp
> @@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
>  
>  set testfile "array-bounds"
>  standard_testfile .f90
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
>      return -1
>  }
>  
> -if {![runto MAIN__]} {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if {![runto $fmain]} {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp b/gdb/testsuite/gdb.fortran/array-slices.exp
> index 11997f926a..e91db62aa1 100644
> --- a/gdb/testsuite/gdb.fortran/array-slices.exp
> +++ b/gdb/testsuite/gdb.fortran/array-slices.exp
> @@ -21,13 +21,14 @@
>  if {[skip_fortran_tests]} { return -1 }
>  
>  standard_testfile ".f90"
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
>  	 {debug f90}]} {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![runto $fmain] {

Out of interest, how is this test even passing on gFortran?
runto_main should place a breakpoint on 'main', and I can't see any
obvious special case handling for Fortran.

And my main thought is that what we should do is override runto_main
in lib/fortran.exp, and then switch all of the test over to using that
instead, this would be more consistent with how the C/C++ tests work
then.

Thanks,
Andrew

>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/block-data.exp b/gdb/testsuite/gdb.fortran/block-data.exp
> index 292afe6c16..520f0d5d28 100644
> --- a/gdb/testsuite/gdb.fortran/block-data.exp
> +++ b/gdb/testsuite/gdb.fortran/block-data.exp
> @@ -30,8 +30,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>  
> -if ![runto MAIN__] then {
> -    untested "couldn't run to breakpoint MAIN__"
> +if ![runto $fmain] then {
> +    untested "couldn't run to breakpoint $fmain"
>      return -1
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/charset.exp b/gdb/testsuite/gdb.fortran/charset.exp
> index f0f62f8490..11ab9dfdf0 100644
> --- a/gdb/testsuite/gdb.fortran/charset.exp
> +++ b/gdb/testsuite/gdb.fortran/charset.exp
> @@ -19,12 +19,14 @@
>  if { [skip_fortran_tests] } { return -1 }
>  
>  standard_testfile .f90
> +load_lib fortran.exp
> +
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug additional_flags=-fbackslash f90}] } {
>      return -1
>  }
>  
> -if ![runto MAIN__] {
> -    perror "Couldn't run to MAIN__"
> +if ![runto $fmain] {
> +    perror "Couldn't run to $fmain"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/common-block.exp b/gdb/testsuite/gdb.fortran/common-block.exp
> index 19c1af0d81..2b74a18e75 100644
> --- a/gdb/testsuite/gdb.fortran/common-block.exp
> +++ b/gdb/testsuite/gdb.fortran/common-block.exp
> @@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" ${testfile} \
>      return -1
>  }
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![runto $fmain] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/complex.exp b/gdb/testsuite/gdb.fortran/complex.exp
> index c092ab29f1..8ac81c1fcb 100644
> --- a/gdb/testsuite/gdb.fortran/complex.exp
> +++ b/gdb/testsuite/gdb.fortran/complex.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile .f90
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
>      return -1
>  }
>  
> -if ![runto MAIN__] then {
> -    perror "Couldn't run to MAIN__"
> +if ![runto $fmain] then {
> +    perror "Couldn't run to $fmain"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/derived-type-function.exp b/gdb/testsuite/gdb.fortran/derived-type-function.exp
> index 1f0f957317..8a298f5f7b 100644
> --- a/gdb/testsuite/gdb.fortran/derived-type-function.exp
> +++ b/gdb/testsuite/gdb.fortran/derived-type-function.exp
> @@ -21,13 +21,14 @@
>  if { [skip_fortran_tests] } { return -1 }
>  
>  standard_testfile .f90
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![runto $fmain] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/derived-type.exp b/gdb/testsuite/gdb.fortran/derived-type.exp
> index f1705bffd8..eddd985e59 100644
> --- a/gdb/testsuite/gdb.fortran/derived-type.exp
> +++ b/gdb/testsuite/gdb.fortran/derived-type.exp
> @@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![runto $fmain] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/info-modules.exp b/gdb/testsuite/gdb.fortran/info-modules.exp
> index 0c3c6a58e1..9967803dcc 100644
> --- a/gdb/testsuite/gdb.fortran/info-modules.exp
> +++ b/gdb/testsuite/gdb.fortran/info-modules.exp
> @@ -28,8 +28,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
>      return -1
>  }
>  
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![runto $fmain] } {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/info-types.exp b/gdb/testsuite/gdb.fortran/info-types.exp
> index 2138937782..7f58740ed8 100644
> --- a/gdb/testsuite/gdb.fortran/info-types.exp
> +++ b/gdb/testsuite/gdb.fortran/info-types.exp
> @@ -27,8 +27,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
>      return -1
>  }
>  
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![runto $fmain] } {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/intrinsics.exp b/gdb/testsuite/gdb.fortran/intrinsics.exp
> index 504bce4138..dca2d98cf4 100644
> --- a/gdb/testsuite/gdb.fortran/intrinsics.exp
> +++ b/gdb/testsuite/gdb.fortran/intrinsics.exp
> @@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
>      return -1
>  }
>  
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![runto $fmain] } {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/library-module.exp b/gdb/testsuite/gdb.fortran/library-module.exp
> index f25988e32c..eb26551f4d 100644
> --- a/gdb/testsuite/gdb.fortran/library-module.exp
> +++ b/gdb/testsuite/gdb.fortran/library-module.exp
> @@ -40,9 +40,10 @@ if  { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list debug f90
>  clean_restart $testfile
>  
>  gdb_load_shlib $libfile
> +load_lib fortran.exp
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![runto $fmain] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/logical.exp b/gdb/testsuite/gdb.fortran/logical.exp
> index 324714fa49..ef5954aaf9 100644
> --- a/gdb/testsuite/gdb.fortran/logical.exp
> +++ b/gdb/testsuite/gdb.fortran/logical.exp
> @@ -16,13 +16,14 @@
>  # This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
>  
>  standard_testfile .f90
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
>      return -1
>  }
>  
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![runto $fmain] } {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/max-depth.exp b/gdb/testsuite/gdb.fortran/max-depth.exp
> index 262d0fdfa1..52b5a24b98 100644
> --- a/gdb/testsuite/gdb.fortran/max-depth.exp
> +++ b/gdb/testsuite/gdb.fortran/max-depth.exp
> @@ -26,8 +26,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
>      return -1
>  }
>  
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![runto $fmain] } {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/module.exp b/gdb/testsuite/gdb.fortran/module.exp
> index 1c269e2fed..9f5c79fba2 100644
> --- a/gdb/testsuite/gdb.fortran/module.exp
> +++ b/gdb/testsuite/gdb.fortran/module.exp
> @@ -29,8 +29,8 @@ gdb_test "p modmany::var_i" " = 14" "stopped language detection"
>  
>  gdb_test "print mod1::var_const" " = 20" "fully qualified name of DW_TAG_constant"
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![runto $fmain] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>  
> @@ -123,7 +123,7 @@ complete "modmany::var" $modmany_list
>  # Breakpoint would work in language "c".
>  gdb_test "show language" {The current source language is "(auto; currently )?fortran".}
>  
> -# gcc-4.4.2: The main program is always MAIN__ in .symtab so "runto" above
> +# gcc-4.4.2: The main program is always $fmain in .symtab so "runto" above
>  # works.  But DWARF DW_TAG_subprogram contains the name specified by
>  # the "program" Fortran statement.
>  if [gdb_breakpoint "module"] {
> diff --git a/gdb/testsuite/gdb.fortran/multi-dim.exp b/gdb/testsuite/gdb.fortran/multi-dim.exp
> index 05590914df..2567f166e2 100644
> --- a/gdb/testsuite/gdb.fortran/multi-dim.exp
> +++ b/gdb/testsuite/gdb.fortran/multi-dim.exp
> @@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug f90}
>      return -1
>  }
>  
> -if ![runto MAIN__] {
> -    perror "Couldn't run to MAIN__"
> +if ![runto $fmain] {
> +    perror "Couldn't run to $fmain"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/nested-funcs.exp b/gdb/testsuite/gdb.fortran/nested-funcs.exp
> index e4fc02ffa5..b68227cb5a 100755
> --- a/gdb/testsuite/gdb.fortran/nested-funcs.exp
> +++ b/gdb/testsuite/gdb.fortran/nested-funcs.exp
> @@ -25,8 +25,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![runto $fmain] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/print-formatted.exp b/gdb/testsuite/gdb.fortran/print-formatted.exp
> index 8c6529ce7f..cd12c6b3c4 100644
> --- a/gdb/testsuite/gdb.fortran/print-formatted.exp
> +++ b/gdb/testsuite/gdb.fortran/print-formatted.exp
> @@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
>      return -1
>  }
>  
> -if { ![runto MAIN__] } {
> -    fail "runto MAIN__"
> +if { ![runto $fmain] } {
> +    fail "runto $fmain"
>      return -1
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/print_type.exp b/gdb/testsuite/gdb.fortran/print_type.exp
> index 7d5915390d..615c2be226 100755
> --- a/gdb/testsuite/gdb.fortran/print_type.exp
> +++ b/gdb/testsuite/gdb.fortran/print_type.exp
> @@ -24,7 +24,7 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/printing-types.exp b/gdb/testsuite/gdb.fortran/printing-types.exp
> index 2c88f9e003..206cccd19b 100644
> --- a/gdb/testsuite/gdb.fortran/printing-types.exp
> +++ b/gdb/testsuite/gdb.fortran/printing-types.exp
> @@ -16,13 +16,14 @@
>  if {[skip_fortran_tests]} { return -1 }
>  
>  standard_testfile .f90
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>  
> -if {![runto MAIN__]} then {
> -    untested "could not run to breakpoint MAIN__"
> +if {![runto $fmain]} then {
> +    untested "could not run to breakpoint $fmain"
>      return -1
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/ptr-indentation.exp b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
> index 285e24e2cc..bffd4983f0 100644
> --- a/gdb/testsuite/gdb.fortran/ptr-indentation.exp
> +++ b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
> @@ -22,8 +22,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>  
> -if {![runto MAIN__]} then {
> -    untested "couldn't run to breakpoint MAIN__"
> +if {![runto $fmain]} then {
> +    untested "couldn't run to breakpoint $fmain"
>      return -1
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> index d91e4bd48e..bf1f5d8637 100644
> --- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> +++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> @@ -24,8 +24,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![runto $fmain] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/subarray.exp b/gdb/testsuite/gdb.fortran/subarray.exp
> index 5e3e8c38cb..c8aa5fe829 100644
> --- a/gdb/testsuite/gdb.fortran/subarray.exp
> +++ b/gdb/testsuite/gdb.fortran/subarray.exp
> @@ -21,6 +21,7 @@
>  if { [skip_fortran_tests] } { return -1 }
>  
>  standard_testfile .f
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
> @@ -31,8 +32,8 @@ gdb_start
>  gdb_reinitialize_dir $srcdir/$subdir
>  gdb_load ${binfile}
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![runto $fmain] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
> index 5d8585c2ee..ba1ee8e58c 100644
> --- a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>  
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-datatypes.exp b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
> index 2db9b3e110..b4c4b198c3 100644
> --- a/gdb/testsuite/gdb.fortran/vla-datatypes.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
> @@ -24,7 +24,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>  # check that all fortran standard datatypes will be
>  # handled correctly when using as VLA's
>  
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-history.exp b/gdb/testsuite/gdb.fortran/vla-history.exp
> index 24bd945f4a..aa38d5288c 100644
> --- a/gdb/testsuite/gdb.fortran/vla-history.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-history.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>  
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> index 24c7b45840..1538f689e2 100644
> --- a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>  
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
> index 09909e74b0..90455601e4 100644
> --- a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-ptype.exp b/gdb/testsuite/gdb.fortran/vla-ptype.exp
> index 22b2005317..39d00a32c2 100644
> --- a/gdb/testsuite/gdb.fortran/vla-ptype.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-ptype.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
> index 8e7d36314e..c826d96eb9 100644
> --- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>  
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-type.exp b/gdb/testsuite/gdb.fortran/vla-type.exp
> index 6d885e7889..d9b66ff395 100755
> --- a/gdb/testsuite/gdb.fortran/vla-type.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-type.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
> index ab61dde06f..a18b4e4209 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile "vla-sub.f90"
> +load_lib fortran.exp
>  
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
> index afd992cee4..a056fc2732 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile "vla-sub.f90"
> +load_lib fortran.exp
>  
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub.exp b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
> index 3311f6befa..e0a42260a4 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value-sub.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile "vla-sub.f90"
> +load_lib fortran.exp
>  
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp
> index 5af17b570c..994a5a3e7a 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> @@ -129,8 +129,8 @@ gdb_test "print vla1(9, 9, 9)" "no such vector element \\\(vector not allocated\
>  # Try to assign VLA to user variable
>  clean_restart ${testfile}
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![runto $fmain] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>  gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
> diff --git a/gdb/testsuite/gdb.fortran/whatis_type.exp b/gdb/testsuite/gdb.fortran/whatis_type.exp
> index 6a9cc0a81e..8a9a1eb79f 100644
> --- a/gdb/testsuite/gdb.fortran/whatis_type.exp
> +++ b/gdb/testsuite/gdb.fortran/whatis_type.exp
> @@ -23,8 +23,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
>      return -1
>  }
>  
> -if ![runto MAIN__] {
> -    fail "run to MAIN__"
> +if ![runto $fmain] {
> +    fail "run to $fmain"
>      return
>  }
>  
> diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
> index 8cfffa7c08..363da0b7ed 100644
> --- a/gdb/testsuite/gdb.mi/mi-var-child-f.exp
> +++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
> @@ -36,7 +36,7 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
>  mi_gdb_reinitialize_dir $srcdir/$subdir
>  mi_gdb_load ${binfile}
>  
> -mi_runto MAIN__
> +mi_runto $fmain
>  
>  mi_create_varobj "array" "array" "create local variable array"
>  
> diff --git a/gdb/testsuite/lib/fortran.exp b/gdb/testsuite/lib/fortran.exp
> index 549ed65790..0bd95504c8 100644
> --- a/gdb/testsuite/lib/fortran.exp
> +++ b/gdb/testsuite/lib/fortran.exp
> @@ -18,6 +18,8 @@
>  # Auxiliary function to set the language to fortran.
>  # The result is 1 (true) for success, 0 (false) for failure.
>  
> +global fmain
> +
>  proc set_lang_fortran {} {
>      if [gdb_test_no_output "set language fortran"] {
>  	return 0
> @@ -126,3 +128,17 @@ proc fortran_character1 {} {
>  	return "unknown"
>      }
>  }
> +
> +proc fortran_main {} {
> +    if {[test_compiler_info {gcc-4-[012]-*}]
> +         || [test_compiler_info {gcc-*}]
> +         || [test_compiler_info {icc-*}]} {
> +	return "MAIN__"
> +    } elseif {[test_compiler_info {clang-*}]} {
> +	return "MAIN_"
> +    } else {
> +	return "unknown"
> +    }
> +}
> +
> +set fmain  [fortran_main]
> -- 
> 2.17.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing
  2020-04-24 10:17 ` Andrew Burgess
@ 2020-04-24 11:48   ` Sharma, Alok Kumar
  2020-04-24 12:58     ` Tom Tromey
  2020-04-24 12:56   ` Tom Tromey
  1 sibling, 1 reply; 14+ messages in thread
From: Sharma, Alok Kumar @ 2020-04-24 11:48 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches, George, Jini Susan, Achra, Nitika

[-- Attachment #1: Type: text/plain, Size: 42159 bytes --]

Hi Andrew,

Thanks a lot for your review comments.

I have incorporated your comments in updated patch attached. Below are the details.
-  Removed unrelated changes in gdb/testsuite/gdb.dwarf2/dw2-common-block.exp, Will upload as separate patch.
-  Overridden runto_main in lib/fortran.exp to handle fortran main.
- updated gdb/testsuite/Changelog accordingly.

    gdb/testsuite/ChangeLog

            * lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
            proc runto_main is overloaded to handle fortran main function.
            * gdb.fortran/array-bounds-high.exp: Handle flang MAIN_.
            * gdb.fortran/array-bounds.exp: Likewise.
            * gdb.fortran/array-slices.exp: Likewise.
            * gdb.fortran/block-data.exp: Likewise.
            * gdb.fortran/charset.exp: Likewise.
            * gdb.fortran/common-block.exp: Likewise.
            * gdb.fortran/complex.exp: Likewise.
            * gdb.fortran/derived-type-function.exp: Likewise.
            * gdb.fortran/derived-type.exp: Likewise.
            * gdb.fortran/info-modules.exp: Likewise.
            * gdb.fortran/info-types.exp: Likewise.
            * gdb.fortran/intrinsics.exp: Likewise.
            * gdb.fortran/library-module.exp: Likewise.
            * gdb.fortran/logical.exp: Likewise.
            * gdb.fortran/max-depth.exp: Likewise.
            * gdb.fortran/module.exp: Likewise.
            * gdb.fortran/multi-dim.exp: Likewise.
            * gdb.fortran/nested-funcs.exp: Likewise.
            * gdb.fortran/print-formatted.exp: Likewise.
            * gdb.fortran/printing-types.exp: Likewise.
            * gdb.fortran/ptr-indentation.exp: Likewise.
            * gdb.fortran/ptype-on-functions.exp: Likewise.
            * gdb.fortran/subarray.exp: Likewise.
            * gdb.fortran/vla-alloc-assoc.exp: Likewise.
            * gdb.fortran/vla-history.exp: Likewise.
            * gdb.fortran/vla-ptr-info.exp: Likewise.
            * gdb.fortran/vla-sizeof.exp: Likewise.
            * gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
            * gdb.fortran/vla-value-sub-finish.exp: Likewise.
            * gdb.fortran/vla-value-sub.exp: Likewise.
            * gdb.fortran/vla-value.exp: Likewise.
            * gdb.fortran/whatis_type.exp: Likewise.
            * gdb.mi/mi-var-child-f.exp: Likewise.

Please let me know any further comments.

Regards,
Alok


-----Original Message-----
From: Andrew Burgess <andrew.burgess@embecosm.com> 
Sent: Friday, April 24, 2020 3:48 PM
To: Sharma, Alok Kumar <AlokKumar.Sharma@amd.com>
Cc: gdb-patches@sourceware.org; George, Jini Susan <JiniSusan.George@amd.com>; Achra, Nitika <Nitika.Achra@amd.com>
Subject: Re: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing

[CAUTION: External Email]

Hi,

Thanks for look at this.

* Sharma, Alok Kumar <AlokKumar.Sharma@amd.com> [2020-04-24 09:44:18 +0000]:

> [AMD Official Use Only - Internal Distribution Only]

You may want to figure out how to disable this for external mail.

>
> Hi all,
>
> I request you all to please review this patch. Below are the details.
>
> Problem Description:
>
> Name of fortran main function for Flang compiler is MAIN_ while for 
> gfortran it is MAIN__ . In test cases MAIN__ is hardcoded for the 
> purpose of inserting breakpoint.
> (please note the number of underscores after MAIN)
>
> Resolution:
>
> New proc is added to detect main function name depending on the 
> compiler used. Which is used in testcases.
>
> This commit adds support for Flang main function, there should be no 
> change for gfortran.
>
>     gdb/testsuite/ChangeLog
>
>             * gdb.dwarf2/dw2-common-block.exp: Skip test except for gfortran,
>             as assembly file to be tested is generated by gfortran.
>             * lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_.
>             * gdb.fortran/array-bounds-high.exp: Handle flang MAIN_
>             * gdb.fortran/array-bounds.exp: Likewise.
>             * gdb.fortran/array-slices.exp: Likewise.
>             * gdb.fortran/block-data.exp: Likewise.
>             * gdb.fortran/charset.exp: Likewise.
>             * gdb.fortran/common-block.exp: Likewise.
>             * gdb.fortran/complex.exp: Likewise.
>             * gdb.fortran/derived-type-function.exp: Likewise.
>             * gdb.fortran/derived-type.exp: Likewise.
>             * gdb.fortran/info-modules.exp: Likewise.
>             * gdb.fortran/info-types.exp: Likewise.
>             * gdb.fortran/intrinsics.exp: Likewise.
>             * gdb.fortran/library-module.exp: Likewise.
>             * gdb.fortran/logical.exp: Likewise.
>             * gdb.fortran/max-depth.exp: Likewise.
>             * gdb.fortran/module.exp: Likewise.
>             * gdb.fortran/multi-dim.exp: Likewise.
>             * gdb.fortran/nested-funcs.exp: Likewise.
>             * gdb.fortran/print-formatted.exp: Likewise.
>             * gdb.fortran/print_type.exp: Likewise.
>             * gdb.fortran/printing-types.exp: Likewise.
>             * gdb.fortran/ptr-indentation.exp: Likewise.
>             * gdb.fortran/ptype-on-functions.exp: Likewise.
>             * gdb.fortran/subarray.exp: Likewise.
>             * gdb.fortran/vla-alloc-assoc.exp: Likewise.
>             * gdb.fortran/vla-datatypes.exp: Likewise.
>             * gdb.fortran/vla-history.exp: Likewise.
>             * gdb.fortran/vla-ptr-info.exp: Likewise.
>             * gdb.fortran/vla-ptype-sub.exp: Likewise.
>             * gdb.fortran/vla-ptype.exp: Likewise.
>             * gdb.fortran/vla-sizeof.exp: Likewise.
>             * gdb.fortran/vla-type.exp: Likewise.
>             * gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
>             * gdb.fortran/vla-value-sub-finish.exp: Likewise.
>             * gdb.fortran/vla-value-sub.exp: Likewise.
>             * gdb.fortran/vla-value.exp: Likewise.
>             * gdb.fortran/whatis_type.exp: Likewise.
>             * gdb.mi/mi-var-child-f.exp: Likewise.
>
> Please let me know your comments.
>
> Regards,
> Alok


> From 7c1667f2e074dc1e0d9a0336d9ec07da59124a72 Mon Sep 17 00:00:00 2001
> From: Alok Kumar Sharma <AlokKumar.Sharma@amd.com>
> Date: Fri, 24 Apr 2020 14:46:09 +0530
> Subject: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing
>
> Name of fortran main function for Flang compiler is MAIN_ while for 
> gfortran it is MAIN__ . In test cases MAIN__ is hardcoded for the 
> purpose of inserting breakpoint.
>
> New proc is added to detect main function name depending on the 
> compiler used. Which is used in testcases.
>
> This commit adds support for Flang main function, there should be no 
> change for gfortran.
>
> gdb/testsuite/ChangeLog
>
>       * gdb.dwarf2/dw2-common-block.exp: Skip test except for gfortran,
>       as assembly file to be tested is generated by gfortran.
>       * lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_.
>       * gdb.fortran/array-bounds-high.exp: Handle flang MAIN_
>       * gdb.fortran/array-bounds.exp: Likewise.
>       * gdb.fortran/array-slices.exp: Likewise.
>       * gdb.fortran/block-data.exp: Likewise.
>       * gdb.fortran/charset.exp: Likewise.
>       * gdb.fortran/common-block.exp: Likewise.
>       * gdb.fortran/complex.exp: Likewise.
>       * gdb.fortran/derived-type-function.exp: Likewise.
>       * gdb.fortran/derived-type.exp: Likewise.
>       * gdb.fortran/info-modules.exp: Likewise.
>       * gdb.fortran/info-types.exp: Likewise.
>       * gdb.fortran/intrinsics.exp: Likewise.
>       * gdb.fortran/library-module.exp: Likewise.
>       * gdb.fortran/logical.exp: Likewise.
>       * gdb.fortran/max-depth.exp: Likewise.
>       * gdb.fortran/module.exp: Likewise.
>       * gdb.fortran/multi-dim.exp: Likewise.
>       * gdb.fortran/nested-funcs.exp: Likewise.
>       * gdb.fortran/print-formatted.exp: Likewise.
>       * gdb.fortran/print_type.exp: Likewise.
>       * gdb.fortran/printing-types.exp: Likewise.
>       * gdb.fortran/ptr-indentation.exp: Likewise.
>       * gdb.fortran/ptype-on-functions.exp: Likewise.
>       * gdb.fortran/subarray.exp: Likewise.
>       * gdb.fortran/vla-alloc-assoc.exp: Likewise.
>       * gdb.fortran/vla-datatypes.exp: Likewise.
>       * gdb.fortran/vla-history.exp: Likewise.
>       * gdb.fortran/vla-ptr-info.exp: Likewise.
>       * gdb.fortran/vla-ptype-sub.exp: Likewise.
>       * gdb.fortran/vla-ptype.exp: Likewise.
>       * gdb.fortran/vla-sizeof.exp: Likewise.
>       * gdb.fortran/vla-type.exp: Likewise.
>       * gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
>       * gdb.fortran/vla-value-sub-finish.exp: Likewise.
>       * gdb.fortran/vla-value-sub.exp: Likewise.
>       * gdb.fortran/vla-value.exp: Likewise.
>       * gdb.fortran/whatis_type.exp: Likewise.
>       * gdb.mi/mi-var-child-f.exp: Likewise.
>
> Change-Id: I0a30f5dad684879b416f71d3d08c385c159325bf
> ---
>  gdb/testsuite/ChangeLog                       | 44 +++++++++++++++++++
>  gdb/testsuite/gdb.dwarf2/dw2-common-block.exp |  6 +++
>  .../gdb.fortran/array-bounds-high.exp         |  5 ++-
>  gdb/testsuite/gdb.fortran/array-bounds.exp    |  5 ++-
>  gdb/testsuite/gdb.fortran/array-slices.exp    |  3 +-
>  gdb/testsuite/gdb.fortran/block-data.exp      |  4 +-
>  gdb/testsuite/gdb.fortran/charset.exp         |  6 ++-
>  gdb/testsuite/gdb.fortran/common-block.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/complex.exp         |  5 ++-
>  .../gdb.fortran/derived-type-function.exp     |  5 ++-
>  gdb/testsuite/gdb.fortran/derived-type.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/info-modules.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/info-types.exp      |  4 +-
>  gdb/testsuite/gdb.fortran/intrinsics.exp      |  4 +-
>  gdb/testsuite/gdb.fortran/library-module.exp  |  5 ++-
>  gdb/testsuite/gdb.fortran/logical.exp         |  5 ++-
>  gdb/testsuite/gdb.fortran/max-depth.exp       |  4 +-
>  gdb/testsuite/gdb.fortran/module.exp          |  6 +--
>  gdb/testsuite/gdb.fortran/multi-dim.exp       |  4 +-
>  gdb/testsuite/gdb.fortran/nested-funcs.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/print-formatted.exp |  4 +-
>  gdb/testsuite/gdb.fortran/print_type.exp      |  2 +-
>  gdb/testsuite/gdb.fortran/printing-types.exp  |  5 ++-  
> gdb/testsuite/gdb.fortran/ptr-indentation.exp |  4 +-
>  .../gdb.fortran/ptype-on-functions.exp        |  4 +-
>  gdb/testsuite/gdb.fortran/subarray.exp        |  5 ++-
>  gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp |  3 +-
>  gdb/testsuite/gdb.fortran/vla-datatypes.exp   |  2 +-
>  gdb/testsuite/gdb.fortran/vla-history.exp     |  3 +-
>  gdb/testsuite/gdb.fortran/vla-ptr-info.exp    |  3 +-
>  gdb/testsuite/gdb.fortran/vla-ptype-sub.exp   |  2 +-
>  gdb/testsuite/gdb.fortran/vla-ptype.exp       |  2 +-
>  gdb/testsuite/gdb.fortran/vla-sizeof.exp      |  3 +-
>  gdb/testsuite/gdb.fortran/vla-type.exp        |  2 +-
>  .../gdb.fortran/vla-value-sub-arbitrary.exp   |  3 +-
>  .../gdb.fortran/vla-value-sub-finish.exp      |  3 +-
>  gdb/testsuite/gdb.fortran/vla-value-sub.exp   |  3 +-
>  gdb/testsuite/gdb.fortran/vla-value.exp       |  6 +--
>  gdb/testsuite/gdb.fortran/whatis_type.exp     |  4 +-
>  gdb/testsuite/gdb.mi/mi-var-child-f.exp       |  2 +-
>  gdb/testsuite/lib/fortran.exp                 | 16 +++++++
>  41 files changed, 148 insertions(+), 64 deletions(-)
>
> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 
> 10683db566..e972f97fad 100644
> --- a/gdb/testsuite/ChangeLog
> +++ b/gdb/testsuite/ChangeLog
> @@ -1,3 +1,47 @@
> +2020-04-24  Alok Kumar Sharma  <alokkumar.sharma@amd.com>
> +
> +     * gdb.dwarf2/dw2-common-block.exp: Skip test except for gfortran,
> +     as assembly file to be tested is generated by gfortran.
> +     * lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_.
> +     * gdb.fortran/array-bounds-high.exp: Handle flang MAIN_
> +     * gdb.fortran/array-bounds.exp: Likewise.
> +     * gdb.fortran/array-slices.exp: Likewise.
> +     * gdb.fortran/block-data.exp: Likewise.
> +     * gdb.fortran/charset.exp: Likewise.
> +     * gdb.fortran/common-block.exp: Likewise.
> +     * gdb.fortran/complex.exp: Likewise.
> +     * gdb.fortran/derived-type-function.exp: Likewise.
> +     * gdb.fortran/derived-type.exp: Likewise.
> +     * gdb.fortran/info-modules.exp: Likewise.
> +     * gdb.fortran/info-types.exp: Likewise.
> +     * gdb.fortran/intrinsics.exp: Likewise.
> +     * gdb.fortran/library-module.exp: Likewise.
> +     * gdb.fortran/logical.exp: Likewise.
> +     * gdb.fortran/max-depth.exp: Likewise.
> +     * gdb.fortran/module.exp: Likewise.
> +     * gdb.fortran/multi-dim.exp: Likewise.
> +     * gdb.fortran/nested-funcs.exp: Likewise.
> +     * gdb.fortran/print-formatted.exp: Likewise.
> +     * gdb.fortran/print_type.exp: Likewise.
> +     * gdb.fortran/printing-types.exp: Likewise.
> +     * gdb.fortran/ptr-indentation.exp: Likewise.
> +     * gdb.fortran/ptype-on-functions.exp: Likewise.
> +     * gdb.fortran/subarray.exp: Likewise.
> +     * gdb.fortran/vla-alloc-assoc.exp: Likewise.
> +     * gdb.fortran/vla-datatypes.exp: Likewise.
> +     * gdb.fortran/vla-history.exp: Likewise.
> +     * gdb.fortran/vla-ptr-info.exp: Likewise.
> +     * gdb.fortran/vla-ptype-sub.exp: Likewise.
> +     * gdb.fortran/vla-ptype.exp: Likewise.
> +     * gdb.fortran/vla-sizeof.exp: Likewise.
> +     * gdb.fortran/vla-type.exp: Likewise.
> +     * gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
> +     * gdb.fortran/vla-value-sub-finish.exp: Likewise.
> +     * gdb.fortran/vla-value-sub.exp: Likewise.
> +     * gdb.fortran/vla-value.exp: Likewise.
> +     * gdb.fortran/whatis_type.exp: Likewise.
> +     * gdb.mi/mi-var-child-f.exp: Likewise.
> +
>  2020-04-23  Tom de Vries  <tdevries@suse.de>
>
>       * gdb.base/decl-before-def.exp: Run to main and print a again.
> diff --git a/gdb/testsuite/gdb.dwarf2/dw2-common-block.exp 
> b/gdb/testsuite/gdb.dwarf2/dw2-common-block.exp
> index 9bcf06b17f..cf41c6833f 100644
> --- a/gdb/testsuite/gdb.dwarf2/dw2-common-block.exp
> +++ b/gdb/testsuite/gdb.dwarf2/dw2-common-block.exp
> @@ -30,6 +30,12 @@ if {[skip_fortran_tests]} {
>      return 0
>  }
>
> +# Assembly file is generated using gfortran.
> +# skip running for other compilers.
> +if {![test_compiler_info {gcc-*}]} {
> +    return 0
> +}


I don't think this change relates to the name of the main function, right?  So it should be split into a separate patch.

> +
>  standard_testfile .S
>
>  if { [prepare_for_testing "failed to prepare" "${testfile}" $srcfile 
> \ diff --git a/gdb/testsuite/gdb.fortran/array-bounds-high.exp 
> b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
> index 81e2f87b89..f1945b4112 100644
> --- a/gdb/testsuite/gdb.fortran/array-bounds-high.exp
> +++ b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
> @@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
>
>  set testfile "array-bounds-high"
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
>      return -1
>  }
>
> -if {![runto MAIN__]} {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if {![runto $fmain]} {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/array-bounds.exp 
> b/gdb/testsuite/gdb.fortran/array-bounds.exp
> index 12bf5c2db3..be28ff6da9 100644
> --- a/gdb/testsuite/gdb.fortran/array-bounds.exp
> +++ b/gdb/testsuite/gdb.fortran/array-bounds.exp
> @@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
>
>  set testfile "array-bounds"
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
>      return -1
>  }
>
> -if {![runto MAIN__]} {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if {![runto $fmain]} {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp 
> b/gdb/testsuite/gdb.fortran/array-slices.exp
> index 11997f926a..e91db62aa1 100644
> --- a/gdb/testsuite/gdb.fortran/array-slices.exp
> +++ b/gdb/testsuite/gdb.fortran/array-slices.exp
> @@ -21,13 +21,14 @@
>  if {[skip_fortran_tests]} { return -1 }
>
>  standard_testfile ".f90"
> +load_lib fortran.exp
>
>  if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
>        {debug f90}]} {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![runto $fmain] {

Out of interest, how is this test even passing on gFortran?
runto_main should place a breakpoint on 'main', and I can't see any obvious special case handling for Fortran.

And my main thought is that what we should do is override runto_main in lib/fortran.exp, and then switch all of the test over to using that instead, this would be more consistent with how the C/C++ tests work then.

Thanks,
Andrew

>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/block-data.exp 
> b/gdb/testsuite/gdb.fortran/block-data.exp
> index 292afe6c16..520f0d5d28 100644
> --- a/gdb/testsuite/gdb.fortran/block-data.exp
> +++ b/gdb/testsuite/gdb.fortran/block-data.exp
> @@ -30,8 +30,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    untested "couldn't run to breakpoint MAIN__"
> +if ![runto $fmain] then {
> +    untested "couldn't run to breakpoint $fmain"
>      return -1
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/charset.exp 
> b/gdb/testsuite/gdb.fortran/charset.exp
> index f0f62f8490..11ab9dfdf0 100644
> --- a/gdb/testsuite/gdb.fortran/charset.exp
> +++ b/gdb/testsuite/gdb.fortran/charset.exp
> @@ -19,12 +19,14 @@
>  if { [skip_fortran_tests] } { return -1 }
>
>  standard_testfile .f90
> +load_lib fortran.exp
> +
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug additional_flags=-fbackslash f90}] } {
>      return -1
>  }
>
> -if ![runto MAIN__] {
> -    perror "Couldn't run to MAIN__"
> +if ![runto $fmain] {
> +    perror "Couldn't run to $fmain"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/common-block.exp 
> b/gdb/testsuite/gdb.fortran/common-block.exp
> index 19c1af0d81..2b74a18e75 100644
> --- a/gdb/testsuite/gdb.fortran/common-block.exp
> +++ b/gdb/testsuite/gdb.fortran/common-block.exp
> @@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" ${testfile} \
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![runto $fmain] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/complex.exp 
> b/gdb/testsuite/gdb.fortran/complex.exp
> index c092ab29f1..8ac81c1fcb 100644
> --- a/gdb/testsuite/gdb.fortran/complex.exp
> +++ b/gdb/testsuite/gdb.fortran/complex.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cb7392cd73e1c436d40bd08d7e838c14c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637233202780899083&amp;sdata=%2FojecdGcIV3p2o50VWqN4WjFdhC8fXbtO0NngSBBYPE%3D&amp;reserved=0>.
>
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "Couldn't run to MAIN__"
> +if ![runto $fmain] then {
> +    perror "Couldn't run to $fmain"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/derived-type-function.exp 
> b/gdb/testsuite/gdb.fortran/derived-type-function.exp
> index 1f0f957317..8a298f5f7b 100644
> --- a/gdb/testsuite/gdb.fortran/derived-type-function.exp
> +++ b/gdb/testsuite/gdb.fortran/derived-type-function.exp
> @@ -21,13 +21,14 @@
>  if { [skip_fortran_tests] } { return -1 }
>
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![runto $fmain] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/derived-type.exp 
> b/gdb/testsuite/gdb.fortran/derived-type.exp
> index f1705bffd8..eddd985e59 100644
> --- a/gdb/testsuite/gdb.fortran/derived-type.exp
> +++ b/gdb/testsuite/gdb.fortran/derived-type.exp
> @@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![runto $fmain] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/info-modules.exp 
> b/gdb/testsuite/gdb.fortran/info-modules.exp
> index 0c3c6a58e1..9967803dcc 100644
> --- a/gdb/testsuite/gdb.fortran/info-modules.exp
> +++ b/gdb/testsuite/gdb.fortran/info-modules.exp
> @@ -28,8 +28,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![runto $fmain] } {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/info-types.exp 
> b/gdb/testsuite/gdb.fortran/info-types.exp
> index 2138937782..7f58740ed8 100644
> --- a/gdb/testsuite/gdb.fortran/info-types.exp
> +++ b/gdb/testsuite/gdb.fortran/info-types.exp
> @@ -27,8 +27,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![runto $fmain] } {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/intrinsics.exp 
> b/gdb/testsuite/gdb.fortran/intrinsics.exp
> index 504bce4138..dca2d98cf4 100644
> --- a/gdb/testsuite/gdb.fortran/intrinsics.exp
> +++ b/gdb/testsuite/gdb.fortran/intrinsics.exp
> @@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![runto $fmain] } {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/library-module.exp 
> b/gdb/testsuite/gdb.fortran/library-module.exp
> index f25988e32c..eb26551f4d 100644
> --- a/gdb/testsuite/gdb.fortran/library-module.exp
> +++ b/gdb/testsuite/gdb.fortran/library-module.exp
> @@ -40,9 +40,10 @@ if  { [gdb_compile $srcdir/$subdir/$srcfile 
> $binfile executable [list debug f90  clean_restart $testfile
>
>  gdb_load_shlib $libfile
> +load_lib fortran.exp
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![runto $fmain] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/logical.exp 
> b/gdb/testsuite/gdb.fortran/logical.exp
> index 324714fa49..ef5954aaf9 100644
> --- a/gdb/testsuite/gdb.fortran/logical.exp
> +++ b/gdb/testsuite/gdb.fortran/logical.exp
> @@ -16,13 +16,14 @@
>  # This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
>
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![runto $fmain] } {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/max-depth.exp 
> b/gdb/testsuite/gdb.fortran/max-depth.exp
> index 262d0fdfa1..52b5a24b98 100644
> --- a/gdb/testsuite/gdb.fortran/max-depth.exp
> +++ b/gdb/testsuite/gdb.fortran/max-depth.exp
> @@ -26,8 +26,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![runto $fmain] } {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/module.exp 
> b/gdb/testsuite/gdb.fortran/module.exp
> index 1c269e2fed..9f5c79fba2 100644
> --- a/gdb/testsuite/gdb.fortran/module.exp
> +++ b/gdb/testsuite/gdb.fortran/module.exp
> @@ -29,8 +29,8 @@ gdb_test "p modmany::var_i" " = 14" "stopped language detection"
>
>  gdb_test "print mod1::var_const" " = 20" "fully qualified name of DW_TAG_constant"
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![runto $fmain] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>
> @@ -123,7 +123,7 @@ complete "modmany::var" $modmany_list  # 
> Breakpoint would work in language "c".
>  gdb_test "show language" {The current source language is "(auto; 
> currently )?fortran".}
>
> -# gcc-4.4.2: The main program is always MAIN__ in .symtab so "runto" 
> above
> +# gcc-4.4.2: The main program is always $fmain in .symtab so "runto" 
> +above
>  # works.  But DWARF DW_TAG_subprogram contains the name specified by  
> # the "program" Fortran statement.
>  if [gdb_breakpoint "module"] {
> diff --git a/gdb/testsuite/gdb.fortran/multi-dim.exp 
> b/gdb/testsuite/gdb.fortran/multi-dim.exp
> index 05590914df..2567f166e2 100644
> --- a/gdb/testsuite/gdb.fortran/multi-dim.exp
> +++ b/gdb/testsuite/gdb.fortran/multi-dim.exp
> @@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug f90}
>      return -1
>  }
>
> -if ![runto MAIN__] {
> -    perror "Couldn't run to MAIN__"
> +if ![runto $fmain] {
> +    perror "Couldn't run to $fmain"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/nested-funcs.exp 
> b/gdb/testsuite/gdb.fortran/nested-funcs.exp
> index e4fc02ffa5..b68227cb5a 100755
> --- a/gdb/testsuite/gdb.fortran/nested-funcs.exp
> +++ b/gdb/testsuite/gdb.fortran/nested-funcs.exp
> @@ -25,8 +25,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![runto $fmain] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/print-formatted.exp 
> b/gdb/testsuite/gdb.fortran/print-formatted.exp
> index 8c6529ce7f..cd12c6b3c4 100644
> --- a/gdb/testsuite/gdb.fortran/print-formatted.exp
> +++ b/gdb/testsuite/gdb.fortran/print-formatted.exp
> @@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    fail "runto MAIN__"
> +if { ![runto $fmain] } {
> +    fail "runto $fmain"
>      return -1
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/print_type.exp 
> b/gdb/testsuite/gdb.fortran/print_type.exp
> index 7d5915390d..615c2be226 100755
> --- a/gdb/testsuite/gdb.fortran/print_type.exp
> +++ b/gdb/testsuite/gdb.fortran/print_type.exp
> @@ -24,7 +24,7 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/printing-types.exp 
> b/gdb/testsuite/gdb.fortran/printing-types.exp
> index 2c88f9e003..206cccd19b 100644
> --- a/gdb/testsuite/gdb.fortran/printing-types.exp
> +++ b/gdb/testsuite/gdb.fortran/printing-types.exp
> @@ -16,13 +16,14 @@
>  if {[skip_fortran_tests]} { return -1 }
>
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if {![runto MAIN__]} then {
> -    untested "could not run to breakpoint MAIN__"
> +if {![runto $fmain]} then {
> +    untested "could not run to breakpoint $fmain"
>      return -1
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/ptr-indentation.exp 
> b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
> index 285e24e2cc..bffd4983f0 100644
> --- a/gdb/testsuite/gdb.fortran/ptr-indentation.exp
> +++ b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
> @@ -22,8 +22,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if {![runto MAIN__]} then {
> -    untested "couldn't run to breakpoint MAIN__"
> +if {![runto $fmain]} then {
> +    untested "couldn't run to breakpoint $fmain"
>      return -1
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp 
> b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> index d91e4bd48e..bf1f5d8637 100644
> --- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> +++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> @@ -24,8 +24,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![runto $fmain] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/subarray.exp 
> b/gdb/testsuite/gdb.fortran/subarray.exp
> index 5e3e8c38cb..c8aa5fe829 100644
> --- a/gdb/testsuite/gdb.fortran/subarray.exp
> +++ b/gdb/testsuite/gdb.fortran/subarray.exp
> @@ -21,6 +21,7 @@
>  if { [skip_fortran_tests] } { return -1 }
>
>  standard_testfile .f
> +load_lib fortran.exp
>
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
> @@ -31,8 +32,8 @@ gdb_start
>  gdb_reinitialize_dir $srcdir/$subdir
>  gdb_load ${binfile}
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![runto $fmain] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp 
> b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
> index 5d8585c2ee..ba1ee8e58c 100644
> --- a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cb7392cd73e1c436d40bd08d7e838c14c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637233202780899083&amp;sdata=%2FojecdGcIV3p2o50VWqN4WjFdhC8fXbtO0NngSBBYPE%3D&amp;reserved=0>.
>
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-datatypes.exp 
> b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
> index 2db9b3e110..b4c4b198c3 100644
> --- a/gdb/testsuite/gdb.fortran/vla-datatypes.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
> @@ -24,7 +24,7 @@ if { [prepare_for_testing "failed to prepare" 
> ${testfile} ${srcfile} \  # check that all fortran standard datatypes 
> will be  # handled correctly when using as VLA's
>
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-history.exp 
> b/gdb/testsuite/gdb.fortran/vla-history.exp
> index 24bd945f4a..aa38d5288c 100644
> --- a/gdb/testsuite/gdb.fortran/vla-history.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-history.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cb7392cd73e1c436d40bd08d7e838c14c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637233202780899083&amp;sdata=%2FojecdGcIV3p2o50VWqN4WjFdhC8fXbtO0NngSBBYPE%3D&amp;reserved=0>.
>
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp 
> b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> index 24c7b45840..1538f689e2 100644
> --- a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cb7392cd73e1c436d40bd08d7e838c14c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637233202780899083&amp;sdata=%2FojecdGcIV3p2o50VWqN4WjFdhC8fXbtO0NngSBBYPE%3D&amp;reserved=0>.
>
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp 
> b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
> index 09909e74b0..90455601e4 100644
> --- a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-ptype.exp 
> b/gdb/testsuite/gdb.fortran/vla-ptype.exp
> index 22b2005317..39d00a32c2 100644
> --- a/gdb/testsuite/gdb.fortran/vla-ptype.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-ptype.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp 
> b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
> index 8e7d36314e..c826d96eb9 100644
> --- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cb7392cd73e1c436d40bd08d7e838c14c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637233202780899083&amp;sdata=%2FojecdGcIV3p2o50VWqN4WjFdhC8fXbtO0NngSBBYPE%3D&amp;reserved=0>.
>
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-type.exp 
> b/gdb/testsuite/gdb.fortran/vla-type.exp
> index 6d885e7889..d9b66ff395 100755
> --- a/gdb/testsuite/gdb.fortran/vla-type.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-type.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp 
> b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
> index ab61dde06f..a18b4e4209 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cb7392cd73e1c436d40bd08d7e838c14c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637233202780899083&amp;sdata=%2FojecdGcIV3p2o50VWqN4WjFdhC8fXbtO0NngSBBYPE%3D&amp;reserved=0>.
>
>  standard_testfile "vla-sub.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp 
> b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
> index afd992cee4..a056fc2732 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cb7392cd73e1c436d40bd08d7e838c14c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637233202780899083&amp;sdata=%2FojecdGcIV3p2o50VWqN4WjFdhC8fXbtO0NngSBBYPE%3D&amp;reserved=0>.
>
>  standard_testfile "vla-sub.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub.exp 
> b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
> index 3311f6befa..e0a42260a4 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value-sub.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cb7392cd73e1c436d40bd08d7e838c14c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637233202780899083&amp;sdata=%2FojecdGcIV3p2o50VWqN4WjFdhC8fXbtO0NngSBBYPE%3D&amp;reserved=0>.
>
>  standard_testfile "vla-sub.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp 
> b/gdb/testsuite/gdb.fortran/vla-value.exp
> index 5af17b570c..994a5a3e7a 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![runto $fmain] {
>      untested "could not run to main"
>      return -1
>  }
> @@ -129,8 +129,8 @@ gdb_test "print vla1(9, 9, 9)" "no such vector 
> element \\\(vector not allocated\  # Try to assign VLA to user 
> variable  clean_restart ${testfile}
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![runto $fmain] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>  gdb_breakpoint [gdb_get_line_number "vla2-allocated"] diff --git 
> a/gdb/testsuite/gdb.fortran/whatis_type.exp 
> b/gdb/testsuite/gdb.fortran/whatis_type.exp
> index 6a9cc0a81e..8a9a1eb79f 100644
> --- a/gdb/testsuite/gdb.fortran/whatis_type.exp
> +++ b/gdb/testsuite/gdb.fortran/whatis_type.exp
> @@ -23,8 +23,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
>      return -1
>  }
>
> -if ![runto MAIN__] {
> -    fail "run to MAIN__"
> +if ![runto $fmain] {
> +    fail "run to $fmain"
>      return
>  }
>
> diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp 
> b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
> index 8cfffa7c08..363da0b7ed 100644
> --- a/gdb/testsuite/gdb.mi/mi-var-child-f.exp
> +++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
> @@ -36,7 +36,7 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" 
> "${binfile}" \  mi_gdb_reinitialize_dir $srcdir/$subdir  mi_gdb_load 
> ${binfile}
>
> -mi_runto MAIN__
> +mi_runto $fmain
>
>  mi_create_varobj "array" "array" "create local variable array"
>
> diff --git a/gdb/testsuite/lib/fortran.exp 
> b/gdb/testsuite/lib/fortran.exp index 549ed65790..0bd95504c8 100644
> --- a/gdb/testsuite/lib/fortran.exp
> +++ b/gdb/testsuite/lib/fortran.exp
> @@ -18,6 +18,8 @@
>  # Auxiliary function to set the language to fortran.
>  # The result is 1 (true) for success, 0 (false) for failure.
>
> +global fmain
> +
>  proc set_lang_fortran {} {
>      if [gdb_test_no_output "set language fortran"] {
>       return 0
> @@ -126,3 +128,17 @@ proc fortran_character1 {} {
>       return "unknown"
>      }
>  }
> +
> +proc fortran_main {} {
> +    if {[test_compiler_info {gcc-4-[012]-*}]
> +         || [test_compiler_info {gcc-*}]
> +         || [test_compiler_info {icc-*}]} {
> +     return "MAIN__"
> +    } elseif {[test_compiler_info {clang-*}]} {
> +     return "MAIN_"
> +    } else {
> +     return "unknown"
> +    }
> +}
> +
> +set fmain  [fortran_main]
> --
> 2.17.1


[-- Attachment #2: 0001-gdb-fortran-Allow-Flang-MAIN_-in-Fortran-testing.patch --]
[-- Type: application/octet-stream, Size: 25358 bytes --]

From a04f53ce7528e238083a2189b487f206342274fa Mon Sep 17 00:00:00 2001
From: Alok Kumar Sharma <AlokKumar.Sharma@amd.com>
Date: Fri, 24 Apr 2020 14:46:09 +0530
Subject: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing

Name of fortran main function for Flang compiler is MAIN_ while
for gfortran it is MAIN__ . In test cases MAIN__ is hardcoded for
the purpose of inserting breakpoint.

New proc is added to detect main function name depending on the
compiler used.
runto_main proc is overloaded in fortran.exp

This commit adds support for Flang main function, there should be
no change for gfortran.

gdb/testsuite/ChangeLog

	* lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
	proc runto_main is overloaded to handle fortran main function.
	* gdb.fortran/array-bounds-high.exp: Handle flang MAIN_.
	* gdb.fortran/array-bounds.exp: Likewise.
	* gdb.fortran/array-slices.exp: Likewise.
	* gdb.fortran/block-data.exp: Likewise.
	* gdb.fortran/charset.exp: Likewise.
	* gdb.fortran/common-block.exp: Likewise.
	* gdb.fortran/complex.exp: Likewise.
	* gdb.fortran/derived-type-function.exp: Likewise.
	* gdb.fortran/derived-type.exp: Likewise.
	* gdb.fortran/info-modules.exp: Likewise.
	* gdb.fortran/info-types.exp: Likewise.
	* gdb.fortran/intrinsics.exp: Likewise.
	* gdb.fortran/library-module.exp: Likewise.
	* gdb.fortran/logical.exp: Likewise.
	* gdb.fortran/max-depth.exp: Likewise.
	* gdb.fortran/module.exp: Likewise.
	* gdb.fortran/multi-dim.exp: Likewise.
	* gdb.fortran/nested-funcs.exp: Likewise.
	* gdb.fortran/print-formatted.exp: Likewise.
	* gdb.fortran/printing-types.exp: Likewise.
	* gdb.fortran/ptr-indentation.exp: Likewise.
	* gdb.fortran/ptype-on-functions.exp: Likewise.
	* gdb.fortran/subarray.exp: Likewise.
	* gdb.fortran/vla-alloc-assoc.exp: Likewise.
	* gdb.fortran/vla-history.exp: Likewise.
	* gdb.fortran/vla-ptr-info.exp: Likewise.
	* gdb.fortran/vla-sizeof.exp: Likewise.
	* gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
	* gdb.fortran/vla-value-sub-finish.exp: Likewise.
	* gdb.fortran/vla-value-sub.exp: Likewise.
	* gdb.fortran/vla-value.exp: Likewise.
	* gdb.fortran/whatis_type.exp: Likewise.
	* gdb.mi/mi-var-child-f.exp: Likewise.

Change-Id: I0a30f5dad684879b416f71d3d08c385c159325bf
---
 gdb/testsuite/ChangeLog                       | 37 +++++++++++++++++++
 .../gdb.fortran/array-bounds-high.exp         |  5 ++-
 gdb/testsuite/gdb.fortran/array-bounds.exp    |  5 ++-
 gdb/testsuite/gdb.fortran/array-slices.exp    |  1 +
 gdb/testsuite/gdb.fortran/block-data.exp      |  4 +-
 gdb/testsuite/gdb.fortran/charset.exp         |  6 ++-
 gdb/testsuite/gdb.fortran/common-block.exp    |  4 +-
 gdb/testsuite/gdb.fortran/complex.exp         |  5 ++-
 .../gdb.fortran/derived-type-function.exp     |  5 ++-
 gdb/testsuite/gdb.fortran/derived-type.exp    |  4 +-
 gdb/testsuite/gdb.fortran/info-modules.exp    |  4 +-
 gdb/testsuite/gdb.fortran/info-types.exp      |  4 +-
 gdb/testsuite/gdb.fortran/intrinsics.exp      |  4 +-
 gdb/testsuite/gdb.fortran/library-module.exp  |  5 ++-
 gdb/testsuite/gdb.fortran/logical.exp         |  5 ++-
 gdb/testsuite/gdb.fortran/max-depth.exp       |  4 +-
 gdb/testsuite/gdb.fortran/module.exp          |  6 +--
 gdb/testsuite/gdb.fortran/multi-dim.exp       |  4 +-
 gdb/testsuite/gdb.fortran/nested-funcs.exp    |  4 +-
 gdb/testsuite/gdb.fortran/print-formatted.exp |  4 +-
 gdb/testsuite/gdb.fortran/printing-types.exp  |  5 ++-
 gdb/testsuite/gdb.fortran/ptr-indentation.exp |  4 +-
 .../gdb.fortran/ptype-on-functions.exp        |  4 +-
 gdb/testsuite/gdb.fortran/subarray.exp        |  5 ++-
 gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp |  1 +
 gdb/testsuite/gdb.fortran/vla-history.exp     |  1 +
 gdb/testsuite/gdb.fortran/vla-ptr-info.exp    |  1 +
 gdb/testsuite/gdb.fortran/vla-sizeof.exp      |  1 +
 .../gdb.fortran/vla-value-sub-arbitrary.exp   |  1 +
 .../gdb.fortran/vla-value-sub-finish.exp      |  1 +
 gdb/testsuite/gdb.fortran/vla-value-sub.exp   |  1 +
 gdb/testsuite/gdb.fortran/vla-value.exp       |  4 +-
 gdb/testsuite/gdb.fortran/whatis_type.exp     |  4 +-
 gdb/testsuite/gdb.mi/mi-var-child-f.exp       |  2 +-
 gdb/testsuite/lib/fortran.exp                 | 22 +++++++++++
 35 files changed, 127 insertions(+), 50 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 10683db566..a7a2726aa7 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,40 @@
+2020-04-24  Alok Kumar Sharma  <alokkumar.sharma@amd.com>
+
+	* lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_.
+	* gdb.fortran/array-bounds-high.exp: Handle flang MAIN_
+	* gdb.fortran/array-bounds.exp: Likewise.
+	* gdb.fortran/array-slices.exp: Likewise.
+	* gdb.fortran/block-data.exp: Likewise.
+	* gdb.fortran/charset.exp: Likewise.
+	* gdb.fortran/common-block.exp: Likewise.
+	* gdb.fortran/complex.exp: Likewise.
+	* gdb.fortran/derived-type-function.exp: Likewise.
+	* gdb.fortran/derived-type.exp: Likewise.
+	* gdb.fortran/info-modules.exp: Likewise.
+	* gdb.fortran/info-types.exp: Likewise.
+	* gdb.fortran/intrinsics.exp: Likewise.
+	* gdb.fortran/library-module.exp: Likewise.
+	* gdb.fortran/logical.exp: Likewise.
+	* gdb.fortran/max-depth.exp: Likewise.
+	* gdb.fortran/module.exp: Likewise.
+	* gdb.fortran/multi-dim.exp: Likewise.
+	* gdb.fortran/nested-funcs.exp: Likewise.
+	* gdb.fortran/print-formatted.exp: Likewise.
+	* gdb.fortran/printing-types.exp: Likewise.
+	* gdb.fortran/ptr-indentation.exp: Likewise.
+	* gdb.fortran/ptype-on-functions.exp: Likewise.
+	* gdb.fortran/subarray.exp: Likewise.
+	* gdb.fortran/vla-alloc-assoc.exp: Likewise.
+	* gdb.fortran/vla-history.exp: Likewise.
+	* gdb.fortran/vla-ptr-info.exp: Likewise.
+	* gdb.fortran/vla-sizeof.exp: Likewise.
+	* gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
+	* gdb.fortran/vla-value-sub-finish.exp: Likewise.
+	* gdb.fortran/vla-value-sub.exp: Likewise.
+	* gdb.fortran/vla-value.exp: Likewise.
+	* gdb.fortran/whatis_type.exp: Likewise.
+	* gdb.mi/mi-var-child-f.exp: Likewise.
+
 2020-04-23  Tom de Vries  <tdevries@suse.de>
 
 	* gdb.base/decl-before-def.exp: Run to main and print a again.
diff --git a/gdb/testsuite/gdb.fortran/array-bounds-high.exp b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
index 81e2f87b89..9d403c0de0 100644
--- a/gdb/testsuite/gdb.fortran/array-bounds-high.exp
+++ b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
@@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
 
 set testfile "array-bounds-high"
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
     return -1
 }
 
-if {![runto MAIN__]} {
-    perror "Could not run to breakpoint `MAIN__'."
+if {![runto_main]} {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/array-bounds.exp b/gdb/testsuite/gdb.fortran/array-bounds.exp
index 12bf5c2db3..3c06886e35 100644
--- a/gdb/testsuite/gdb.fortran/array-bounds.exp
+++ b/gdb/testsuite/gdb.fortran/array-bounds.exp
@@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
 
 set testfile "array-bounds"
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
     return -1
 }
 
-if {![runto MAIN__]} {
-    perror "Could not run to breakpoint `MAIN__'."
+if {![runto_main]} {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp b/gdb/testsuite/gdb.fortran/array-slices.exp
index 11997f926a..927415cfb6 100644
--- a/gdb/testsuite/gdb.fortran/array-slices.exp
+++ b/gdb/testsuite/gdb.fortran/array-slices.exp
@@ -21,6 +21,7 @@
 if {[skip_fortran_tests]} { return -1 }
 
 standard_testfile ".f90"
+load_lib fortran.exp
 
 if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
 	 {debug f90}]} {
diff --git a/gdb/testsuite/gdb.fortran/block-data.exp b/gdb/testsuite/gdb.fortran/block-data.exp
index 292afe6c16..15824a04bf 100644
--- a/gdb/testsuite/gdb.fortran/block-data.exp
+++ b/gdb/testsuite/gdb.fortran/block-data.exp
@@ -30,8 +30,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    untested "couldn't run to breakpoint MAIN__"
+if ![runto_main] then {
+    untested "couldn't run to breakpoint $fmain"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/charset.exp b/gdb/testsuite/gdb.fortran/charset.exp
index f0f62f8490..a4fccfadbd 100644
--- a/gdb/testsuite/gdb.fortran/charset.exp
+++ b/gdb/testsuite/gdb.fortran/charset.exp
@@ -19,12 +19,14 @@
 if { [skip_fortran_tests] } { return -1 }
 
 standard_testfile .f90
+load_lib fortran.exp
+
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug additional_flags=-fbackslash f90}] } {
     return -1
 }
 
-if ![runto MAIN__] {
-    perror "Couldn't run to MAIN__"
+if ![runto_main] {
+    perror "Couldn't run to $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/common-block.exp b/gdb/testsuite/gdb.fortran/common-block.exp
index 19c1af0d81..9ab6b07b37 100644
--- a/gdb/testsuite/gdb.fortran/common-block.exp
+++ b/gdb/testsuite/gdb.fortran/common-block.exp
@@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" ${testfile} \
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto_main] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/complex.exp b/gdb/testsuite/gdb.fortran/complex.exp
index c092ab29f1..257d78184b 100644
--- a/gdb/testsuite/gdb.fortran/complex.exp
+++ b/gdb/testsuite/gdb.fortran/complex.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "Couldn't run to MAIN__"
+if ![runto_main] then {
+    perror "Couldn't run to $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/derived-type-function.exp b/gdb/testsuite/gdb.fortran/derived-type-function.exp
index 1f0f957317..d9dd5c9d78 100644
--- a/gdb/testsuite/gdb.fortran/derived-type-function.exp
+++ b/gdb/testsuite/gdb.fortran/derived-type-function.exp
@@ -21,13 +21,14 @@
 if { [skip_fortran_tests] } { return -1 }
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto_main] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/derived-type.exp b/gdb/testsuite/gdb.fortran/derived-type.exp
index f1705bffd8..bbaa0e3faa 100644
--- a/gdb/testsuite/gdb.fortran/derived-type.exp
+++ b/gdb/testsuite/gdb.fortran/derived-type.exp
@@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto_main] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/info-modules.exp b/gdb/testsuite/gdb.fortran/info-modules.exp
index 0c3c6a58e1..806e68726f 100644
--- a/gdb/testsuite/gdb.fortran/info-modules.exp
+++ b/gdb/testsuite/gdb.fortran/info-modules.exp
@@ -28,8 +28,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![runto_main] } {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/info-types.exp b/gdb/testsuite/gdb.fortran/info-types.exp
index 2138937782..5fec89b106 100644
--- a/gdb/testsuite/gdb.fortran/info-types.exp
+++ b/gdb/testsuite/gdb.fortran/info-types.exp
@@ -27,8 +27,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![runto_main] } {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/intrinsics.exp b/gdb/testsuite/gdb.fortran/intrinsics.exp
index 504bce4138..ece9fe4dd2 100644
--- a/gdb/testsuite/gdb.fortran/intrinsics.exp
+++ b/gdb/testsuite/gdb.fortran/intrinsics.exp
@@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![runto_main] } {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/library-module.exp b/gdb/testsuite/gdb.fortran/library-module.exp
index f25988e32c..964bf0d460 100644
--- a/gdb/testsuite/gdb.fortran/library-module.exp
+++ b/gdb/testsuite/gdb.fortran/library-module.exp
@@ -40,9 +40,10 @@ if  { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list debug f90
 clean_restart $testfile
 
 gdb_load_shlib $libfile
+load_lib fortran.exp
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto_main] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/logical.exp b/gdb/testsuite/gdb.fortran/logical.exp
index 324714fa49..f454d7439a 100644
--- a/gdb/testsuite/gdb.fortran/logical.exp
+++ b/gdb/testsuite/gdb.fortran/logical.exp
@@ -16,13 +16,14 @@
 # This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![runto_main] } {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/max-depth.exp b/gdb/testsuite/gdb.fortran/max-depth.exp
index 262d0fdfa1..020ba26144 100644
--- a/gdb/testsuite/gdb.fortran/max-depth.exp
+++ b/gdb/testsuite/gdb.fortran/max-depth.exp
@@ -26,8 +26,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![runto_main] } {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/module.exp b/gdb/testsuite/gdb.fortran/module.exp
index 1c269e2fed..4b5a8acd9d 100644
--- a/gdb/testsuite/gdb.fortran/module.exp
+++ b/gdb/testsuite/gdb.fortran/module.exp
@@ -29,8 +29,8 @@ gdb_test "p modmany::var_i" " = 14" "stopped language detection"
 
 gdb_test "print mod1::var_const" " = 20" "fully qualified name of DW_TAG_constant"
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto_main] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
@@ -123,7 +123,7 @@ complete "modmany::var" $modmany_list
 # Breakpoint would work in language "c".
 gdb_test "show language" {The current source language is "(auto; currently )?fortran".}
 
-# gcc-4.4.2: The main program is always MAIN__ in .symtab so "runto" above
+# gcc-4.4.2: The main program is always $fmain in .symtab so "runto" above
 # works.  But DWARF DW_TAG_subprogram contains the name specified by
 # the "program" Fortran statement.
 if [gdb_breakpoint "module"] {
diff --git a/gdb/testsuite/gdb.fortran/multi-dim.exp b/gdb/testsuite/gdb.fortran/multi-dim.exp
index 05590914df..e2a4220e1c 100644
--- a/gdb/testsuite/gdb.fortran/multi-dim.exp
+++ b/gdb/testsuite/gdb.fortran/multi-dim.exp
@@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug f90}
     return -1
 }
 
-if ![runto MAIN__] {
-    perror "Couldn't run to MAIN__"
+if ![runto_main] {
+    perror "Couldn't run to $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/nested-funcs.exp b/gdb/testsuite/gdb.fortran/nested-funcs.exp
index e4fc02ffa5..07a5b6d8c3 100755
--- a/gdb/testsuite/gdb.fortran/nested-funcs.exp
+++ b/gdb/testsuite/gdb.fortran/nested-funcs.exp
@@ -25,8 +25,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto_main] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/print-formatted.exp b/gdb/testsuite/gdb.fortran/print-formatted.exp
index 8c6529ce7f..785fa6f798 100644
--- a/gdb/testsuite/gdb.fortran/print-formatted.exp
+++ b/gdb/testsuite/gdb.fortran/print-formatted.exp
@@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
     return -1
 }
 
-if { ![runto MAIN__] } {
-    fail "runto MAIN__"
+if { ![runto_main] } {
+    fail "runto_main"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/printing-types.exp b/gdb/testsuite/gdb.fortran/printing-types.exp
index 2c88f9e003..32ad00281f 100644
--- a/gdb/testsuite/gdb.fortran/printing-types.exp
+++ b/gdb/testsuite/gdb.fortran/printing-types.exp
@@ -16,13 +16,14 @@
 if {[skip_fortran_tests]} { return -1 }
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if {![runto MAIN__]} then {
-    untested "could not run to breakpoint MAIN__"
+if {![runto_main]} then {
+    untested "could not run to breakpoint $fmain"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/ptr-indentation.exp b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
index 285e24e2cc..2ed94dcad8 100644
--- a/gdb/testsuite/gdb.fortran/ptr-indentation.exp
+++ b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
@@ -22,8 +22,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if {![runto MAIN__]} then {
-    untested "couldn't run to breakpoint MAIN__"
+if {![runto_main]} then {
+    untested "couldn't run to breakpoint $fmain"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
index d91e4bd48e..0f81104345 100644
--- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
+++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
@@ -24,8 +24,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto_main] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/subarray.exp b/gdb/testsuite/gdb.fortran/subarray.exp
index 5e3e8c38cb..c17c9b43cd 100644
--- a/gdb/testsuite/gdb.fortran/subarray.exp
+++ b/gdb/testsuite/gdb.fortran/subarray.exp
@@ -21,6 +21,7 @@
 if { [skip_fortran_tests] } { return -1 }
 
 standard_testfile .f
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
@@ -31,8 +32,8 @@ gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_load ${binfile}
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto_main] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
index 5d8585c2ee..5b06115446 100644
--- a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
+++ b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
@@ -14,6 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
diff --git a/gdb/testsuite/gdb.fortran/vla-history.exp b/gdb/testsuite/gdb.fortran/vla-history.exp
index 24bd945f4a..811e1a9275 100644
--- a/gdb/testsuite/gdb.fortran/vla-history.exp
+++ b/gdb/testsuite/gdb.fortran/vla-history.exp
@@ -14,6 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
diff --git a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
index 24c7b45840..f94dfeec17 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
@@ -14,6 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
index 8e7d36314e..6122220139 100644
--- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp
+++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
@@ -14,6 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
index ab61dde06f..d5d143a472 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
@@ -14,6 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla-sub.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
index afd992cee4..280d1eb1eb 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
@@ -14,6 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla-sub.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub.exp b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
index 3311f6befa..d6956da713 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
@@ -14,6 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla-sub.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp
index 5af17b570c..aa35f22b0a 100644
--- a/gdb/testsuite/gdb.fortran/vla-value.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value.exp
@@ -129,8 +129,8 @@ gdb_test "print vla1(9, 9, 9)" "no such vector element \\\(vector not allocated\
 # Try to assign VLA to user variable
 clean_restart ${testfile}
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto_main] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
diff --git a/gdb/testsuite/gdb.fortran/whatis_type.exp b/gdb/testsuite/gdb.fortran/whatis_type.exp
index 6a9cc0a81e..6d66f8d93d 100644
--- a/gdb/testsuite/gdb.fortran/whatis_type.exp
+++ b/gdb/testsuite/gdb.fortran/whatis_type.exp
@@ -23,8 +23,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
     return -1
 }
 
-if ![runto MAIN__] {
-    fail "run to MAIN__"
+if ![runto_main] {
+    fail "run to $fmain"
     return
 }
 
diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
index 8cfffa7c08..363da0b7ed 100644
--- a/gdb/testsuite/gdb.mi/mi-var-child-f.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
@@ -36,7 +36,7 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
 mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load ${binfile}
 
-mi_runto MAIN__
+mi_runto $fmain
 
 mi_create_varobj "array" "array" "create local variable array"
 
diff --git a/gdb/testsuite/lib/fortran.exp b/gdb/testsuite/lib/fortran.exp
index 549ed65790..250db60548 100644
--- a/gdb/testsuite/lib/fortran.exp
+++ b/gdb/testsuite/lib/fortran.exp
@@ -18,6 +18,8 @@
 # Auxiliary function to set the language to fortran.
 # The result is 1 (true) for success, 0 (false) for failure.
 
+global fmain
+
 proc set_lang_fortran {} {
     if [gdb_test_no_output "set language fortran"] {
 	return 0
@@ -126,3 +128,23 @@ proc fortran_character1 {} {
 	return "unknown"
     }
 }
+
+proc fortran_main {} {
+    if {[test_compiler_info {gcc-4-[012]-*}]
+         || [test_compiler_info {gcc-*}]
+         || [test_compiler_info {icc-*}]} {
+	return "MAIN__"
+    } elseif {[test_compiler_info {clang-*}]} {
+	return "MAIN_"
+    } else {
+	return "unknown"
+    }
+}
+
+set fmain  [fortran_main]
+
+# fortran version of runto_main.
+
+proc runto_main { } {
+    return [runto [fortran_main]]
+}
-- 
2.17.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing
  2020-04-24 10:17 ` Andrew Burgess
  2020-04-24 11:48   ` Sharma, Alok Kumar
@ 2020-04-24 12:56   ` Tom Tromey
  2020-04-24 13:37     ` Andrew Burgess
  1 sibling, 1 reply; 14+ messages in thread
From: Tom Tromey @ 2020-04-24 12:56 UTC (permalink / raw)
  To: Andrew Burgess
  Cc: Sharma, Alok Kumar, George, Jini Susan, Achra, Nitika, gdb-patches

>>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:

Andrew> And my main thought is that what we should do is override runto_main
Andrew> in lib/fortran.exp, and then switch all of the test over to using that
Andrew> instead, this would be more consistent with how the C/C++ tests work
Andrew> then.

Redefining procs is a bit dangerous because it can change the test
environment for subsequent tests, which may not be Fortran tests.  I'm
not sure if that's what you were proposing but I figured I'd point it
out just in case.

Tom

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing
  2020-04-24 11:48   ` Sharma, Alok Kumar
@ 2020-04-24 12:58     ` Tom Tromey
  0 siblings, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2020-04-24 12:58 UTC (permalink / raw)
  To: Sharma, Alok Kumar
  Cc: Andrew Burgess, George, Jini Susan, Achra, Nitika, gdb-patches

>>>>> ">" == Sharma, Alok Kumar <AlokKumar.Sharma@amd.com> writes:

Following on to my previous note...

>> +proc runto_main { } {
>> +    return [runto [fortran_main]]
>> +}

If you try "runtest some-fortran-test.exp some-c++-test.exp", I think
this redefinition will cause failures.

Tom

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing
  2020-04-24 12:56   ` Tom Tromey
@ 2020-04-24 13:37     ` Andrew Burgess
  2020-04-24 14:02       ` Tom Tromey
  2020-04-24 15:54       ` Sharma, Alok Kumar
  0 siblings, 2 replies; 14+ messages in thread
From: Andrew Burgess @ 2020-04-24 13:37 UTC (permalink / raw)
  To: Tom Tromey
  Cc: Sharma, Alok Kumar, George, Jini Susan, Achra, Nitika, gdb-patches

* Tom Tromey <tom@tromey.com> [2020-04-24 06:56:13 -0600]:

> >>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:
> 
> Andrew> And my main thought is that what we should do is override runto_main
> Andrew> in lib/fortran.exp, and then switch all of the test over to using that
> Andrew> instead, this would be more consistent with how the C/C++ tests work
> Andrew> then.
> 
> Redefining procs is a bit dangerous because it can change the test
> environment for subsequent tests, which may not be Fortran tests.  I'm
> not sure if that's what you were proposing but I figured I'd point it
> out just in case.

OK, that's a valid point.

Maybe we should just make 'proc runto_main' smarter then?  Add some
logic to pick a suitable name for the main function per-language?

Or maybe we should do 'proc fortran_runto_main' .... ?

I'd just like something that's more inline with the existing
'runto_main' in style I think..

Thanks,
Andrew

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing
  2020-04-24 13:37     ` Andrew Burgess
@ 2020-04-24 14:02       ` Tom Tromey
  2020-04-24 15:54       ` Sharma, Alok Kumar
  1 sibling, 0 replies; 14+ messages in thread
From: Tom Tromey @ 2020-04-24 14:02 UTC (permalink / raw)
  To: Andrew Burgess
  Cc: Tom Tromey, Sharma, Alok Kumar, George, Jini Susan, Achra,
	Nitika, gdb-patches

>>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:

Andrew> Maybe we should just make 'proc runto_main' smarter then?  Add some
Andrew> logic to pick a suitable name for the main function per-language?

Andrew> Or maybe we should do 'proc fortran_runto_main' .... ?

Either of these would be fine by me.

Tom

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing
  2020-04-24 13:37     ` Andrew Burgess
  2020-04-24 14:02       ` Tom Tromey
@ 2020-04-24 15:54       ` Sharma, Alok Kumar
  2020-04-27  9:07         ` Andrew Burgess
  1 sibling, 1 reply; 14+ messages in thread
From: Sharma, Alok Kumar @ 2020-04-24 15:54 UTC (permalink / raw)
  To: Andrew Burgess, Tom Tromey; +Cc: George, Jini Susan, Achra, Nitika, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 3980 bytes --]

Thanks a lot Tom and Andrew for your reviews.

Please find the updated patch as an attachment. 
Now fortran specific runto_main is renamed as fortran_runto_main, which is inline with the other such procedures as go_runto_main etc.

    gdb/testsuite/ChangeLog

            * lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
            (fortran_runto_main): New Proc, fortran version of runto_main.
            * gdb.fortran/array-bounds-high.exp: Handle flang MAIN_.
            * gdb.fortran/array-bounds.exp: Likewise.
            * gdb.fortran/array-slices.exp: Likewise.
            * gdb.fortran/block-data.exp: Likewise.
            * gdb.fortran/charset.exp: Likewise.
            * gdb.fortran/common-block.exp: Likewise.
            * gdb.fortran/complex.exp: Likewise.
            * gdb.fortran/derived-type-function.exp: Likewise.
            * gdb.fortran/derived-type.exp: Likewise.
            * gdb.fortran/info-modules.exp: Likewise.
            * gdb.fortran/info-types.exp: Likewise.
            * gdb.fortran/intrinsics.exp: Likewise.
            * gdb.fortran/library-module.exp: Likewise.
            * gdb.fortran/logical.exp: Likewise.
            * gdb.fortran/max-depth.exp: Likewise.
            * gdb.fortran/module.exp: Likewise.
            * gdb.fortran/multi-dim.exp: Likewise.
            * gdb.fortran/nested-funcs.exp: Likewise.
            * gdb.fortran/print-formatted.exp: Likewise.
            * gdb.fortran/print_type.exp: Likewise.
            * gdb.fortran/printing-types.exp: Likewise.
            * gdb.fortran/ptr-indentation.exp: Likewise.
            * gdb.fortran/ptype-on-functions.exp: Likewise.
            * gdb.fortran/subarray.exp: Likewise.
            * gdb.fortran/vla-alloc-assoc.exp: Likewise.
            * gdb.fortran/vla-datatypes.exp: Likewise.
            * gdb.fortran/vla-history.exp: Likewise.
            * gdb.fortran/vla-ptr-info.exp: Likewise.
            * gdb.fortran/vla-ptype-sub.exp: Likewise.
            * gdb.fortran/vla-ptype.exp: Likewise.
            * gdb.fortran/vla-sizeof.exp: Likewise.
            * gdb.fortran/vla-type.exp: Likewise.
            * gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
            * gdb.fortran/vla-value-sub-finish.exp: Likewise.
            * gdb.fortran/vla-value-sub.exp: Likewise.
            * gdb.fortran/vla-value.exp: Likewise.
            * gdb.fortran/whatis_type.exp: Likewise.
            * gdb.mi/mi-var-child-f.exp: Likewise.

Please let me know your comments.

Regards,
Alok

-----Original Message-----
From: Andrew Burgess <andrew.burgess@embecosm.com> 
Sent: Friday, April 24, 2020 7:08 PM
To: Tom Tromey <tom@tromey.com>
Cc: Sharma, Alok Kumar <AlokKumar.Sharma@amd.com>; George, Jini Susan <JiniSusan.George@amd.com>; Achra, Nitika <Nitika.Achra@amd.com>; gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing

[CAUTION: External Email]

* Tom Tromey <tom@tromey.com> [2020-04-24 06:56:13 -0600]:

> >>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:
>
> Andrew> And my main thought is that what we should do is override 
> Andrew> runto_main in lib/fortran.exp, and then switch all of the test 
> Andrew> over to using that instead, this would be more consistent with 
> Andrew> how the C/C++ tests work then.
>
> Redefining procs is a bit dangerous because it can change the test 
> environment for subsequent tests, which may not be Fortran tests.  I'm 
> not sure if that's what you were proposing but I figured I'd point it 
> out just in case.

OK, that's a valid point.

Maybe we should just make 'proc runto_main' smarter then?  Add some logic to pick a suitable name for the main function per-language?

Or maybe we should do 'proc fortran_runto_main' .... ?

I'd just like something that's more inline with the existing 'runto_main' in style I think..

Thanks,
Andrew

[-- Attachment #2: 0001-gdb-fortran-Allow-Flang-MAIN_-in-Fortran-testing.patch --]
[-- Type: application/octet-stream, Size: 29869 bytes --]

From f19a15b6afaabda49dd0d102f1defff72cfae4e9 Mon Sep 17 00:00:00 2001
From: Alok Kumar Sharma <AlokKumar.Sharma@amd.com>
Date: Fri, 24 Apr 2020 14:46:09 +0530
Subject: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing

Name of fortran main function for Flang compiler is MAIN_ while
for gfortran it is MAIN__ . In test cases MAIN__ is hardcoded for
the purpose of inserting breakpoint.

New proc is added to detect main function name depending on the
compiler used.
Fortran specific version of runto_main named fortran_runto_main
is added.

This commit adds support for Flang main function, there should be
no change for gfortran.

gdb/testsuite/ChangeLog

	* lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
	(fortran_runto_main): New Proc, fortran version of runto_main.
	* gdb.fortran/array-bounds-high.exp: Handle flang MAIN_.
	* gdb.fortran/array-bounds.exp: Likewise.
	* gdb.fortran/array-slices.exp: Likewise.
	* gdb.fortran/block-data.exp: Likewise.
	* gdb.fortran/charset.exp: Likewise.
	* gdb.fortran/common-block.exp: Likewise.
	* gdb.fortran/complex.exp: Likewise.
	* gdb.fortran/derived-type-function.exp: Likewise.
	* gdb.fortran/derived-type.exp: Likewise.
	* gdb.fortran/info-modules.exp: Likewise.
	* gdb.fortran/info-types.exp: Likewise.
	* gdb.fortran/intrinsics.exp: Likewise.
	* gdb.fortran/library-module.exp: Likewise.
	* gdb.fortran/logical.exp: Likewise.
	* gdb.fortran/max-depth.exp: Likewise.
	* gdb.fortran/module.exp: Likewise.
	* gdb.fortran/multi-dim.exp: Likewise.
	* gdb.fortran/nested-funcs.exp: Likewise.
	* gdb.fortran/print-formatted.exp: Likewise.
	* gdb.fortran/print_type.exp: Likewise.
	* gdb.fortran/printing-types.exp: Likewise.
	* gdb.fortran/ptr-indentation.exp: Likewise.
	* gdb.fortran/ptype-on-functions.exp: Likewise.
	* gdb.fortran/subarray.exp: Likewise.
	* gdb.fortran/vla-alloc-assoc.exp: Likewise.
	* gdb.fortran/vla-datatypes.exp: Likewise.
	* gdb.fortran/vla-history.exp: Likewise.
	* gdb.fortran/vla-ptr-info.exp: Likewise.
	* gdb.fortran/vla-ptype-sub.exp: Likewise.
	* gdb.fortran/vla-ptype.exp: Likewise.
	* gdb.fortran/vla-sizeof.exp: Likewise.
	* gdb.fortran/vla-type.exp: Likewise.
	* gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
	* gdb.fortran/vla-value-sub-finish.exp: Likewise.
	* gdb.fortran/vla-value-sub.exp: Likewise.
	* gdb.fortran/vla-value.exp: Likewise.
	* gdb.fortran/whatis_type.exp: Likewise.
	* gdb.mi/mi-var-child-f.exp: Likewise.

Change-Id: I0a30f5dad684879b416f71d3d08c385c159325bf
---
 gdb/testsuite/ChangeLog                       | 43 +++++++++++++++++++
 .../gdb.fortran/array-bounds-high.exp         |  5 ++-
 gdb/testsuite/gdb.fortran/array-bounds.exp    |  5 ++-
 gdb/testsuite/gdb.fortran/array-slices.exp    |  3 +-
 gdb/testsuite/gdb.fortran/block-data.exp      |  4 +-
 gdb/testsuite/gdb.fortran/charset.exp         |  6 ++-
 gdb/testsuite/gdb.fortran/common-block.exp    |  4 +-
 gdb/testsuite/gdb.fortran/complex.exp         |  5 ++-
 .../gdb.fortran/derived-type-function.exp     |  5 ++-
 gdb/testsuite/gdb.fortran/derived-type.exp    |  4 +-
 gdb/testsuite/gdb.fortran/info-modules.exp    |  4 +-
 gdb/testsuite/gdb.fortran/info-types.exp      |  4 +-
 gdb/testsuite/gdb.fortran/intrinsics.exp      |  4 +-
 gdb/testsuite/gdb.fortran/library-module.exp  |  5 ++-
 gdb/testsuite/gdb.fortran/logical.exp         |  5 ++-
 gdb/testsuite/gdb.fortran/max-depth.exp       |  4 +-
 gdb/testsuite/gdb.fortran/module.exp          |  6 +--
 gdb/testsuite/gdb.fortran/multi-dim.exp       |  4 +-
 gdb/testsuite/gdb.fortran/nested-funcs.exp    |  4 +-
 gdb/testsuite/gdb.fortran/print-formatted.exp |  4 +-
 gdb/testsuite/gdb.fortran/print_type.exp      |  2 +-
 gdb/testsuite/gdb.fortran/printing-types.exp  |  5 ++-
 gdb/testsuite/gdb.fortran/ptr-indentation.exp |  4 +-
 .../gdb.fortran/ptype-on-functions.exp        |  4 +-
 gdb/testsuite/gdb.fortran/subarray.exp        |  5 ++-
 gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp |  3 +-
 gdb/testsuite/gdb.fortran/vla-datatypes.exp   |  2 +-
 gdb/testsuite/gdb.fortran/vla-history.exp     |  3 +-
 gdb/testsuite/gdb.fortran/vla-ptr-info.exp    |  3 +-
 gdb/testsuite/gdb.fortran/vla-ptype-sub.exp   |  2 +-
 gdb/testsuite/gdb.fortran/vla-ptype.exp       |  2 +-
 gdb/testsuite/gdb.fortran/vla-sizeof.exp      |  3 +-
 gdb/testsuite/gdb.fortran/vla-type.exp        |  2 +-
 .../gdb.fortran/vla-value-sub-arbitrary.exp   |  3 +-
 .../gdb.fortran/vla-value-sub-finish.exp      |  3 +-
 gdb/testsuite/gdb.fortran/vla-value-sub.exp   |  3 +-
 gdb/testsuite/gdb.fortran/vla-value.exp       |  6 +--
 gdb/testsuite/gdb.fortran/whatis_type.exp     |  4 +-
 gdb/testsuite/gdb.mi/mi-var-child-f.exp       |  2 +-
 gdb/testsuite/lib/fortran.exp                 | 22 ++++++++++
 40 files changed, 147 insertions(+), 64 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 10683db566..0e3c207f85 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,46 @@
+2020-04-24  Alok Kumar Sharma  <alokkumar.sharma@amd.com>
+
+	* lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
+	(fortran_runto_main): New Proc, fortran version of runto_main.
+	* gdb.fortran/array-bounds-high.exp: Handle flang MAIN_
+	* gdb.fortran/array-bounds.exp: Likewise.
+	* gdb.fortran/array-slices.exp: Likewise.
+	* gdb.fortran/block-data.exp: Likewise.
+	* gdb.fortran/charset.exp: Likewise.
+	* gdb.fortran/common-block.exp: Likewise.
+	* gdb.fortran/complex.exp: Likewise.
+	* gdb.fortran/derived-type-function.exp: Likewise.
+	* gdb.fortran/derived-type.exp: Likewise.
+	* gdb.fortran/info-modules.exp: Likewise.
+	* gdb.fortran/info-types.exp: Likewise.
+	* gdb.fortran/intrinsics.exp: Likewise.
+	* gdb.fortran/library-module.exp: Likewise.
+	* gdb.fortran/logical.exp: Likewise.
+	* gdb.fortran/max-depth.exp: Likewise.
+	* gdb.fortran/module.exp: Likewise.
+	* gdb.fortran/multi-dim.exp: Likewise.
+	* gdb.fortran/nested-funcs.exp: Likewise.
+	* gdb.fortran/print-formatted.exp: Likewise.
+	* gdb.fortran/print_type.exp: Likewise.
+	* gdb.fortran/printing-types.exp: Likewise.
+	* gdb.fortran/ptr-indentation.exp: Likewise.
+	* gdb.fortran/ptype-on-functions.exp: Likewise.
+	* gdb.fortran/subarray.exp: Likewise.
+	* gdb.fortran/vla-alloc-assoc.exp: Likewise.
+	* gdb.fortran/vla-datatypes.exp: Likewise.
+	* gdb.fortran/vla-history.exp: Likewise.
+	* gdb.fortran/vla-ptr-info.exp: Likewise.
+	* gdb.fortran/vla-ptype-sub.exp: Likewise.
+	* gdb.fortran/vla-ptype.exp: Likewise.
+	* gdb.fortran/vla-sizeof.exp: Likewise.
+	* gdb.fortran/vla-type.exp: Likewise.
+	* gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
+	* gdb.fortran/vla-value-sub-finish.exp: Likewise.
+	* gdb.fortran/vla-value-sub.exp: Likewise.
+	* gdb.fortran/vla-value.exp: Likewise.
+	* gdb.fortran/whatis_type.exp: Likewise.
+	* gdb.mi/mi-var-child-f.exp: Likewise.
+
 2020-04-23  Tom de Vries  <tdevries@suse.de>
 
 	* gdb.base/decl-before-def.exp: Run to main and print a again.
diff --git a/gdb/testsuite/gdb.fortran/array-bounds-high.exp b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
index 81e2f87b89..07688c44bf 100644
--- a/gdb/testsuite/gdb.fortran/array-bounds-high.exp
+++ b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
@@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
 
 set testfile "array-bounds-high"
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
     return -1
 }
 
-if {![runto MAIN__]} {
-    perror "Could not run to breakpoint `MAIN__'."
+if {![fortran_runto_main]} {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/array-bounds.exp b/gdb/testsuite/gdb.fortran/array-bounds.exp
index 12bf5c2db3..b5c33e39c3 100644
--- a/gdb/testsuite/gdb.fortran/array-bounds.exp
+++ b/gdb/testsuite/gdb.fortran/array-bounds.exp
@@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
 
 set testfile "array-bounds"
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
     return -1
 }
 
-if {![runto MAIN__]} {
-    perror "Could not run to breakpoint `MAIN__'."
+if {![fortran_runto_main]} {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp b/gdb/testsuite/gdb.fortran/array-slices.exp
index 11997f926a..4ca1db90f7 100644
--- a/gdb/testsuite/gdb.fortran/array-slices.exp
+++ b/gdb/testsuite/gdb.fortran/array-slices.exp
@@ -21,13 +21,14 @@
 if {[skip_fortran_tests]} { return -1 }
 
 standard_testfile ".f90"
+load_lib fortran.exp
 
 if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
 	 {debug f90}]} {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/block-data.exp b/gdb/testsuite/gdb.fortran/block-data.exp
index 292afe6c16..420797fd29 100644
--- a/gdb/testsuite/gdb.fortran/block-data.exp
+++ b/gdb/testsuite/gdb.fortran/block-data.exp
@@ -30,8 +30,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    untested "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    untested "couldn't run to breakpoint $fmain"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/charset.exp b/gdb/testsuite/gdb.fortran/charset.exp
index f0f62f8490..58b7e66f79 100644
--- a/gdb/testsuite/gdb.fortran/charset.exp
+++ b/gdb/testsuite/gdb.fortran/charset.exp
@@ -19,12 +19,14 @@
 if { [skip_fortran_tests] } { return -1 }
 
 standard_testfile .f90
+load_lib fortran.exp
+
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug additional_flags=-fbackslash f90}] } {
     return -1
 }
 
-if ![runto MAIN__] {
-    perror "Couldn't run to MAIN__"
+if ![fortran_runto_main] {
+    perror "Couldn't run to $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/common-block.exp b/gdb/testsuite/gdb.fortran/common-block.exp
index 19c1af0d81..5f7bdd5829 100644
--- a/gdb/testsuite/gdb.fortran/common-block.exp
+++ b/gdb/testsuite/gdb.fortran/common-block.exp
@@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" ${testfile} \
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/complex.exp b/gdb/testsuite/gdb.fortran/complex.exp
index c092ab29f1..eb4705812b 100644
--- a/gdb/testsuite/gdb.fortran/complex.exp
+++ b/gdb/testsuite/gdb.fortran/complex.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "Couldn't run to MAIN__"
+if ![fortran_runto_main] then {
+    perror "Couldn't run to $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/derived-type-function.exp b/gdb/testsuite/gdb.fortran/derived-type-function.exp
index 1f0f957317..fad7bb9b37 100644
--- a/gdb/testsuite/gdb.fortran/derived-type-function.exp
+++ b/gdb/testsuite/gdb.fortran/derived-type-function.exp
@@ -21,13 +21,14 @@
 if { [skip_fortran_tests] } { return -1 }
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/derived-type.exp b/gdb/testsuite/gdb.fortran/derived-type.exp
index f1705bffd8..54aae80263 100644
--- a/gdb/testsuite/gdb.fortran/derived-type.exp
+++ b/gdb/testsuite/gdb.fortran/derived-type.exp
@@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/info-modules.exp b/gdb/testsuite/gdb.fortran/info-modules.exp
index 0c3c6a58e1..e1d96d6ced 100644
--- a/gdb/testsuite/gdb.fortran/info-modules.exp
+++ b/gdb/testsuite/gdb.fortran/info-modules.exp
@@ -28,8 +28,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![fortran_runto_main] } {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/info-types.exp b/gdb/testsuite/gdb.fortran/info-types.exp
index 2138937782..0c509e505d 100644
--- a/gdb/testsuite/gdb.fortran/info-types.exp
+++ b/gdb/testsuite/gdb.fortran/info-types.exp
@@ -27,8 +27,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![fortran_runto_main] } {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/intrinsics.exp b/gdb/testsuite/gdb.fortran/intrinsics.exp
index 504bce4138..800450cd3e 100644
--- a/gdb/testsuite/gdb.fortran/intrinsics.exp
+++ b/gdb/testsuite/gdb.fortran/intrinsics.exp
@@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![fortran_runto_main] } {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/library-module.exp b/gdb/testsuite/gdb.fortran/library-module.exp
index f25988e32c..22475690b9 100644
--- a/gdb/testsuite/gdb.fortran/library-module.exp
+++ b/gdb/testsuite/gdb.fortran/library-module.exp
@@ -40,9 +40,10 @@ if  { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list debug f90
 clean_restart $testfile
 
 gdb_load_shlib $libfile
+load_lib fortran.exp
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/logical.exp b/gdb/testsuite/gdb.fortran/logical.exp
index 324714fa49..d93c95bba5 100644
--- a/gdb/testsuite/gdb.fortran/logical.exp
+++ b/gdb/testsuite/gdb.fortran/logical.exp
@@ -16,13 +16,14 @@
 # This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![fortran_runto_main] } {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/max-depth.exp b/gdb/testsuite/gdb.fortran/max-depth.exp
index 262d0fdfa1..889e0be110 100644
--- a/gdb/testsuite/gdb.fortran/max-depth.exp
+++ b/gdb/testsuite/gdb.fortran/max-depth.exp
@@ -26,8 +26,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![fortran_runto_main] } {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/module.exp b/gdb/testsuite/gdb.fortran/module.exp
index 1c269e2fed..7b57ff78b4 100644
--- a/gdb/testsuite/gdb.fortran/module.exp
+++ b/gdb/testsuite/gdb.fortran/module.exp
@@ -29,8 +29,8 @@ gdb_test "p modmany::var_i" " = 14" "stopped language detection"
 
 gdb_test "print mod1::var_const" " = 20" "fully qualified name of DW_TAG_constant"
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
@@ -123,7 +123,7 @@ complete "modmany::var" $modmany_list
 # Breakpoint would work in language "c".
 gdb_test "show language" {The current source language is "(auto; currently )?fortran".}
 
-# gcc-4.4.2: The main program is always MAIN__ in .symtab so "runto" above
+# gcc-4.4.2: The main program is always $fmain in .symtab so "runto" above
 # works.  But DWARF DW_TAG_subprogram contains the name specified by
 # the "program" Fortran statement.
 if [gdb_breakpoint "module"] {
diff --git a/gdb/testsuite/gdb.fortran/multi-dim.exp b/gdb/testsuite/gdb.fortran/multi-dim.exp
index 05590914df..cc3cdc88de 100644
--- a/gdb/testsuite/gdb.fortran/multi-dim.exp
+++ b/gdb/testsuite/gdb.fortran/multi-dim.exp
@@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug f90}
     return -1
 }
 
-if ![runto MAIN__] {
-    perror "Couldn't run to MAIN__"
+if ![fortran_runto_main] {
+    perror "Couldn't run to $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/nested-funcs.exp b/gdb/testsuite/gdb.fortran/nested-funcs.exp
index e4fc02ffa5..1c87fea3b6 100755
--- a/gdb/testsuite/gdb.fortran/nested-funcs.exp
+++ b/gdb/testsuite/gdb.fortran/nested-funcs.exp
@@ -25,8 +25,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/print-formatted.exp b/gdb/testsuite/gdb.fortran/print-formatted.exp
index 8c6529ce7f..adb9e2e996 100644
--- a/gdb/testsuite/gdb.fortran/print-formatted.exp
+++ b/gdb/testsuite/gdb.fortran/print-formatted.exp
@@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
     return -1
 }
 
-if { ![runto MAIN__] } {
-    fail "runto MAIN__"
+if { ![fortran_runto_main] } {
+    fail "fortran_runto_main"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/print_type.exp b/gdb/testsuite/gdb.fortran/print_type.exp
index 7d5915390d..fcedb9579a 100755
--- a/gdb/testsuite/gdb.fortran/print_type.exp
+++ b/gdb/testsuite/gdb.fortran/print_type.exp
@@ -24,7 +24,7 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/printing-types.exp b/gdb/testsuite/gdb.fortran/printing-types.exp
index 2c88f9e003..e68386eea7 100644
--- a/gdb/testsuite/gdb.fortran/printing-types.exp
+++ b/gdb/testsuite/gdb.fortran/printing-types.exp
@@ -16,13 +16,14 @@
 if {[skip_fortran_tests]} { return -1 }
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if {![runto MAIN__]} then {
-    untested "could not run to breakpoint MAIN__"
+if {![fortran_runto_main]} then {
+    untested "could not run to breakpoint $fmain"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/ptr-indentation.exp b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
index 285e24e2cc..10debb417a 100644
--- a/gdb/testsuite/gdb.fortran/ptr-indentation.exp
+++ b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
@@ -22,8 +22,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if {![runto MAIN__]} then {
-    untested "couldn't run to breakpoint MAIN__"
+if {![fortran_runto_main]} then {
+    untested "couldn't run to breakpoint $fmain"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
index d91e4bd48e..2f9d093dac 100644
--- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
+++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
@@ -24,8 +24,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/subarray.exp b/gdb/testsuite/gdb.fortran/subarray.exp
index 5e3e8c38cb..6510483509 100644
--- a/gdb/testsuite/gdb.fortran/subarray.exp
+++ b/gdb/testsuite/gdb.fortran/subarray.exp
@@ -21,6 +21,7 @@
 if { [skip_fortran_tests] } { return -1 }
 
 standard_testfile .f
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
@@ -31,8 +32,8 @@ gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_load ${binfile}
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
index 5d8585c2ee..2ae0411cf1 100644
--- a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
+++ b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-datatypes.exp b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
index 2db9b3e110..b69636f600 100644
--- a/gdb/testsuite/gdb.fortran/vla-datatypes.exp
+++ b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
@@ -24,7 +24,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
 # check that all fortran standard datatypes will be
 # handled correctly when using as VLA's
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-history.exp b/gdb/testsuite/gdb.fortran/vla-history.exp
index 24bd945f4a..3bf98db197 100644
--- a/gdb/testsuite/gdb.fortran/vla-history.exp
+++ b/gdb/testsuite/gdb.fortran/vla-history.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
index 24c7b45840..d3fa595bea 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
index 09909e74b0..07a4a5fc2e 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-ptype.exp b/gdb/testsuite/gdb.fortran/vla-ptype.exp
index 22b2005317..bbb81ea0c8 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptype.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptype.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
index 8e7d36314e..d26b8c60f8 100644
--- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp
+++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-type.exp b/gdb/testsuite/gdb.fortran/vla-type.exp
index 6d885e7889..f007ea3a78 100755
--- a/gdb/testsuite/gdb.fortran/vla-type.exp
+++ b/gdb/testsuite/gdb.fortran/vla-type.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
index ab61dde06f..c3ed909a81 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla-sub.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
index afd992cee4..403e411cc2 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla-sub.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub.exp b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
index 3311f6befa..fd923edf40 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla-sub.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp
index 5af17b570c..5e696fd4f3 100644
--- a/gdb/testsuite/gdb.fortran/vla-value.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
@@ -129,8 +129,8 @@ gdb_test "print vla1(9, 9, 9)" "no such vector element \\\(vector not allocated\
 # Try to assign VLA to user variable
 clean_restart ${testfile}
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
diff --git a/gdb/testsuite/gdb.fortran/whatis_type.exp b/gdb/testsuite/gdb.fortran/whatis_type.exp
index 6a9cc0a81e..44b256c325 100644
--- a/gdb/testsuite/gdb.fortran/whatis_type.exp
+++ b/gdb/testsuite/gdb.fortran/whatis_type.exp
@@ -23,8 +23,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
     return -1
 }
 
-if ![runto MAIN__] {
-    fail "run to MAIN__"
+if ![fortran_runto_main] {
+    fail "run to $fmain"
     return
 }
 
diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
index 8cfffa7c08..363da0b7ed 100644
--- a/gdb/testsuite/gdb.mi/mi-var-child-f.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
@@ -36,7 +36,7 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
 mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load ${binfile}
 
-mi_runto MAIN__
+mi_runto $fmain
 
 mi_create_varobj "array" "array" "create local variable array"
 
diff --git a/gdb/testsuite/lib/fortran.exp b/gdb/testsuite/lib/fortran.exp
index 549ed65790..9451e96000 100644
--- a/gdb/testsuite/lib/fortran.exp
+++ b/gdb/testsuite/lib/fortran.exp
@@ -18,6 +18,8 @@
 # Auxiliary function to set the language to fortran.
 # The result is 1 (true) for success, 0 (false) for failure.
 
+global fmain
+
 proc set_lang_fortran {} {
     if [gdb_test_no_output "set language fortran"] {
 	return 0
@@ -126,3 +128,23 @@ proc fortran_character1 {} {
 	return "unknown"
     }
 }
+
+proc fortran_main {} {
+    if {[test_compiler_info {gcc-4-[012]-*}]
+         || [test_compiler_info {gcc-*}]
+         || [test_compiler_info {icc-*}]} {
+	return "MAIN__"
+    } elseif {[test_compiler_info {clang-*}]} {
+	return "MAIN_"
+    } else {
+	return "unknown"
+    }
+}
+
+set fmain  [fortran_main]
+
+# fortran version of runto_main.
+
+proc fortran_runto_main { } {
+    return [runto [fortran_main]]
+}
-- 
2.17.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing
  2020-04-24 15:54       ` Sharma, Alok Kumar
@ 2020-04-27  9:07         ` Andrew Burgess
  2020-04-27 18:02           ` Sharma, Alok Kumar
  0 siblings, 1 reply; 14+ messages in thread
From: Andrew Burgess @ 2020-04-27  9:07 UTC (permalink / raw)
  To: Sharma, Alok Kumar
  Cc: Tom Tromey, George, Jini Susan, Achra, Nitika, gdb-patches

* Sharma, Alok Kumar <AlokKumar.Sharma@amd.com> [2020-04-24 15:54:15 +0000]:

> Thanks a lot Tom and Andrew for your reviews.
> 
> Please find the updated patch as an attachment. 
> Now fortran specific runto_main is renamed as fortran_runto_main, which is inline with the other such procedures as go_runto_main etc.
> 
>     gdb/testsuite/ChangeLog
> 
>             * lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
>             (fortran_runto_main): New Proc, fortran version of runto_main.
>             * gdb.fortran/array-bounds-high.exp: Handle flang MAIN_.
>             * gdb.fortran/array-bounds.exp: Likewise.
>             * gdb.fortran/array-slices.exp: Likewise.
>             * gdb.fortran/block-data.exp: Likewise.
>             * gdb.fortran/charset.exp: Likewise.
>             * gdb.fortran/common-block.exp: Likewise.
>             * gdb.fortran/complex.exp: Likewise.
>             * gdb.fortran/derived-type-function.exp: Likewise.
>             * gdb.fortran/derived-type.exp: Likewise.
>             * gdb.fortran/info-modules.exp: Likewise.
>             * gdb.fortran/info-types.exp: Likewise.
>             * gdb.fortran/intrinsics.exp: Likewise.
>             * gdb.fortran/library-module.exp: Likewise.
>             * gdb.fortran/logical.exp: Likewise.
>             * gdb.fortran/max-depth.exp: Likewise.
>             * gdb.fortran/module.exp: Likewise.
>             * gdb.fortran/multi-dim.exp: Likewise.
>             * gdb.fortran/nested-funcs.exp: Likewise.
>             * gdb.fortran/print-formatted.exp: Likewise.
>             * gdb.fortran/print_type.exp: Likewise.
>             * gdb.fortran/printing-types.exp: Likewise.
>             * gdb.fortran/ptr-indentation.exp: Likewise.
>             * gdb.fortran/ptype-on-functions.exp: Likewise.
>             * gdb.fortran/subarray.exp: Likewise.
>             * gdb.fortran/vla-alloc-assoc.exp: Likewise.
>             * gdb.fortran/vla-datatypes.exp: Likewise.
>             * gdb.fortran/vla-history.exp: Likewise.
>             * gdb.fortran/vla-ptr-info.exp: Likewise.
>             * gdb.fortran/vla-ptype-sub.exp: Likewise.
>             * gdb.fortran/vla-ptype.exp: Likewise.
>             * gdb.fortran/vla-sizeof.exp: Likewise.
>             * gdb.fortran/vla-type.exp: Likewise.
>             * gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
>             * gdb.fortran/vla-value-sub-finish.exp: Likewise.
>             * gdb.fortran/vla-value-sub.exp: Likewise.
>             * gdb.fortran/vla-value.exp: Likewise.
>             * gdb.fortran/whatis_type.exp: Likewise.
>             * gdb.mi/mi-var-child-f.exp: Likewise.
> 
> Please let me know your comments.
>
> ---
> From f19a15b6afaabda49dd0d102f1defff72cfae4e9 Mon Sep 17 00:00:00 2001
> From: Alok Kumar Sharma <AlokKumar.Sharma@amd.com>
> Date: Fri, 24 Apr 2020 14:46:09 +0530
> Subject: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing
> 
> Name of fortran main function for Flang compiler is MAIN_ while
> for gfortran it is MAIN__ . In test cases MAIN__ is hardcoded for
> the purpose of inserting breakpoint.
> 
> New proc is added to detect main function name depending on the
> compiler used.
> Fortran specific version of runto_main named fortran_runto_main
> is added.
> 
> This commit adds support for Flang main function, there should be
> no change for gfortran.
> 
> gdb/testsuite/ChangeLog
> 
> 	* lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
> 	(fortran_runto_main): New Proc, fortran version of runto_main.
> 	* gdb.fortran/array-bounds-high.exp: Handle flang MAIN_.
> 	* gdb.fortran/array-bounds.exp: Likewise.
> 	* gdb.fortran/array-slices.exp: Likewise.
> 	* gdb.fortran/block-data.exp: Likewise.
> 	* gdb.fortran/charset.exp: Likewise.
> 	* gdb.fortran/common-block.exp: Likewise.
> 	* gdb.fortran/complex.exp: Likewise.
> 	* gdb.fortran/derived-type-function.exp: Likewise.
> 	* gdb.fortran/derived-type.exp: Likewise.
> 	* gdb.fortran/info-modules.exp: Likewise.
> 	* gdb.fortran/info-types.exp: Likewise.
> 	* gdb.fortran/intrinsics.exp: Likewise.
> 	* gdb.fortran/library-module.exp: Likewise.
> 	* gdb.fortran/logical.exp: Likewise.
> 	* gdb.fortran/max-depth.exp: Likewise.
> 	* gdb.fortran/module.exp: Likewise.
> 	* gdb.fortran/multi-dim.exp: Likewise.
> 	* gdb.fortran/nested-funcs.exp: Likewise.
> 	* gdb.fortran/print-formatted.exp: Likewise.
> 	* gdb.fortran/print_type.exp: Likewise.
> 	* gdb.fortran/printing-types.exp: Likewise.
> 	* gdb.fortran/ptr-indentation.exp: Likewise.
> 	* gdb.fortran/ptype-on-functions.exp: Likewise.
> 	* gdb.fortran/subarray.exp: Likewise.
> 	* gdb.fortran/vla-alloc-assoc.exp: Likewise.
> 	* gdb.fortran/vla-datatypes.exp: Likewise.
> 	* gdb.fortran/vla-history.exp: Likewise.
> 	* gdb.fortran/vla-ptr-info.exp: Likewise.
> 	* gdb.fortran/vla-ptype-sub.exp: Likewise.
> 	* gdb.fortran/vla-ptype.exp: Likewise.
> 	* gdb.fortran/vla-sizeof.exp: Likewise.
> 	* gdb.fortran/vla-type.exp: Likewise.
> 	* gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
> 	* gdb.fortran/vla-value-sub-finish.exp: Likewise.
> 	* gdb.fortran/vla-value-sub.exp: Likewise.
> 	* gdb.fortran/vla-value.exp: Likewise.
> 	* gdb.fortran/whatis_type.exp: Likewise.
> 	* gdb.mi/mi-var-child-f.exp: Likewise.
> 
> Change-Id: I0a30f5dad684879b416f71d3d08c385c159325bf
> ---
>  gdb/testsuite/ChangeLog                       | 43 +++++++++++++++++++
>  .../gdb.fortran/array-bounds-high.exp         |  5 ++-
>  gdb/testsuite/gdb.fortran/array-bounds.exp    |  5 ++-
>  gdb/testsuite/gdb.fortran/array-slices.exp    |  3 +-
>  gdb/testsuite/gdb.fortran/block-data.exp      |  4 +-
>  gdb/testsuite/gdb.fortran/charset.exp         |  6 ++-
>  gdb/testsuite/gdb.fortran/common-block.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/complex.exp         |  5 ++-
>  .../gdb.fortran/derived-type-function.exp     |  5 ++-
>  gdb/testsuite/gdb.fortran/derived-type.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/info-modules.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/info-types.exp      |  4 +-
>  gdb/testsuite/gdb.fortran/intrinsics.exp      |  4 +-
>  gdb/testsuite/gdb.fortran/library-module.exp  |  5 ++-
>  gdb/testsuite/gdb.fortran/logical.exp         |  5 ++-
>  gdb/testsuite/gdb.fortran/max-depth.exp       |  4 +-
>  gdb/testsuite/gdb.fortran/module.exp          |  6 +--
>  gdb/testsuite/gdb.fortran/multi-dim.exp       |  4 +-
>  gdb/testsuite/gdb.fortran/nested-funcs.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/print-formatted.exp |  4 +-
>  gdb/testsuite/gdb.fortran/print_type.exp      |  2 +-
>  gdb/testsuite/gdb.fortran/printing-types.exp  |  5 ++-
>  gdb/testsuite/gdb.fortran/ptr-indentation.exp |  4 +-
>  .../gdb.fortran/ptype-on-functions.exp        |  4 +-
>  gdb/testsuite/gdb.fortran/subarray.exp        |  5 ++-
>  gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp |  3 +-
>  gdb/testsuite/gdb.fortran/vla-datatypes.exp   |  2 +-
>  gdb/testsuite/gdb.fortran/vla-history.exp     |  3 +-
>  gdb/testsuite/gdb.fortran/vla-ptr-info.exp    |  3 +-
>  gdb/testsuite/gdb.fortran/vla-ptype-sub.exp   |  2 +-
>  gdb/testsuite/gdb.fortran/vla-ptype.exp       |  2 +-
>  gdb/testsuite/gdb.fortran/vla-sizeof.exp      |  3 +-
>  gdb/testsuite/gdb.fortran/vla-type.exp        |  2 +-
>  .../gdb.fortran/vla-value-sub-arbitrary.exp   |  3 +-
>  .../gdb.fortran/vla-value-sub-finish.exp      |  3 +-
>  gdb/testsuite/gdb.fortran/vla-value-sub.exp   |  3 +-
>  gdb/testsuite/gdb.fortran/vla-value.exp       |  6 +--
>  gdb/testsuite/gdb.fortran/whatis_type.exp     |  4 +-
>  gdb/testsuite/gdb.mi/mi-var-child-f.exp       |  2 +-
>  gdb/testsuite/lib/fortran.exp                 | 22 ++++++++++
>  40 files changed, 147 insertions(+), 64 deletions(-)
> 
> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
> index 10683db566..0e3c207f85 100644
> --- a/gdb/testsuite/ChangeLog
> +++ b/gdb/testsuite/ChangeLog
> @@ -1,3 +1,46 @@
> +2020-04-24  Alok Kumar Sharma  <alokkumar.sharma@amd.com>
> +
> +	* lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
> +	(fortran_runto_main): New Proc, fortran version of runto_main.
> +	* gdb.fortran/array-bounds-high.exp: Handle flang MAIN_
> +	* gdb.fortran/array-bounds.exp: Likewise.
> +	* gdb.fortran/array-slices.exp: Likewise.
> +	* gdb.fortran/block-data.exp: Likewise.
> +	* gdb.fortran/charset.exp: Likewise.
> +	* gdb.fortran/common-block.exp: Likewise.
> +	* gdb.fortran/complex.exp: Likewise.
> +	* gdb.fortran/derived-type-function.exp: Likewise.
> +	* gdb.fortran/derived-type.exp: Likewise.
> +	* gdb.fortran/info-modules.exp: Likewise.
> +	* gdb.fortran/info-types.exp: Likewise.
> +	* gdb.fortran/intrinsics.exp: Likewise.
> +	* gdb.fortran/library-module.exp: Likewise.
> +	* gdb.fortran/logical.exp: Likewise.
> +	* gdb.fortran/max-depth.exp: Likewise.
> +	* gdb.fortran/module.exp: Likewise.
> +	* gdb.fortran/multi-dim.exp: Likewise.
> +	* gdb.fortran/nested-funcs.exp: Likewise.
> +	* gdb.fortran/print-formatted.exp: Likewise.
> +	* gdb.fortran/print_type.exp: Likewise.
> +	* gdb.fortran/printing-types.exp: Likewise.
> +	* gdb.fortran/ptr-indentation.exp: Likewise.
> +	* gdb.fortran/ptype-on-functions.exp: Likewise.
> +	* gdb.fortran/subarray.exp: Likewise.
> +	* gdb.fortran/vla-alloc-assoc.exp: Likewise.
> +	* gdb.fortran/vla-datatypes.exp: Likewise.
> +	* gdb.fortran/vla-history.exp: Likewise.
> +	* gdb.fortran/vla-ptr-info.exp: Likewise.
> +	* gdb.fortran/vla-ptype-sub.exp: Likewise.
> +	* gdb.fortran/vla-ptype.exp: Likewise.
> +	* gdb.fortran/vla-sizeof.exp: Likewise.
> +	* gdb.fortran/vla-type.exp: Likewise.
> +	* gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
> +	* gdb.fortran/vla-value-sub-finish.exp: Likewise.
> +	* gdb.fortran/vla-value-sub.exp: Likewise.
> +	* gdb.fortran/vla-value.exp: Likewise.
> +	* gdb.fortran/whatis_type.exp: Likewise.
> +	* gdb.mi/mi-var-child-f.exp: Likewise.
> +
>  2020-04-23  Tom de Vries  <tdevries@suse.de>
>  
>  	* gdb.base/decl-before-def.exp: Run to main and print a again.
> diff --git a/gdb/testsuite/gdb.fortran/array-bounds-high.exp b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
> index 81e2f87b89..07688c44bf 100644
> --- a/gdb/testsuite/gdb.fortran/array-bounds-high.exp
> +++ b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
> @@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
>  
>  set testfile "array-bounds-high"
>  standard_testfile .f90
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
>      return -1
>  }
>  
> -if {![runto MAIN__]} {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if {![fortran_runto_main]} {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/array-bounds.exp b/gdb/testsuite/gdb.fortran/array-bounds.exp
> index 12bf5c2db3..b5c33e39c3 100644
> --- a/gdb/testsuite/gdb.fortran/array-bounds.exp
> +++ b/gdb/testsuite/gdb.fortran/array-bounds.exp
> @@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
>  
>  set testfile "array-bounds"
>  standard_testfile .f90
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
>      return -1
>  }
>  
> -if {![runto MAIN__]} {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if {![fortran_runto_main]} {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp b/gdb/testsuite/gdb.fortran/array-slices.exp
> index 11997f926a..4ca1db90f7 100644
> --- a/gdb/testsuite/gdb.fortran/array-slices.exp
> +++ b/gdb/testsuite/gdb.fortran/array-slices.exp
> @@ -21,13 +21,14 @@
>  if {[skip_fortran_tests]} { return -1 }
>  
>  standard_testfile ".f90"
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
>  	 {debug f90}]} {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/block-data.exp b/gdb/testsuite/gdb.fortran/block-data.exp
> index 292afe6c16..420797fd29 100644
> --- a/gdb/testsuite/gdb.fortran/block-data.exp
> +++ b/gdb/testsuite/gdb.fortran/block-data.exp
> @@ -30,8 +30,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>  
> -if ![runto MAIN__] then {
> -    untested "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    untested "couldn't run to breakpoint $fmain"
>      return -1
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/charset.exp b/gdb/testsuite/gdb.fortran/charset.exp
> index f0f62f8490..58b7e66f79 100644
> --- a/gdb/testsuite/gdb.fortran/charset.exp
> +++ b/gdb/testsuite/gdb.fortran/charset.exp
> @@ -19,12 +19,14 @@
>  if { [skip_fortran_tests] } { return -1 }
>  
>  standard_testfile .f90
> +load_lib fortran.exp
> +
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug additional_flags=-fbackslash f90}] } {
>      return -1
>  }
>  
> -if ![runto MAIN__] {
> -    perror "Couldn't run to MAIN__"
> +if ![fortran_runto_main] {
> +    perror "Couldn't run to $fmain"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/common-block.exp b/gdb/testsuite/gdb.fortran/common-block.exp
> index 19c1af0d81..5f7bdd5829 100644
> --- a/gdb/testsuite/gdb.fortran/common-block.exp
> +++ b/gdb/testsuite/gdb.fortran/common-block.exp
> @@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" ${testfile} \
>      return -1
>  }
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/complex.exp b/gdb/testsuite/gdb.fortran/complex.exp
> index c092ab29f1..eb4705812b 100644
> --- a/gdb/testsuite/gdb.fortran/complex.exp
> +++ b/gdb/testsuite/gdb.fortran/complex.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile .f90
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
>      return -1
>  }
>  
> -if ![runto MAIN__] then {
> -    perror "Couldn't run to MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "Couldn't run to $fmain"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/derived-type-function.exp b/gdb/testsuite/gdb.fortran/derived-type-function.exp
> index 1f0f957317..fad7bb9b37 100644
> --- a/gdb/testsuite/gdb.fortran/derived-type-function.exp
> +++ b/gdb/testsuite/gdb.fortran/derived-type-function.exp
> @@ -21,13 +21,14 @@
>  if { [skip_fortran_tests] } { return -1 }
>  
>  standard_testfile .f90
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/derived-type.exp b/gdb/testsuite/gdb.fortran/derived-type.exp
> index f1705bffd8..54aae80263 100644
> --- a/gdb/testsuite/gdb.fortran/derived-type.exp
> +++ b/gdb/testsuite/gdb.fortran/derived-type.exp
> @@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/info-modules.exp b/gdb/testsuite/gdb.fortran/info-modules.exp
> index 0c3c6a58e1..e1d96d6ced 100644
> --- a/gdb/testsuite/gdb.fortran/info-modules.exp
> +++ b/gdb/testsuite/gdb.fortran/info-modules.exp
> @@ -28,8 +28,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
>      return -1
>  }
>  
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/info-types.exp b/gdb/testsuite/gdb.fortran/info-types.exp
> index 2138937782..0c509e505d 100644
> --- a/gdb/testsuite/gdb.fortran/info-types.exp
> +++ b/gdb/testsuite/gdb.fortran/info-types.exp
> @@ -27,8 +27,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
>      return -1
>  }
>  
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/intrinsics.exp b/gdb/testsuite/gdb.fortran/intrinsics.exp
> index 504bce4138..800450cd3e 100644
> --- a/gdb/testsuite/gdb.fortran/intrinsics.exp
> +++ b/gdb/testsuite/gdb.fortran/intrinsics.exp
> @@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
>      return -1
>  }
>  
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/library-module.exp b/gdb/testsuite/gdb.fortran/library-module.exp
> index f25988e32c..22475690b9 100644
> --- a/gdb/testsuite/gdb.fortran/library-module.exp
> +++ b/gdb/testsuite/gdb.fortran/library-module.exp
> @@ -40,9 +40,10 @@ if  { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list debug f90
>  clean_restart $testfile
>  
>  gdb_load_shlib $libfile
> +load_lib fortran.exp
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/logical.exp b/gdb/testsuite/gdb.fortran/logical.exp
> index 324714fa49..d93c95bba5 100644
> --- a/gdb/testsuite/gdb.fortran/logical.exp
> +++ b/gdb/testsuite/gdb.fortran/logical.exp
> @@ -16,13 +16,14 @@
>  # This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
>  
>  standard_testfile .f90
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
>      return -1
>  }
>  
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/max-depth.exp b/gdb/testsuite/gdb.fortran/max-depth.exp
> index 262d0fdfa1..889e0be110 100644
> --- a/gdb/testsuite/gdb.fortran/max-depth.exp
> +++ b/gdb/testsuite/gdb.fortran/max-depth.exp
> @@ -26,8 +26,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
>      return -1
>  }
>  
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/module.exp b/gdb/testsuite/gdb.fortran/module.exp
> index 1c269e2fed..7b57ff78b4 100644
> --- a/gdb/testsuite/gdb.fortran/module.exp
> +++ b/gdb/testsuite/gdb.fortran/module.exp
> @@ -29,8 +29,8 @@ gdb_test "p modmany::var_i" " = 14" "stopped language detection"
>  
>  gdb_test "print mod1::var_const" " = 20" "fully qualified name of DW_TAG_constant"
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>  
> @@ -123,7 +123,7 @@ complete "modmany::var" $modmany_list
>  # Breakpoint would work in language "c".
>  gdb_test "show language" {The current source language is "(auto; currently )?fortran".}
>  
> -# gcc-4.4.2: The main program is always MAIN__ in .symtab so "runto" above
> +# gcc-4.4.2: The main program is always $fmain in .symtab so "runto" above
>  # works.  But DWARF DW_TAG_subprogram contains the name specified by
>  # the "program" Fortran statement.
>  if [gdb_breakpoint "module"] {
> diff --git a/gdb/testsuite/gdb.fortran/multi-dim.exp b/gdb/testsuite/gdb.fortran/multi-dim.exp
> index 05590914df..cc3cdc88de 100644
> --- a/gdb/testsuite/gdb.fortran/multi-dim.exp
> +++ b/gdb/testsuite/gdb.fortran/multi-dim.exp
> @@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug f90}
>      return -1
>  }
>  
> -if ![runto MAIN__] {
> -    perror "Couldn't run to MAIN__"
> +if ![fortran_runto_main] {
> +    perror "Couldn't run to $fmain"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/nested-funcs.exp b/gdb/testsuite/gdb.fortran/nested-funcs.exp
> index e4fc02ffa5..1c87fea3b6 100755
> --- a/gdb/testsuite/gdb.fortran/nested-funcs.exp
> +++ b/gdb/testsuite/gdb.fortran/nested-funcs.exp
> @@ -25,8 +25,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/print-formatted.exp b/gdb/testsuite/gdb.fortran/print-formatted.exp
> index 8c6529ce7f..adb9e2e996 100644
> --- a/gdb/testsuite/gdb.fortran/print-formatted.exp
> +++ b/gdb/testsuite/gdb.fortran/print-formatted.exp
> @@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
>      return -1
>  }
>  
> -if { ![runto MAIN__] } {
> -    fail "runto MAIN__"
> +if { ![fortran_runto_main] } {
> +    fail "fortran_runto_main"
>      return -1
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/print_type.exp b/gdb/testsuite/gdb.fortran/print_type.exp
> index 7d5915390d..fcedb9579a 100755
> --- a/gdb/testsuite/gdb.fortran/print_type.exp
> +++ b/gdb/testsuite/gdb.fortran/print_type.exp
> @@ -24,7 +24,7 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/printing-types.exp b/gdb/testsuite/gdb.fortran/printing-types.exp
> index 2c88f9e003..e68386eea7 100644
> --- a/gdb/testsuite/gdb.fortran/printing-types.exp
> +++ b/gdb/testsuite/gdb.fortran/printing-types.exp
> @@ -16,13 +16,14 @@
>  if {[skip_fortran_tests]} { return -1 }
>  
>  standard_testfile .f90
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>  
> -if {![runto MAIN__]} then {
> -    untested "could not run to breakpoint MAIN__"
> +if {![fortran_runto_main]} then {
> +    untested "could not run to breakpoint $fmain"
>      return -1
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/ptr-indentation.exp b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
> index 285e24e2cc..10debb417a 100644
> --- a/gdb/testsuite/gdb.fortran/ptr-indentation.exp
> +++ b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
> @@ -22,8 +22,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>  
> -if {![runto MAIN__]} then {
> -    untested "couldn't run to breakpoint MAIN__"
> +if {![fortran_runto_main]} then {
> +    untested "couldn't run to breakpoint $fmain"
>      return -1
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> index d91e4bd48e..2f9d093dac 100644
> --- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> +++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> @@ -24,8 +24,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/subarray.exp b/gdb/testsuite/gdb.fortran/subarray.exp
> index 5e3e8c38cb..6510483509 100644
> --- a/gdb/testsuite/gdb.fortran/subarray.exp
> +++ b/gdb/testsuite/gdb.fortran/subarray.exp
> @@ -21,6 +21,7 @@
>  if { [skip_fortran_tests] } { return -1 }
>  
>  standard_testfile .f
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
> @@ -31,8 +32,8 @@ gdb_start
>  gdb_reinitialize_dir $srcdir/$subdir
>  gdb_load ${binfile}
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
> index 5d8585c2ee..2ae0411cf1 100644
> --- a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>  
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-datatypes.exp b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
> index 2db9b3e110..b69636f600 100644
> --- a/gdb/testsuite/gdb.fortran/vla-datatypes.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
> @@ -24,7 +24,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>  # check that all fortran standard datatypes will be
>  # handled correctly when using as VLA's
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-history.exp b/gdb/testsuite/gdb.fortran/vla-history.exp
> index 24bd945f4a..3bf98db197 100644
> --- a/gdb/testsuite/gdb.fortran/vla-history.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-history.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>  
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> index 24c7b45840..d3fa595bea 100644
> --- a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>  
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
> index 09909e74b0..07a4a5fc2e 100644
> --- a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-ptype.exp b/gdb/testsuite/gdb.fortran/vla-ptype.exp
> index 22b2005317..bbb81ea0c8 100644
> --- a/gdb/testsuite/gdb.fortran/vla-ptype.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-ptype.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
> index 8e7d36314e..d26b8c60f8 100644
> --- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>  
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-type.exp b/gdb/testsuite/gdb.fortran/vla-type.exp
> index 6d885e7889..f007ea3a78 100755
> --- a/gdb/testsuite/gdb.fortran/vla-type.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-type.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
> index ab61dde06f..c3ed909a81 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile "vla-sub.f90"
> +load_lib fortran.exp
>  
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
> index afd992cee4..403e411cc2 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile "vla-sub.f90"
> +load_lib fortran.exp
>  
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub.exp b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
> index 3311f6befa..fd923edf40 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value-sub.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile "vla-sub.f90"
> +load_lib fortran.exp
>  
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp
> index 5af17b570c..5e696fd4f3 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> @@ -129,8 +129,8 @@ gdb_test "print vla1(9, 9, 9)" "no such vector element \\\(vector not allocated\
>  # Try to assign VLA to user variable
>  clean_restart ${testfile}
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>  gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
> diff --git a/gdb/testsuite/gdb.fortran/whatis_type.exp b/gdb/testsuite/gdb.fortran/whatis_type.exp
> index 6a9cc0a81e..44b256c325 100644
> --- a/gdb/testsuite/gdb.fortran/whatis_type.exp
> +++ b/gdb/testsuite/gdb.fortran/whatis_type.exp
> @@ -23,8 +23,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
>      return -1
>  }
>  
> -if ![runto MAIN__] {
> -    fail "run to MAIN__"
> +if ![fortran_runto_main] {
> +    fail "run to $fmain"
>      return
>  }
>  
> diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
> index 8cfffa7c08..363da0b7ed 100644
> --- a/gdb/testsuite/gdb.mi/mi-var-child-f.exp
> +++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
> @@ -36,7 +36,7 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
>  mi_gdb_reinitialize_dir $srcdir/$subdir
>  mi_gdb_load ${binfile}
>  
> -mi_runto MAIN__
> +mi_runto $fmain
>  
>  mi_create_varobj "array" "array" "create local variable array"
>  
> diff --git a/gdb/testsuite/lib/fortran.exp b/gdb/testsuite/lib/fortran.exp
> index 549ed65790..9451e96000 100644
> --- a/gdb/testsuite/lib/fortran.exp
> +++ b/gdb/testsuite/lib/fortran.exp
> @@ -18,6 +18,8 @@
>  # Auxiliary function to set the language to fortran.
>  # The result is 1 (true) for success, 0 (false) for failure.
>  
> +global fmain
> +
>  proc set_lang_fortran {} {
>      if [gdb_test_no_output "set language fortran"] {
>  	return 0
> @@ -126,3 +128,23 @@ proc fortran_character1 {} {
>  	return "unknown"
>      }
>  }
> +
> +proc fortran_main {} {
> +    if {[test_compiler_info {gcc-4-[012]-*}]
> +         || [test_compiler_info {gcc-*}]
> +         || [test_compiler_info {icc-*}]} {
> +	return "MAIN__"
> +    } elseif {[test_compiler_info {clang-*}]} {
> +	return "MAIN_"
> +    } else {
> +	return "unknown"
> +    }
> +}
> +
> +set fmain  [fortran_main]

Sorry to be a massive pain, but could you just drop the use of $fmain
entirely, and replace the code in gdb.fortran/*.exp that references
$fmain with just 'main'.  We already do this for go, and in many
Fortran tests.

Adding $fmain doesn't seem to add much and is just another library
variable that might clash with a user variable.

With that change made this patch is approved.

Thanks,
Andrew


> +
> +# fortran version of runto_main.
> +
> +proc fortran_runto_main { } {
> +    return [runto [fortran_main]]
> +}
> -- 
> 2.17.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing
  2020-04-27  9:07         ` Andrew Burgess
@ 2020-04-27 18:02           ` Sharma, Alok Kumar
  2020-04-29  9:15             ` Andrew Burgess
  0 siblings, 1 reply; 14+ messages in thread
From: Sharma, Alok Kumar @ 2020-04-27 18:02 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: Tom Tromey, George, Jini Susan, Achra, Nitika, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 38742 bytes --]

Hi Andrew,

Thanks a lot for your valuable comments. Please have a look at the updated patch in attachment.

Regards,
Alok

-----Original Message-----
From: Andrew Burgess <andrew.burgess@embecosm.com> 
Sent: Monday, April 27, 2020 2:38 PM
To: Sharma, Alok Kumar <AlokKumar.Sharma@amd.com>
Cc: Tom Tromey <tom@tromey.com>; George, Jini Susan <JiniSusan.George@amd.com>; Achra, Nitika <Nitika.Achra@amd.com>; gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing

[CAUTION: External Email]

* Sharma, Alok Kumar <AlokKumar.Sharma@amd.com> [2020-04-24 15:54:15 +0000]:

> Thanks a lot Tom and Andrew for your reviews.
>
> Please find the updated patch as an attachment.
> Now fortran specific runto_main is renamed as fortran_runto_main, which is inline with the other such procedures as go_runto_main etc.
>
>     gdb/testsuite/ChangeLog
>
>             * lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
>             (fortran_runto_main): New Proc, fortran version of runto_main.
>             * gdb.fortran/array-bounds-high.exp: Handle flang MAIN_.
>             * gdb.fortran/array-bounds.exp: Likewise.
>             * gdb.fortran/array-slices.exp: Likewise.
>             * gdb.fortran/block-data.exp: Likewise.
>             * gdb.fortran/charset.exp: Likewise.
>             * gdb.fortran/common-block.exp: Likewise.
>             * gdb.fortran/complex.exp: Likewise.
>             * gdb.fortran/derived-type-function.exp: Likewise.
>             * gdb.fortran/derived-type.exp: Likewise.
>             * gdb.fortran/info-modules.exp: Likewise.
>             * gdb.fortran/info-types.exp: Likewise.
>             * gdb.fortran/intrinsics.exp: Likewise.
>             * gdb.fortran/library-module.exp: Likewise.
>             * gdb.fortran/logical.exp: Likewise.
>             * gdb.fortran/max-depth.exp: Likewise.
>             * gdb.fortran/module.exp: Likewise.
>             * gdb.fortran/multi-dim.exp: Likewise.
>             * gdb.fortran/nested-funcs.exp: Likewise.
>             * gdb.fortran/print-formatted.exp: Likewise.
>             * gdb.fortran/print_type.exp: Likewise.
>             * gdb.fortran/printing-types.exp: Likewise.
>             * gdb.fortran/ptr-indentation.exp: Likewise.
>             * gdb.fortran/ptype-on-functions.exp: Likewise.
>             * gdb.fortran/subarray.exp: Likewise.
>             * gdb.fortran/vla-alloc-assoc.exp: Likewise.
>             * gdb.fortran/vla-datatypes.exp: Likewise.
>             * gdb.fortran/vla-history.exp: Likewise.
>             * gdb.fortran/vla-ptr-info.exp: Likewise.
>             * gdb.fortran/vla-ptype-sub.exp: Likewise.
>             * gdb.fortran/vla-ptype.exp: Likewise.
>             * gdb.fortran/vla-sizeof.exp: Likewise.
>             * gdb.fortran/vla-type.exp: Likewise.
>             * gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
>             * gdb.fortran/vla-value-sub-finish.exp: Likewise.
>             * gdb.fortran/vla-value-sub.exp: Likewise.
>             * gdb.fortran/vla-value.exp: Likewise.
>             * gdb.fortran/whatis_type.exp: Likewise.
>             * gdb.mi/mi-var-child-f.exp: Likewise.
>
> Please let me know your comments.
>
> ---
> From f19a15b6afaabda49dd0d102f1defff72cfae4e9 Mon Sep 17 00:00:00 2001
> From: Alok Kumar Sharma <AlokKumar.Sharma@amd.com>
> Date: Fri, 24 Apr 2020 14:46:09 +0530
> Subject: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing
>
> Name of fortran main function for Flang compiler is MAIN_ while for 
> gfortran it is MAIN__ . In test cases MAIN__ is hardcoded for the 
> purpose of inserting breakpoint.
>
> New proc is added to detect main function name depending on the 
> compiler used.
> Fortran specific version of runto_main named fortran_runto_main is 
> added.
>
> This commit adds support for Flang main function, there should be no 
> change for gfortran.
>
> gdb/testsuite/ChangeLog
>
>       * lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
>       (fortran_runto_main): New Proc, fortran version of runto_main.
>       * gdb.fortran/array-bounds-high.exp: Handle flang MAIN_.
>       * gdb.fortran/array-bounds.exp: Likewise.
>       * gdb.fortran/array-slices.exp: Likewise.
>       * gdb.fortran/block-data.exp: Likewise.
>       * gdb.fortran/charset.exp: Likewise.
>       * gdb.fortran/common-block.exp: Likewise.
>       * gdb.fortran/complex.exp: Likewise.
>       * gdb.fortran/derived-type-function.exp: Likewise.
>       * gdb.fortran/derived-type.exp: Likewise.
>       * gdb.fortran/info-modules.exp: Likewise.
>       * gdb.fortran/info-types.exp: Likewise.
>       * gdb.fortran/intrinsics.exp: Likewise.
>       * gdb.fortran/library-module.exp: Likewise.
>       * gdb.fortran/logical.exp: Likewise.
>       * gdb.fortran/max-depth.exp: Likewise.
>       * gdb.fortran/module.exp: Likewise.
>       * gdb.fortran/multi-dim.exp: Likewise.
>       * gdb.fortran/nested-funcs.exp: Likewise.
>       * gdb.fortran/print-formatted.exp: Likewise.
>       * gdb.fortran/print_type.exp: Likewise.
>       * gdb.fortran/printing-types.exp: Likewise.
>       * gdb.fortran/ptr-indentation.exp: Likewise.
>       * gdb.fortran/ptype-on-functions.exp: Likewise.
>       * gdb.fortran/subarray.exp: Likewise.
>       * gdb.fortran/vla-alloc-assoc.exp: Likewise.
>       * gdb.fortran/vla-datatypes.exp: Likewise.
>       * gdb.fortran/vla-history.exp: Likewise.
>       * gdb.fortran/vla-ptr-info.exp: Likewise.
>       * gdb.fortran/vla-ptype-sub.exp: Likewise.
>       * gdb.fortran/vla-ptype.exp: Likewise.
>       * gdb.fortran/vla-sizeof.exp: Likewise.
>       * gdb.fortran/vla-type.exp: Likewise.
>       * gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
>       * gdb.fortran/vla-value-sub-finish.exp: Likewise.
>       * gdb.fortran/vla-value-sub.exp: Likewise.
>       * gdb.fortran/vla-value.exp: Likewise.
>       * gdb.fortran/whatis_type.exp: Likewise.
>       * gdb.mi/mi-var-child-f.exp: Likewise.
>
> Change-Id: I0a30f5dad684879b416f71d3d08c385c159325bf
> ---
>  gdb/testsuite/ChangeLog                       | 43 +++++++++++++++++++
>  .../gdb.fortran/array-bounds-high.exp         |  5 ++-
>  gdb/testsuite/gdb.fortran/array-bounds.exp    |  5 ++-
>  gdb/testsuite/gdb.fortran/array-slices.exp    |  3 +-
>  gdb/testsuite/gdb.fortran/block-data.exp      |  4 +-
>  gdb/testsuite/gdb.fortran/charset.exp         |  6 ++-
>  gdb/testsuite/gdb.fortran/common-block.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/complex.exp         |  5 ++-
>  .../gdb.fortran/derived-type-function.exp     |  5 ++-
>  gdb/testsuite/gdb.fortran/derived-type.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/info-modules.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/info-types.exp      |  4 +-
>  gdb/testsuite/gdb.fortran/intrinsics.exp      |  4 +-
>  gdb/testsuite/gdb.fortran/library-module.exp  |  5 ++-
>  gdb/testsuite/gdb.fortran/logical.exp         |  5 ++-
>  gdb/testsuite/gdb.fortran/max-depth.exp       |  4 +-
>  gdb/testsuite/gdb.fortran/module.exp          |  6 +--
>  gdb/testsuite/gdb.fortran/multi-dim.exp       |  4 +-
>  gdb/testsuite/gdb.fortran/nested-funcs.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/print-formatted.exp |  4 +-
>  gdb/testsuite/gdb.fortran/print_type.exp      |  2 +-
>  gdb/testsuite/gdb.fortran/printing-types.exp  |  5 ++-  
> gdb/testsuite/gdb.fortran/ptr-indentation.exp |  4 +-
>  .../gdb.fortran/ptype-on-functions.exp        |  4 +-
>  gdb/testsuite/gdb.fortran/subarray.exp        |  5 ++-
>  gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp |  3 +-
>  gdb/testsuite/gdb.fortran/vla-datatypes.exp   |  2 +-
>  gdb/testsuite/gdb.fortran/vla-history.exp     |  3 +-
>  gdb/testsuite/gdb.fortran/vla-ptr-info.exp    |  3 +-
>  gdb/testsuite/gdb.fortran/vla-ptype-sub.exp   |  2 +-
>  gdb/testsuite/gdb.fortran/vla-ptype.exp       |  2 +-
>  gdb/testsuite/gdb.fortran/vla-sizeof.exp      |  3 +-
>  gdb/testsuite/gdb.fortran/vla-type.exp        |  2 +-
>  .../gdb.fortran/vla-value-sub-arbitrary.exp   |  3 +-
>  .../gdb.fortran/vla-value-sub-finish.exp      |  3 +-
>  gdb/testsuite/gdb.fortran/vla-value-sub.exp   |  3 +-
>  gdb/testsuite/gdb.fortran/vla-value.exp       |  6 +--
>  gdb/testsuite/gdb.fortran/whatis_type.exp     |  4 +-
>  gdb/testsuite/gdb.mi/mi-var-child-f.exp       |  2 +-
>  gdb/testsuite/lib/fortran.exp                 | 22 ++++++++++
>  40 files changed, 147 insertions(+), 64 deletions(-)
>
> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 
> 10683db566..0e3c207f85 100644
> --- a/gdb/testsuite/ChangeLog
> +++ b/gdb/testsuite/ChangeLog
> @@ -1,3 +1,46 @@
> +2020-04-24  Alok Kumar Sharma  <alokkumar.sharma@amd.com>
> +
> +     * lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
> +     (fortran_runto_main): New Proc, fortran version of runto_main.
> +     * gdb.fortran/array-bounds-high.exp: Handle flang MAIN_
> +     * gdb.fortran/array-bounds.exp: Likewise.
> +     * gdb.fortran/array-slices.exp: Likewise.
> +     * gdb.fortran/block-data.exp: Likewise.
> +     * gdb.fortran/charset.exp: Likewise.
> +     * gdb.fortran/common-block.exp: Likewise.
> +     * gdb.fortran/complex.exp: Likewise.
> +     * gdb.fortran/derived-type-function.exp: Likewise.
> +     * gdb.fortran/derived-type.exp: Likewise.
> +     * gdb.fortran/info-modules.exp: Likewise.
> +     * gdb.fortran/info-types.exp: Likewise.
> +     * gdb.fortran/intrinsics.exp: Likewise.
> +     * gdb.fortran/library-module.exp: Likewise.
> +     * gdb.fortran/logical.exp: Likewise.
> +     * gdb.fortran/max-depth.exp: Likewise.
> +     * gdb.fortran/module.exp: Likewise.
> +     * gdb.fortran/multi-dim.exp: Likewise.
> +     * gdb.fortran/nested-funcs.exp: Likewise.
> +     * gdb.fortran/print-formatted.exp: Likewise.
> +     * gdb.fortran/print_type.exp: Likewise.
> +     * gdb.fortran/printing-types.exp: Likewise.
> +     * gdb.fortran/ptr-indentation.exp: Likewise.
> +     * gdb.fortran/ptype-on-functions.exp: Likewise.
> +     * gdb.fortran/subarray.exp: Likewise.
> +     * gdb.fortran/vla-alloc-assoc.exp: Likewise.
> +     * gdb.fortran/vla-datatypes.exp: Likewise.
> +     * gdb.fortran/vla-history.exp: Likewise.
> +     * gdb.fortran/vla-ptr-info.exp: Likewise.
> +     * gdb.fortran/vla-ptype-sub.exp: Likewise.
> +     * gdb.fortran/vla-ptype.exp: Likewise.
> +     * gdb.fortran/vla-sizeof.exp: Likewise.
> +     * gdb.fortran/vla-type.exp: Likewise.
> +     * gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
> +     * gdb.fortran/vla-value-sub-finish.exp: Likewise.
> +     * gdb.fortran/vla-value-sub.exp: Likewise.
> +     * gdb.fortran/vla-value.exp: Likewise.
> +     * gdb.fortran/whatis_type.exp: Likewise.
> +     * gdb.mi/mi-var-child-f.exp: Likewise.
> +
>  2020-04-23  Tom de Vries  <tdevries@suse.de>
>
>       * gdb.base/decl-before-def.exp: Run to main and print a again.
> diff --git a/gdb/testsuite/gdb.fortran/array-bounds-high.exp 
> b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
> index 81e2f87b89..07688c44bf 100644
> --- a/gdb/testsuite/gdb.fortran/array-bounds-high.exp
> +++ b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
> @@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
>
>  set testfile "array-bounds-high"
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
>      return -1
>  }
>
> -if {![runto MAIN__]} {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if {![fortran_runto_main]} {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/array-bounds.exp 
> b/gdb/testsuite/gdb.fortran/array-bounds.exp
> index 12bf5c2db3..b5c33e39c3 100644
> --- a/gdb/testsuite/gdb.fortran/array-bounds.exp
> +++ b/gdb/testsuite/gdb.fortran/array-bounds.exp
> @@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
>
>  set testfile "array-bounds"
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
>      return -1
>  }
>
> -if {![runto MAIN__]} {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if {![fortran_runto_main]} {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp 
> b/gdb/testsuite/gdb.fortran/array-slices.exp
> index 11997f926a..4ca1db90f7 100644
> --- a/gdb/testsuite/gdb.fortran/array-slices.exp
> +++ b/gdb/testsuite/gdb.fortran/array-slices.exp
> @@ -21,13 +21,14 @@
>  if {[skip_fortran_tests]} { return -1 }
>
>  standard_testfile ".f90"
> +load_lib fortran.exp
>
>  if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
>        {debug f90}]} {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/block-data.exp 
> b/gdb/testsuite/gdb.fortran/block-data.exp
> index 292afe6c16..420797fd29 100644
> --- a/gdb/testsuite/gdb.fortran/block-data.exp
> +++ b/gdb/testsuite/gdb.fortran/block-data.exp
> @@ -30,8 +30,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    untested "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    untested "couldn't run to breakpoint $fmain"
>      return -1
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/charset.exp 
> b/gdb/testsuite/gdb.fortran/charset.exp
> index f0f62f8490..58b7e66f79 100644
> --- a/gdb/testsuite/gdb.fortran/charset.exp
> +++ b/gdb/testsuite/gdb.fortran/charset.exp
> @@ -19,12 +19,14 @@
>  if { [skip_fortran_tests] } { return -1 }
>
>  standard_testfile .f90
> +load_lib fortran.exp
> +
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug additional_flags=-fbackslash f90}] } {
>      return -1
>  }
>
> -if ![runto MAIN__] {
> -    perror "Couldn't run to MAIN__"
> +if ![fortran_runto_main] {
> +    perror "Couldn't run to $fmain"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/common-block.exp 
> b/gdb/testsuite/gdb.fortran/common-block.exp
> index 19c1af0d81..5f7bdd5829 100644
> --- a/gdb/testsuite/gdb.fortran/common-block.exp
> +++ b/gdb/testsuite/gdb.fortran/common-block.exp
> @@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" ${testfile} \
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/complex.exp 
> b/gdb/testsuite/gdb.fortran/complex.exp
> index c092ab29f1..eb4705812b 100644
> --- a/gdb/testsuite/gdb.fortran/complex.exp
> +++ b/gdb/testsuite/gdb.fortran/complex.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7C5235a10304594111ce9208d7ea8a7846%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637235752761423982&amp;sdata=Bs4a6A6FLtYAzZOgzvmIeJgPH26CJezOWpsaUd5lkis%3D&amp;reserved=0>.
>
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "Couldn't run to MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "Couldn't run to $fmain"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/derived-type-function.exp 
> b/gdb/testsuite/gdb.fortran/derived-type-function.exp
> index 1f0f957317..fad7bb9b37 100644
> --- a/gdb/testsuite/gdb.fortran/derived-type-function.exp
> +++ b/gdb/testsuite/gdb.fortran/derived-type-function.exp
> @@ -21,13 +21,14 @@
>  if { [skip_fortran_tests] } { return -1 }
>
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/derived-type.exp 
> b/gdb/testsuite/gdb.fortran/derived-type.exp
> index f1705bffd8..54aae80263 100644
> --- a/gdb/testsuite/gdb.fortran/derived-type.exp
> +++ b/gdb/testsuite/gdb.fortran/derived-type.exp
> @@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/info-modules.exp 
> b/gdb/testsuite/gdb.fortran/info-modules.exp
> index 0c3c6a58e1..e1d96d6ced 100644
> --- a/gdb/testsuite/gdb.fortran/info-modules.exp
> +++ b/gdb/testsuite/gdb.fortran/info-modules.exp
> @@ -28,8 +28,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/info-types.exp 
> b/gdb/testsuite/gdb.fortran/info-types.exp
> index 2138937782..0c509e505d 100644
> --- a/gdb/testsuite/gdb.fortran/info-types.exp
> +++ b/gdb/testsuite/gdb.fortran/info-types.exp
> @@ -27,8 +27,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/intrinsics.exp 
> b/gdb/testsuite/gdb.fortran/intrinsics.exp
> index 504bce4138..800450cd3e 100644
> --- a/gdb/testsuite/gdb.fortran/intrinsics.exp
> +++ b/gdb/testsuite/gdb.fortran/intrinsics.exp
> @@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/library-module.exp 
> b/gdb/testsuite/gdb.fortran/library-module.exp
> index f25988e32c..22475690b9 100644
> --- a/gdb/testsuite/gdb.fortran/library-module.exp
> +++ b/gdb/testsuite/gdb.fortran/library-module.exp
> @@ -40,9 +40,10 @@ if  { [gdb_compile $srcdir/$subdir/$srcfile 
> $binfile executable [list debug f90  clean_restart $testfile
>
>  gdb_load_shlib $libfile
> +load_lib fortran.exp
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/logical.exp 
> b/gdb/testsuite/gdb.fortran/logical.exp
> index 324714fa49..d93c95bba5 100644
> --- a/gdb/testsuite/gdb.fortran/logical.exp
> +++ b/gdb/testsuite/gdb.fortran/logical.exp
> @@ -16,13 +16,14 @@
>  # This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
>
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/max-depth.exp 
> b/gdb/testsuite/gdb.fortran/max-depth.exp
> index 262d0fdfa1..889e0be110 100644
> --- a/gdb/testsuite/gdb.fortran/max-depth.exp
> +++ b/gdb/testsuite/gdb.fortran/max-depth.exp
> @@ -26,8 +26,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to breakpoint `$fmain'."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/module.exp 
> b/gdb/testsuite/gdb.fortran/module.exp
> index 1c269e2fed..7b57ff78b4 100644
> --- a/gdb/testsuite/gdb.fortran/module.exp
> +++ b/gdb/testsuite/gdb.fortran/module.exp
> @@ -29,8 +29,8 @@ gdb_test "p modmany::var_i" " = 14" "stopped language detection"
>
>  gdb_test "print mod1::var_const" " = 20" "fully qualified name of DW_TAG_constant"
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>
> @@ -123,7 +123,7 @@ complete "modmany::var" $modmany_list  # 
> Breakpoint would work in language "c".
>  gdb_test "show language" {The current source language is "(auto; 
> currently )?fortran".}
>
> -# gcc-4.4.2: The main program is always MAIN__ in .symtab so "runto" 
> above
> +# gcc-4.4.2: The main program is always $fmain in .symtab so "runto" 
> +above
>  # works.  But DWARF DW_TAG_subprogram contains the name specified by  
> # the "program" Fortran statement.
>  if [gdb_breakpoint "module"] {
> diff --git a/gdb/testsuite/gdb.fortran/multi-dim.exp 
> b/gdb/testsuite/gdb.fortran/multi-dim.exp
> index 05590914df..cc3cdc88de 100644
> --- a/gdb/testsuite/gdb.fortran/multi-dim.exp
> +++ b/gdb/testsuite/gdb.fortran/multi-dim.exp
> @@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug f90}
>      return -1
>  }
>
> -if ![runto MAIN__] {
> -    perror "Couldn't run to MAIN__"
> +if ![fortran_runto_main] {
> +    perror "Couldn't run to $fmain"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/nested-funcs.exp 
> b/gdb/testsuite/gdb.fortran/nested-funcs.exp
> index e4fc02ffa5..1c87fea3b6 100755
> --- a/gdb/testsuite/gdb.fortran/nested-funcs.exp
> +++ b/gdb/testsuite/gdb.fortran/nested-funcs.exp
> @@ -25,8 +25,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/print-formatted.exp 
> b/gdb/testsuite/gdb.fortran/print-formatted.exp
> index 8c6529ce7f..adb9e2e996 100644
> --- a/gdb/testsuite/gdb.fortran/print-formatted.exp
> +++ b/gdb/testsuite/gdb.fortran/print-formatted.exp
> @@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    fail "runto MAIN__"
> +if { ![fortran_runto_main] } {
> +    fail "fortran_runto_main"
>      return -1
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/print_type.exp 
> b/gdb/testsuite/gdb.fortran/print_type.exp
> index 7d5915390d..fcedb9579a 100755
> --- a/gdb/testsuite/gdb.fortran/print_type.exp
> +++ b/gdb/testsuite/gdb.fortran/print_type.exp
> @@ -24,7 +24,7 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/printing-types.exp 
> b/gdb/testsuite/gdb.fortran/printing-types.exp
> index 2c88f9e003..e68386eea7 100644
> --- a/gdb/testsuite/gdb.fortran/printing-types.exp
> +++ b/gdb/testsuite/gdb.fortran/printing-types.exp
> @@ -16,13 +16,14 @@
>  if {[skip_fortran_tests]} { return -1 }
>
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if {![runto MAIN__]} then {
> -    untested "could not run to breakpoint MAIN__"
> +if {![fortran_runto_main]} then {
> +    untested "could not run to breakpoint $fmain"
>      return -1
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/ptr-indentation.exp 
> b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
> index 285e24e2cc..10debb417a 100644
> --- a/gdb/testsuite/gdb.fortran/ptr-indentation.exp
> +++ b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
> @@ -22,8 +22,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if {![runto MAIN__]} then {
> -    untested "couldn't run to breakpoint MAIN__"
> +if {![fortran_runto_main]} then {
> +    untested "couldn't run to breakpoint $fmain"
>      return -1
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp 
> b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> index d91e4bd48e..2f9d093dac 100644
> --- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> +++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> @@ -24,8 +24,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/subarray.exp 
> b/gdb/testsuite/gdb.fortran/subarray.exp
> index 5e3e8c38cb..6510483509 100644
> --- a/gdb/testsuite/gdb.fortran/subarray.exp
> +++ b/gdb/testsuite/gdb.fortran/subarray.exp
> @@ -21,6 +21,7 @@
>  if { [skip_fortran_tests] } { return -1 }
>
>  standard_testfile .f
> +load_lib fortran.exp
>
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
> @@ -31,8 +32,8 @@ gdb_start
>  gdb_reinitialize_dir $srcdir/$subdir
>  gdb_load ${binfile}
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp 
> b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
> index 5d8585c2ee..2ae0411cf1 100644
> --- a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7C5235a10304594111ce9208d7ea8a7846%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637235752761423982&amp;sdata=Bs4a6A6FLtYAzZOgzvmIeJgPH26CJezOWpsaUd5lkis%3D&amp;reserved=0>.
>
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-datatypes.exp 
> b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
> index 2db9b3e110..b69636f600 100644
> --- a/gdb/testsuite/gdb.fortran/vla-datatypes.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
> @@ -24,7 +24,7 @@ if { [prepare_for_testing "failed to prepare" 
> ${testfile} ${srcfile} \  # check that all fortran standard datatypes 
> will be  # handled correctly when using as VLA's
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-history.exp 
> b/gdb/testsuite/gdb.fortran/vla-history.exp
> index 24bd945f4a..3bf98db197 100644
> --- a/gdb/testsuite/gdb.fortran/vla-history.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-history.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7C5235a10304594111ce9208d7ea8a7846%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637235752761423982&amp;sdata=Bs4a6A6FLtYAzZOgzvmIeJgPH26CJezOWpsaUd5lkis%3D&amp;reserved=0>.
>
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp 
> b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> index 24c7b45840..d3fa595bea 100644
> --- a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7C5235a10304594111ce9208d7ea8a7846%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637235752761423982&amp;sdata=Bs4a6A6FLtYAzZOgzvmIeJgPH26CJezOWpsaUd5lkis%3D&amp;reserved=0>.
>
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp 
> b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
> index 09909e74b0..07a4a5fc2e 100644
> --- a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-ptype.exp 
> b/gdb/testsuite/gdb.fortran/vla-ptype.exp
> index 22b2005317..bbb81ea0c8 100644
> --- a/gdb/testsuite/gdb.fortran/vla-ptype.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-ptype.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp 
> b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
> index 8e7d36314e..d26b8c60f8 100644
> --- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7C5235a10304594111ce9208d7ea8a7846%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637235752761423982&amp;sdata=Bs4a6A6FLtYAzZOgzvmIeJgPH26CJezOWpsaUd5lkis%3D&amp;reserved=0>.
>
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-type.exp 
> b/gdb/testsuite/gdb.fortran/vla-type.exp
> index 6d885e7889..f007ea3a78 100755
> --- a/gdb/testsuite/gdb.fortran/vla-type.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-type.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp 
> b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
> index ab61dde06f..c3ed909a81 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7C5235a10304594111ce9208d7ea8a7846%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637235752761423982&amp;sdata=Bs4a6A6FLtYAzZOgzvmIeJgPH26CJezOWpsaUd5lkis%3D&amp;reserved=0>.
>
>  standard_testfile "vla-sub.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp 
> b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
> index afd992cee4..403e411cc2 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7C5235a10304594111ce9208d7ea8a7846%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637235752761423982&amp;sdata=Bs4a6A6FLtYAzZOgzvmIeJgPH26CJezOWpsaUd5lkis%3D&amp;reserved=0>.
>
>  standard_testfile "vla-sub.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub.exp 
> b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
> index 3311f6befa..fd923edf40 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value-sub.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7C5235a10304594111ce9208d7ea8a7846%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637235752761423982&amp;sdata=Bs4a6A6FLtYAzZOgzvmIeJgPH26CJezOWpsaUd5lkis%3D&amp;reserved=0>.
>
>  standard_testfile "vla-sub.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp 
> b/gdb/testsuite/gdb.fortran/vla-value.exp
> index 5af17b570c..5e696fd4f3 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> @@ -129,8 +129,8 @@ gdb_test "print vla1(9, 9, 9)" "no such vector 
> element \\\(vector not allocated\  # Try to assign VLA to user 
> variable  clean_restart ${testfile}
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to breakpoint $fmain"
>      continue
>  }
>  gdb_breakpoint [gdb_get_line_number "vla2-allocated"] diff --git 
> a/gdb/testsuite/gdb.fortran/whatis_type.exp 
> b/gdb/testsuite/gdb.fortran/whatis_type.exp
> index 6a9cc0a81e..44b256c325 100644
> --- a/gdb/testsuite/gdb.fortran/whatis_type.exp
> +++ b/gdb/testsuite/gdb.fortran/whatis_type.exp
> @@ -23,8 +23,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
>      return -1
>  }
>
> -if ![runto MAIN__] {
> -    fail "run to MAIN__"
> +if ![fortran_runto_main] {
> +    fail "run to $fmain"
>      return
>  }
>
> diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp 
> b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
> index 8cfffa7c08..363da0b7ed 100644
> --- a/gdb/testsuite/gdb.mi/mi-var-child-f.exp
> +++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
> @@ -36,7 +36,7 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" 
> "${binfile}" \  mi_gdb_reinitialize_dir $srcdir/$subdir  mi_gdb_load 
> ${binfile}
>
> -mi_runto MAIN__
> +mi_runto $fmain
>
>  mi_create_varobj "array" "array" "create local variable array"
>
> diff --git a/gdb/testsuite/lib/fortran.exp 
> b/gdb/testsuite/lib/fortran.exp index 549ed65790..9451e96000 100644
> --- a/gdb/testsuite/lib/fortran.exp
> +++ b/gdb/testsuite/lib/fortran.exp
> @@ -18,6 +18,8 @@
>  # Auxiliary function to set the language to fortran.
>  # The result is 1 (true) for success, 0 (false) for failure.
>
> +global fmain
> +
>  proc set_lang_fortran {} {
>      if [gdb_test_no_output "set language fortran"] {
>       return 0
> @@ -126,3 +128,23 @@ proc fortran_character1 {} {
>       return "unknown"
>      }
>  }
> +
> +proc fortran_main {} {
> +    if {[test_compiler_info {gcc-4-[012]-*}]
> +         || [test_compiler_info {gcc-*}]
> +         || [test_compiler_info {icc-*}]} {
> +     return "MAIN__"
> +    } elseif {[test_compiler_info {clang-*}]} {
> +     return "MAIN_"
> +    } else {
> +     return "unknown"
> +    }
> +}
> +
> +set fmain  [fortran_main]

Sorry to be a massive pain, but could you just drop the use of $fmain entirely, and replace the code in gdb.fortran/*.exp that references $fmain with just 'main'.  We already do this for go, and in many Fortran tests.

Adding $fmain doesn't seem to add much and is just another library variable that might clash with a user variable.

With that change made this patch is approved.

Thanks,
Andrew


> +
> +# fortran version of runto_main.
> +
> +proc fortran_runto_main { } {
> +    return [runto [fortran_main]]
> +}
> --
> 2.17.1


[-- Attachment #2: 0001-gdb-fortran-Allow-Flang-MAIN_-in-Fortran-testing.patch --]
[-- Type: application/octet-stream, Size: 29335 bytes --]

From 75e55e41ddc83ee3db6879fd955baf31d1301ba4 Mon Sep 17 00:00:00 2001
From: Alok Kumar Sharma <AlokKumar.Sharma@amd.com>
Date: Fri, 24 Apr 2020 14:46:09 +0530
Subject: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing

Name of fortran main function for Flang compiler is MAIN_ while
for gfortran it is MAIN__ . In test cases MAIN__ is hardcoded for
the purpose of inserting breakpoint.

New proc is added to detect main function name depending on the
compiler used.
Fortran specific version of runto_main named fortran_runto_main
is added.

This commit adds support for Flang main function, there should be
no change for gfortran.

gdb/testsuite/ChangeLog

	* lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
	(fortran_runto_main): New Proc, fortran version of runto_main.
	* gdb.fortran/array-bounds-high.exp: Handle flang MAIN_.
	* gdb.fortran/array-bounds.exp: Likewise.
	* gdb.fortran/array-slices.exp: Likewise.
	* gdb.fortran/block-data.exp: Likewise.
	* gdb.fortran/charset.exp: Likewise.
	* gdb.fortran/common-block.exp: Likewise.
	* gdb.fortran/complex.exp: Likewise.
	* gdb.fortran/derived-type-function.exp: Likewise.
	* gdb.fortran/derived-type.exp: Likewise.
	* gdb.fortran/info-modules.exp: Likewise.
	* gdb.fortran/info-types.exp: Likewise.
	* gdb.fortran/intrinsics.exp: Likewise.
	* gdb.fortran/library-module.exp: Likewise.
	* gdb.fortran/logical.exp: Likewise.
	* gdb.fortran/max-depth.exp: Likewise.
	* gdb.fortran/module.exp: Likewise.
	* gdb.fortran/multi-dim.exp: Likewise.
	* gdb.fortran/nested-funcs.exp: Likewise.
	* gdb.fortran/print-formatted.exp: Likewise.
	* gdb.fortran/print_type.exp: Likewise.
	* gdb.fortran/printing-types.exp: Likewise.
	* gdb.fortran/ptr-indentation.exp: Likewise.
	* gdb.fortran/ptype-on-functions.exp: Likewise.
	* gdb.fortran/subarray.exp: Likewise.
	* gdb.fortran/vla-alloc-assoc.exp: Likewise.
	* gdb.fortran/vla-datatypes.exp: Likewise.
	* gdb.fortran/vla-history.exp: Likewise.
	* gdb.fortran/vla-ptr-info.exp: Likewise.
	* gdb.fortran/vla-ptype-sub.exp: Likewise.
	* gdb.fortran/vla-ptype.exp: Likewise.
	* gdb.fortran/vla-sizeof.exp: Likewise.
	* gdb.fortran/vla-type.exp: Likewise.
	* gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
	* gdb.fortran/vla-value-sub-finish.exp: Likewise.
	* gdb.fortran/vla-value-sub.exp: Likewise.
	* gdb.fortran/vla-value.exp: Likewise.
	* gdb.fortran/whatis_type.exp: Likewise.
	* gdb.mi/mi-var-child-f.exp: Likewise.

Change-Id: I0a30f5dad684879b416f71d3d08c385c159325bf
---
 gdb/testsuite/ChangeLog                       | 43 +++++++++++++++++++
 .../gdb.fortran/array-bounds-high.exp         |  5 ++-
 gdb/testsuite/gdb.fortran/array-bounds.exp    |  5 ++-
 gdb/testsuite/gdb.fortran/array-slices.exp    |  3 +-
 gdb/testsuite/gdb.fortran/block-data.exp      |  4 +-
 gdb/testsuite/gdb.fortran/charset.exp         |  6 ++-
 gdb/testsuite/gdb.fortran/common-block.exp    |  4 +-
 gdb/testsuite/gdb.fortran/complex.exp         |  5 ++-
 .../gdb.fortran/derived-type-function.exp     |  5 ++-
 gdb/testsuite/gdb.fortran/derived-type.exp    |  4 +-
 gdb/testsuite/gdb.fortran/info-modules.exp    |  4 +-
 gdb/testsuite/gdb.fortran/info-types.exp      |  4 +-
 gdb/testsuite/gdb.fortran/intrinsics.exp      |  4 +-
 gdb/testsuite/gdb.fortran/library-module.exp  |  5 ++-
 gdb/testsuite/gdb.fortran/logical.exp         |  5 ++-
 gdb/testsuite/gdb.fortran/max-depth.exp       |  4 +-
 gdb/testsuite/gdb.fortran/module.exp          |  6 +--
 gdb/testsuite/gdb.fortran/multi-dim.exp       |  4 +-
 gdb/testsuite/gdb.fortran/nested-funcs.exp    |  4 +-
 gdb/testsuite/gdb.fortran/print-formatted.exp |  4 +-
 gdb/testsuite/gdb.fortran/print_type.exp      |  2 +-
 gdb/testsuite/gdb.fortran/printing-types.exp  |  5 ++-
 gdb/testsuite/gdb.fortran/ptr-indentation.exp |  4 +-
 .../gdb.fortran/ptype-on-functions.exp        |  4 +-
 gdb/testsuite/gdb.fortran/subarray.exp        |  5 ++-
 gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp |  3 +-
 gdb/testsuite/gdb.fortran/vla-datatypes.exp   |  2 +-
 gdb/testsuite/gdb.fortran/vla-history.exp     |  3 +-
 gdb/testsuite/gdb.fortran/vla-ptr-info.exp    |  3 +-
 gdb/testsuite/gdb.fortran/vla-ptype-sub.exp   |  2 +-
 gdb/testsuite/gdb.fortran/vla-ptype.exp       |  2 +-
 gdb/testsuite/gdb.fortran/vla-sizeof.exp      |  3 +-
 gdb/testsuite/gdb.fortran/vla-type.exp        |  2 +-
 .../gdb.fortran/vla-value-sub-arbitrary.exp   |  3 +-
 .../gdb.fortran/vla-value-sub-finish.exp      |  3 +-
 gdb/testsuite/gdb.fortran/vla-value-sub.exp   |  3 +-
 gdb/testsuite/gdb.fortran/vla-value.exp       |  6 +--
 gdb/testsuite/gdb.fortran/whatis_type.exp     |  4 +-
 gdb/testsuite/gdb.mi/mi-var-child-f.exp       |  2 +-
 gdb/testsuite/lib/fortran.exp                 | 18 ++++++++
 40 files changed, 143 insertions(+), 64 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 10683db566..0e3c207f85 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,46 @@
+2020-04-24  Alok Kumar Sharma  <alokkumar.sharma@amd.com>
+
+	* lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
+	(fortran_runto_main): New Proc, fortran version of runto_main.
+	* gdb.fortran/array-bounds-high.exp: Handle flang MAIN_
+	* gdb.fortran/array-bounds.exp: Likewise.
+	* gdb.fortran/array-slices.exp: Likewise.
+	* gdb.fortran/block-data.exp: Likewise.
+	* gdb.fortran/charset.exp: Likewise.
+	* gdb.fortran/common-block.exp: Likewise.
+	* gdb.fortran/complex.exp: Likewise.
+	* gdb.fortran/derived-type-function.exp: Likewise.
+	* gdb.fortran/derived-type.exp: Likewise.
+	* gdb.fortran/info-modules.exp: Likewise.
+	* gdb.fortran/info-types.exp: Likewise.
+	* gdb.fortran/intrinsics.exp: Likewise.
+	* gdb.fortran/library-module.exp: Likewise.
+	* gdb.fortran/logical.exp: Likewise.
+	* gdb.fortran/max-depth.exp: Likewise.
+	* gdb.fortran/module.exp: Likewise.
+	* gdb.fortran/multi-dim.exp: Likewise.
+	* gdb.fortran/nested-funcs.exp: Likewise.
+	* gdb.fortran/print-formatted.exp: Likewise.
+	* gdb.fortran/print_type.exp: Likewise.
+	* gdb.fortran/printing-types.exp: Likewise.
+	* gdb.fortran/ptr-indentation.exp: Likewise.
+	* gdb.fortran/ptype-on-functions.exp: Likewise.
+	* gdb.fortran/subarray.exp: Likewise.
+	* gdb.fortran/vla-alloc-assoc.exp: Likewise.
+	* gdb.fortran/vla-datatypes.exp: Likewise.
+	* gdb.fortran/vla-history.exp: Likewise.
+	* gdb.fortran/vla-ptr-info.exp: Likewise.
+	* gdb.fortran/vla-ptype-sub.exp: Likewise.
+	* gdb.fortran/vla-ptype.exp: Likewise.
+	* gdb.fortran/vla-sizeof.exp: Likewise.
+	* gdb.fortran/vla-type.exp: Likewise.
+	* gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
+	* gdb.fortran/vla-value-sub-finish.exp: Likewise.
+	* gdb.fortran/vla-value-sub.exp: Likewise.
+	* gdb.fortran/vla-value.exp: Likewise.
+	* gdb.fortran/whatis_type.exp: Likewise.
+	* gdb.mi/mi-var-child-f.exp: Likewise.
+
 2020-04-23  Tom de Vries  <tdevries@suse.de>
 
 	* gdb.base/decl-before-def.exp: Run to main and print a again.
diff --git a/gdb/testsuite/gdb.fortran/array-bounds-high.exp b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
index 81e2f87b89..ba34dbc23e 100644
--- a/gdb/testsuite/gdb.fortran/array-bounds-high.exp
+++ b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
@@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
 
 set testfile "array-bounds-high"
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
     return -1
 }
 
-if {![runto MAIN__]} {
-    perror "Could not run to breakpoint `MAIN__'."
+if {![fortran_runto_main]} {
+    perror "Could not run to main."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/array-bounds.exp b/gdb/testsuite/gdb.fortran/array-bounds.exp
index 12bf5c2db3..3f2527343b 100644
--- a/gdb/testsuite/gdb.fortran/array-bounds.exp
+++ b/gdb/testsuite/gdb.fortran/array-bounds.exp
@@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
 
 set testfile "array-bounds"
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
     return -1
 }
 
-if {![runto MAIN__]} {
-    perror "Could not run to breakpoint `MAIN__'."
+if {![fortran_runto_main]} {
+    perror "Could not run to main."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp b/gdb/testsuite/gdb.fortran/array-slices.exp
index 11997f926a..4ca1db90f7 100644
--- a/gdb/testsuite/gdb.fortran/array-slices.exp
+++ b/gdb/testsuite/gdb.fortran/array-slices.exp
@@ -21,13 +21,14 @@
 if {[skip_fortran_tests]} { return -1 }
 
 standard_testfile ".f90"
+load_lib fortran.exp
 
 if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
 	 {debug f90}]} {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/block-data.exp b/gdb/testsuite/gdb.fortran/block-data.exp
index 292afe6c16..632c0141a3 100644
--- a/gdb/testsuite/gdb.fortran/block-data.exp
+++ b/gdb/testsuite/gdb.fortran/block-data.exp
@@ -30,8 +30,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    untested "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    untested "couldn't run to main"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/charset.exp b/gdb/testsuite/gdb.fortran/charset.exp
index f0f62f8490..fc504ae0b0 100644
--- a/gdb/testsuite/gdb.fortran/charset.exp
+++ b/gdb/testsuite/gdb.fortran/charset.exp
@@ -19,12 +19,14 @@
 if { [skip_fortran_tests] } { return -1 }
 
 standard_testfile .f90
+load_lib fortran.exp
+
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug additional_flags=-fbackslash f90}] } {
     return -1
 }
 
-if ![runto MAIN__] {
-    perror "Couldn't run to MAIN__"
+if ![fortran_runto_main] {
+    perror "Couldn't run to main"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/common-block.exp b/gdb/testsuite/gdb.fortran/common-block.exp
index 19c1af0d81..3dacfd32b2 100644
--- a/gdb/testsuite/gdb.fortran/common-block.exp
+++ b/gdb/testsuite/gdb.fortran/common-block.exp
@@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" ${testfile} \
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to main"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/complex.exp b/gdb/testsuite/gdb.fortran/complex.exp
index c092ab29f1..a88e553e58 100644
--- a/gdb/testsuite/gdb.fortran/complex.exp
+++ b/gdb/testsuite/gdb.fortran/complex.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "Couldn't run to MAIN__"
+if ![fortran_runto_main] then {
+    perror "Couldn't run to main"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/derived-type-function.exp b/gdb/testsuite/gdb.fortran/derived-type-function.exp
index 1f0f957317..2ae6f46c1e 100644
--- a/gdb/testsuite/gdb.fortran/derived-type-function.exp
+++ b/gdb/testsuite/gdb.fortran/derived-type-function.exp
@@ -21,13 +21,14 @@
 if { [skip_fortran_tests] } { return -1 }
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to main"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/derived-type.exp b/gdb/testsuite/gdb.fortran/derived-type.exp
index f1705bffd8..4b86ba97de 100644
--- a/gdb/testsuite/gdb.fortran/derived-type.exp
+++ b/gdb/testsuite/gdb.fortran/derived-type.exp
@@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to main"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/info-modules.exp b/gdb/testsuite/gdb.fortran/info-modules.exp
index 0c3c6a58e1..a3a9b2cb18 100644
--- a/gdb/testsuite/gdb.fortran/info-modules.exp
+++ b/gdb/testsuite/gdb.fortran/info-modules.exp
@@ -28,8 +28,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![fortran_runto_main] } {
+    perror "Could not run to main."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/info-types.exp b/gdb/testsuite/gdb.fortran/info-types.exp
index 2138937782..e80c990a85 100644
--- a/gdb/testsuite/gdb.fortran/info-types.exp
+++ b/gdb/testsuite/gdb.fortran/info-types.exp
@@ -27,8 +27,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![fortran_runto_main] } {
+    perror "Could not run to main."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/intrinsics.exp b/gdb/testsuite/gdb.fortran/intrinsics.exp
index 504bce4138..2cb0237c95 100644
--- a/gdb/testsuite/gdb.fortran/intrinsics.exp
+++ b/gdb/testsuite/gdb.fortran/intrinsics.exp
@@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![fortran_runto_main] } {
+    perror "Could not run to main."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/library-module.exp b/gdb/testsuite/gdb.fortran/library-module.exp
index f25988e32c..8254fcf10a 100644
--- a/gdb/testsuite/gdb.fortran/library-module.exp
+++ b/gdb/testsuite/gdb.fortran/library-module.exp
@@ -40,9 +40,10 @@ if  { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list debug f90
 clean_restart $testfile
 
 gdb_load_shlib $libfile
+load_lib fortran.exp
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to main"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/logical.exp b/gdb/testsuite/gdb.fortran/logical.exp
index 324714fa49..161bbdd908 100644
--- a/gdb/testsuite/gdb.fortran/logical.exp
+++ b/gdb/testsuite/gdb.fortran/logical.exp
@@ -16,13 +16,14 @@
 # This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![fortran_runto_main] } {
+    perror "Could not run to main."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/max-depth.exp b/gdb/testsuite/gdb.fortran/max-depth.exp
index 262d0fdfa1..420b72539f 100644
--- a/gdb/testsuite/gdb.fortran/max-depth.exp
+++ b/gdb/testsuite/gdb.fortran/max-depth.exp
@@ -26,8 +26,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![fortran_runto_main] } {
+    perror "Could not run to main."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/module.exp b/gdb/testsuite/gdb.fortran/module.exp
index 1c269e2fed..4a8251c44c 100644
--- a/gdb/testsuite/gdb.fortran/module.exp
+++ b/gdb/testsuite/gdb.fortran/module.exp
@@ -29,8 +29,8 @@ gdb_test "p modmany::var_i" " = 14" "stopped language detection"
 
 gdb_test "print mod1::var_const" " = 20" "fully qualified name of DW_TAG_constant"
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to main"
     continue
 }
 
@@ -123,7 +123,7 @@ complete "modmany::var" $modmany_list
 # Breakpoint would work in language "c".
 gdb_test "show language" {The current source language is "(auto; currently )?fortran".}
 
-# gcc-4.4.2: The main program is always MAIN__ in .symtab so "runto" above
+# gcc-4.4.2: The main program is always $fmain in .symtab so "runto" above
 # works.  But DWARF DW_TAG_subprogram contains the name specified by
 # the "program" Fortran statement.
 if [gdb_breakpoint "module"] {
diff --git a/gdb/testsuite/gdb.fortran/multi-dim.exp b/gdb/testsuite/gdb.fortran/multi-dim.exp
index 05590914df..ef6c6da8bd 100644
--- a/gdb/testsuite/gdb.fortran/multi-dim.exp
+++ b/gdb/testsuite/gdb.fortran/multi-dim.exp
@@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug f90}
     return -1
 }
 
-if ![runto MAIN__] {
-    perror "Couldn't run to MAIN__"
+if ![fortran_runto_main] {
+    perror "Couldn't run to main"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/nested-funcs.exp b/gdb/testsuite/gdb.fortran/nested-funcs.exp
index e4fc02ffa5..9e0073d210 100755
--- a/gdb/testsuite/gdb.fortran/nested-funcs.exp
+++ b/gdb/testsuite/gdb.fortran/nested-funcs.exp
@@ -25,8 +25,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to main"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/print-formatted.exp b/gdb/testsuite/gdb.fortran/print-formatted.exp
index 8c6529ce7f..e71287724b 100644
--- a/gdb/testsuite/gdb.fortran/print-formatted.exp
+++ b/gdb/testsuite/gdb.fortran/print-formatted.exp
@@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
     return -1
 }
 
-if { ![runto MAIN__] } {
-    fail "runto MAIN__"
+if { ![fortran_runto_main] } {
+    fail "could not run to main"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/print_type.exp b/gdb/testsuite/gdb.fortran/print_type.exp
index 7d5915390d..fcedb9579a 100755
--- a/gdb/testsuite/gdb.fortran/print_type.exp
+++ b/gdb/testsuite/gdb.fortran/print_type.exp
@@ -24,7 +24,7 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/printing-types.exp b/gdb/testsuite/gdb.fortran/printing-types.exp
index 2c88f9e003..44fd93cc56 100644
--- a/gdb/testsuite/gdb.fortran/printing-types.exp
+++ b/gdb/testsuite/gdb.fortran/printing-types.exp
@@ -16,13 +16,14 @@
 if {[skip_fortran_tests]} { return -1 }
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if {![runto MAIN__]} then {
-    untested "could not run to breakpoint MAIN__"
+if {![fortran_runto_main]} then {
+    untested "could not run to main"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/ptr-indentation.exp b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
index 285e24e2cc..209809a292 100644
--- a/gdb/testsuite/gdb.fortran/ptr-indentation.exp
+++ b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
@@ -22,8 +22,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if {![runto MAIN__]} then {
-    untested "couldn't run to breakpoint MAIN__"
+if {![fortran_runto_main]} then {
+    untested "couldn't run to main"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
index d91e4bd48e..8dc5f76d93 100644
--- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
+++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
@@ -24,8 +24,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to main"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/subarray.exp b/gdb/testsuite/gdb.fortran/subarray.exp
index 5e3e8c38cb..9ee5a9b3cb 100644
--- a/gdb/testsuite/gdb.fortran/subarray.exp
+++ b/gdb/testsuite/gdb.fortran/subarray.exp
@@ -21,6 +21,7 @@
 if { [skip_fortran_tests] } { return -1 }
 
 standard_testfile .f
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
@@ -31,8 +32,8 @@ gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_load ${binfile}
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to main"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
index 5d8585c2ee..2ae0411cf1 100644
--- a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
+++ b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-datatypes.exp b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
index 2db9b3e110..b69636f600 100644
--- a/gdb/testsuite/gdb.fortran/vla-datatypes.exp
+++ b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
@@ -24,7 +24,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
 # check that all fortran standard datatypes will be
 # handled correctly when using as VLA's
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-history.exp b/gdb/testsuite/gdb.fortran/vla-history.exp
index 24bd945f4a..3bf98db197 100644
--- a/gdb/testsuite/gdb.fortran/vla-history.exp
+++ b/gdb/testsuite/gdb.fortran/vla-history.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
index 24c7b45840..d3fa595bea 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
index 09909e74b0..07a4a5fc2e 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-ptype.exp b/gdb/testsuite/gdb.fortran/vla-ptype.exp
index 22b2005317..bbb81ea0c8 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptype.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptype.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
index 8e7d36314e..d26b8c60f8 100644
--- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp
+++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-type.exp b/gdb/testsuite/gdb.fortran/vla-type.exp
index 6d885e7889..f007ea3a78 100755
--- a/gdb/testsuite/gdb.fortran/vla-type.exp
+++ b/gdb/testsuite/gdb.fortran/vla-type.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
index ab61dde06f..c3ed909a81 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla-sub.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
index afd992cee4..403e411cc2 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla-sub.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub.exp b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
index 3311f6befa..fd923edf40 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla-sub.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp
index 5af17b570c..9a727fc30a 100644
--- a/gdb/testsuite/gdb.fortran/vla-value.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
@@ -129,8 +129,8 @@ gdb_test "print vla1(9, 9, 9)" "no such vector element \\\(vector not allocated\
 # Try to assign VLA to user variable
 clean_restart ${testfile}
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to main"
     continue
 }
 gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
diff --git a/gdb/testsuite/gdb.fortran/whatis_type.exp b/gdb/testsuite/gdb.fortran/whatis_type.exp
index 6a9cc0a81e..4b0cbf9c28 100644
--- a/gdb/testsuite/gdb.fortran/whatis_type.exp
+++ b/gdb/testsuite/gdb.fortran/whatis_type.exp
@@ -23,8 +23,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
     return -1
 }
 
-if ![runto MAIN__] {
-    fail "run to MAIN__"
+if ![fortran_runto_main] {
+    fail "run to main"
     return
 }
 
diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
index 8cfffa7c08..3af80a8e60 100644
--- a/gdb/testsuite/gdb.mi/mi-var-child-f.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
@@ -36,7 +36,7 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
 mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load ${binfile}
 
-mi_runto MAIN__
+mi_runto [fortran_main]
 
 mi_create_varobj "array" "array" "create local variable array"
 
diff --git a/gdb/testsuite/lib/fortran.exp b/gdb/testsuite/lib/fortran.exp
index 549ed65790..654afd2b74 100644
--- a/gdb/testsuite/lib/fortran.exp
+++ b/gdb/testsuite/lib/fortran.exp
@@ -126,3 +126,21 @@ proc fortran_character1 {} {
 	return "unknown"
     }
 }
+
+proc fortran_main {} {
+    if {[test_compiler_info {gcc-4-[012]-*}]
+         || [test_compiler_info {gcc-*}]
+         || [test_compiler_info {icc-*}]} {
+	return "MAIN__"
+    } elseif {[test_compiler_info {clang-*}]} {
+	return "MAIN_"
+    } else {
+	return "unknown"
+    }
+}
+
+# fortran version of runto_main.
+
+proc fortran_runto_main { } {
+    return [runto [fortran_main]]
+}
-- 
2.17.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing
  2020-04-27 18:02           ` Sharma, Alok Kumar
@ 2020-04-29  9:15             ` Andrew Burgess
  2020-05-10  9:21               ` Sharma, Alok Kumar
  0 siblings, 1 reply; 14+ messages in thread
From: Andrew Burgess @ 2020-04-29  9:15 UTC (permalink / raw)
  To: Sharma, Alok Kumar
  Cc: Tom Tromey, George, Jini Susan, Achra, Nitika, gdb-patches

* Sharma, Alok Kumar <AlokKumar.Sharma@amd.com> [2020-04-27 18:02:03 +0000]:

> Hi Andrew,
> 
> Thanks a lot for your valuable comments. Please have a look at the
> updated patch in attachment.
>
>
>
> From 75e55e41ddc83ee3db6879fd955baf31d1301ba4 Mon Sep 17 00:00:00 2001
> From: Alok Kumar Sharma <AlokKumar.Sharma@amd.com>
> Date: Fri, 24 Apr 2020 14:46:09 +0530
> Subject: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing
> 
> Name of fortran main function for Flang compiler is MAIN_ while
> for gfortran it is MAIN__ . In test cases MAIN__ is hardcoded for
> the purpose of inserting breakpoint.
> 
> New proc is added to detect main function name depending on the
> compiler used.
> Fortran specific version of runto_main named fortran_runto_main
> is added.
> 
> This commit adds support for Flang main function, there should be
> no change for gfortran.

This looks great.  Please go ahead an commit it.  I did have one minor
last fix, but don't feel you know you need to repost the patch, just
update and merge.

> 
> gdb/testsuite/ChangeLog
> 
> 	* lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
> 	(fortran_runto_main): New Proc, fortran version of runto_main.
> 	* gdb.fortran/array-bounds-high.exp: Handle flang MAIN_.
> 	* gdb.fortran/array-bounds.exp: Likewise.
> 	* gdb.fortran/array-slices.exp: Likewise.
> 	* gdb.fortran/block-data.exp: Likewise.
> 	* gdb.fortran/charset.exp: Likewise.
> 	* gdb.fortran/common-block.exp: Likewise.
> 	* gdb.fortran/complex.exp: Likewise.
> 	* gdb.fortran/derived-type-function.exp: Likewise.
> 	* gdb.fortran/derived-type.exp: Likewise.
> 	* gdb.fortran/info-modules.exp: Likewise.
> 	* gdb.fortran/info-types.exp: Likewise.
> 	* gdb.fortran/intrinsics.exp: Likewise.
> 	* gdb.fortran/library-module.exp: Likewise.
> 	* gdb.fortran/logical.exp: Likewise.
> 	* gdb.fortran/max-depth.exp: Likewise.
> 	* gdb.fortran/module.exp: Likewise.
> 	* gdb.fortran/multi-dim.exp: Likewise.
> 	* gdb.fortran/nested-funcs.exp: Likewise.
> 	* gdb.fortran/print-formatted.exp: Likewise.
> 	* gdb.fortran/print_type.exp: Likewise.
> 	* gdb.fortran/printing-types.exp: Likewise.
> 	* gdb.fortran/ptr-indentation.exp: Likewise.
> 	* gdb.fortran/ptype-on-functions.exp: Likewise.
> 	* gdb.fortran/subarray.exp: Likewise.
> 	* gdb.fortran/vla-alloc-assoc.exp: Likewise.
> 	* gdb.fortran/vla-datatypes.exp: Likewise.
> 	* gdb.fortran/vla-history.exp: Likewise.
> 	* gdb.fortran/vla-ptr-info.exp: Likewise.
> 	* gdb.fortran/vla-ptype-sub.exp: Likewise.
> 	* gdb.fortran/vla-ptype.exp: Likewise.
> 	* gdb.fortran/vla-sizeof.exp: Likewise.
> 	* gdb.fortran/vla-type.exp: Likewise.
> 	* gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
> 	* gdb.fortran/vla-value-sub-finish.exp: Likewise.
> 	* gdb.fortran/vla-value-sub.exp: Likewise.
> 	* gdb.fortran/vla-value.exp: Likewise.
> 	* gdb.fortran/whatis_type.exp: Likewise.
> 	* gdb.mi/mi-var-child-f.exp: Likewise.
> 
> Change-Id: I0a30f5dad684879b416f71d3d08c385c159325bf
> ---
>  gdb/testsuite/ChangeLog                       | 43 +++++++++++++++++++
>  .../gdb.fortran/array-bounds-high.exp         |  5 ++-
>  gdb/testsuite/gdb.fortran/array-bounds.exp    |  5 ++-
>  gdb/testsuite/gdb.fortran/array-slices.exp    |  3 +-
>  gdb/testsuite/gdb.fortran/block-data.exp      |  4 +-
>  gdb/testsuite/gdb.fortran/charset.exp         |  6 ++-
>  gdb/testsuite/gdb.fortran/common-block.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/complex.exp         |  5 ++-
>  .../gdb.fortran/derived-type-function.exp     |  5 ++-
>  gdb/testsuite/gdb.fortran/derived-type.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/info-modules.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/info-types.exp      |  4 +-
>  gdb/testsuite/gdb.fortran/intrinsics.exp      |  4 +-
>  gdb/testsuite/gdb.fortran/library-module.exp  |  5 ++-
>  gdb/testsuite/gdb.fortran/logical.exp         |  5 ++-
>  gdb/testsuite/gdb.fortran/max-depth.exp       |  4 +-
>  gdb/testsuite/gdb.fortran/module.exp          |  6 +--
>  gdb/testsuite/gdb.fortran/multi-dim.exp       |  4 +-
>  gdb/testsuite/gdb.fortran/nested-funcs.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/print-formatted.exp |  4 +-
>  gdb/testsuite/gdb.fortran/print_type.exp      |  2 +-
>  gdb/testsuite/gdb.fortran/printing-types.exp  |  5 ++-
>  gdb/testsuite/gdb.fortran/ptr-indentation.exp |  4 +-
>  .../gdb.fortran/ptype-on-functions.exp        |  4 +-
>  gdb/testsuite/gdb.fortran/subarray.exp        |  5 ++-
>  gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp |  3 +-
>  gdb/testsuite/gdb.fortran/vla-datatypes.exp   |  2 +-
>  gdb/testsuite/gdb.fortran/vla-history.exp     |  3 +-
>  gdb/testsuite/gdb.fortran/vla-ptr-info.exp    |  3 +-
>  gdb/testsuite/gdb.fortran/vla-ptype-sub.exp   |  2 +-
>  gdb/testsuite/gdb.fortran/vla-ptype.exp       |  2 +-
>  gdb/testsuite/gdb.fortran/vla-sizeof.exp      |  3 +-
>  gdb/testsuite/gdb.fortran/vla-type.exp        |  2 +-
>  .../gdb.fortran/vla-value-sub-arbitrary.exp   |  3 +-
>  .../gdb.fortran/vla-value-sub-finish.exp      |  3 +-
>  gdb/testsuite/gdb.fortran/vla-value-sub.exp   |  3 +-
>  gdb/testsuite/gdb.fortran/vla-value.exp       |  6 +--
>  gdb/testsuite/gdb.fortran/whatis_type.exp     |  4 +-
>  gdb/testsuite/gdb.mi/mi-var-child-f.exp       |  2 +-
>  gdb/testsuite/lib/fortran.exp                 | 18 ++++++++
>  40 files changed, 143 insertions(+), 64 deletions(-)
> 
> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
> index 10683db566..0e3c207f85 100644
> --- a/gdb/testsuite/ChangeLog
> +++ b/gdb/testsuite/ChangeLog
> @@ -1,3 +1,46 @@
> +2020-04-24  Alok Kumar Sharma  <alokkumar.sharma@amd.com>
> +
> +	* lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
> +	(fortran_runto_main): New Proc, fortran version of runto_main.
> +	* gdb.fortran/array-bounds-high.exp: Handle flang MAIN_
> +	* gdb.fortran/array-bounds.exp: Likewise.
> +	* gdb.fortran/array-slices.exp: Likewise.
> +	* gdb.fortran/block-data.exp: Likewise.
> +	* gdb.fortran/charset.exp: Likewise.
> +	* gdb.fortran/common-block.exp: Likewise.
> +	* gdb.fortran/complex.exp: Likewise.
> +	* gdb.fortran/derived-type-function.exp: Likewise.
> +	* gdb.fortran/derived-type.exp: Likewise.
> +	* gdb.fortran/info-modules.exp: Likewise.
> +	* gdb.fortran/info-types.exp: Likewise.
> +	* gdb.fortran/intrinsics.exp: Likewise.
> +	* gdb.fortran/library-module.exp: Likewise.
> +	* gdb.fortran/logical.exp: Likewise.
> +	* gdb.fortran/max-depth.exp: Likewise.
> +	* gdb.fortran/module.exp: Likewise.
> +	* gdb.fortran/multi-dim.exp: Likewise.
> +	* gdb.fortran/nested-funcs.exp: Likewise.
> +	* gdb.fortran/print-formatted.exp: Likewise.
> +	* gdb.fortran/print_type.exp: Likewise.
> +	* gdb.fortran/printing-types.exp: Likewise.
> +	* gdb.fortran/ptr-indentation.exp: Likewise.
> +	* gdb.fortran/ptype-on-functions.exp: Likewise.
> +	* gdb.fortran/subarray.exp: Likewise.
> +	* gdb.fortran/vla-alloc-assoc.exp: Likewise.
> +	* gdb.fortran/vla-datatypes.exp: Likewise.
> +	* gdb.fortran/vla-history.exp: Likewise.
> +	* gdb.fortran/vla-ptr-info.exp: Likewise.
> +	* gdb.fortran/vla-ptype-sub.exp: Likewise.
> +	* gdb.fortran/vla-ptype.exp: Likewise.
> +	* gdb.fortran/vla-sizeof.exp: Likewise.
> +	* gdb.fortran/vla-type.exp: Likewise.
> +	* gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
> +	* gdb.fortran/vla-value-sub-finish.exp: Likewise.
> +	* gdb.fortran/vla-value-sub.exp: Likewise.
> +	* gdb.fortran/vla-value.exp: Likewise.
> +	* gdb.fortran/whatis_type.exp: Likewise.
> +	* gdb.mi/mi-var-child-f.exp: Likewise.
> +
>  2020-04-23  Tom de Vries  <tdevries@suse.de>
>  
>  	* gdb.base/decl-before-def.exp: Run to main and print a again.
> diff --git a/gdb/testsuite/gdb.fortran/array-bounds-high.exp b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
> index 81e2f87b89..ba34dbc23e 100644
> --- a/gdb/testsuite/gdb.fortran/array-bounds-high.exp
> +++ b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
> @@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
>  
>  set testfile "array-bounds-high"
>  standard_testfile .f90
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
>      return -1
>  }
>  
> -if {![runto MAIN__]} {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if {![fortran_runto_main]} {
> +    perror "Could not run to main."
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/array-bounds.exp b/gdb/testsuite/gdb.fortran/array-bounds.exp
> index 12bf5c2db3..3f2527343b 100644
> --- a/gdb/testsuite/gdb.fortran/array-bounds.exp
> +++ b/gdb/testsuite/gdb.fortran/array-bounds.exp
> @@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
>  
>  set testfile "array-bounds"
>  standard_testfile .f90
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
>      return -1
>  }
>  
> -if {![runto MAIN__]} {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if {![fortran_runto_main]} {
> +    perror "Could not run to main."
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp b/gdb/testsuite/gdb.fortran/array-slices.exp
> index 11997f926a..4ca1db90f7 100644
> --- a/gdb/testsuite/gdb.fortran/array-slices.exp
> +++ b/gdb/testsuite/gdb.fortran/array-slices.exp
> @@ -21,13 +21,14 @@
>  if {[skip_fortran_tests]} { return -1 }
>  
>  standard_testfile ".f90"
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
>  	 {debug f90}]} {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/block-data.exp b/gdb/testsuite/gdb.fortran/block-data.exp
> index 292afe6c16..632c0141a3 100644
> --- a/gdb/testsuite/gdb.fortran/block-data.exp
> +++ b/gdb/testsuite/gdb.fortran/block-data.exp
> @@ -30,8 +30,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>  
> -if ![runto MAIN__] then {
> -    untested "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    untested "couldn't run to main"
>      return -1
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/charset.exp b/gdb/testsuite/gdb.fortran/charset.exp
> index f0f62f8490..fc504ae0b0 100644
> --- a/gdb/testsuite/gdb.fortran/charset.exp
> +++ b/gdb/testsuite/gdb.fortran/charset.exp
> @@ -19,12 +19,14 @@
>  if { [skip_fortran_tests] } { return -1 }
>  
>  standard_testfile .f90
> +load_lib fortran.exp
> +
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug additional_flags=-fbackslash f90}] } {
>      return -1
>  }
>  
> -if ![runto MAIN__] {
> -    perror "Couldn't run to MAIN__"
> +if ![fortran_runto_main] {
> +    perror "Couldn't run to main"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/common-block.exp b/gdb/testsuite/gdb.fortran/common-block.exp
> index 19c1af0d81..3dacfd32b2 100644
> --- a/gdb/testsuite/gdb.fortran/common-block.exp
> +++ b/gdb/testsuite/gdb.fortran/common-block.exp
> @@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" ${testfile} \
>      return -1
>  }
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/complex.exp b/gdb/testsuite/gdb.fortran/complex.exp
> index c092ab29f1..a88e553e58 100644
> --- a/gdb/testsuite/gdb.fortran/complex.exp
> +++ b/gdb/testsuite/gdb.fortran/complex.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile .f90
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
>      return -1
>  }
>  
> -if ![runto MAIN__] then {
> -    perror "Couldn't run to MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "Couldn't run to main"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/derived-type-function.exp b/gdb/testsuite/gdb.fortran/derived-type-function.exp
> index 1f0f957317..2ae6f46c1e 100644
> --- a/gdb/testsuite/gdb.fortran/derived-type-function.exp
> +++ b/gdb/testsuite/gdb.fortran/derived-type-function.exp
> @@ -21,13 +21,14 @@
>  if { [skip_fortran_tests] } { return -1 }
>  
>  standard_testfile .f90
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/derived-type.exp b/gdb/testsuite/gdb.fortran/derived-type.exp
> index f1705bffd8..4b86ba97de 100644
> --- a/gdb/testsuite/gdb.fortran/derived-type.exp
> +++ b/gdb/testsuite/gdb.fortran/derived-type.exp
> @@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/info-modules.exp b/gdb/testsuite/gdb.fortran/info-modules.exp
> index 0c3c6a58e1..a3a9b2cb18 100644
> --- a/gdb/testsuite/gdb.fortran/info-modules.exp
> +++ b/gdb/testsuite/gdb.fortran/info-modules.exp
> @@ -28,8 +28,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
>      return -1
>  }
>  
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to main."
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/info-types.exp b/gdb/testsuite/gdb.fortran/info-types.exp
> index 2138937782..e80c990a85 100644
> --- a/gdb/testsuite/gdb.fortran/info-types.exp
> +++ b/gdb/testsuite/gdb.fortran/info-types.exp
> @@ -27,8 +27,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
>      return -1
>  }
>  
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to main."
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/intrinsics.exp b/gdb/testsuite/gdb.fortran/intrinsics.exp
> index 504bce4138..2cb0237c95 100644
> --- a/gdb/testsuite/gdb.fortran/intrinsics.exp
> +++ b/gdb/testsuite/gdb.fortran/intrinsics.exp
> @@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
>      return -1
>  }
>  
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to main."
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/library-module.exp b/gdb/testsuite/gdb.fortran/library-module.exp
> index f25988e32c..8254fcf10a 100644
> --- a/gdb/testsuite/gdb.fortran/library-module.exp
> +++ b/gdb/testsuite/gdb.fortran/library-module.exp
> @@ -40,9 +40,10 @@ if  { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list debug f90
>  clean_restart $testfile
>  
>  gdb_load_shlib $libfile
> +load_lib fortran.exp
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/logical.exp b/gdb/testsuite/gdb.fortran/logical.exp
> index 324714fa49..161bbdd908 100644
> --- a/gdb/testsuite/gdb.fortran/logical.exp
> +++ b/gdb/testsuite/gdb.fortran/logical.exp
> @@ -16,13 +16,14 @@
>  # This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
>  
>  standard_testfile .f90
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
>      return -1
>  }
>  
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to main."
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/max-depth.exp b/gdb/testsuite/gdb.fortran/max-depth.exp
> index 262d0fdfa1..420b72539f 100644
> --- a/gdb/testsuite/gdb.fortran/max-depth.exp
> +++ b/gdb/testsuite/gdb.fortran/max-depth.exp
> @@ -26,8 +26,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
>      return -1
>  }
>  
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to main."
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/module.exp b/gdb/testsuite/gdb.fortran/module.exp
> index 1c269e2fed..4a8251c44c 100644
> --- a/gdb/testsuite/gdb.fortran/module.exp
> +++ b/gdb/testsuite/gdb.fortran/module.exp
> @@ -29,8 +29,8 @@ gdb_test "p modmany::var_i" " = 14" "stopped language detection"
>  
>  gdb_test "print mod1::var_const" " = 20" "fully qualified name of DW_TAG_constant"
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>  
> @@ -123,7 +123,7 @@ complete "modmany::var" $modmany_list
>  # Breakpoint would work in language "c".
>  gdb_test "show language" {The current source language is "(auto; currently )?fortran".}
>  
> -# gcc-4.4.2: The main program is always MAIN__ in .symtab so "runto" above
> +# gcc-4.4.2: The main program is always $fmain in .symtab so "runto" above
>  # works.  But DWARF DW_TAG_subprogram contains the name specified by
>  # the "program" Fortran statement.
>  if [gdb_breakpoint "module"] {
> diff --git a/gdb/testsuite/gdb.fortran/multi-dim.exp b/gdb/testsuite/gdb.fortran/multi-dim.exp
> index 05590914df..ef6c6da8bd 100644
> --- a/gdb/testsuite/gdb.fortran/multi-dim.exp
> +++ b/gdb/testsuite/gdb.fortran/multi-dim.exp
> @@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug f90}
>      return -1
>  }
>  
> -if ![runto MAIN__] {
> -    perror "Couldn't run to MAIN__"
> +if ![fortran_runto_main] {
> +    perror "Couldn't run to main"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/nested-funcs.exp b/gdb/testsuite/gdb.fortran/nested-funcs.exp
> index e4fc02ffa5..9e0073d210 100755
> --- a/gdb/testsuite/gdb.fortran/nested-funcs.exp
> +++ b/gdb/testsuite/gdb.fortran/nested-funcs.exp
> @@ -25,8 +25,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/print-formatted.exp b/gdb/testsuite/gdb.fortran/print-formatted.exp
> index 8c6529ce7f..e71287724b 100644
> --- a/gdb/testsuite/gdb.fortran/print-formatted.exp
> +++ b/gdb/testsuite/gdb.fortran/print-formatted.exp
> @@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
>      return -1
>  }
>  
> -if { ![runto MAIN__] } {
> -    fail "runto MAIN__"
> +if { ![fortran_runto_main] } {
> +    fail "could not run to main"
>      return -1
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/print_type.exp b/gdb/testsuite/gdb.fortran/print_type.exp
> index 7d5915390d..fcedb9579a 100755
> --- a/gdb/testsuite/gdb.fortran/print_type.exp
> +++ b/gdb/testsuite/gdb.fortran/print_type.exp
> @@ -24,7 +24,7 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/printing-types.exp b/gdb/testsuite/gdb.fortran/printing-types.exp
> index 2c88f9e003..44fd93cc56 100644
> --- a/gdb/testsuite/gdb.fortran/printing-types.exp
> +++ b/gdb/testsuite/gdb.fortran/printing-types.exp
> @@ -16,13 +16,14 @@
>  if {[skip_fortran_tests]} { return -1 }
>  
>  standard_testfile .f90
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>  
> -if {![runto MAIN__]} then {
> -    untested "could not run to breakpoint MAIN__"
> +if {![fortran_runto_main]} then {
> +    untested "could not run to main"
>      return -1
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/ptr-indentation.exp b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
> index 285e24e2cc..209809a292 100644
> --- a/gdb/testsuite/gdb.fortran/ptr-indentation.exp
> +++ b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
> @@ -22,8 +22,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>  
> -if {![runto MAIN__]} then {
> -    untested "couldn't run to breakpoint MAIN__"
> +if {![fortran_runto_main]} then {
> +    untested "couldn't run to main"
>      return -1
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> index d91e4bd48e..8dc5f76d93 100644
> --- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> +++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> @@ -24,8 +24,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/subarray.exp b/gdb/testsuite/gdb.fortran/subarray.exp
> index 5e3e8c38cb..9ee5a9b3cb 100644
> --- a/gdb/testsuite/gdb.fortran/subarray.exp
> +++ b/gdb/testsuite/gdb.fortran/subarray.exp
> @@ -21,6 +21,7 @@
>  if { [skip_fortran_tests] } { return -1 }
>  
>  standard_testfile .f
> +load_lib fortran.exp
>  
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
> @@ -31,8 +32,8 @@ gdb_start
>  gdb_reinitialize_dir $srcdir/$subdir
>  gdb_load ${binfile}
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>  
> diff --git a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
> index 5d8585c2ee..2ae0411cf1 100644
> --- a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>  
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-datatypes.exp b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
> index 2db9b3e110..b69636f600 100644
> --- a/gdb/testsuite/gdb.fortran/vla-datatypes.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
> @@ -24,7 +24,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>  # check that all fortran standard datatypes will be
>  # handled correctly when using as VLA's
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-history.exp b/gdb/testsuite/gdb.fortran/vla-history.exp
> index 24bd945f4a..3bf98db197 100644
> --- a/gdb/testsuite/gdb.fortran/vla-history.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-history.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>  
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> index 24c7b45840..d3fa595bea 100644
> --- a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>  
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
> index 09909e74b0..07a4a5fc2e 100644
> --- a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-ptype.exp b/gdb/testsuite/gdb.fortran/vla-ptype.exp
> index 22b2005317..bbb81ea0c8 100644
> --- a/gdb/testsuite/gdb.fortran/vla-ptype.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-ptype.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
> index 8e7d36314e..d26b8c60f8 100644
> --- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>  
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-type.exp b/gdb/testsuite/gdb.fortran/vla-type.exp
> index 6d885e7889..f007ea3a78 100755
> --- a/gdb/testsuite/gdb.fortran/vla-type.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-type.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
> index ab61dde06f..c3ed909a81 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile "vla-sub.f90"
> +load_lib fortran.exp
>  
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
> index afd992cee4..403e411cc2 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile "vla-sub.f90"
> +load_lib fortran.exp
>  
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub.exp b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
> index 3311f6befa..fd923edf40 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value-sub.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>  
>  standard_testfile "vla-sub.f90"
> +load_lib fortran.exp
>  
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp
> index 5af17b570c..9a727fc30a 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>  
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> @@ -129,8 +129,8 @@ gdb_test "print vla1(9, 9, 9)" "no such vector element \\\(vector not allocated\
>  # Try to assign VLA to user variable
>  clean_restart ${testfile}
>  
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>  gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
> diff --git a/gdb/testsuite/gdb.fortran/whatis_type.exp b/gdb/testsuite/gdb.fortran/whatis_type.exp
> index 6a9cc0a81e..4b0cbf9c28 100644
> --- a/gdb/testsuite/gdb.fortran/whatis_type.exp
> +++ b/gdb/testsuite/gdb.fortran/whatis_type.exp
> @@ -23,8 +23,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
>      return -1
>  }
>  
> -if ![runto MAIN__] {
> -    fail "run to MAIN__"
> +if ![fortran_runto_main] {
> +    fail "run to main"
>      return
>  }
>  
> diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
> index 8cfffa7c08..3af80a8e60 100644
> --- a/gdb/testsuite/gdb.mi/mi-var-child-f.exp
> +++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
> @@ -36,7 +36,7 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
>  mi_gdb_reinitialize_dir $srcdir/$subdir
>  mi_gdb_load ${binfile}
>  
> -mi_runto MAIN__
> +mi_runto [fortran_main]
>  
>  mi_create_varobj "array" "array" "create local variable array"
>  
> diff --git a/gdb/testsuite/lib/fortran.exp b/gdb/testsuite/lib/fortran.exp
> index 549ed65790..654afd2b74 100644
> --- a/gdb/testsuite/lib/fortran.exp
> +++ b/gdb/testsuite/lib/fortran.exp
> @@ -126,3 +126,21 @@ proc fortran_character1 {} {
>  	return "unknown"
>      }
>  }
> +
> +proc fortran_main {} {

This proc should have a header comment.  Something like:

  # Return name of the main procedure based on the compiler version.

> +    if {[test_compiler_info {gcc-4-[012]-*}]
> +         || [test_compiler_info {gcc-*}]
> +         || [test_compiler_info {icc-*}]} {
> +	return "MAIN__"
> +    } elseif {[test_compiler_info {clang-*}]} {
> +	return "MAIN_"
> +    } else {
> +	return "unknown"
> +    }
> +}
> +
> +# fortran version of runto_main.

Please capitalise Fortran, which I believe is how the name is written.


With those two fixes, please just go ahead and merge.

Thanks,
Andrew



> +
> +proc fortran_runto_main { } {
> +    return [runto [fortran_main]]
> +}
> -- 
> 2.17.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing
  2020-04-29  9:15             ` Andrew Burgess
@ 2020-05-10  9:21               ` Sharma, Alok Kumar
  2020-05-10 19:24                 ` Sharma, Alok Kumar
  0 siblings, 1 reply; 14+ messages in thread
From: Sharma, Alok Kumar @ 2020-05-10  9:21 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: Tom Tromey, George, Jini Susan, Achra, Nitika, gdb-patches

[-- Attachment #1: Type: text/plain, Size: 38121 bytes --]

Thanks a lot Andrew for your comments. Please find the updated patch with your comments incorporated.
As I lost my ssh setup and yet to get new one updated on server, I am unable to commit currently.
I would like to request if someone please commit this?

    gdb/testsuite/ChangeLog

            * lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
            (fortran_runto_main): New Proc, fortran version of runto_main.
            * gdb.fortran/array-bounds-high.exp: Handle flang MAIN_.
            * gdb.fortran/array-bounds.exp: Likewise.
            * gdb.fortran/array-slices.exp: Likewise.
            * gdb.fortran/block-data.exp: Likewise.
            * gdb.fortran/charset.exp: Likewise.
            * gdb.fortran/common-block.exp: Likewise.
            * gdb.fortran/complex.exp: Likewise.
            * gdb.fortran/derived-type-function.exp: Likewise.
            * gdb.fortran/derived-type.exp: Likewise.
            * gdb.fortran/info-modules.exp: Likewise.
            * gdb.fortran/info-types.exp: Likewise.
            * gdb.fortran/intrinsics.exp: Likewise.
            * gdb.fortran/library-module.exp: Likewise.
            * gdb.fortran/logical.exp: Likewise.
            * gdb.fortran/max-depth.exp: Likewise.
            * gdb.fortran/module.exp: Likewise.
            * gdb.fortran/multi-dim.exp: Likewise.
            * gdb.fortran/nested-funcs.exp: Likewise.
            * gdb.fortran/print-formatted.exp: Likewise.
            * gdb.fortran/print_type.exp: Likewise.
            * gdb.fortran/printing-types.exp: Likewise.
            * gdb.fortran/ptr-indentation.exp: Likewise.
            * gdb.fortran/ptype-on-functions.exp: Likewise.
            * gdb.fortran/subarray.exp: Likewise.
            * gdb.fortran/vla-alloc-assoc.exp: Likewise.
            * gdb.fortran/vla-datatypes.exp: Likewise.
            * gdb.fortran/vla-history.exp: Likewise.
            * gdb.fortran/vla-ptr-info.exp: Likewise.
            * gdb.fortran/vla-ptype-sub.exp: Likewise.
            * gdb.fortran/vla-ptype.exp: Likewise.
            * gdb.fortran/vla-sizeof.exp: Likewise.
            * gdb.fortran/vla-type.exp: Likewise.
            * gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
            * gdb.fortran/vla-value-sub-finish.exp: Likewise.
            * gdb.fortran/vla-value-sub.exp: Likewise.
            * gdb.fortran/vla-value.exp: Likewise.
            * gdb.fortran/whatis_type.exp: Likewise.
            * gdb.mi/mi-var-child-f.exp: Likewise.

Regards,
Alok

-----Original Message-----
From: Andrew Burgess <andrew.burgess@embecosm.com> 
Sent: Wednesday, April 29, 2020 2:45 PM
To: Sharma, Alok Kumar <AlokKumar.Sharma@amd.com>
Cc: Tom Tromey <tom@tromey.com>; George, Jini Susan <JiniSusan.George@amd.com>; Achra, Nitika <Nitika.Achra@amd.com>; gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing

[CAUTION: External Email]

* Sharma, Alok Kumar <AlokKumar.Sharma@amd.com> [2020-04-27 18:02:03 +0000]:

> Hi Andrew,
>
> Thanks a lot for your valuable comments. Please have a look at the 
> updated patch in attachment.
>
>
>
> From 75e55e41ddc83ee3db6879fd955baf31d1301ba4 Mon Sep 17 00:00:00 2001
> From: Alok Kumar Sharma <AlokKumar.Sharma@amd.com>
> Date: Fri, 24 Apr 2020 14:46:09 +0530
> Subject: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing
>
> Name of fortran main function for Flang compiler is MAIN_ while for 
> gfortran it is MAIN__ . In test cases MAIN__ is hardcoded for the 
> purpose of inserting breakpoint.
>
> New proc is added to detect main function name depending on the 
> compiler used.
> Fortran specific version of runto_main named fortran_runto_main is 
> added.
>
> This commit adds support for Flang main function, there should be no 
> change for gfortran.

This looks great.  Please go ahead an commit it.  I did have one minor last fix, but don't feel you know you need to repost the patch, just update and merge.

>
> gdb/testsuite/ChangeLog
>
>       * lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
>       (fortran_runto_main): New Proc, fortran version of runto_main.
>       * gdb.fortran/array-bounds-high.exp: Handle flang MAIN_.
>       * gdb.fortran/array-bounds.exp: Likewise.
>       * gdb.fortran/array-slices.exp: Likewise.
>       * gdb.fortran/block-data.exp: Likewise.
>       * gdb.fortran/charset.exp: Likewise.
>       * gdb.fortran/common-block.exp: Likewise.
>       * gdb.fortran/complex.exp: Likewise.
>       * gdb.fortran/derived-type-function.exp: Likewise.
>       * gdb.fortran/derived-type.exp: Likewise.
>       * gdb.fortran/info-modules.exp: Likewise.
>       * gdb.fortran/info-types.exp: Likewise.
>       * gdb.fortran/intrinsics.exp: Likewise.
>       * gdb.fortran/library-module.exp: Likewise.
>       * gdb.fortran/logical.exp: Likewise.
>       * gdb.fortran/max-depth.exp: Likewise.
>       * gdb.fortran/module.exp: Likewise.
>       * gdb.fortran/multi-dim.exp: Likewise.
>       * gdb.fortran/nested-funcs.exp: Likewise.
>       * gdb.fortran/print-formatted.exp: Likewise.
>       * gdb.fortran/print_type.exp: Likewise.
>       * gdb.fortran/printing-types.exp: Likewise.
>       * gdb.fortran/ptr-indentation.exp: Likewise.
>       * gdb.fortran/ptype-on-functions.exp: Likewise.
>       * gdb.fortran/subarray.exp: Likewise.
>       * gdb.fortran/vla-alloc-assoc.exp: Likewise.
>       * gdb.fortran/vla-datatypes.exp: Likewise.
>       * gdb.fortran/vla-history.exp: Likewise.
>       * gdb.fortran/vla-ptr-info.exp: Likewise.
>       * gdb.fortran/vla-ptype-sub.exp: Likewise.
>       * gdb.fortran/vla-ptype.exp: Likewise.
>       * gdb.fortran/vla-sizeof.exp: Likewise.
>       * gdb.fortran/vla-type.exp: Likewise.
>       * gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
>       * gdb.fortran/vla-value-sub-finish.exp: Likewise.
>       * gdb.fortran/vla-value-sub.exp: Likewise.
>       * gdb.fortran/vla-value.exp: Likewise.
>       * gdb.fortran/whatis_type.exp: Likewise.
>       * gdb.mi/mi-var-child-f.exp: Likewise.
>
> Change-Id: I0a30f5dad684879b416f71d3d08c385c159325bf
> ---
>  gdb/testsuite/ChangeLog                       | 43 +++++++++++++++++++
>  .../gdb.fortran/array-bounds-high.exp         |  5 ++-
>  gdb/testsuite/gdb.fortran/array-bounds.exp    |  5 ++-
>  gdb/testsuite/gdb.fortran/array-slices.exp    |  3 +-
>  gdb/testsuite/gdb.fortran/block-data.exp      |  4 +-
>  gdb/testsuite/gdb.fortran/charset.exp         |  6 ++-
>  gdb/testsuite/gdb.fortran/common-block.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/complex.exp         |  5 ++-
>  .../gdb.fortran/derived-type-function.exp     |  5 ++-
>  gdb/testsuite/gdb.fortran/derived-type.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/info-modules.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/info-types.exp      |  4 +-
>  gdb/testsuite/gdb.fortran/intrinsics.exp      |  4 +-
>  gdb/testsuite/gdb.fortran/library-module.exp  |  5 ++-
>  gdb/testsuite/gdb.fortran/logical.exp         |  5 ++-
>  gdb/testsuite/gdb.fortran/max-depth.exp       |  4 +-
>  gdb/testsuite/gdb.fortran/module.exp          |  6 +--
>  gdb/testsuite/gdb.fortran/multi-dim.exp       |  4 +-
>  gdb/testsuite/gdb.fortran/nested-funcs.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/print-formatted.exp |  4 +-
>  gdb/testsuite/gdb.fortran/print_type.exp      |  2 +-
>  gdb/testsuite/gdb.fortran/printing-types.exp  |  5 ++-  
> gdb/testsuite/gdb.fortran/ptr-indentation.exp |  4 +-
>  .../gdb.fortran/ptype-on-functions.exp        |  4 +-
>  gdb/testsuite/gdb.fortran/subarray.exp        |  5 ++-
>  gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp |  3 +-
>  gdb/testsuite/gdb.fortran/vla-datatypes.exp   |  2 +-
>  gdb/testsuite/gdb.fortran/vla-history.exp     |  3 +-
>  gdb/testsuite/gdb.fortran/vla-ptr-info.exp    |  3 +-
>  gdb/testsuite/gdb.fortran/vla-ptype-sub.exp   |  2 +-
>  gdb/testsuite/gdb.fortran/vla-ptype.exp       |  2 +-
>  gdb/testsuite/gdb.fortran/vla-sizeof.exp      |  3 +-
>  gdb/testsuite/gdb.fortran/vla-type.exp        |  2 +-
>  .../gdb.fortran/vla-value-sub-arbitrary.exp   |  3 +-
>  .../gdb.fortran/vla-value-sub-finish.exp      |  3 +-
>  gdb/testsuite/gdb.fortran/vla-value-sub.exp   |  3 +-
>  gdb/testsuite/gdb.fortran/vla-value.exp       |  6 +--
>  gdb/testsuite/gdb.fortran/whatis_type.exp     |  4 +-
>  gdb/testsuite/gdb.mi/mi-var-child-f.exp       |  2 +-
>  gdb/testsuite/lib/fortran.exp                 | 18 ++++++++
>  40 files changed, 143 insertions(+), 64 deletions(-)
>
> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 
> 10683db566..0e3c207f85 100644
> --- a/gdb/testsuite/ChangeLog
> +++ b/gdb/testsuite/ChangeLog
> @@ -1,3 +1,46 @@
> +2020-04-24  Alok Kumar Sharma  <alokkumar.sharma@amd.com>
> +
> +     * lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
> +     (fortran_runto_main): New Proc, fortran version of runto_main.
> +     * gdb.fortran/array-bounds-high.exp: Handle flang MAIN_
> +     * gdb.fortran/array-bounds.exp: Likewise.
> +     * gdb.fortran/array-slices.exp: Likewise.
> +     * gdb.fortran/block-data.exp: Likewise.
> +     * gdb.fortran/charset.exp: Likewise.
> +     * gdb.fortran/common-block.exp: Likewise.
> +     * gdb.fortran/complex.exp: Likewise.
> +     * gdb.fortran/derived-type-function.exp: Likewise.
> +     * gdb.fortran/derived-type.exp: Likewise.
> +     * gdb.fortran/info-modules.exp: Likewise.
> +     * gdb.fortran/info-types.exp: Likewise.
> +     * gdb.fortran/intrinsics.exp: Likewise.
> +     * gdb.fortran/library-module.exp: Likewise.
> +     * gdb.fortran/logical.exp: Likewise.
> +     * gdb.fortran/max-depth.exp: Likewise.
> +     * gdb.fortran/module.exp: Likewise.
> +     * gdb.fortran/multi-dim.exp: Likewise.
> +     * gdb.fortran/nested-funcs.exp: Likewise.
> +     * gdb.fortran/print-formatted.exp: Likewise.
> +     * gdb.fortran/print_type.exp: Likewise.
> +     * gdb.fortran/printing-types.exp: Likewise.
> +     * gdb.fortran/ptr-indentation.exp: Likewise.
> +     * gdb.fortran/ptype-on-functions.exp: Likewise.
> +     * gdb.fortran/subarray.exp: Likewise.
> +     * gdb.fortran/vla-alloc-assoc.exp: Likewise.
> +     * gdb.fortran/vla-datatypes.exp: Likewise.
> +     * gdb.fortran/vla-history.exp: Likewise.
> +     * gdb.fortran/vla-ptr-info.exp: Likewise.
> +     * gdb.fortran/vla-ptype-sub.exp: Likewise.
> +     * gdb.fortran/vla-ptype.exp: Likewise.
> +     * gdb.fortran/vla-sizeof.exp: Likewise.
> +     * gdb.fortran/vla-type.exp: Likewise.
> +     * gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
> +     * gdb.fortran/vla-value-sub-finish.exp: Likewise.
> +     * gdb.fortran/vla-value-sub.exp: Likewise.
> +     * gdb.fortran/vla-value.exp: Likewise.
> +     * gdb.fortran/whatis_type.exp: Likewise.
> +     * gdb.mi/mi-var-child-f.exp: Likewise.
> +
>  2020-04-23  Tom de Vries  <tdevries@suse.de>
>
>       * gdb.base/decl-before-def.exp: Run to main and print a again.
> diff --git a/gdb/testsuite/gdb.fortran/array-bounds-high.exp 
> b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
> index 81e2f87b89..ba34dbc23e 100644
> --- a/gdb/testsuite/gdb.fortran/array-bounds-high.exp
> +++ b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
> @@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
>
>  set testfile "array-bounds-high"
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
>      return -1
>  }
>
> -if {![runto MAIN__]} {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if {![fortran_runto_main]} {
> +    perror "Could not run to main."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/array-bounds.exp 
> b/gdb/testsuite/gdb.fortran/array-bounds.exp
> index 12bf5c2db3..3f2527343b 100644
> --- a/gdb/testsuite/gdb.fortran/array-bounds.exp
> +++ b/gdb/testsuite/gdb.fortran/array-bounds.exp
> @@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
>
>  set testfile "array-bounds"
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
>      return -1
>  }
>
> -if {![runto MAIN__]} {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if {![fortran_runto_main]} {
> +    perror "Could not run to main."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp 
> b/gdb/testsuite/gdb.fortran/array-slices.exp
> index 11997f926a..4ca1db90f7 100644
> --- a/gdb/testsuite/gdb.fortran/array-slices.exp
> +++ b/gdb/testsuite/gdb.fortran/array-slices.exp
> @@ -21,13 +21,14 @@
>  if {[skip_fortran_tests]} { return -1 }
>
>  standard_testfile ".f90"
> +load_lib fortran.exp
>
>  if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
>        {debug f90}]} {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/block-data.exp 
> b/gdb/testsuite/gdb.fortran/block-data.exp
> index 292afe6c16..632c0141a3 100644
> --- a/gdb/testsuite/gdb.fortran/block-data.exp
> +++ b/gdb/testsuite/gdb.fortran/block-data.exp
> @@ -30,8 +30,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    untested "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    untested "couldn't run to main"
>      return -1
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/charset.exp 
> b/gdb/testsuite/gdb.fortran/charset.exp
> index f0f62f8490..fc504ae0b0 100644
> --- a/gdb/testsuite/gdb.fortran/charset.exp
> +++ b/gdb/testsuite/gdb.fortran/charset.exp
> @@ -19,12 +19,14 @@
>  if { [skip_fortran_tests] } { return -1 }
>
>  standard_testfile .f90
> +load_lib fortran.exp
> +
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug additional_flags=-fbackslash f90}] } {
>      return -1
>  }
>
> -if ![runto MAIN__] {
> -    perror "Couldn't run to MAIN__"
> +if ![fortran_runto_main] {
> +    perror "Couldn't run to main"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/common-block.exp 
> b/gdb/testsuite/gdb.fortran/common-block.exp
> index 19c1af0d81..3dacfd32b2 100644
> --- a/gdb/testsuite/gdb.fortran/common-block.exp
> +++ b/gdb/testsuite/gdb.fortran/common-block.exp
> @@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" ${testfile} \
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/complex.exp 
> b/gdb/testsuite/gdb.fortran/complex.exp
> index c092ab29f1..a88e553e58 100644
> --- a/gdb/testsuite/gdb.fortran/complex.exp
> +++ b/gdb/testsuite/gdb.fortran/complex.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cff788c9d006c4aad116208d7ec1ddc15%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637237485308605033&amp;sdata=q99fnfEAaF682EbULeOibMZJ5gzZHAflZeRzUPteiwY%3D&amp;reserved=0>.
>
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "Couldn't run to MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "Couldn't run to main"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/derived-type-function.exp 
> b/gdb/testsuite/gdb.fortran/derived-type-function.exp
> index 1f0f957317..2ae6f46c1e 100644
> --- a/gdb/testsuite/gdb.fortran/derived-type-function.exp
> +++ b/gdb/testsuite/gdb.fortran/derived-type-function.exp
> @@ -21,13 +21,14 @@
>  if { [skip_fortran_tests] } { return -1 }
>
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/derived-type.exp 
> b/gdb/testsuite/gdb.fortran/derived-type.exp
> index f1705bffd8..4b86ba97de 100644
> --- a/gdb/testsuite/gdb.fortran/derived-type.exp
> +++ b/gdb/testsuite/gdb.fortran/derived-type.exp
> @@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/info-modules.exp 
> b/gdb/testsuite/gdb.fortran/info-modules.exp
> index 0c3c6a58e1..a3a9b2cb18 100644
> --- a/gdb/testsuite/gdb.fortran/info-modules.exp
> +++ b/gdb/testsuite/gdb.fortran/info-modules.exp
> @@ -28,8 +28,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to main."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/info-types.exp 
> b/gdb/testsuite/gdb.fortran/info-types.exp
> index 2138937782..e80c990a85 100644
> --- a/gdb/testsuite/gdb.fortran/info-types.exp
> +++ b/gdb/testsuite/gdb.fortran/info-types.exp
> @@ -27,8 +27,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to main."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/intrinsics.exp 
> b/gdb/testsuite/gdb.fortran/intrinsics.exp
> index 504bce4138..2cb0237c95 100644
> --- a/gdb/testsuite/gdb.fortran/intrinsics.exp
> +++ b/gdb/testsuite/gdb.fortran/intrinsics.exp
> @@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to main."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/library-module.exp 
> b/gdb/testsuite/gdb.fortran/library-module.exp
> index f25988e32c..8254fcf10a 100644
> --- a/gdb/testsuite/gdb.fortran/library-module.exp
> +++ b/gdb/testsuite/gdb.fortran/library-module.exp
> @@ -40,9 +40,10 @@ if  { [gdb_compile $srcdir/$subdir/$srcfile 
> $binfile executable [list debug f90  clean_restart $testfile
>
>  gdb_load_shlib $libfile
> +load_lib fortran.exp
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/logical.exp 
> b/gdb/testsuite/gdb.fortran/logical.exp
> index 324714fa49..161bbdd908 100644
> --- a/gdb/testsuite/gdb.fortran/logical.exp
> +++ b/gdb/testsuite/gdb.fortran/logical.exp
> @@ -16,13 +16,14 @@
>  # This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
>
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to main."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/max-depth.exp 
> b/gdb/testsuite/gdb.fortran/max-depth.exp
> index 262d0fdfa1..420b72539f 100644
> --- a/gdb/testsuite/gdb.fortran/max-depth.exp
> +++ b/gdb/testsuite/gdb.fortran/max-depth.exp
> @@ -26,8 +26,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to main."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/module.exp 
> b/gdb/testsuite/gdb.fortran/module.exp
> index 1c269e2fed..4a8251c44c 100644
> --- a/gdb/testsuite/gdb.fortran/module.exp
> +++ b/gdb/testsuite/gdb.fortran/module.exp
> @@ -29,8 +29,8 @@ gdb_test "p modmany::var_i" " = 14" "stopped language detection"
>
>  gdb_test "print mod1::var_const" " = 20" "fully qualified name of DW_TAG_constant"
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>
> @@ -123,7 +123,7 @@ complete "modmany::var" $modmany_list  # 
> Breakpoint would work in language "c".
>  gdb_test "show language" {The current source language is "(auto; 
> currently )?fortran".}
>
> -# gcc-4.4.2: The main program is always MAIN__ in .symtab so "runto" 
> above
> +# gcc-4.4.2: The main program is always $fmain in .symtab so "runto" 
> +above
>  # works.  But DWARF DW_TAG_subprogram contains the name specified by  
> # the "program" Fortran statement.
>  if [gdb_breakpoint "module"] {
> diff --git a/gdb/testsuite/gdb.fortran/multi-dim.exp 
> b/gdb/testsuite/gdb.fortran/multi-dim.exp
> index 05590914df..ef6c6da8bd 100644
> --- a/gdb/testsuite/gdb.fortran/multi-dim.exp
> +++ b/gdb/testsuite/gdb.fortran/multi-dim.exp
> @@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug f90}
>      return -1
>  }
>
> -if ![runto MAIN__] {
> -    perror "Couldn't run to MAIN__"
> +if ![fortran_runto_main] {
> +    perror "Couldn't run to main"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/nested-funcs.exp 
> b/gdb/testsuite/gdb.fortran/nested-funcs.exp
> index e4fc02ffa5..9e0073d210 100755
> --- a/gdb/testsuite/gdb.fortran/nested-funcs.exp
> +++ b/gdb/testsuite/gdb.fortran/nested-funcs.exp
> @@ -25,8 +25,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/print-formatted.exp 
> b/gdb/testsuite/gdb.fortran/print-formatted.exp
> index 8c6529ce7f..e71287724b 100644
> --- a/gdb/testsuite/gdb.fortran/print-formatted.exp
> +++ b/gdb/testsuite/gdb.fortran/print-formatted.exp
> @@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    fail "runto MAIN__"
> +if { ![fortran_runto_main] } {
> +    fail "could not run to main"
>      return -1
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/print_type.exp 
> b/gdb/testsuite/gdb.fortran/print_type.exp
> index 7d5915390d..fcedb9579a 100755
> --- a/gdb/testsuite/gdb.fortran/print_type.exp
> +++ b/gdb/testsuite/gdb.fortran/print_type.exp
> @@ -24,7 +24,7 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/printing-types.exp 
> b/gdb/testsuite/gdb.fortran/printing-types.exp
> index 2c88f9e003..44fd93cc56 100644
> --- a/gdb/testsuite/gdb.fortran/printing-types.exp
> +++ b/gdb/testsuite/gdb.fortran/printing-types.exp
> @@ -16,13 +16,14 @@
>  if {[skip_fortran_tests]} { return -1 }
>
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if {![runto MAIN__]} then {
> -    untested "could not run to breakpoint MAIN__"
> +if {![fortran_runto_main]} then {
> +    untested "could not run to main"
>      return -1
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/ptr-indentation.exp 
> b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
> index 285e24e2cc..209809a292 100644
> --- a/gdb/testsuite/gdb.fortran/ptr-indentation.exp
> +++ b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
> @@ -22,8 +22,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if {![runto MAIN__]} then {
> -    untested "couldn't run to breakpoint MAIN__"
> +if {![fortran_runto_main]} then {
> +    untested "couldn't run to main"
>      return -1
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp 
> b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> index d91e4bd48e..8dc5f76d93 100644
> --- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> +++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> @@ -24,8 +24,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/subarray.exp 
> b/gdb/testsuite/gdb.fortran/subarray.exp
> index 5e3e8c38cb..9ee5a9b3cb 100644
> --- a/gdb/testsuite/gdb.fortran/subarray.exp
> +++ b/gdb/testsuite/gdb.fortran/subarray.exp
> @@ -21,6 +21,7 @@
>  if { [skip_fortran_tests] } { return -1 }
>
>  standard_testfile .f
> +load_lib fortran.exp
>
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
> @@ -31,8 +32,8 @@ gdb_start
>  gdb_reinitialize_dir $srcdir/$subdir
>  gdb_load ${binfile}
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp 
> b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
> index 5d8585c2ee..2ae0411cf1 100644
> --- a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cff788c9d006c4aad116208d7ec1ddc15%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637237485308605033&amp;sdata=q99fnfEAaF682EbULeOibMZJ5gzZHAflZeRzUPteiwY%3D&amp;reserved=0>.
>
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-datatypes.exp 
> b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
> index 2db9b3e110..b69636f600 100644
> --- a/gdb/testsuite/gdb.fortran/vla-datatypes.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
> @@ -24,7 +24,7 @@ if { [prepare_for_testing "failed to prepare" 
> ${testfile} ${srcfile} \  # check that all fortran standard datatypes 
> will be  # handled correctly when using as VLA's
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-history.exp 
> b/gdb/testsuite/gdb.fortran/vla-history.exp
> index 24bd945f4a..3bf98db197 100644
> --- a/gdb/testsuite/gdb.fortran/vla-history.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-history.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cff788c9d006c4aad116208d7ec1ddc15%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637237485308605033&amp;sdata=q99fnfEAaF682EbULeOibMZJ5gzZHAflZeRzUPteiwY%3D&amp;reserved=0>.
>
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp 
> b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> index 24c7b45840..d3fa595bea 100644
> --- a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cff788c9d006c4aad116208d7ec1ddc15%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637237485308605033&amp;sdata=q99fnfEAaF682EbULeOibMZJ5gzZHAflZeRzUPteiwY%3D&amp;reserved=0>.
>
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp 
> b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
> index 09909e74b0..07a4a5fc2e 100644
> --- a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-ptype.exp 
> b/gdb/testsuite/gdb.fortran/vla-ptype.exp
> index 22b2005317..bbb81ea0c8 100644
> --- a/gdb/testsuite/gdb.fortran/vla-ptype.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-ptype.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp 
> b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
> index 8e7d36314e..d26b8c60f8 100644
> --- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cff788c9d006c4aad116208d7ec1ddc15%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637237485308605033&amp;sdata=q99fnfEAaF682EbULeOibMZJ5gzZHAflZeRzUPteiwY%3D&amp;reserved=0>.
>
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-type.exp 
> b/gdb/testsuite/gdb.fortran/vla-type.exp
> index 6d885e7889..f007ea3a78 100755
> --- a/gdb/testsuite/gdb.fortran/vla-type.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-type.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp 
> b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
> index ab61dde06f..c3ed909a81 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cff788c9d006c4aad116208d7ec1ddc15%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637237485308605033&amp;sdata=q99fnfEAaF682EbULeOibMZJ5gzZHAflZeRzUPteiwY%3D&amp;reserved=0>.
>
>  standard_testfile "vla-sub.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp 
> b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
> index afd992cee4..403e411cc2 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cff788c9d006c4aad116208d7ec1ddc15%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637237485308605033&amp;sdata=q99fnfEAaF682EbULeOibMZJ5gzZHAflZeRzUPteiwY%3D&amp;reserved=0>.
>
>  standard_testfile "vla-sub.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub.exp 
> b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
> index 3311f6befa..fd923edf40 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value-sub.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cff788c9d006c4aad116208d7ec1ddc15%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637237485308605033&amp;sdata=q99fnfEAaF682EbULeOibMZJ5gzZHAflZeRzUPteiwY%3D&amp;reserved=0>.
>
>  standard_testfile "vla-sub.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp 
> b/gdb/testsuite/gdb.fortran/vla-value.exp
> index 5af17b570c..9a727fc30a 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> @@ -129,8 +129,8 @@ gdb_test "print vla1(9, 9, 9)" "no such vector 
> element \\\(vector not allocated\  # Try to assign VLA to user 
> variable  clean_restart ${testfile}
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>  gdb_breakpoint [gdb_get_line_number "vla2-allocated"] diff --git 
> a/gdb/testsuite/gdb.fortran/whatis_type.exp 
> b/gdb/testsuite/gdb.fortran/whatis_type.exp
> index 6a9cc0a81e..4b0cbf9c28 100644
> --- a/gdb/testsuite/gdb.fortran/whatis_type.exp
> +++ b/gdb/testsuite/gdb.fortran/whatis_type.exp
> @@ -23,8 +23,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
>      return -1
>  }
>
> -if ![runto MAIN__] {
> -    fail "run to MAIN__"
> +if ![fortran_runto_main] {
> +    fail "run to main"
>      return
>  }
>
> diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp 
> b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
> index 8cfffa7c08..3af80a8e60 100644
> --- a/gdb/testsuite/gdb.mi/mi-var-child-f.exp
> +++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
> @@ -36,7 +36,7 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" 
> "${binfile}" \  mi_gdb_reinitialize_dir $srcdir/$subdir  mi_gdb_load 
> ${binfile}
>
> -mi_runto MAIN__
> +mi_runto [fortran_main]
>
>  mi_create_varobj "array" "array" "create local variable array"
>
> diff --git a/gdb/testsuite/lib/fortran.exp 
> b/gdb/testsuite/lib/fortran.exp index 549ed65790..654afd2b74 100644
> --- a/gdb/testsuite/lib/fortran.exp
> +++ b/gdb/testsuite/lib/fortran.exp
> @@ -126,3 +126,21 @@ proc fortran_character1 {} {
>       return "unknown"
>      }
>  }
> +
> +proc fortran_main {} {

This proc should have a header comment.  Something like:

  # Return name of the main procedure based on the compiler version.

> +    if {[test_compiler_info {gcc-4-[012]-*}]
> +         || [test_compiler_info {gcc-*}]
> +         || [test_compiler_info {icc-*}]} {
> +     return "MAIN__"
> +    } elseif {[test_compiler_info {clang-*}]} {
> +     return "MAIN_"
> +    } else {
> +     return "unknown"
> +    }
> +}
> +
> +# fortran version of runto_main.

Please capitalise Fortran, which I believe is how the name is written.


With those two fixes, please just go ahead and merge.

Thanks,
Andrew



> +
> +proc fortran_runto_main { } {
> +    return [runto [fortran_main]]
> +}
> --
> 2.17.1


[-- Attachment #2: 0001-gdb-fortran-Allow-Flang-MAIN_-in-Fortran-testing.patch --]
[-- Type: application/octet-stream, Size: 29401 bytes --]

From 6b324dbba63a889487b274290702a3b64aba58d6 Mon Sep 17 00:00:00 2001
From: Alok Kumar Sharma <AlokKumar.Sharma@amd.com>
Date: Fri, 24 Apr 2020 14:46:09 +0530
Subject: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing

Name of fortran main function for Flang compiler is MAIN_ while
for gfortran it is MAIN__ . In test cases MAIN__ is hardcoded for
the purpose of inserting breakpoint.

New proc is added to detect main function name depending on the
compiler used.
Fortran specific version of runto_main named fortran_runto_main
is added.

This commit adds support for Flang main function, there should be
no change for gfortran.

gdb/testsuite/ChangeLog

	* lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
	(fortran_runto_main): New Proc, fortran version of runto_main.
	* gdb.fortran/array-bounds-high.exp: Handle flang MAIN_.
	* gdb.fortran/array-bounds.exp: Likewise.
	* gdb.fortran/array-slices.exp: Likewise.
	* gdb.fortran/block-data.exp: Likewise.
	* gdb.fortran/charset.exp: Likewise.
	* gdb.fortran/common-block.exp: Likewise.
	* gdb.fortran/complex.exp: Likewise.
	* gdb.fortran/derived-type-function.exp: Likewise.
	* gdb.fortran/derived-type.exp: Likewise.
	* gdb.fortran/info-modules.exp: Likewise.
	* gdb.fortran/info-types.exp: Likewise.
	* gdb.fortran/intrinsics.exp: Likewise.
	* gdb.fortran/library-module.exp: Likewise.
	* gdb.fortran/logical.exp: Likewise.
	* gdb.fortran/max-depth.exp: Likewise.
	* gdb.fortran/module.exp: Likewise.
	* gdb.fortran/multi-dim.exp: Likewise.
	* gdb.fortran/nested-funcs.exp: Likewise.
	* gdb.fortran/print-formatted.exp: Likewise.
	* gdb.fortran/print_type.exp: Likewise.
	* gdb.fortran/printing-types.exp: Likewise.
	* gdb.fortran/ptr-indentation.exp: Likewise.
	* gdb.fortran/ptype-on-functions.exp: Likewise.
	* gdb.fortran/subarray.exp: Likewise.
	* gdb.fortran/vla-alloc-assoc.exp: Likewise.
	* gdb.fortran/vla-datatypes.exp: Likewise.
	* gdb.fortran/vla-history.exp: Likewise.
	* gdb.fortran/vla-ptr-info.exp: Likewise.
	* gdb.fortran/vla-ptype-sub.exp: Likewise.
	* gdb.fortran/vla-ptype.exp: Likewise.
	* gdb.fortran/vla-sizeof.exp: Likewise.
	* gdb.fortran/vla-type.exp: Likewise.
	* gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
	* gdb.fortran/vla-value-sub-finish.exp: Likewise.
	* gdb.fortran/vla-value-sub.exp: Likewise.
	* gdb.fortran/vla-value.exp: Likewise.
	* gdb.fortran/whatis_type.exp: Likewise.
	* gdb.mi/mi-var-child-f.exp: Likewise.

Change-Id: I0a30f5dad684879b416f71d3d08c385c159325bf
---
 gdb/testsuite/ChangeLog                       | 43 +++++++++++++++++++
 .../gdb.fortran/array-bounds-high.exp         |  5 ++-
 gdb/testsuite/gdb.fortran/array-bounds.exp    |  5 ++-
 gdb/testsuite/gdb.fortran/array-slices.exp    |  3 +-
 gdb/testsuite/gdb.fortran/block-data.exp      |  4 +-
 gdb/testsuite/gdb.fortran/charset.exp         |  6 ++-
 gdb/testsuite/gdb.fortran/common-block.exp    |  4 +-
 gdb/testsuite/gdb.fortran/complex.exp         |  5 ++-
 .../gdb.fortran/derived-type-function.exp     |  5 ++-
 gdb/testsuite/gdb.fortran/derived-type.exp    |  4 +-
 gdb/testsuite/gdb.fortran/info-modules.exp    |  4 +-
 gdb/testsuite/gdb.fortran/info-types.exp      |  4 +-
 gdb/testsuite/gdb.fortran/intrinsics.exp      |  4 +-
 gdb/testsuite/gdb.fortran/library-module.exp  |  5 ++-
 gdb/testsuite/gdb.fortran/logical.exp         |  5 ++-
 gdb/testsuite/gdb.fortran/max-depth.exp       |  4 +-
 gdb/testsuite/gdb.fortran/module.exp          |  6 +--
 gdb/testsuite/gdb.fortran/multi-dim.exp       |  4 +-
 gdb/testsuite/gdb.fortran/nested-funcs.exp    |  4 +-
 gdb/testsuite/gdb.fortran/print-formatted.exp |  4 +-
 gdb/testsuite/gdb.fortran/print_type.exp      |  2 +-
 gdb/testsuite/gdb.fortran/printing-types.exp  |  5 ++-
 gdb/testsuite/gdb.fortran/ptr-indentation.exp |  4 +-
 .../gdb.fortran/ptype-on-functions.exp        |  4 +-
 gdb/testsuite/gdb.fortran/subarray.exp        |  5 ++-
 gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp |  3 +-
 gdb/testsuite/gdb.fortran/vla-datatypes.exp   |  2 +-
 gdb/testsuite/gdb.fortran/vla-history.exp     |  3 +-
 gdb/testsuite/gdb.fortran/vla-ptr-info.exp    |  3 +-
 gdb/testsuite/gdb.fortran/vla-ptype-sub.exp   |  2 +-
 gdb/testsuite/gdb.fortran/vla-ptype.exp       |  2 +-
 gdb/testsuite/gdb.fortran/vla-sizeof.exp      |  3 +-
 gdb/testsuite/gdb.fortran/vla-type.exp        |  2 +-
 .../gdb.fortran/vla-value-sub-arbitrary.exp   |  3 +-
 .../gdb.fortran/vla-value-sub-finish.exp      |  3 +-
 gdb/testsuite/gdb.fortran/vla-value-sub.exp   |  3 +-
 gdb/testsuite/gdb.fortran/vla-value.exp       |  6 +--
 gdb/testsuite/gdb.fortran/whatis_type.exp     |  4 +-
 gdb/testsuite/gdb.mi/mi-var-child-f.exp       |  2 +-
 gdb/testsuite/lib/fortran.exp                 | 20 +++++++++
 40 files changed, 145 insertions(+), 64 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index eccba674a4..c13b651e90 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,46 @@
+2020-05-10  Alok Kumar Sharma  <alokkumar.sharma@amd.com>
+
+	* lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
+	(fortran_runto_main): New Proc, fortran version of runto_main.
+	* gdb.fortran/array-bounds-high.exp: Handle flang MAIN_
+	* gdb.fortran/array-bounds.exp: Likewise.
+	* gdb.fortran/array-slices.exp: Likewise.
+	* gdb.fortran/block-data.exp: Likewise.
+	* gdb.fortran/charset.exp: Likewise.
+	* gdb.fortran/common-block.exp: Likewise.
+	* gdb.fortran/complex.exp: Likewise.
+	* gdb.fortran/derived-type-function.exp: Likewise.
+	* gdb.fortran/derived-type.exp: Likewise.
+	* gdb.fortran/info-modules.exp: Likewise.
+	* gdb.fortran/info-types.exp: Likewise.
+	* gdb.fortran/intrinsics.exp: Likewise.
+	* gdb.fortran/library-module.exp: Likewise.
+	* gdb.fortran/logical.exp: Likewise.
+	* gdb.fortran/max-depth.exp: Likewise.
+	* gdb.fortran/module.exp: Likewise.
+	* gdb.fortran/multi-dim.exp: Likewise.
+	* gdb.fortran/nested-funcs.exp: Likewise.
+	* gdb.fortran/print-formatted.exp: Likewise.
+	* gdb.fortran/print_type.exp: Likewise.
+	* gdb.fortran/printing-types.exp: Likewise.
+	* gdb.fortran/ptr-indentation.exp: Likewise.
+	* gdb.fortran/ptype-on-functions.exp: Likewise.
+	* gdb.fortran/subarray.exp: Likewise.
+	* gdb.fortran/vla-alloc-assoc.exp: Likewise.
+	* gdb.fortran/vla-datatypes.exp: Likewise.
+	* gdb.fortran/vla-history.exp: Likewise.
+	* gdb.fortran/vla-ptr-info.exp: Likewise.
+	* gdb.fortran/vla-ptype-sub.exp: Likewise.
+	* gdb.fortran/vla-ptype.exp: Likewise.
+	* gdb.fortran/vla-sizeof.exp: Likewise.
+	* gdb.fortran/vla-type.exp: Likewise.
+	* gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
+	* gdb.fortran/vla-value-sub-finish.exp: Likewise.
+	* gdb.fortran/vla-value-sub.exp: Likewise.
+	* gdb.fortran/vla-value.exp: Likewise.
+	* gdb.fortran/whatis_type.exp: Likewise.
+	* gdb.mi/mi-var-child-f.exp: Likewise.
+
 2020-05-09  Tom de Vries  <tdevries@suse.de>
 
 	* gdb.dwarf2/clang-debug-names.exp: Remove PR25952 kfail.
diff --git a/gdb/testsuite/gdb.fortran/array-bounds-high.exp b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
index 81e2f87b89..ba34dbc23e 100644
--- a/gdb/testsuite/gdb.fortran/array-bounds-high.exp
+++ b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
@@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
 
 set testfile "array-bounds-high"
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
     return -1
 }
 
-if {![runto MAIN__]} {
-    perror "Could not run to breakpoint `MAIN__'."
+if {![fortran_runto_main]} {
+    perror "Could not run to main."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/array-bounds.exp b/gdb/testsuite/gdb.fortran/array-bounds.exp
index 12bf5c2db3..3f2527343b 100644
--- a/gdb/testsuite/gdb.fortran/array-bounds.exp
+++ b/gdb/testsuite/gdb.fortran/array-bounds.exp
@@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
 
 set testfile "array-bounds"
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
     return -1
 }
 
-if {![runto MAIN__]} {
-    perror "Could not run to breakpoint `MAIN__'."
+if {![fortran_runto_main]} {
+    perror "Could not run to main."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp b/gdb/testsuite/gdb.fortran/array-slices.exp
index 11997f926a..4ca1db90f7 100644
--- a/gdb/testsuite/gdb.fortran/array-slices.exp
+++ b/gdb/testsuite/gdb.fortran/array-slices.exp
@@ -21,13 +21,14 @@
 if {[skip_fortran_tests]} { return -1 }
 
 standard_testfile ".f90"
+load_lib fortran.exp
 
 if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
 	 {debug f90}]} {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/block-data.exp b/gdb/testsuite/gdb.fortran/block-data.exp
index 292afe6c16..632c0141a3 100644
--- a/gdb/testsuite/gdb.fortran/block-data.exp
+++ b/gdb/testsuite/gdb.fortran/block-data.exp
@@ -30,8 +30,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    untested "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    untested "couldn't run to main"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/charset.exp b/gdb/testsuite/gdb.fortran/charset.exp
index f0f62f8490..fc504ae0b0 100644
--- a/gdb/testsuite/gdb.fortran/charset.exp
+++ b/gdb/testsuite/gdb.fortran/charset.exp
@@ -19,12 +19,14 @@
 if { [skip_fortran_tests] } { return -1 }
 
 standard_testfile .f90
+load_lib fortran.exp
+
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug additional_flags=-fbackslash f90}] } {
     return -1
 }
 
-if ![runto MAIN__] {
-    perror "Couldn't run to MAIN__"
+if ![fortran_runto_main] {
+    perror "Couldn't run to main"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/common-block.exp b/gdb/testsuite/gdb.fortran/common-block.exp
index 19c1af0d81..3dacfd32b2 100644
--- a/gdb/testsuite/gdb.fortran/common-block.exp
+++ b/gdb/testsuite/gdb.fortran/common-block.exp
@@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" ${testfile} \
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to main"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/complex.exp b/gdb/testsuite/gdb.fortran/complex.exp
index c092ab29f1..a88e553e58 100644
--- a/gdb/testsuite/gdb.fortran/complex.exp
+++ b/gdb/testsuite/gdb.fortran/complex.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "Couldn't run to MAIN__"
+if ![fortran_runto_main] then {
+    perror "Couldn't run to main"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/derived-type-function.exp b/gdb/testsuite/gdb.fortran/derived-type-function.exp
index 1f0f957317..2ae6f46c1e 100644
--- a/gdb/testsuite/gdb.fortran/derived-type-function.exp
+++ b/gdb/testsuite/gdb.fortran/derived-type-function.exp
@@ -21,13 +21,14 @@
 if { [skip_fortran_tests] } { return -1 }
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to main"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/derived-type.exp b/gdb/testsuite/gdb.fortran/derived-type.exp
index f1705bffd8..4b86ba97de 100644
--- a/gdb/testsuite/gdb.fortran/derived-type.exp
+++ b/gdb/testsuite/gdb.fortran/derived-type.exp
@@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to main"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/info-modules.exp b/gdb/testsuite/gdb.fortran/info-modules.exp
index 0c3c6a58e1..a3a9b2cb18 100644
--- a/gdb/testsuite/gdb.fortran/info-modules.exp
+++ b/gdb/testsuite/gdb.fortran/info-modules.exp
@@ -28,8 +28,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![fortran_runto_main] } {
+    perror "Could not run to main."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/info-types.exp b/gdb/testsuite/gdb.fortran/info-types.exp
index 2138937782..e80c990a85 100644
--- a/gdb/testsuite/gdb.fortran/info-types.exp
+++ b/gdb/testsuite/gdb.fortran/info-types.exp
@@ -27,8 +27,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![fortran_runto_main] } {
+    perror "Could not run to main."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/intrinsics.exp b/gdb/testsuite/gdb.fortran/intrinsics.exp
index 504bce4138..2cb0237c95 100644
--- a/gdb/testsuite/gdb.fortran/intrinsics.exp
+++ b/gdb/testsuite/gdb.fortran/intrinsics.exp
@@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![fortran_runto_main] } {
+    perror "Could not run to main."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/library-module.exp b/gdb/testsuite/gdb.fortran/library-module.exp
index f25988e32c..8254fcf10a 100644
--- a/gdb/testsuite/gdb.fortran/library-module.exp
+++ b/gdb/testsuite/gdb.fortran/library-module.exp
@@ -40,9 +40,10 @@ if  { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list debug f90
 clean_restart $testfile
 
 gdb_load_shlib $libfile
+load_lib fortran.exp
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to main"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/logical.exp b/gdb/testsuite/gdb.fortran/logical.exp
index 324714fa49..161bbdd908 100644
--- a/gdb/testsuite/gdb.fortran/logical.exp
+++ b/gdb/testsuite/gdb.fortran/logical.exp
@@ -16,13 +16,14 @@
 # This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![fortran_runto_main] } {
+    perror "Could not run to main."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/max-depth.exp b/gdb/testsuite/gdb.fortran/max-depth.exp
index 262d0fdfa1..420b72539f 100644
--- a/gdb/testsuite/gdb.fortran/max-depth.exp
+++ b/gdb/testsuite/gdb.fortran/max-depth.exp
@@ -26,8 +26,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![fortran_runto_main] } {
+    perror "Could not run to main."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/module.exp b/gdb/testsuite/gdb.fortran/module.exp
index 1c269e2fed..4a8251c44c 100644
--- a/gdb/testsuite/gdb.fortran/module.exp
+++ b/gdb/testsuite/gdb.fortran/module.exp
@@ -29,8 +29,8 @@ gdb_test "p modmany::var_i" " = 14" "stopped language detection"
 
 gdb_test "print mod1::var_const" " = 20" "fully qualified name of DW_TAG_constant"
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to main"
     continue
 }
 
@@ -123,7 +123,7 @@ complete "modmany::var" $modmany_list
 # Breakpoint would work in language "c".
 gdb_test "show language" {The current source language is "(auto; currently )?fortran".}
 
-# gcc-4.4.2: The main program is always MAIN__ in .symtab so "runto" above
+# gcc-4.4.2: The main program is always $fmain in .symtab so "runto" above
 # works.  But DWARF DW_TAG_subprogram contains the name specified by
 # the "program" Fortran statement.
 if [gdb_breakpoint "module"] {
diff --git a/gdb/testsuite/gdb.fortran/multi-dim.exp b/gdb/testsuite/gdb.fortran/multi-dim.exp
index 05590914df..ef6c6da8bd 100644
--- a/gdb/testsuite/gdb.fortran/multi-dim.exp
+++ b/gdb/testsuite/gdb.fortran/multi-dim.exp
@@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug f90}
     return -1
 }
 
-if ![runto MAIN__] {
-    perror "Couldn't run to MAIN__"
+if ![fortran_runto_main] {
+    perror "Couldn't run to main"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/nested-funcs.exp b/gdb/testsuite/gdb.fortran/nested-funcs.exp
index e4fc02ffa5..9e0073d210 100755
--- a/gdb/testsuite/gdb.fortran/nested-funcs.exp
+++ b/gdb/testsuite/gdb.fortran/nested-funcs.exp
@@ -25,8 +25,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to main"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/print-formatted.exp b/gdb/testsuite/gdb.fortran/print-formatted.exp
index 8c6529ce7f..e71287724b 100644
--- a/gdb/testsuite/gdb.fortran/print-formatted.exp
+++ b/gdb/testsuite/gdb.fortran/print-formatted.exp
@@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
     return -1
 }
 
-if { ![runto MAIN__] } {
-    fail "runto MAIN__"
+if { ![fortran_runto_main] } {
+    fail "could not run to main"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/print_type.exp b/gdb/testsuite/gdb.fortran/print_type.exp
index 7d5915390d..fcedb9579a 100755
--- a/gdb/testsuite/gdb.fortran/print_type.exp
+++ b/gdb/testsuite/gdb.fortran/print_type.exp
@@ -24,7 +24,7 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/printing-types.exp b/gdb/testsuite/gdb.fortran/printing-types.exp
index 2c88f9e003..44fd93cc56 100644
--- a/gdb/testsuite/gdb.fortran/printing-types.exp
+++ b/gdb/testsuite/gdb.fortran/printing-types.exp
@@ -16,13 +16,14 @@
 if {[skip_fortran_tests]} { return -1 }
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if {![runto MAIN__]} then {
-    untested "could not run to breakpoint MAIN__"
+if {![fortran_runto_main]} then {
+    untested "could not run to main"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/ptr-indentation.exp b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
index 285e24e2cc..209809a292 100644
--- a/gdb/testsuite/gdb.fortran/ptr-indentation.exp
+++ b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
@@ -22,8 +22,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if {![runto MAIN__]} then {
-    untested "couldn't run to breakpoint MAIN__"
+if {![fortran_runto_main]} then {
+    untested "couldn't run to main"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
index d91e4bd48e..8dc5f76d93 100644
--- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
+++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
@@ -24,8 +24,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to main"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/subarray.exp b/gdb/testsuite/gdb.fortran/subarray.exp
index 5e3e8c38cb..9ee5a9b3cb 100644
--- a/gdb/testsuite/gdb.fortran/subarray.exp
+++ b/gdb/testsuite/gdb.fortran/subarray.exp
@@ -21,6 +21,7 @@
 if { [skip_fortran_tests] } { return -1 }
 
 standard_testfile .f
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
@@ -31,8 +32,8 @@ gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_load ${binfile}
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to main"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
index 5d8585c2ee..2ae0411cf1 100644
--- a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
+++ b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-datatypes.exp b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
index 2db9b3e110..b69636f600 100644
--- a/gdb/testsuite/gdb.fortran/vla-datatypes.exp
+++ b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
@@ -24,7 +24,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
 # check that all fortran standard datatypes will be
 # handled correctly when using as VLA's
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-history.exp b/gdb/testsuite/gdb.fortran/vla-history.exp
index 24bd945f4a..3bf98db197 100644
--- a/gdb/testsuite/gdb.fortran/vla-history.exp
+++ b/gdb/testsuite/gdb.fortran/vla-history.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
index 24c7b45840..d3fa595bea 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
index 09909e74b0..07a4a5fc2e 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-ptype.exp b/gdb/testsuite/gdb.fortran/vla-ptype.exp
index 22b2005317..bbb81ea0c8 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptype.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptype.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
index 8e7d36314e..d26b8c60f8 100644
--- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp
+++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-type.exp b/gdb/testsuite/gdb.fortran/vla-type.exp
index 6d885e7889..f007ea3a78 100755
--- a/gdb/testsuite/gdb.fortran/vla-type.exp
+++ b/gdb/testsuite/gdb.fortran/vla-type.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
index ab61dde06f..c3ed909a81 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla-sub.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
index afd992cee4..403e411cc2 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla-sub.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub.exp b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
index 3311f6befa..fd923edf40 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla-sub.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp
index 5af17b570c..9a727fc30a 100644
--- a/gdb/testsuite/gdb.fortran/vla-value.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![fortran_runto_main] {
     untested "could not run to main"
     return -1
 }
@@ -129,8 +129,8 @@ gdb_test "print vla1(9, 9, 9)" "no such vector element \\\(vector not allocated\
 # Try to assign VLA to user variable
 clean_restart ${testfile}
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![fortran_runto_main] then {
+    perror "couldn't run to main"
     continue
 }
 gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
diff --git a/gdb/testsuite/gdb.fortran/whatis_type.exp b/gdb/testsuite/gdb.fortran/whatis_type.exp
index 6a9cc0a81e..4b0cbf9c28 100644
--- a/gdb/testsuite/gdb.fortran/whatis_type.exp
+++ b/gdb/testsuite/gdb.fortran/whatis_type.exp
@@ -23,8 +23,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
     return -1
 }
 
-if ![runto MAIN__] {
-    fail "run to MAIN__"
+if ![fortran_runto_main] {
+    fail "run to main"
     return
 }
 
diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
index 8cfffa7c08..3af80a8e60 100644
--- a/gdb/testsuite/gdb.mi/mi-var-child-f.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
@@ -36,7 +36,7 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
 mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load ${binfile}
 
-mi_runto MAIN__
+mi_runto [fortran_main]
 
 mi_create_varobj "array" "array" "create local variable array"
 
diff --git a/gdb/testsuite/lib/fortran.exp b/gdb/testsuite/lib/fortran.exp
index 549ed65790..b9def7fa21 100644
--- a/gdb/testsuite/lib/fortran.exp
+++ b/gdb/testsuite/lib/fortran.exp
@@ -126,3 +126,23 @@ proc fortran_character1 {} {
 	return "unknown"
     }
 }
+
+# Return name of the main procedure based on the compiler version.
+
+proc fortran_main {} {
+    if {[test_compiler_info {gcc-4-[012]-*}]
+         || [test_compiler_info {gcc-*}]
+         || [test_compiler_info {icc-*}]} {
+	return "MAIN__"
+    } elseif {[test_compiler_info {clang-*}]} {
+	return "MAIN_"
+    } else {
+	return "unknown"
+    }
+}
+
+# Fortran version of runto_main.
+
+proc fortran_runto_main { } {
+    return [runto [fortran_main]]
+}
-- 
2.17.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing
  2020-05-10  9:21               ` Sharma, Alok Kumar
@ 2020-05-10 19:24                 ` Sharma, Alok Kumar
  0 siblings, 0 replies; 14+ messages in thread
From: Sharma, Alok Kumar @ 2020-05-10 19:24 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: Tom Tromey, George, Jini Susan, Achra, Nitika, gdb-patches

Just to inform, I just got back the access and pushed the changes.

Thanks.

Regards,
Alok

-----Original Message-----
From: Sharma, Alok Kumar 
Sent: Sunday, May 10, 2020 2:52 PM
To: Andrew Burgess <andrew.burgess@embecosm.com>
Cc: Tom Tromey <tom@tromey.com>; George, Jini Susan <JiniSusan.George@amd.com>; Achra, Nitika <Nitika.Achra@amd.com>; gdb-patches@sourceware.org
Subject: RE: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing

Thanks a lot Andrew for your comments. Please find the updated patch with your comments incorporated.
As I lost my ssh setup and yet to get new one updated on server, I am unable to commit currently.
I would like to request if someone please commit this?

    gdb/testsuite/ChangeLog

            * lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
            (fortran_runto_main): New Proc, fortran version of runto_main.
            * gdb.fortran/array-bounds-high.exp: Handle flang MAIN_.
            * gdb.fortran/array-bounds.exp: Likewise.
            * gdb.fortran/array-slices.exp: Likewise.
            * gdb.fortran/block-data.exp: Likewise.
            * gdb.fortran/charset.exp: Likewise.
            * gdb.fortran/common-block.exp: Likewise.
            * gdb.fortran/complex.exp: Likewise.
            * gdb.fortran/derived-type-function.exp: Likewise.
            * gdb.fortran/derived-type.exp: Likewise.
            * gdb.fortran/info-modules.exp: Likewise.
            * gdb.fortran/info-types.exp: Likewise.
            * gdb.fortran/intrinsics.exp: Likewise.
            * gdb.fortran/library-module.exp: Likewise.
            * gdb.fortran/logical.exp: Likewise.
            * gdb.fortran/max-depth.exp: Likewise.
            * gdb.fortran/module.exp: Likewise.
            * gdb.fortran/multi-dim.exp: Likewise.
            * gdb.fortran/nested-funcs.exp: Likewise.
            * gdb.fortran/print-formatted.exp: Likewise.
            * gdb.fortran/print_type.exp: Likewise.
            * gdb.fortran/printing-types.exp: Likewise.
            * gdb.fortran/ptr-indentation.exp: Likewise.
            * gdb.fortran/ptype-on-functions.exp: Likewise.
            * gdb.fortran/subarray.exp: Likewise.
            * gdb.fortran/vla-alloc-assoc.exp: Likewise.
            * gdb.fortran/vla-datatypes.exp: Likewise.
            * gdb.fortran/vla-history.exp: Likewise.
            * gdb.fortran/vla-ptr-info.exp: Likewise.
            * gdb.fortran/vla-ptype-sub.exp: Likewise.
            * gdb.fortran/vla-ptype.exp: Likewise.
            * gdb.fortran/vla-sizeof.exp: Likewise.
            * gdb.fortran/vla-type.exp: Likewise.
            * gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
            * gdb.fortran/vla-value-sub-finish.exp: Likewise.
            * gdb.fortran/vla-value-sub.exp: Likewise.
            * gdb.fortran/vla-value.exp: Likewise.
            * gdb.fortran/whatis_type.exp: Likewise.
            * gdb.mi/mi-var-child-f.exp: Likewise.

Regards,
Alok

-----Original Message-----
From: Andrew Burgess <andrew.burgess@embecosm.com>
Sent: Wednesday, April 29, 2020 2:45 PM
To: Sharma, Alok Kumar <AlokKumar.Sharma@amd.com>
Cc: Tom Tromey <tom@tromey.com>; George, Jini Susan <JiniSusan.George@amd.com>; Achra, Nitika <Nitika.Achra@amd.com>; gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing

[CAUTION: External Email]

* Sharma, Alok Kumar <AlokKumar.Sharma@amd.com> [2020-04-27 18:02:03 +0000]:

> Hi Andrew,
>
> Thanks a lot for your valuable comments. Please have a look at the 
> updated patch in attachment.
>
>
>
> From 75e55e41ddc83ee3db6879fd955baf31d1301ba4 Mon Sep 17 00:00:00 2001
> From: Alok Kumar Sharma <AlokKumar.Sharma@amd.com>
> Date: Fri, 24 Apr 2020 14:46:09 +0530
> Subject: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing
>
> Name of fortran main function for Flang compiler is MAIN_ while for 
> gfortran it is MAIN__ . In test cases MAIN__ is hardcoded for the 
> purpose of inserting breakpoint.
>
> New proc is added to detect main function name depending on the 
> compiler used.
> Fortran specific version of runto_main named fortran_runto_main is 
> added.
>
> This commit adds support for Flang main function, there should be no 
> change for gfortran.

This looks great.  Please go ahead an commit it.  I did have one minor last fix, but don't feel you know you need to repost the patch, just update and merge.

>
> gdb/testsuite/ChangeLog
>
>       * lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
>       (fortran_runto_main): New Proc, fortran version of runto_main.
>       * gdb.fortran/array-bounds-high.exp: Handle flang MAIN_.
>       * gdb.fortran/array-bounds.exp: Likewise.
>       * gdb.fortran/array-slices.exp: Likewise.
>       * gdb.fortran/block-data.exp: Likewise.
>       * gdb.fortran/charset.exp: Likewise.
>       * gdb.fortran/common-block.exp: Likewise.
>       * gdb.fortran/complex.exp: Likewise.
>       * gdb.fortran/derived-type-function.exp: Likewise.
>       * gdb.fortran/derived-type.exp: Likewise.
>       * gdb.fortran/info-modules.exp: Likewise.
>       * gdb.fortran/info-types.exp: Likewise.
>       * gdb.fortran/intrinsics.exp: Likewise.
>       * gdb.fortran/library-module.exp: Likewise.
>       * gdb.fortran/logical.exp: Likewise.
>       * gdb.fortran/max-depth.exp: Likewise.
>       * gdb.fortran/module.exp: Likewise.
>       * gdb.fortran/multi-dim.exp: Likewise.
>       * gdb.fortran/nested-funcs.exp: Likewise.
>       * gdb.fortran/print-formatted.exp: Likewise.
>       * gdb.fortran/print_type.exp: Likewise.
>       * gdb.fortran/printing-types.exp: Likewise.
>       * gdb.fortran/ptr-indentation.exp: Likewise.
>       * gdb.fortran/ptype-on-functions.exp: Likewise.
>       * gdb.fortran/subarray.exp: Likewise.
>       * gdb.fortran/vla-alloc-assoc.exp: Likewise.
>       * gdb.fortran/vla-datatypes.exp: Likewise.
>       * gdb.fortran/vla-history.exp: Likewise.
>       * gdb.fortran/vla-ptr-info.exp: Likewise.
>       * gdb.fortran/vla-ptype-sub.exp: Likewise.
>       * gdb.fortran/vla-ptype.exp: Likewise.
>       * gdb.fortran/vla-sizeof.exp: Likewise.
>       * gdb.fortran/vla-type.exp: Likewise.
>       * gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
>       * gdb.fortran/vla-value-sub-finish.exp: Likewise.
>       * gdb.fortran/vla-value-sub.exp: Likewise.
>       * gdb.fortran/vla-value.exp: Likewise.
>       * gdb.fortran/whatis_type.exp: Likewise.
>       * gdb.mi/mi-var-child-f.exp: Likewise.
>
> Change-Id: I0a30f5dad684879b416f71d3d08c385c159325bf
> ---
>  gdb/testsuite/ChangeLog                       | 43 +++++++++++++++++++
>  .../gdb.fortran/array-bounds-high.exp         |  5 ++-
>  gdb/testsuite/gdb.fortran/array-bounds.exp    |  5 ++-
>  gdb/testsuite/gdb.fortran/array-slices.exp    |  3 +-
>  gdb/testsuite/gdb.fortran/block-data.exp      |  4 +-
>  gdb/testsuite/gdb.fortran/charset.exp         |  6 ++-
>  gdb/testsuite/gdb.fortran/common-block.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/complex.exp         |  5 ++-
>  .../gdb.fortran/derived-type-function.exp     |  5 ++-
>  gdb/testsuite/gdb.fortran/derived-type.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/info-modules.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/info-types.exp      |  4 +-
>  gdb/testsuite/gdb.fortran/intrinsics.exp      |  4 +-
>  gdb/testsuite/gdb.fortran/library-module.exp  |  5 ++-
>  gdb/testsuite/gdb.fortran/logical.exp         |  5 ++-
>  gdb/testsuite/gdb.fortran/max-depth.exp       |  4 +-
>  gdb/testsuite/gdb.fortran/module.exp          |  6 +--
>  gdb/testsuite/gdb.fortran/multi-dim.exp       |  4 +-
>  gdb/testsuite/gdb.fortran/nested-funcs.exp    |  4 +-
>  gdb/testsuite/gdb.fortran/print-formatted.exp |  4 +-
>  gdb/testsuite/gdb.fortran/print_type.exp      |  2 +-
>  gdb/testsuite/gdb.fortran/printing-types.exp  |  5 ++- 
> gdb/testsuite/gdb.fortran/ptr-indentation.exp |  4 +-
>  .../gdb.fortran/ptype-on-functions.exp        |  4 +-
>  gdb/testsuite/gdb.fortran/subarray.exp        |  5 ++-
>  gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp |  3 +-
>  gdb/testsuite/gdb.fortran/vla-datatypes.exp   |  2 +-
>  gdb/testsuite/gdb.fortran/vla-history.exp     |  3 +-
>  gdb/testsuite/gdb.fortran/vla-ptr-info.exp    |  3 +-
>  gdb/testsuite/gdb.fortran/vla-ptype-sub.exp   |  2 +-
>  gdb/testsuite/gdb.fortran/vla-ptype.exp       |  2 +-
>  gdb/testsuite/gdb.fortran/vla-sizeof.exp      |  3 +-
>  gdb/testsuite/gdb.fortran/vla-type.exp        |  2 +-
>  .../gdb.fortran/vla-value-sub-arbitrary.exp   |  3 +-
>  .../gdb.fortran/vla-value-sub-finish.exp      |  3 +-
>  gdb/testsuite/gdb.fortran/vla-value-sub.exp   |  3 +-
>  gdb/testsuite/gdb.fortran/vla-value.exp       |  6 +--
>  gdb/testsuite/gdb.fortran/whatis_type.exp     |  4 +-
>  gdb/testsuite/gdb.mi/mi-var-child-f.exp       |  2 +-
>  gdb/testsuite/lib/fortran.exp                 | 18 ++++++++
>  40 files changed, 143 insertions(+), 64 deletions(-)
>
> diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index
> 10683db566..0e3c207f85 100644
> --- a/gdb/testsuite/ChangeLog
> +++ b/gdb/testsuite/ChangeLog
> @@ -1,3 +1,46 @@
> +2020-04-24  Alok Kumar Sharma  <alokkumar.sharma@amd.com>
> +
> +     * lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_,
> +     (fortran_runto_main): New Proc, fortran version of runto_main.
> +     * gdb.fortran/array-bounds-high.exp: Handle flang MAIN_
> +     * gdb.fortran/array-bounds.exp: Likewise.
> +     * gdb.fortran/array-slices.exp: Likewise.
> +     * gdb.fortran/block-data.exp: Likewise.
> +     * gdb.fortran/charset.exp: Likewise.
> +     * gdb.fortran/common-block.exp: Likewise.
> +     * gdb.fortran/complex.exp: Likewise.
> +     * gdb.fortran/derived-type-function.exp: Likewise.
> +     * gdb.fortran/derived-type.exp: Likewise.
> +     * gdb.fortran/info-modules.exp: Likewise.
> +     * gdb.fortran/info-types.exp: Likewise.
> +     * gdb.fortran/intrinsics.exp: Likewise.
> +     * gdb.fortran/library-module.exp: Likewise.
> +     * gdb.fortran/logical.exp: Likewise.
> +     * gdb.fortran/max-depth.exp: Likewise.
> +     * gdb.fortran/module.exp: Likewise.
> +     * gdb.fortran/multi-dim.exp: Likewise.
> +     * gdb.fortran/nested-funcs.exp: Likewise.
> +     * gdb.fortran/print-formatted.exp: Likewise.
> +     * gdb.fortran/print_type.exp: Likewise.
> +     * gdb.fortran/printing-types.exp: Likewise.
> +     * gdb.fortran/ptr-indentation.exp: Likewise.
> +     * gdb.fortran/ptype-on-functions.exp: Likewise.
> +     * gdb.fortran/subarray.exp: Likewise.
> +     * gdb.fortran/vla-alloc-assoc.exp: Likewise.
> +     * gdb.fortran/vla-datatypes.exp: Likewise.
> +     * gdb.fortran/vla-history.exp: Likewise.
> +     * gdb.fortran/vla-ptr-info.exp: Likewise.
> +     * gdb.fortran/vla-ptype-sub.exp: Likewise.
> +     * gdb.fortran/vla-ptype.exp: Likewise.
> +     * gdb.fortran/vla-sizeof.exp: Likewise.
> +     * gdb.fortran/vla-type.exp: Likewise.
> +     * gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
> +     * gdb.fortran/vla-value-sub-finish.exp: Likewise.
> +     * gdb.fortran/vla-value-sub.exp: Likewise.
> +     * gdb.fortran/vla-value.exp: Likewise.
> +     * gdb.fortran/whatis_type.exp: Likewise.
> +     * gdb.mi/mi-var-child-f.exp: Likewise.
> +
>  2020-04-23  Tom de Vries  <tdevries@suse.de>
>
>       * gdb.base/decl-before-def.exp: Run to main and print a again.
> diff --git a/gdb/testsuite/gdb.fortran/array-bounds-high.exp
> b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
> index 81e2f87b89..ba34dbc23e 100644
> --- a/gdb/testsuite/gdb.fortran/array-bounds-high.exp
> +++ b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
> @@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
>
>  set testfile "array-bounds-high"
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
>      return -1
>  }
>
> -if {![runto MAIN__]} {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if {![fortran_runto_main]} {
> +    perror "Could not run to main."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/array-bounds.exp
> b/gdb/testsuite/gdb.fortran/array-bounds.exp
> index 12bf5c2db3..3f2527343b 100644
> --- a/gdb/testsuite/gdb.fortran/array-bounds.exp
> +++ b/gdb/testsuite/gdb.fortran/array-bounds.exp
> @@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
>
>  set testfile "array-bounds"
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
>      return -1
>  }
>
> -if {![runto MAIN__]} {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if {![fortran_runto_main]} {
> +    perror "Could not run to main."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp
> b/gdb/testsuite/gdb.fortran/array-slices.exp
> index 11997f926a..4ca1db90f7 100644
> --- a/gdb/testsuite/gdb.fortran/array-slices.exp
> +++ b/gdb/testsuite/gdb.fortran/array-slices.exp
> @@ -21,13 +21,14 @@
>  if {[skip_fortran_tests]} { return -1 }
>
>  standard_testfile ".f90"
> +load_lib fortran.exp
>
>  if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
>        {debug f90}]} {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/block-data.exp
> b/gdb/testsuite/gdb.fortran/block-data.exp
> index 292afe6c16..632c0141a3 100644
> --- a/gdb/testsuite/gdb.fortran/block-data.exp
> +++ b/gdb/testsuite/gdb.fortran/block-data.exp
> @@ -30,8 +30,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    untested "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    untested "couldn't run to main"
>      return -1
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/charset.exp
> b/gdb/testsuite/gdb.fortran/charset.exp
> index f0f62f8490..fc504ae0b0 100644
> --- a/gdb/testsuite/gdb.fortran/charset.exp
> +++ b/gdb/testsuite/gdb.fortran/charset.exp
> @@ -19,12 +19,14 @@
>  if { [skip_fortran_tests] } { return -1 }
>
>  standard_testfile .f90
> +load_lib fortran.exp
> +
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug additional_flags=-fbackslash f90}] } {
>      return -1
>  }
>
> -if ![runto MAIN__] {
> -    perror "Couldn't run to MAIN__"
> +if ![fortran_runto_main] {
> +    perror "Couldn't run to main"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/common-block.exp
> b/gdb/testsuite/gdb.fortran/common-block.exp
> index 19c1af0d81..3dacfd32b2 100644
> --- a/gdb/testsuite/gdb.fortran/common-block.exp
> +++ b/gdb/testsuite/gdb.fortran/common-block.exp
> @@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" ${testfile} \
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/complex.exp
> b/gdb/testsuite/gdb.fortran/complex.exp
> index c092ab29f1..a88e553e58 100644
> --- a/gdb/testsuite/gdb.fortran/complex.exp
> +++ b/gdb/testsuite/gdb.fortran/complex.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cff788c9d006c4aad116208d7ec1ddc15%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637237485308605033&amp;sdata=q99fnfEAaF682EbULeOibMZJ5gzZHAflZeRzUPteiwY%3D&amp;reserved=0>.
>
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "Couldn't run to MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "Couldn't run to main"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/derived-type-function.exp
> b/gdb/testsuite/gdb.fortran/derived-type-function.exp
> index 1f0f957317..2ae6f46c1e 100644
> --- a/gdb/testsuite/gdb.fortran/derived-type-function.exp
> +++ b/gdb/testsuite/gdb.fortran/derived-type-function.exp
> @@ -21,13 +21,14 @@
>  if { [skip_fortran_tests] } { return -1 }
>
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/derived-type.exp
> b/gdb/testsuite/gdb.fortran/derived-type.exp
> index f1705bffd8..4b86ba97de 100644
> --- a/gdb/testsuite/gdb.fortran/derived-type.exp
> +++ b/gdb/testsuite/gdb.fortran/derived-type.exp
> @@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/info-modules.exp
> b/gdb/testsuite/gdb.fortran/info-modules.exp
> index 0c3c6a58e1..a3a9b2cb18 100644
> --- a/gdb/testsuite/gdb.fortran/info-modules.exp
> +++ b/gdb/testsuite/gdb.fortran/info-modules.exp
> @@ -28,8 +28,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to main."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/info-types.exp
> b/gdb/testsuite/gdb.fortran/info-types.exp
> index 2138937782..e80c990a85 100644
> --- a/gdb/testsuite/gdb.fortran/info-types.exp
> +++ b/gdb/testsuite/gdb.fortran/info-types.exp
> @@ -27,8 +27,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to main."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/intrinsics.exp
> b/gdb/testsuite/gdb.fortran/intrinsics.exp
> index 504bce4138..2cb0237c95 100644
> --- a/gdb/testsuite/gdb.fortran/intrinsics.exp
> +++ b/gdb/testsuite/gdb.fortran/intrinsics.exp
> @@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to main."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/library-module.exp
> b/gdb/testsuite/gdb.fortran/library-module.exp
> index f25988e32c..8254fcf10a 100644
> --- a/gdb/testsuite/gdb.fortran/library-module.exp
> +++ b/gdb/testsuite/gdb.fortran/library-module.exp
> @@ -40,9 +40,10 @@ if  { [gdb_compile $srcdir/$subdir/$srcfile 
> $binfile executable [list debug f90  clean_restart $testfile
>
>  gdb_load_shlib $libfile
> +load_lib fortran.exp
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/logical.exp
> b/gdb/testsuite/gdb.fortran/logical.exp
> index 324714fa49..161bbdd908 100644
> --- a/gdb/testsuite/gdb.fortran/logical.exp
> +++ b/gdb/testsuite/gdb.fortran/logical.exp
> @@ -16,13 +16,14 @@
>  # This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
>
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to main."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/max-depth.exp
> b/gdb/testsuite/gdb.fortran/max-depth.exp
> index 262d0fdfa1..420b72539f 100644
> --- a/gdb/testsuite/gdb.fortran/max-depth.exp
> +++ b/gdb/testsuite/gdb.fortran/max-depth.exp
> @@ -26,8 +26,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    perror "Could not run to breakpoint `MAIN__'."
> +if { ![fortran_runto_main] } {
> +    perror "Could not run to main."
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/module.exp
> b/gdb/testsuite/gdb.fortran/module.exp
> index 1c269e2fed..4a8251c44c 100644
> --- a/gdb/testsuite/gdb.fortran/module.exp
> +++ b/gdb/testsuite/gdb.fortran/module.exp
> @@ -29,8 +29,8 @@ gdb_test "p modmany::var_i" " = 14" "stopped language detection"
>
>  gdb_test "print mod1::var_const" " = 20" "fully qualified name of DW_TAG_constant"
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>
> @@ -123,7 +123,7 @@ complete "modmany::var" $modmany_list  # 
> Breakpoint would work in language "c".
>  gdb_test "show language" {The current source language is "(auto; 
> currently )?fortran".}
>
> -# gcc-4.4.2: The main program is always MAIN__ in .symtab so "runto" 
> above
> +# gcc-4.4.2: The main program is always $fmain in .symtab so "runto" 
> +above
>  # works.  But DWARF DW_TAG_subprogram contains the name specified by 
> # the "program" Fortran statement.
>  if [gdb_breakpoint "module"] {
> diff --git a/gdb/testsuite/gdb.fortran/multi-dim.exp
> b/gdb/testsuite/gdb.fortran/multi-dim.exp
> index 05590914df..ef6c6da8bd 100644
> --- a/gdb/testsuite/gdb.fortran/multi-dim.exp
> +++ b/gdb/testsuite/gdb.fortran/multi-dim.exp
> @@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug f90}
>      return -1
>  }
>
> -if ![runto MAIN__] {
> -    perror "Couldn't run to MAIN__"
> +if ![fortran_runto_main] {
> +    perror "Couldn't run to main"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/nested-funcs.exp
> b/gdb/testsuite/gdb.fortran/nested-funcs.exp
> index e4fc02ffa5..9e0073d210 100755
> --- a/gdb/testsuite/gdb.fortran/nested-funcs.exp
> +++ b/gdb/testsuite/gdb.fortran/nested-funcs.exp
> @@ -25,8 +25,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/print-formatted.exp
> b/gdb/testsuite/gdb.fortran/print-formatted.exp
> index 8c6529ce7f..e71287724b 100644
> --- a/gdb/testsuite/gdb.fortran/print-formatted.exp
> +++ b/gdb/testsuite/gdb.fortran/print-formatted.exp
> @@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
>      return -1
>  }
>
> -if { ![runto MAIN__] } {
> -    fail "runto MAIN__"
> +if { ![fortran_runto_main] } {
> +    fail "could not run to main"
>      return -1
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/print_type.exp
> b/gdb/testsuite/gdb.fortran/print_type.exp
> index 7d5915390d..fcedb9579a 100755
> --- a/gdb/testsuite/gdb.fortran/print_type.exp
> +++ b/gdb/testsuite/gdb.fortran/print_type.exp
> @@ -24,7 +24,7 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/printing-types.exp
> b/gdb/testsuite/gdb.fortran/printing-types.exp
> index 2c88f9e003..44fd93cc56 100644
> --- a/gdb/testsuite/gdb.fortran/printing-types.exp
> +++ b/gdb/testsuite/gdb.fortran/printing-types.exp
> @@ -16,13 +16,14 @@
>  if {[skip_fortran_tests]} { return -1 }
>
>  standard_testfile .f90
> +load_lib fortran.exp
>
>  if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if {![runto MAIN__]} then {
> -    untested "could not run to breakpoint MAIN__"
> +if {![fortran_runto_main]} then {
> +    untested "could not run to main"
>      return -1
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/ptr-indentation.exp
> b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
> index 285e24e2cc..209809a292 100644
> --- a/gdb/testsuite/gdb.fortran/ptr-indentation.exp
> +++ b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
> @@ -22,8 +22,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if {![runto MAIN__]} then {
> -    untested "couldn't run to breakpoint MAIN__"
> +if {![fortran_runto_main]} then {
> +    untested "couldn't run to main"
>      return -1
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> index d91e4bd48e..8dc5f76d93 100644
> --- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> +++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
> @@ -24,8 +24,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
>  }
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/subarray.exp
> b/gdb/testsuite/gdb.fortran/subarray.exp
> index 5e3e8c38cb..9ee5a9b3cb 100644
> --- a/gdb/testsuite/gdb.fortran/subarray.exp
> +++ b/gdb/testsuite/gdb.fortran/subarray.exp
> @@ -21,6 +21,7 @@
>  if { [skip_fortran_tests] } { return -1 }
>
>  standard_testfile .f
> +load_lib fortran.exp
>
>  if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
>      return -1
> @@ -31,8 +32,8 @@ gdb_start
>  gdb_reinitialize_dir $srcdir/$subdir
>  gdb_load ${binfile}
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>
> diff --git a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
> b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
> index 5d8585c2ee..2ae0411cf1 100644
> --- a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cff788c9d006c4aad116208d7ec1ddc15%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637237485308605033&amp;sdata=q99fnfEAaF682EbULeOibMZJ5gzZHAflZeRzUPteiwY%3D&amp;reserved=0>.
>
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-datatypes.exp
> b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
> index 2db9b3e110..b69636f600 100644
> --- a/gdb/testsuite/gdb.fortran/vla-datatypes.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
> @@ -24,7 +24,7 @@ if { [prepare_for_testing "failed to prepare" 
> ${testfile} ${srcfile} \  # check that all fortran standard datatypes 
> will be  # handled correctly when using as VLA's
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-history.exp
> b/gdb/testsuite/gdb.fortran/vla-history.exp
> index 24bd945f4a..3bf98db197 100644
> --- a/gdb/testsuite/gdb.fortran/vla-history.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-history.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cff788c9d006c4aad116208d7ec1ddc15%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637237485308605033&amp;sdata=q99fnfEAaF682EbULeOibMZJ5gzZHAflZeRzUPteiwY%3D&amp;reserved=0>.
>
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> index 24c7b45840..d3fa595bea 100644
> --- a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cff788c9d006c4aad116208d7ec1ddc15%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637237485308605033&amp;sdata=q99fnfEAaF682EbULeOibMZJ5gzZHAflZeRzUPteiwY%3D&amp;reserved=0>.
>
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
> b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
> index 09909e74b0..07a4a5fc2e 100644
> --- a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-ptype.exp
> b/gdb/testsuite/gdb.fortran/vla-ptype.exp
> index 22b2005317..bbb81ea0c8 100644
> --- a/gdb/testsuite/gdb.fortran/vla-ptype.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-ptype.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp
> b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
> index 8e7d36314e..d26b8c60f8 100644
> --- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cff788c9d006c4aad116208d7ec1ddc15%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637237485308605033&amp;sdata=q99fnfEAaF682EbULeOibMZJ5gzZHAflZeRzUPteiwY%3D&amp;reserved=0>.
>
>  standard_testfile "vla.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-type.exp
> b/gdb/testsuite/gdb.fortran/vla-type.exp
> index 6d885e7889..f007ea3a78 100755
> --- a/gdb/testsuite/gdb.fortran/vla-type.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-type.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
> b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
> index ab61dde06f..c3ed909a81 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cff788c9d006c4aad116208d7ec1ddc15%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637237485308605033&amp;sdata=q99fnfEAaF682EbULeOibMZJ5gzZHAflZeRzUPteiwY%3D&amp;reserved=0>.
>
>  standard_testfile "vla-sub.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
> b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
> index afd992cee4..403e411cc2 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cff788c9d006c4aad116208d7ec1ddc15%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637237485308605033&amp;sdata=q99fnfEAaF682EbULeOibMZJ5gzZHAflZeRzUPteiwY%3D&amp;reserved=0>.
>
>  standard_testfile "vla-sub.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub.exp
> b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
> index 3311f6befa..fd923edf40 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value-sub.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
> @@ -14,13 +14,14 @@
>  # along with this program.  If not, see <https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.gnu.org%2Flicenses%2F&amp;data=02%7C01%7CAlokKumar.Sharma%40amd.com%7Cff788c9d006c4aad116208d7ec1ddc15%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637237485308605033&amp;sdata=q99fnfEAaF682EbULeOibMZJ5gzZHAflZeRzUPteiwY%3D&amp;reserved=0>.
>
>  standard_testfile "vla-sub.f90"
> +load_lib fortran.exp
>
>  if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      {debug f90 quiet}] } {
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp
> b/gdb/testsuite/gdb.fortran/vla-value.exp
> index 5af17b570c..9a727fc30a 100644
> --- a/gdb/testsuite/gdb.fortran/vla-value.exp
> +++ b/gdb/testsuite/gdb.fortran/vla-value.exp
> @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
>      return -1
>  }
>
> -if ![runto_main] {
> +if ![fortran_runto_main] {
>      untested "could not run to main"
>      return -1
>  }
> @@ -129,8 +129,8 @@ gdb_test "print vla1(9, 9, 9)" "no such vector 
> element \\\(vector not allocated\  # Try to assign VLA to user 
> variable  clean_restart ${testfile}
>
> -if ![runto MAIN__] then {
> -    perror "couldn't run to breakpoint MAIN__"
> +if ![fortran_runto_main] then {
> +    perror "couldn't run to main"
>      continue
>  }
>  gdb_breakpoint [gdb_get_line_number "vla2-allocated"] diff --git 
> a/gdb/testsuite/gdb.fortran/whatis_type.exp
> b/gdb/testsuite/gdb.fortran/whatis_type.exp
> index 6a9cc0a81e..4b0cbf9c28 100644
> --- a/gdb/testsuite/gdb.fortran/whatis_type.exp
> +++ b/gdb/testsuite/gdb.fortran/whatis_type.exp
> @@ -23,8 +23,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
>      return -1
>  }
>
> -if ![runto MAIN__] {
> -    fail "run to MAIN__"
> +if ![fortran_runto_main] {
> +    fail "run to main"
>      return
>  }
>
> diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp
> b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
> index 8cfffa7c08..3af80a8e60 100644
> --- a/gdb/testsuite/gdb.mi/mi-var-child-f.exp
> +++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
> @@ -36,7 +36,7 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" 
> "${binfile}" \  mi_gdb_reinitialize_dir $srcdir/$subdir  mi_gdb_load 
> ${binfile}
>
> -mi_runto MAIN__
> +mi_runto [fortran_main]
>
>  mi_create_varobj "array" "array" "create local variable array"
>
> diff --git a/gdb/testsuite/lib/fortran.exp 
> b/gdb/testsuite/lib/fortran.exp index 549ed65790..654afd2b74 100644
> --- a/gdb/testsuite/lib/fortran.exp
> +++ b/gdb/testsuite/lib/fortran.exp
> @@ -126,3 +126,21 @@ proc fortran_character1 {} {
>       return "unknown"
>      }
>  }
> +
> +proc fortran_main {} {

This proc should have a header comment.  Something like:

  # Return name of the main procedure based on the compiler version.

> +    if {[test_compiler_info {gcc-4-[012]-*}]
> +         || [test_compiler_info {gcc-*}]
> +         || [test_compiler_info {icc-*}]} {
> +     return "MAIN__"
> +    } elseif {[test_compiler_info {clang-*}]} {
> +     return "MAIN_"
> +    } else {
> +     return "unknown"
> +    }
> +}
> +
> +# fortran version of runto_main.

Please capitalise Fortran, which I believe is how the name is written.


With those two fixes, please just go ahead and merge.

Thanks,
Andrew



> +
> +proc fortran_runto_main { } {
> +    return [runto [fortran_main]]
> +}
> --
> 2.17.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing
@ 2020-04-24 10:26 Sharma, Alok Kumar
  0 siblings, 0 replies; 14+ messages in thread
From: Sharma, Alok Kumar @ 2020-04-24 10:26 UTC (permalink / raw)
  To: gdb-patches; +Cc: George, Jini Susan, Achra, Nitika

[-- Attachment #1: Type: text/plain, Size: 3014 bytes --]

Hi all,

(Resending as previous mail was sent with wrong tag)

I request you all to please review this patch. Below are the details.

Problem Description:

Name of fortran main function for Flang compiler is MAIN_ while for gfortran it is MAIN__ . In test cases MAIN__ is hardcoded for the purpose of inserting breakpoint.
(please note the number of underscores after MAIN) 

Resolution:

New proc is added to detect main function name depending on the compiler used. Which is used in testcases.

This commit adds support for Flang main function, there should be no change for gfortran.

    gdb/testsuite/ChangeLog

            * gdb.dwarf2/dw2-common-block.exp: Skip test except for gfortran,
            as assembly file to be tested is generated by gfortran.
            * lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_.
            * gdb.fortran/array-bounds-high.exp: Handle flang MAIN_
            * gdb.fortran/array-bounds.exp: Likewise.
            * gdb.fortran/array-slices.exp: Likewise.
            * gdb.fortran/block-data.exp: Likewise.
            * gdb.fortran/charset.exp: Likewise.
            * gdb.fortran/common-block.exp: Likewise.
            * gdb.fortran/complex.exp: Likewise.
            * gdb.fortran/derived-type-function.exp: Likewise.
            * gdb.fortran/derived-type.exp: Likewise.
            * gdb.fortran/info-modules.exp: Likewise.
            * gdb.fortran/info-types.exp: Likewise.
            * gdb.fortran/intrinsics.exp: Likewise.
            * gdb.fortran/library-module.exp: Likewise.
            * gdb.fortran/logical.exp: Likewise.
            * gdb.fortran/max-depth.exp: Likewise.
            * gdb.fortran/module.exp: Likewise.
            * gdb.fortran/multi-dim.exp: Likewise.
            * gdb.fortran/nested-funcs.exp: Likewise.
            * gdb.fortran/print-formatted.exp: Likewise.
            * gdb.fortran/print_type.exp: Likewise.
            * gdb.fortran/printing-types.exp: Likewise.
            * gdb.fortran/ptr-indentation.exp: Likewise.
            * gdb.fortran/ptype-on-functions.exp: Likewise.
            * gdb.fortran/subarray.exp: Likewise.
            * gdb.fortran/vla-alloc-assoc.exp: Likewise.
            * gdb.fortran/vla-datatypes.exp: Likewise.
            * gdb.fortran/vla-history.exp: Likewise.
            * gdb.fortran/vla-ptr-info.exp: Likewise.
            * gdb.fortran/vla-ptype-sub.exp: Likewise.
            * gdb.fortran/vla-ptype.exp: Likewise.
            * gdb.fortran/vla-sizeof.exp: Likewise.
            * gdb.fortran/vla-type.exp: Likewise.
            * gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
            * gdb.fortran/vla-value-sub-finish.exp: Likewise.
            * gdb.fortran/vla-value-sub.exp: Likewise.
            * gdb.fortran/vla-value.exp: Likewise.
            * gdb.fortran/whatis_type.exp: Likewise.
            * gdb.mi/mi-var-child-f.exp: Likewise.

Please let me know your comments.

Regards,
Alok

[-- Attachment #2: 0001-gdb-fortran-Allow-Flang-MAIN_-in-Fortran-testing.patch --]
[-- Type: application/octet-stream, Size: 30204 bytes --]

From 7c1667f2e074dc1e0d9a0336d9ec07da59124a72 Mon Sep 17 00:00:00 2001
From: Alok Kumar Sharma <AlokKumar.Sharma@amd.com>
Date: Fri, 24 Apr 2020 14:46:09 +0530
Subject: [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing

Name of fortran main function for Flang compiler is MAIN_ while
for gfortran it is MAIN__ . In test cases MAIN__ is hardcoded for
the purpose of inserting breakpoint.

New proc is added to detect main function name depending on the
compiler used. Which is used in testcases.

This commit adds support for Flang main function, there should be
no change for gfortran.

gdb/testsuite/ChangeLog

	* gdb.dwarf2/dw2-common-block.exp: Skip test except for gfortran,
	as assembly file to be tested is generated by gfortran.
	* lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_.
	* gdb.fortran/array-bounds-high.exp: Handle flang MAIN_
	* gdb.fortran/array-bounds.exp: Likewise.
	* gdb.fortran/array-slices.exp: Likewise.
	* gdb.fortran/block-data.exp: Likewise.
	* gdb.fortran/charset.exp: Likewise.
	* gdb.fortran/common-block.exp: Likewise.
	* gdb.fortran/complex.exp: Likewise.
	* gdb.fortran/derived-type-function.exp: Likewise.
	* gdb.fortran/derived-type.exp: Likewise.
	* gdb.fortran/info-modules.exp: Likewise.
	* gdb.fortran/info-types.exp: Likewise.
	* gdb.fortran/intrinsics.exp: Likewise.
	* gdb.fortran/library-module.exp: Likewise.
	* gdb.fortran/logical.exp: Likewise.
	* gdb.fortran/max-depth.exp: Likewise.
	* gdb.fortran/module.exp: Likewise.
	* gdb.fortran/multi-dim.exp: Likewise.
	* gdb.fortran/nested-funcs.exp: Likewise.
	* gdb.fortran/print-formatted.exp: Likewise.
	* gdb.fortran/print_type.exp: Likewise.
	* gdb.fortran/printing-types.exp: Likewise.
	* gdb.fortran/ptr-indentation.exp: Likewise.
	* gdb.fortran/ptype-on-functions.exp: Likewise.
	* gdb.fortran/subarray.exp: Likewise.
	* gdb.fortran/vla-alloc-assoc.exp: Likewise.
	* gdb.fortran/vla-datatypes.exp: Likewise.
	* gdb.fortran/vla-history.exp: Likewise.
	* gdb.fortran/vla-ptr-info.exp: Likewise.
	* gdb.fortran/vla-ptype-sub.exp: Likewise.
	* gdb.fortran/vla-ptype.exp: Likewise.
	* gdb.fortran/vla-sizeof.exp: Likewise.
	* gdb.fortran/vla-type.exp: Likewise.
	* gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
	* gdb.fortran/vla-value-sub-finish.exp: Likewise.
	* gdb.fortran/vla-value-sub.exp: Likewise.
	* gdb.fortran/vla-value.exp: Likewise.
	* gdb.fortran/whatis_type.exp: Likewise.
	* gdb.mi/mi-var-child-f.exp: Likewise.

Change-Id: I0a30f5dad684879b416f71d3d08c385c159325bf
---
 gdb/testsuite/ChangeLog                       | 44 +++++++++++++++++++
 gdb/testsuite/gdb.dwarf2/dw2-common-block.exp |  6 +++
 .../gdb.fortran/array-bounds-high.exp         |  5 ++-
 gdb/testsuite/gdb.fortran/array-bounds.exp    |  5 ++-
 gdb/testsuite/gdb.fortran/array-slices.exp    |  3 +-
 gdb/testsuite/gdb.fortran/block-data.exp      |  4 +-
 gdb/testsuite/gdb.fortran/charset.exp         |  6 ++-
 gdb/testsuite/gdb.fortran/common-block.exp    |  4 +-
 gdb/testsuite/gdb.fortran/complex.exp         |  5 ++-
 .../gdb.fortran/derived-type-function.exp     |  5 ++-
 gdb/testsuite/gdb.fortran/derived-type.exp    |  4 +-
 gdb/testsuite/gdb.fortran/info-modules.exp    |  4 +-
 gdb/testsuite/gdb.fortran/info-types.exp      |  4 +-
 gdb/testsuite/gdb.fortran/intrinsics.exp      |  4 +-
 gdb/testsuite/gdb.fortran/library-module.exp  |  5 ++-
 gdb/testsuite/gdb.fortran/logical.exp         |  5 ++-
 gdb/testsuite/gdb.fortran/max-depth.exp       |  4 +-
 gdb/testsuite/gdb.fortran/module.exp          |  6 +--
 gdb/testsuite/gdb.fortran/multi-dim.exp       |  4 +-
 gdb/testsuite/gdb.fortran/nested-funcs.exp    |  4 +-
 gdb/testsuite/gdb.fortran/print-formatted.exp |  4 +-
 gdb/testsuite/gdb.fortran/print_type.exp      |  2 +-
 gdb/testsuite/gdb.fortran/printing-types.exp  |  5 ++-
 gdb/testsuite/gdb.fortran/ptr-indentation.exp |  4 +-
 .../gdb.fortran/ptype-on-functions.exp        |  4 +-
 gdb/testsuite/gdb.fortran/subarray.exp        |  5 ++-
 gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp |  3 +-
 gdb/testsuite/gdb.fortran/vla-datatypes.exp   |  2 +-
 gdb/testsuite/gdb.fortran/vla-history.exp     |  3 +-
 gdb/testsuite/gdb.fortran/vla-ptr-info.exp    |  3 +-
 gdb/testsuite/gdb.fortran/vla-ptype-sub.exp   |  2 +-
 gdb/testsuite/gdb.fortran/vla-ptype.exp       |  2 +-
 gdb/testsuite/gdb.fortran/vla-sizeof.exp      |  3 +-
 gdb/testsuite/gdb.fortran/vla-type.exp        |  2 +-
 .../gdb.fortran/vla-value-sub-arbitrary.exp   |  3 +-
 .../gdb.fortran/vla-value-sub-finish.exp      |  3 +-
 gdb/testsuite/gdb.fortran/vla-value-sub.exp   |  3 +-
 gdb/testsuite/gdb.fortran/vla-value.exp       |  6 +--
 gdb/testsuite/gdb.fortran/whatis_type.exp     |  4 +-
 gdb/testsuite/gdb.mi/mi-var-child-f.exp       |  2 +-
 gdb/testsuite/lib/fortran.exp                 | 16 +++++++
 41 files changed, 148 insertions(+), 64 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 10683db566..e972f97fad 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,47 @@
+2020-04-24  Alok Kumar Sharma  <alokkumar.sharma@amd.com>
+
+	* gdb.dwarf2/dw2-common-block.exp: Skip test except for gfortran,
+	as assembly file to be tested is generated by gfortran.
+	* lib/fortran.exp (fortran_main): New Proc, handle flang MAIN_.
+	* gdb.fortran/array-bounds-high.exp: Handle flang MAIN_
+	* gdb.fortran/array-bounds.exp: Likewise.
+	* gdb.fortran/array-slices.exp: Likewise.
+	* gdb.fortran/block-data.exp: Likewise.
+	* gdb.fortran/charset.exp: Likewise.
+	* gdb.fortran/common-block.exp: Likewise.
+	* gdb.fortran/complex.exp: Likewise.
+	* gdb.fortran/derived-type-function.exp: Likewise.
+	* gdb.fortran/derived-type.exp: Likewise.
+	* gdb.fortran/info-modules.exp: Likewise.
+	* gdb.fortran/info-types.exp: Likewise.
+	* gdb.fortran/intrinsics.exp: Likewise.
+	* gdb.fortran/library-module.exp: Likewise.
+	* gdb.fortran/logical.exp: Likewise.
+	* gdb.fortran/max-depth.exp: Likewise.
+	* gdb.fortran/module.exp: Likewise.
+	* gdb.fortran/multi-dim.exp: Likewise.
+	* gdb.fortran/nested-funcs.exp: Likewise.
+	* gdb.fortran/print-formatted.exp: Likewise.
+	* gdb.fortran/print_type.exp: Likewise.
+	* gdb.fortran/printing-types.exp: Likewise.
+	* gdb.fortran/ptr-indentation.exp: Likewise.
+	* gdb.fortran/ptype-on-functions.exp: Likewise.
+	* gdb.fortran/subarray.exp: Likewise.
+	* gdb.fortran/vla-alloc-assoc.exp: Likewise.
+	* gdb.fortran/vla-datatypes.exp: Likewise.
+	* gdb.fortran/vla-history.exp: Likewise.
+	* gdb.fortran/vla-ptr-info.exp: Likewise.
+	* gdb.fortran/vla-ptype-sub.exp: Likewise.
+	* gdb.fortran/vla-ptype.exp: Likewise.
+	* gdb.fortran/vla-sizeof.exp: Likewise.
+	* gdb.fortran/vla-type.exp: Likewise.
+	* gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
+	* gdb.fortran/vla-value-sub-finish.exp: Likewise.
+	* gdb.fortran/vla-value-sub.exp: Likewise.
+	* gdb.fortran/vla-value.exp: Likewise.
+	* gdb.fortran/whatis_type.exp: Likewise.
+	* gdb.mi/mi-var-child-f.exp: Likewise.
+
 2020-04-23  Tom de Vries  <tdevries@suse.de>
 
 	* gdb.base/decl-before-def.exp: Run to main and print a again.
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-common-block.exp b/gdb/testsuite/gdb.dwarf2/dw2-common-block.exp
index 9bcf06b17f..cf41c6833f 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-common-block.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-common-block.exp
@@ -30,6 +30,12 @@ if {[skip_fortran_tests]} {
     return 0
 }
 
+# Assembly file is generated using gfortran.
+# skip running for other compilers.
+if {![test_compiler_info {gcc-*}]} {
+    return 0
+}
+
 standard_testfile .S
 
 if { [prepare_for_testing "failed to prepare" "${testfile}" $srcfile \
diff --git a/gdb/testsuite/gdb.fortran/array-bounds-high.exp b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
index 81e2f87b89..f1945b4112 100644
--- a/gdb/testsuite/gdb.fortran/array-bounds-high.exp
+++ b/gdb/testsuite/gdb.fortran/array-bounds-high.exp
@@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
 
 set testfile "array-bounds-high"
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
     return -1
 }
 
-if {![runto MAIN__]} {
-    perror "Could not run to breakpoint `MAIN__'."
+if {![runto $fmain]} {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/array-bounds.exp b/gdb/testsuite/gdb.fortran/array-bounds.exp
index 12bf5c2db3..be28ff6da9 100644
--- a/gdb/testsuite/gdb.fortran/array-bounds.exp
+++ b/gdb/testsuite/gdb.fortran/array-bounds.exp
@@ -20,13 +20,14 @@ if { [skip_fortran_tests] } { return -1 }
 
 set testfile "array-bounds"
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing $testfile.exp $testfile $srcfile {f90 debug}]} {
     return -1
 }
 
-if {![runto MAIN__]} {
-    perror "Could not run to breakpoint `MAIN__'."
+if {![runto $fmain]} {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp b/gdb/testsuite/gdb.fortran/array-slices.exp
index 11997f926a..e91db62aa1 100644
--- a/gdb/testsuite/gdb.fortran/array-slices.exp
+++ b/gdb/testsuite/gdb.fortran/array-slices.exp
@@ -21,13 +21,14 @@
 if {[skip_fortran_tests]} { return -1 }
 
 standard_testfile ".f90"
+load_lib fortran.exp
 
 if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
 	 {debug f90}]} {
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/block-data.exp b/gdb/testsuite/gdb.fortran/block-data.exp
index 292afe6c16..520f0d5d28 100644
--- a/gdb/testsuite/gdb.fortran/block-data.exp
+++ b/gdb/testsuite/gdb.fortran/block-data.exp
@@ -30,8 +30,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    untested "couldn't run to breakpoint MAIN__"
+if ![runto $fmain] then {
+    untested "couldn't run to breakpoint $fmain"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/charset.exp b/gdb/testsuite/gdb.fortran/charset.exp
index f0f62f8490..11ab9dfdf0 100644
--- a/gdb/testsuite/gdb.fortran/charset.exp
+++ b/gdb/testsuite/gdb.fortran/charset.exp
@@ -19,12 +19,14 @@
 if { [skip_fortran_tests] } { return -1 }
 
 standard_testfile .f90
+load_lib fortran.exp
+
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug additional_flags=-fbackslash f90}] } {
     return -1
 }
 
-if ![runto MAIN__] {
-    perror "Couldn't run to MAIN__"
+if ![runto $fmain] {
+    perror "Couldn't run to $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/common-block.exp b/gdb/testsuite/gdb.fortran/common-block.exp
index 19c1af0d81..2b74a18e75 100644
--- a/gdb/testsuite/gdb.fortran/common-block.exp
+++ b/gdb/testsuite/gdb.fortran/common-block.exp
@@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" ${testfile} \
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto $fmain] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/complex.exp b/gdb/testsuite/gdb.fortran/complex.exp
index c092ab29f1..8ac81c1fcb 100644
--- a/gdb/testsuite/gdb.fortran/complex.exp
+++ b/gdb/testsuite/gdb.fortran/complex.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "Couldn't run to MAIN__"
+if ![runto $fmain] then {
+    perror "Couldn't run to $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/derived-type-function.exp b/gdb/testsuite/gdb.fortran/derived-type-function.exp
index 1f0f957317..8a298f5f7b 100644
--- a/gdb/testsuite/gdb.fortran/derived-type-function.exp
+++ b/gdb/testsuite/gdb.fortran/derived-type-function.exp
@@ -21,13 +21,14 @@
 if { [skip_fortran_tests] } { return -1 }
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto $fmain] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/derived-type.exp b/gdb/testsuite/gdb.fortran/derived-type.exp
index f1705bffd8..eddd985e59 100644
--- a/gdb/testsuite/gdb.fortran/derived-type.exp
+++ b/gdb/testsuite/gdb.fortran/derived-type.exp
@@ -27,8 +27,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto $fmain] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/info-modules.exp b/gdb/testsuite/gdb.fortran/info-modules.exp
index 0c3c6a58e1..9967803dcc 100644
--- a/gdb/testsuite/gdb.fortran/info-modules.exp
+++ b/gdb/testsuite/gdb.fortran/info-modules.exp
@@ -28,8 +28,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![runto $fmain] } {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/info-types.exp b/gdb/testsuite/gdb.fortran/info-types.exp
index 2138937782..7f58740ed8 100644
--- a/gdb/testsuite/gdb.fortran/info-types.exp
+++ b/gdb/testsuite/gdb.fortran/info-types.exp
@@ -27,8 +27,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![runto $fmain] } {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/intrinsics.exp b/gdb/testsuite/gdb.fortran/intrinsics.exp
index 504bce4138..dca2d98cf4 100644
--- a/gdb/testsuite/gdb.fortran/intrinsics.exp
+++ b/gdb/testsuite/gdb.fortran/intrinsics.exp
@@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![runto $fmain] } {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/library-module.exp b/gdb/testsuite/gdb.fortran/library-module.exp
index f25988e32c..eb26551f4d 100644
--- a/gdb/testsuite/gdb.fortran/library-module.exp
+++ b/gdb/testsuite/gdb.fortran/library-module.exp
@@ -40,9 +40,10 @@ if  { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable [list debug f90
 clean_restart $testfile
 
 gdb_load_shlib $libfile
+load_lib fortran.exp
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto $fmain] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/logical.exp b/gdb/testsuite/gdb.fortran/logical.exp
index 324714fa49..ef5954aaf9 100644
--- a/gdb/testsuite/gdb.fortran/logical.exp
+++ b/gdb/testsuite/gdb.fortran/logical.exp
@@ -16,13 +16,14 @@
 # This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90 quiet}]} {
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![runto $fmain] } {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/max-depth.exp b/gdb/testsuite/gdb.fortran/max-depth.exp
index 262d0fdfa1..52b5a24b98 100644
--- a/gdb/testsuite/gdb.fortran/max-depth.exp
+++ b/gdb/testsuite/gdb.fortran/max-depth.exp
@@ -26,8 +26,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
     return -1
 }
 
-if { ![runto MAIN__] } {
-    perror "Could not run to breakpoint `MAIN__'."
+if { ![runto $fmain] } {
+    perror "Could not run to breakpoint `$fmain'."
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/module.exp b/gdb/testsuite/gdb.fortran/module.exp
index 1c269e2fed..9f5c79fba2 100644
--- a/gdb/testsuite/gdb.fortran/module.exp
+++ b/gdb/testsuite/gdb.fortran/module.exp
@@ -29,8 +29,8 @@ gdb_test "p modmany::var_i" " = 14" "stopped language detection"
 
 gdb_test "print mod1::var_const" " = 20" "fully qualified name of DW_TAG_constant"
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto $fmain] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
@@ -123,7 +123,7 @@ complete "modmany::var" $modmany_list
 # Breakpoint would work in language "c".
 gdb_test "show language" {The current source language is "(auto; currently )?fortran".}
 
-# gcc-4.4.2: The main program is always MAIN__ in .symtab so "runto" above
+# gcc-4.4.2: The main program is always $fmain in .symtab so "runto" above
 # works.  But DWARF DW_TAG_subprogram contains the name specified by
 # the "program" Fortran statement.
 if [gdb_breakpoint "module"] {
diff --git a/gdb/testsuite/gdb.fortran/multi-dim.exp b/gdb/testsuite/gdb.fortran/multi-dim.exp
index 05590914df..2567f166e2 100644
--- a/gdb/testsuite/gdb.fortran/multi-dim.exp
+++ b/gdb/testsuite/gdb.fortran/multi-dim.exp
@@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug f90}
     return -1
 }
 
-if ![runto MAIN__] {
-    perror "Couldn't run to MAIN__"
+if ![runto $fmain] {
+    perror "Couldn't run to $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/nested-funcs.exp b/gdb/testsuite/gdb.fortran/nested-funcs.exp
index e4fc02ffa5..b68227cb5a 100755
--- a/gdb/testsuite/gdb.fortran/nested-funcs.exp
+++ b/gdb/testsuite/gdb.fortran/nested-funcs.exp
@@ -25,8 +25,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto $fmain] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/print-formatted.exp b/gdb/testsuite/gdb.fortran/print-formatted.exp
index 8c6529ce7f..cd12c6b3c4 100644
--- a/gdb/testsuite/gdb.fortran/print-formatted.exp
+++ b/gdb/testsuite/gdb.fortran/print-formatted.exp
@@ -25,8 +25,8 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
     return -1
 }
 
-if { ![runto MAIN__] } {
-    fail "runto MAIN__"
+if { ![runto $fmain] } {
+    fail "runto $fmain"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/print_type.exp b/gdb/testsuite/gdb.fortran/print_type.exp
index 7d5915390d..615c2be226 100755
--- a/gdb/testsuite/gdb.fortran/print_type.exp
+++ b/gdb/testsuite/gdb.fortran/print_type.exp
@@ -24,7 +24,7 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/printing-types.exp b/gdb/testsuite/gdb.fortran/printing-types.exp
index 2c88f9e003..206cccd19b 100644
--- a/gdb/testsuite/gdb.fortran/printing-types.exp
+++ b/gdb/testsuite/gdb.fortran/printing-types.exp
@@ -16,13 +16,14 @@
 if {[skip_fortran_tests]} { return -1 }
 
 standard_testfile .f90
+load_lib fortran.exp
 
 if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if {![runto MAIN__]} then {
-    untested "could not run to breakpoint MAIN__"
+if {![runto $fmain]} then {
+    untested "could not run to breakpoint $fmain"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/ptr-indentation.exp b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
index 285e24e2cc..bffd4983f0 100644
--- a/gdb/testsuite/gdb.fortran/ptr-indentation.exp
+++ b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
@@ -22,8 +22,8 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if {![runto MAIN__]} then {
-    untested "couldn't run to breakpoint MAIN__"
+if {![runto $fmain]} then {
+    untested "couldn't run to breakpoint $fmain"
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
index d91e4bd48e..bf1f5d8637 100644
--- a/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
+++ b/gdb/testsuite/gdb.fortran/ptype-on-functions.exp
@@ -24,8 +24,8 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
 }
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto $fmain] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/subarray.exp b/gdb/testsuite/gdb.fortran/subarray.exp
index 5e3e8c38cb..c8aa5fe829 100644
--- a/gdb/testsuite/gdb.fortran/subarray.exp
+++ b/gdb/testsuite/gdb.fortran/subarray.exp
@@ -21,6 +21,7 @@
 if { [skip_fortran_tests] } { return -1 }
 
 standard_testfile .f
+load_lib fortran.exp
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
     return -1
@@ -31,8 +32,8 @@ gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_load ${binfile}
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto $fmain] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 
diff --git a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
index 5d8585c2ee..ba1ee8e58c 100644
--- a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
+++ b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-datatypes.exp b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
index 2db9b3e110..b4c4b198c3 100644
--- a/gdb/testsuite/gdb.fortran/vla-datatypes.exp
+++ b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
@@ -24,7 +24,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
 # check that all fortran standard datatypes will be
 # handled correctly when using as VLA's
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-history.exp b/gdb/testsuite/gdb.fortran/vla-history.exp
index 24bd945f4a..aa38d5288c 100644
--- a/gdb/testsuite/gdb.fortran/vla-history.exp
+++ b/gdb/testsuite/gdb.fortran/vla-history.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
index 24c7b45840..1538f689e2 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
index 09909e74b0..90455601e4 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-ptype.exp b/gdb/testsuite/gdb.fortran/vla-ptype.exp
index 22b2005317..39d00a32c2 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptype.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptype.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
index 8e7d36314e..c826d96eb9 100644
--- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp
+++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-type.exp b/gdb/testsuite/gdb.fortran/vla-type.exp
index 6d885e7889..d9b66ff395 100755
--- a/gdb/testsuite/gdb.fortran/vla-type.exp
+++ b/gdb/testsuite/gdb.fortran/vla-type.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
index ab61dde06f..a18b4e4209 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla-sub.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
index afd992cee4..a056fc2732 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla-sub.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub.exp b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
index 3311f6befa..e0a42260a4 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
@@ -14,13 +14,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile "vla-sub.f90"
+load_lib fortran.exp
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     {debug f90 quiet}] } {
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp
index 5af17b570c..994a5a3e7a 100644
--- a/gdb/testsuite/gdb.fortran/vla-value.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
     return -1
 }
 
-if ![runto_main] {
+if ![runto $fmain] {
     untested "could not run to main"
     return -1
 }
@@ -129,8 +129,8 @@ gdb_test "print vla1(9, 9, 9)" "no such vector element \\\(vector not allocated\
 # Try to assign VLA to user variable
 clean_restart ${testfile}
 
-if ![runto MAIN__] then {
-    perror "couldn't run to breakpoint MAIN__"
+if ![runto $fmain] then {
+    perror "couldn't run to breakpoint $fmain"
     continue
 }
 gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
diff --git a/gdb/testsuite/gdb.fortran/whatis_type.exp b/gdb/testsuite/gdb.fortran/whatis_type.exp
index 6a9cc0a81e..8a9a1eb79f 100644
--- a/gdb/testsuite/gdb.fortran/whatis_type.exp
+++ b/gdb/testsuite/gdb.fortran/whatis_type.exp
@@ -23,8 +23,8 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
     return -1
 }
 
-if ![runto MAIN__] {
-    fail "run to MAIN__"
+if ![runto $fmain] {
+    fail "run to $fmain"
     return
 }
 
diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
index 8cfffa7c08..363da0b7ed 100644
--- a/gdb/testsuite/gdb.mi/mi-var-child-f.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
@@ -36,7 +36,7 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
 mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load ${binfile}
 
-mi_runto MAIN__
+mi_runto $fmain
 
 mi_create_varobj "array" "array" "create local variable array"
 
diff --git a/gdb/testsuite/lib/fortran.exp b/gdb/testsuite/lib/fortran.exp
index 549ed65790..0bd95504c8 100644
--- a/gdb/testsuite/lib/fortran.exp
+++ b/gdb/testsuite/lib/fortran.exp
@@ -18,6 +18,8 @@
 # Auxiliary function to set the language to fortran.
 # The result is 1 (true) for success, 0 (false) for failure.
 
+global fmain
+
 proc set_lang_fortran {} {
     if [gdb_test_no_output "set language fortran"] {
 	return 0
@@ -126,3 +128,17 @@ proc fortran_character1 {} {
 	return "unknown"
     }
 }
+
+proc fortran_main {} {
+    if {[test_compiler_info {gcc-4-[012]-*}]
+         || [test_compiler_info {gcc-*}]
+         || [test_compiler_info {icc-*}]} {
+	return "MAIN__"
+    } elseif {[test_compiler_info {clang-*}]} {
+	return "MAIN_"
+    } else {
+	return "unknown"
+    }
+}
+
+set fmain  [fortran_main]
-- 
2.17.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-05-10 19:25 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-24  9:44 [PATCH] gdb/fortran: Allow Flang MAIN_ in Fortran testing Sharma, Alok Kumar
2020-04-24 10:17 ` Andrew Burgess
2020-04-24 11:48   ` Sharma, Alok Kumar
2020-04-24 12:58     ` Tom Tromey
2020-04-24 12:56   ` Tom Tromey
2020-04-24 13:37     ` Andrew Burgess
2020-04-24 14:02       ` Tom Tromey
2020-04-24 15:54       ` Sharma, Alok Kumar
2020-04-27  9:07         ` Andrew Burgess
2020-04-27 18:02           ` Sharma, Alok Kumar
2020-04-29  9:15             ` Andrew Burgess
2020-05-10  9:21               ` Sharma, Alok Kumar
2020-05-10 19:24                 ` Sharma, Alok Kumar
2020-04-24 10:26 Sharma, Alok Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).