aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2019-02-14 15:49:39 +0000
committerAndrew Burgess <andrew.burgess@embecosm.com>2019-04-01 21:41:51 +0100
commitd7df654955c2423190b05b2507caf624ce3d65bc (patch)
treefabbf61ca39144ed03690e66c239837e7e42d41f /gdb
parent8bdc16587e26100282094c8eaa8e83180ba57afd (diff)
downloadgdb-d7df654955c2423190b05b2507caf624ce3d65bc.zip
gdb-d7df654955c2423190b05b2507caf624ce3d65bc.tar.gz
gdb-d7df654955c2423190b05b2507caf624ce3d65bc.tar.bz2
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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/eval.c12
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.python/py-function.exp8
-rw-r--r--gdb/testsuite/lib/gdb.exp8
5 files changed, 34 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 35a9550..aee0d96 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2019-04-01 Andrew Burgess <andrew.burgess@embecosm.com>
+ * eval.c (evaluate_subexp_standard): Handle internal functions
+ during Fortran function call handling.
+
+2019-04-01 Andrew Burgess <andrew.burgess@embecosm.com>
+
* NEWS: Mention new internal functions.
* dwarf2read.c (dwarf2_init_complex_target_type): New function.
(read_base_type): Use dwarf2_init_complex_target_type.
diff --git a/gdb/eval.c b/gdb/eval.c
index 9d8eb34..3f768b4 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1979,6 +1979,7 @@ evaluate_subexp_standard (struct type *expect_type,
case TYPE_CODE_PTR:
case TYPE_CODE_FUNC:
+ case TYPE_CODE_INTERNAL_FUNCTION:
/* It's a function call. */
/* Allocate arg vector, including space for the function to be
called in argvec[0] and a terminating NULL. */
@@ -1996,10 +1997,13 @@ evaluate_subexp_standard (struct type *expect_type,
results in malloc being called with a pointer to an integer
followed by an attempt to malloc the arguments to malloc in
target memory. Infinite recursion ensues. */
- bool is_artificial =
- TYPE_FIELD_ARTIFICIAL (value_type (arg1), tem - 1);
- argvec[tem] = fortran_argument_convert (argvec[tem],
- is_artificial);
+ if (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC)
+ {
+ bool is_artificial
+ = TYPE_FIELD_ARTIFICIAL (value_type (arg1), tem - 1);
+ argvec[tem] = fortran_argument_convert (argvec[tem],
+ is_artificial);
+ }
}
argvec[tem] = 0; /* signal end of arglist */
if (noside == EVAL_SKIP)
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 7d603ad..45c5eb1 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,11 @@
2019-04-01 Andrew Burgess <andrew.burgess@embecosm.com>
+ * gdb.python/py-function.exp: Check calling helper function from
+ all languages.
+ * lib/gdb.exp (gdb_supported_languages): New proc.
+
+2019-04-01 Andrew Burgess <andrew.burgess@embecosm.com>
+
* gdb.base/complex-parts.c: New file.
* gdb.base/complex-parts.exp: New file.
diff --git a/gdb/testsuite/gdb.python/py-function.exp b/gdb/testsuite/gdb.python/py-function.exp
index 76cc57d..01c326b 100644
--- a/gdb/testsuite/gdb.python/py-function.exp
+++ b/gdb/testsuite/gdb.python/py-function.exp
@@ -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" "" \
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index e3c6b2d..1176fdd 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -6353,5 +6353,13 @@ proc cd { dir } {
builtin_cd $dir
}
+# Return a list of all languages supported by GDB, suitable for use in
+# 'set language NAME'. This doesn't include either the 'local' or
+# 'auto' keywords.
+proc gdb_supported_languages {} {
+ return [list c objective-c c++ d go fortran modula-2 asm pascal \
+ opencl rust minimal ada]
+}
+
# Always load compatibility stuff.
load_lib future.exp