Fix function call regression in new evaluator
The internal AdaCore test suite revealed a bug in the new evaluator. A hunk of evaluate_funcall was not correctly transcribed. This was not caught in my original testing because the feature in question was apparently not tested in gdb. This patch fixes the oversight. The idea here is that ordinary function calls should use the function's formal parameter types as the expected types of subexpressions. Regression tested on x86-64 Fedora 32. gdb/ChangeLog 2021-03-09 Tom Tromey <tromey@adacore.com> * eval.c (operation::evaluate_funcall): Use function formal parameter types when evaluating. gdb/testsuite/ChangeLog 2021-03-09 Tom Tromey <tromey@adacore.com> * gdb.base/cast-call.exp: New file. * gdb.base/cast-call.c: New file.
This commit is contained in:
parent
5dc75cf325
commit
ccdc02ed07
@ -1,3 +1,8 @@
|
||||
2021-03-09 Tom Tromey <tromey@adacore.com>
|
||||
|
||||
* eval.c (operation::evaluate_funcall): Use function formal
|
||||
parameter types when evaluating.
|
||||
|
||||
2021-03-09 Andrew Burgess <andrew.burgess@embecosm.com>
|
||||
|
||||
* gdb-gdb.py.in (StructMainTypePrettyPrinter) <owner_to_string>:
|
||||
|
||||
10
gdb/eval.c
10
gdb/eval.c
@ -687,8 +687,16 @@ operation::evaluate_funcall (struct type *expect_type,
|
||||
std::vector<value *> vals (args.size ());
|
||||
|
||||
value *callee = evaluate_with_coercion (exp, noside);
|
||||
struct type *type = value_type (callee);
|
||||
if (type->code () == TYPE_CODE_PTR)
|
||||
type = TYPE_TARGET_TYPE (type);
|
||||
for (int i = 0; i < args.size (); ++i)
|
||||
vals[i] = args[i]->evaluate_with_coercion (exp, noside);
|
||||
{
|
||||
if (i < type->num_fields ())
|
||||
vals[i] = args[i]->evaluate (type->field (i).type (), exp, noside);
|
||||
else
|
||||
vals[i] = args[i]->evaluate_with_coercion (exp, noside);
|
||||
}
|
||||
|
||||
return evaluate_subexp_do_call (exp, noside, callee, vals,
|
||||
function_name, expect_type);
|
||||
|
||||
@ -1,3 +1,8 @@
|
||||
2021-03-09 Tom Tromey <tromey@adacore.com>
|
||||
|
||||
* gdb.base/cast-call.exp: New file.
|
||||
* gdb.base/cast-call.c: New file.
|
||||
|
||||
2021-03-09 Andrew Burgess <andrew.burgess@embecosm.com>
|
||||
|
||||
* gdb.gdb/python-helper.exp: New file.
|
||||
|
||||
37
gdb/testsuite/gdb.base/cast-call.c
Normal file
37
gdb/testsuite/gdb.base/cast-call.c
Normal file
@ -0,0 +1,37 @@
|
||||
/* This testcase is part of GDB, the GNU debugger.
|
||||
|
||||
Copyright 2021 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
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
struct thestruct
|
||||
{
|
||||
int x;
|
||||
};
|
||||
|
||||
int
|
||||
f (struct thestruct value)
|
||||
{
|
||||
return value.x;
|
||||
}
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
struct thestruct y;
|
||||
y.x = 0;
|
||||
|
||||
int result = f (y); /* STOP */
|
||||
return 0;
|
||||
}
|
||||
38
gdb/testsuite/gdb.base/cast-call.exp
Normal file
38
gdb/testsuite/gdb.base/cast-call.exp
Normal file
@ -0,0 +1,38 @@
|
||||
# This testcase is part of GDB, the GNU debugger.
|
||||
|
||||
# Copyright 2021 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
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
if {[target_info exists gdb,cannot_call_functions]} {
|
||||
unsupported "this target can not call functions"
|
||||
continue
|
||||
}
|
||||
|
||||
standard_testfile .c
|
||||
|
||||
if { [prepare_for_testing "failed to prepare" ${testfile} $srcfile] } {
|
||||
return -1
|
||||
}
|
||||
|
||||
if {![runto_main]} {
|
||||
untested "could not run to main"
|
||||
return -1
|
||||
}
|
||||
|
||||
gdb_breakpoint [gdb_get_line_number "STOP"]
|
||||
gdb_continue_to_breakpoint "STOP"
|
||||
|
||||
gdb_test "print f({73})" " = 73" "call f with braced argument"
|
||||
Loading…
Reference in New Issue
Block a user