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)
commitdb77748be8aaa4926946d75b74947fff3775edcf
tree88f4bee44d6bd75fe208c684dd33398c63a7a1e1
parent48ec4c05c68bfec4b79e95807bd82e0df4634a6c
gdb, testsuite: Fix mi-var-child-f.exp for Intel compilers.

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