non-trivial-retval.exp revision 1.1.1.7
1# Copyright 2014-2024 Free Software Foundation, Inc.
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16# This file is part of the gdb testsuite
17
18set additional_flags ""
19
20require allow_cplus_tests
21
22standard_testfile .cc
23
24if {[have_fvar_tracking]} {
25    set additional_flags "additional_flags= -fvar-tracking"
26}
27
28if {[prepare_for_testing "failed to prepare" $testfile $srcfile [list debug c++ $additional_flags]]} {
29
30    return -1
31}
32
33if {![runto_main]} {
34    return -1
35}
36
37gdb_breakpoint [gdb_get_line_number "Break here"]
38gdb_continue_to_breakpoint "Break here"
39
40gdb_test "p f1 (i1, i2)" ".* = {a = 123}"
41gdb_test "p f2 (i1, i2)" ".* = {b = 123}"
42gdb_test "p f22 (i1, i2)" ".* = {b1 = 123}"
43gdb_test "p f3 (i1, i2)" ".* = {.* c = 123}"
44gdb_test "p f4 (i1, i2)" ".* = {.* e = 123}"
45
46gdb_breakpoint "f1"
47gdb_breakpoint "f2"
48gdb_breakpoint "f22"
49gdb_breakpoint "f3"
50gdb_breakpoint "f4"
51
52gdb_continue_to_breakpoint "Break in f1"
53gdb_test "finish" " = {a = 123}" \
54    "finish from f1"
55
56gdb_continue_to_breakpoint "Break in f2"
57gdb_test "finish" " = {b = 123}" \
58    "finish from f2"
59
60gdb_continue_to_breakpoint "Break in f22"
61gdb_test "finish" " = {b1 = 123}" \
62    "finish from f22"
63
64gdb_continue_to_breakpoint "Break in f3"
65gdb_test "finish" " = {.* c = 123}" \
66    "finish from f3"
67
68gdb_continue_to_breakpoint "Break in f4"
69gdb_test "finish" " = {.* e = 123}" \
70    "finish from f4"
71