binutils-gdb/gdb/testsuite/gdb.base/retval-large-struct.exp
Carl Love f68eca29d3 PowerPC, fix gdb.base/retval-large-struct.exp
Support for printining non-trivial return values was recently added in
commit:

  commit a0eda3df5b
  Author: Carl Love <cel@us.ibm.com>
  Date:   Mon Nov 14 16:22:37 2022 -0500

    PowerPC, fix support for printing the function return value for non-trivial values.

The functionality can now be used to fix gdb.base/retval-large-struct.exp.
The test just needs to be compiled with -fvar-tracking to enable GDB to
determine the address off the return buffer when the function is called.

The current output from the test:

34        return big_struct;
(gdb) PASS: gdb.base/retval-large-struct.exp: continue to breakpoint: Break in print_large_struct
finish
warning: Cannot determine the function return value.
Try compiling with -fvar-tracking.
Run till exit from #0  return_large_struct () at binutils-gdb-current/gdb/testsuite/gdb.base/retval-large-struct.c:34
main (argc=1, argv=0x7fffffffcd58) at binutils-gdb-current/gdb/testsuite/gdb.base/retval-large-struct.c:44
44        return 0;
Value returned has type: struct big_struct_t. Cannot determine contents
(gdb) FAIL: gdb.base/retval-large-struct.exp: finish from return_large_struct
testcase binutils-gdb-current/gdb/testsuite/gdb.base/retval-large-struct.exp completed in 1 seconds

This patch adds the command line argument -fvar-tracking to enable gdb to
determine the return vaule and thus fixing the test.

Patch tested on Power 10 with no regressions.
2022-11-17 11:40:00 -05:00

44 lines
1.4 KiB
Plaintext

# Copyright 2022 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/>.
# This file is part of the gdb testsuite
#
# Test if "finish" behaves correctly when a function returns a
# large (> 16 bytes) struct.
standard_testfile
set additional_flags ""
if {[have_fvar_tracking]} {
set additional_flags "additional_flags= -fvar-tracking"
}
if {[prepare_for_testing "failed to prepare" $testfile $srcfile [list debug $additional_flags]]} {
return -1
}
if {![runto_main]} {
return -1
}
set pattern ".* = \\{int_array = \\{1, 2, 3, 4, 5\\}, double_array = \\{3.25, 5, 6.25, 1.325, -1.95\\}, char_array = \"abcde\"\\}"
gdb_test "p return_large_struct ()" $pattern
gdb_breakpoint "return_large_struct"
gdb_continue_to_breakpoint "Break in print_large_struct"
gdb_test "finish" $pattern "finish from return_large_struct"