From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Cc: Richard Bunt <Richard.Bunt@arm.com>,
Andrew Burgess <andrew.burgess@embecosm.com>
Subject: [PATCH 2/8] gdb/fortran: Handle internal function calls
Date: Mon, 18 Mar 2019 12:52:00 -0000 [thread overview]
Message-ID: <e8ddc573732bbbde4e92beb802b7198c6583b0b7.1552913183.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <cover.1552913183.git.andrew.burgess@embecosm.com>
In-Reply-To: <cover.1552913183.git.andrew.burgess@embecosm.com>
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.
---
gdb/ChangeLog | 5 +++++
gdb/eval.c | 12 ++++++++----
gdb/testsuite/ChangeLog | 6 ++++++
gdb/testsuite/gdb.python/py-function.exp | 8 +++++++-
gdb/testsuite/lib/gdb.exp | 8 ++++++++
5 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 705bcaff49f..51863b21dc6 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2019-03-18 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * eval.c (evaluate_subexp_standard): Handle internal functions
+ during Fortran function call handling.
+
2019-03-18 Andrew Burgess <andrew.burgess@embecosm.com>
* NEWS: Mention new internal functions.
diff --git a/gdb/eval.c b/gdb/eval.c
index 0c0cf7f6ac7..085c00a7d65 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 b471f374271..6094d773163 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2019-03-18 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-03-18 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb.base/complex-parts.c: New file.
diff --git a/gdb/testsuite/gdb.python/py-function.exp b/gdb/testsuite/gdb.python/py-function.exp
index 76cc57d81c9..01c326b5d0b 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 f13f909c344..ad5f1857e1c 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -6308,5 +6308,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
--
2.14.5
next prev parent reply other threads:[~2019-03-18 12:52 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-02 23:58 [PATCHv2 0/8] Series of Fortran type printing patches Andrew Burgess
2019-03-18 12:52 ` [PATCH " Andrew Burgess
2019-03-18 12:52 ` [PATCH 8/8] gdb/fortran: Add allocatable type qualifier Andrew Burgess
2019-03-18 12:52 ` Andrew Burgess [this message]
2019-03-19 19:52 ` [PATCH 2/8] gdb/fortran: Handle internal function calls Tom Tromey
2019-03-18 12:52 ` [PATCH 5/8] gdb/fortran: Print 'void' type in lower case Andrew Burgess
2019-03-18 12:52 ` [PATCH 1/8] gdb: Add $_cimag and $_creal internal functions Andrew Burgess
2019-03-18 17:20 ` Eli Zaretskii
2019-03-29 22:41 ` Andrew Burgess
2019-03-30 7:15 ` Eli Zaretskii
2019-03-19 19:47 ` Tom Tromey
2019-04-12 20:24 ` New FAIL on gdb.base/complex-parts.exp - unix/-m32 (was: Re: [PATCH 1/8] gdb: Add $_cimag and $_creal internal functions) Sergio Durigan Junior
2019-04-13 0:02 ` Andrew Burgess
2019-04-16 18:30 ` New FAIL on gdb.base/complex-parts.exp - unix/-m32 Tom Tromey
2019-04-17 0:03 ` Andrew Burgess
2019-03-18 12:52 ` [PATCH 6/8] gdb/fortran: print function arguments when printing function type Andrew Burgess
2019-03-18 12:52 ` [PATCH 3/8] gdb/fortran: Additional builtin procedures Andrew Burgess
2019-03-19 20:06 ` Tom Tromey
2019-03-18 12:52 ` [PATCH 4/8] gdb/fortran: better types for components of complex numbers Andrew Burgess
2019-03-19 20:18 ` Tom Tromey
2019-03-18 12:52 ` [PATCH 7/8] gdb/fortran: Update rules for printing whitespace in types Andrew Burgess
2019-03-19 20:27 ` [PATCH 0/8] Series of Fortran type printing patches Tom Tromey
2019-04-02 23:58 ` [PATCHv2 2/8] gdb/fortran: Introduce fortran-operator.def file Andrew Burgess
2019-04-02 23:58 ` [PATCHv2 3/8] gdb/fortran: Additional builtin procedures Andrew Burgess
2019-04-02 23:58 ` [PATCHv2 1/8] gdb: Remove an unbalanced stray double quote from a comment Andrew Burgess
2019-04-02 23:59 ` [PATCHv2 8/8] gdb/fortran: Add allocatable type qualifier Andrew Burgess
2019-04-02 23:59 ` [PATCHv2 5/8] gdb/fortran: Print 'void' type in lower case Andrew Burgess
2019-04-02 23:59 ` [PATCHv2 4/8] gdb/fortran: better types for components of complex numbers Andrew Burgess
2019-05-03 0:21 ` Regression on gdb.fortran/complex.exp on unix/-m32 (was: Re: [PATCHv2 4/8] gdb/fortran: better types for components of complex numbers) Sergio Durigan Junior
2019-04-02 23:59 ` [PATCHv2 6/8] gdb/fortran: print function arguments when printing function type Andrew Burgess
2019-04-02 23:59 ` [PATCHv2 7/8] gdb/fortran: Update rules for printing whitespace in types Andrew Burgess
2019-04-23 22:16 ` [PATCHv2 0/8] Series of Fortran type printing patches Andrew Burgess
2019-04-24 19:19 ` Tom Tromey
2019-04-30 12:37 ` Andrew Burgess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e8ddc573732bbbde4e92beb802b7198c6583b0b7.1552913183.git.andrew.burgess@embecosm.com \
--to=andrew.burgess@embecosm.com \
--cc=Richard.Bunt@arm.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox