]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/testsuite/gdb.fortran/call-no-debug.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.fortran / call-no-debug.exp
index 82bf32c82c701213218cbf4efd23f00a673da657..57074447802ec9d1a8aec73408b9e0a75ae0ba6b 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2020-2021 Free Software Foundation, Inc.
+# Copyright 2020-2024 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
@@ -16,7 +16,7 @@
 # Test calling Fortran functions that are compiled without debug
 # information.
 
-if {[skip_fortran_tests]} { return -1 }
+require allow_fortran_tests
 
 standard_testfile call-no-debug-prog.f90 call-no-debug-func.f90
 load_lib fortran.exp
@@ -28,11 +28,6 @@ if {[prepare_for_testing_full "failed to prepare" \
     return -1
 }
 
-if ![fortran_runto_main] {
-    untested "could not run to main"
-    return -1
-}
-
 # Find a possibly mangled version of NAME, a function we want to call
 # that has no debug information available.  We hope that the mangled
 # version of NAME contains the pattern NAME, and so we use 'info
@@ -67,12 +62,21 @@ proc find_mangled_name { name } {
     return $symbol_name
 }
 
+# Sample before before starting the exec, in order to avoid picking up symbols
+# from shared libs.
+set some_func [find_mangled_name "some_func"]
+set string_func [find_mangled_name "string_func"]
+
+if ![fortran_runto_main] {
+    return -1
+}
+
 # Call the function SOME_FUNC, that takes a single integer and returns
 # an integer.  As the function has no debug information then we have
 # to pass the integer argument as '&1' so that GDB will send the
 # address of an integer '1' (as Fortran arguments are pass by
 # reference).
-set symbol_name [find_mangled_name "some_func"]
+set symbol_name $some_func
 if { $symbol_name == "" } {
     untested "couldn't find suitable name for 'some_func'"
 } else {
@@ -91,12 +95,14 @@ if { $symbol_name == "" } {
 # The compiled program is expecting the address of the string, so we
 # prefix that argument with '&', but the artificial length parameter
 # is pass by value, so there's no need for '&' in that case.
-set symbol_name [find_mangled_name "string_func"]
+set symbol_name $string_func
 if { $symbol_name == "" } {
     untested "couldn't find suitable name for 'string_func'"
 } else {
     gdb_test "ptype ${symbol_name}" "type = <unknown return type> \\(\\)"
     gdb_test "print ${symbol_name} (&'abcdefg', 3)" \
        "'${symbol_name}' has unknown return type; cast the call to its declared return type"
-    gdb_test "call (integer) ${symbol_name} (&'abcdefg', 3)" " abc\r\n\\\$\\d+ = 0"
+    gdb_test_stdio "call (integer) ${symbol_name} (&'abcdefg', 3)" \
+       " abc" \
+       "\\\$\\d+ = 0"
 }