[binutils-gdb] testsuite, fortran: make mixed-lang-stack less compiler dependent

Abdul Basit Ijaz abijaz@sourceware.org
Thu Sep 7 22:37:22 GMT 2023


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=85832a8c3c91c8ac39b8c6ef50a4894a55b17ab2

commit 85832a8c3c91c8ac39b8c6ef50a4894a55b17ab2
Author: Nils-Christian Kempke <nils-christian.kempke@intel.com>
Date:   Fri May 20 17:44:31 2022 +0200

    testsuite, fortran: make mixed-lang-stack less compiler dependent
    
    In the gdb.fortran/mixed-lang-stack.exp test when somewhere deep in a
    bunch of nested function calls we issue and test a 'info args' command
    for the mixed_func_1b function (when in that function's frame).
    
    The signature of the function looks like
    
      subroutine mixed_func_1b(a, b, c, d, e, g)
        use type_module
        implicit none
    
        integer :: a
        real(kind=4) :: b
        real(kind=8) :: c
        complex(kind=4) :: d
        character(len=*) :: e
        character(len=:), allocatable :: f
        TYPE(MyType) :: g
    
    and usually one would expect arguments a, b, c, d, e, and g to be
    emitted here.  However, due to some compiler dependent treatment of the
    e array the actual output in the test (with gfortran/ifx) is
    
      (gdb) info args
      a = 1
      b = 2
      c = 3
      d = (4,5)
      e = 'abcdef'
      g = ( a = 1.5, b = 2.5 )
      _e = 6
    
    where the compiler generated '_e' is emitted as the length of e.  While
    ifort also generates an additional length argument, the naming (which is
    up to the compilers here I think, I could not find anything in the
    Fortran standard about this) is different and we see
    
      (gdb) info args
      a = 1
      b = 2
      c = 3
      d = (4,5)
      e = 'abcdef'
      g = ( a = 1.5, b = 2.5 )
      .tmp.E.len_V$4a = 6
    
    To make both outputs pass the test, I kept the additional argument for now and
    made the regex for the emitted name of the last variable match any
    arbitrary name.
    
    Approved-by: Tom Tromey <tom@tromey.com>

Diff:
---
 gdb/testsuite/gdb.fortran/mixed-lang-stack.exp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp b/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp
index 3973f68c666..20983d661fe 100644
--- a/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp
+++ b/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp
@@ -181,6 +181,13 @@ proc run_tests { lang } {
 	    set g_val_pattern "\\( a = 1.5, b = 2.5 \\)"
 	}
 
+	# The last argument here in info args is compiler generated.  It
+	# contains length of the passed array e (we are in mixed_func_1b here).
+	# For gfortran and ifx the compilers conveniently named this '_e',
+	# ifort however prints .tmp.E.len_V$4a.  As is seems unreasonable to
+	# test for an artificially created name and as at the same time all
+	# 3 tested compilers emit this argument, we only check for its
+	# existence and its value (6).
 	set args_pattern [multi_line \
 			      "a = 1" \
 			      "b = 2" \
@@ -188,7 +195,7 @@ proc run_tests { lang } {
 			      "d = ${d_pattern}" \
 			      "e = ${e_pattern}" \
 			      "g = ${g_val_pattern}" \
-			      "_e = 6" ]
+			      ".* = 6" ]
 
 	gdb_test "info args" $args_pattern \
 	    "info args in frame #7"


More information about the Gdb-cvs mailing list