gdb/fortran: Handle internal function calls

If an convenience function is defined in python (or guile), then
currently this will not work in Fortran, instead the user is given
this message:

  (gdb) set language fortran
  (gdb) p $myfunc (3)
  Cannot perform substring on this type

Compare this to C:

  (gdb) set language c
  (gdb) p $myfunc (3)
  $1 = 1

After this patch we see the same behaviour in both C and Fortran.
I've extended the test to check that all languages can call the
convenience functions - only Fortran was broken.

When calling convenience functions in Fortran we don't need to perform
the same value preparation (passing by pointer) that we would for
calling a native function - passing the real value is fine.

gdb/ChangeLog:

	* eval.c (evaluate_subexp_standard): Handle internal functions
	during Fortran function call handling.

gdb/testsuite/ChangeLog:

	* gdb.python/py-function.exp: Check calling helper function from
	all languages.
	* lib/gdb.exp (gdb_supported_languages): New proc.
This commit is contained in:
Andrew Burgess
2019-02-14 15:49:39 +00:00
parent 8bdc16587e
commit d7df654955
5 changed files with 34 additions and 5 deletions

View File

@ -51,7 +51,13 @@ gdb_py_test_multiple "input value-returning convenience function" \
"Double ()" "" \
"end" ""
gdb_test "print \$double (1)" "= 2" "call value-returning function"
# Different languages can have different parsers, so lets check that
# internal functions are understood by every language. Place auto
# last in the list so we end up back in 'auto' language mode.
foreach lang [concat [gdb_supported_languages] auto] {
gdb_test_no_output "set language $lang"
gdb_test "print \$double (1)" "= 2" "call value-returning function, language = $lang"
}
gdb_py_test_multiple "input int-returning function" \
"python" "" \