diff options
author | Pedro Alves <palves@redhat.com> | 2017-09-04 20:21:13 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2017-09-04 20:21:13 +0100 |
commit | 54990598c4c74b6af113baf801064d3b1837973f (patch) | |
tree | ae03eeeaca8298edb3fc821edcc4841afbce58df /gdb/valops.c | |
parent | 34d16ea2a144cdac8a89050d9aab723fb675cb45 (diff) | |
download | gdb-54990598c4c74b6af113baf801064d3b1837973f.zip gdb-54990598c4c74b6af113baf801064d3b1837973f.tar.gz gdb-54990598c4c74b6af113baf801064d3b1837973f.tar.bz2 |
Fix calling prototyped functions via function pointers
Calling a prototyped function via a function pointer with the right
prototype doesn't work correctly, if the called function requires
argument coercion... Like, e.g., with:
float mult (float f1, float f2) { return f1 * f2; }
(gdb) p mult (2, 3.5)
$1 = 7
(gdb) p ((float (*) (float, float)) mult) (2, 3.5)
$2 = 0
both calls should have returned the same, of course. The problem is
that GDB misses marking the type of the function pointer target as
prototyped...
Without the fix, the new test fails like this:
(gdb) p ((int (*) (float, float)) t_float_values2)(3.14159,float_val2)
$30 = 0
(gdb) FAIL: gdb.base/callfuncs.exp: p ((int (*) (float, float)) t_float_values2)(3.14159,float_val2)
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* gdbtypes.c (lookup_function_type_with_arguments): Mark function
types with more than one parameter as prototyped.
gdb/testsuite/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* gdb.base/callfuncs.exp (do_function_calls): New parameter
"prototypes". Test calling float functions via prototyped and
unprototyped function pointers.
(perform_all_tests): New parameter "prototypes". Pass it down.
(top level): Pass down "prototypes" parameter to
perform_all_tests.
Diffstat (limited to 'gdb/valops.c')
0 files changed, 0 insertions, 0 deletions