gdb, testsuite: Fix mi-var-child-f.exp for Intel compilers.
authorFelix Willgerodt <felix.willgerodt@intel.com>
Thu, 6 May 2021 12:14:07 +0000 (14:14 +0200)
committerFelix Willgerodt <felix.willgerodt@intel.com>
Fri, 11 Jun 2021 15:16:46 +0000 (17:16 +0200)
mi-var-child-f.exp uses array.f as the inferior, which uses an unnamed
main function.  This causes false positive fails for Intel compilers, as
they emit the following DWARF:

~~~
0x0000002a:   DW_TAG_subprogram
                DW_AT_low_pc    (0x0000000000404800)
                DW_AT_high_pc   (0x000000000040484c)
                DW_AT_frame_base        (DW_OP_reg6 RBP)
                DW_AT_linkage_name      ("MAIN__")
                DW_AT_name      ("_unnamed_main$$")
                DW_AT_decl_file ("array.f")
                DW_AT_decl_line (16)
                DW_AT_external  (true)
                DW_AT_main_subprogram   (true)
~~~

The testsuite for fortran uses test_compiler_info to determine a hardcoded
string which is used to run to main and as a testing regex:

~~~
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"
    }
}
~~~

GDB however uses DW_AT_name mostly in its output, which fails the regex.
To fix this testcase immediately, I modernized array.f and gave it a named
main.  There was no specific reason it was unnamed anyway.  Fixing
the testsuite properly is not straightforward.  fortran_main and
test_compiler_info would need some changes, which has broader influences.
I might look at this later down the road.

gdb/testsuite/ChangeLog:
2021-06-11  Felix Willgerodt  <felix.willgerodt@intel.com>

* gdb.mi/array.f: Convert into...
* gdb.mi/array.f90: ...this.
* gdb.mi/mi-var-child-f.exp: Use array.f90.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.mi/array.f [deleted file]
gdb/testsuite/gdb.mi/array.f90 [new file with mode: 0644]
gdb/testsuite/gdb.mi/mi-var-child-f.exp

index 9168a6a4b70c4e94badee49c628517d7b7c39eef..ba11a4d3d7f95ac2d15630902cde00024ec70e66 100644 (file)
@@ -1,3 +1,9 @@
+2021-06-11  Felix Willgerodt  <felix.willgerodt@intel.com>
+
+       * gdb.mi/array.f: Convert into...
+       * gdb.mi/array.f90: ...this.
+       * gdb.mi/mi-var-child-f.exp: Use array.f90.
+
 2021-06-11  Tom Tromey  <tom@tromey.com>
 
        PR rust/23427
diff --git a/gdb/testsuite/gdb.mi/array.f b/gdb/testsuite/gdb.mi/array.f
deleted file mode 100644 (file)
index 2d31eca..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-c Copyright 2006-2021 Free Software Foundation, Inc.
-
-c This program is free software; you can redistribute it and/or modify
-c it under the terms of the GNU General Public License as published by
-c the Free Software Foundation; either version 3 of the License, or
-c (at your option) any later version.
-c
-c This program is distributed in the hope that it will be useful,
-c but WITHOUT ANY WARRANTY; without even the implied warranty of
-c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-c GNU General Public License for more details.
-c
-c You should have received a copy of the GNU General Public License
-c along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-      INTEGER array(1:2,-1:1)
-      DATA array/11,21,12,22,13,23/
-      CONTINUE
-      STOP
-      END
diff --git a/gdb/testsuite/gdb.mi/array.f90 b/gdb/testsuite/gdb.mi/array.f90
new file mode 100644 (file)
index 0000000..b414b27
--- /dev/null
@@ -0,0 +1,21 @@
+! Copyright 2006-2021 Free Software Foundation, Inc.
+
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 3 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License
+! along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+program prog_array
+  INTEGER array (1:2,-1:1)
+  DATA array/11,21,12,22,13,23/
+  CONTINUE
+  STOP
+end program prog_array
index 272505a4d6978accdc81ed9be79d6da0ff4f9a15..f35c0cdd6d3848efbc63f38514a4cd82fce4fdce 100644 (file)
@@ -26,7 +26,7 @@ if [mi_gdb_start] {
     continue
 }
 
-standard_testfile array.f
+standard_testfile array.f90
 
 if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
         executable {debug f90}] != ""} {
@@ -36,7 +36,7 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
 mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load ${binfile}
 
-mi_runto [fortran_main]
+mi_runto prog_array
 
 mi_create_varobj "array" "array" "create local variable array"
 
This page took 0.043397 seconds and 4 git commands to generate.