Update copyright year range in all GDB files.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.btrace / tailcall-only.exp
CommitLineData
33b4777c
MM
1# This testcase is part of GDB, the GNU debugger.
2#
b811d2c2 3# Copyright 2016-2020 Free Software Foundation, Inc.
33b4777c
MM
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17#
18#
19# This is a variant of tailcall.exp where the entire trace contains only tail
20# calls. This used to cause a crash in get_frame_type.
21#
22
b5ac99b0
MM
23if { [skip_btrace_tests] } {
24 unsupported "target does not support record-btrace"
25 return -1
26}
33b4777c
MM
27
28# This test requires the compiler to generate a tail call. To guarantee that
29# we always get one, we use an assembly source file.
30#
31# We use different assembly sources based on the target architecture.
32#
33# Luckily, they are similar enough that a single test script can handle
34# both.
35set opts {}
36if [info exists COMPILE] {
37 # make check RUNTESTFLAGS="gdb.btrace/tailcall-only.exp COMPILE=1"
38 standard_testfile tailcall-only.c
39 lappend opts debug optimize=-O2
7674d381 40} elseif {[istarget "i?86-*-*"] || [istarget "x86_64-*-*"]} {
e0461dbb
MM
41 if {[is_amd64_regs_target]} {
42 standard_testfile x86_64-tailcall-only.S
43 } else {
44 standard_testfile i686-tailcall-only.S
45 }
33b4777c 46} else {
b5ac99b0 47 unsupported "target architecture not supported"
e0461dbb 48 return -1
33b4777c
MM
49}
50
5b362f04 51if [prepare_for_testing "failed to prepare" $testfile $srcfile $opts] {
33b4777c
MM
52 return -1
53}
b5ac99b0 54
33b4777c 55if ![runto_main] {
b5ac99b0 56 untested "failed to run to main"
33b4777c
MM
57 return -1
58}
59
60# we want to see the full trace for this test
61gdb_test_no_output "set record function-call-history-size 0"
62
63# trace foo
64gdb_test "step" ".*" "prepare for recording"
65gdb_test_no_output "record btrace"
66gdb_test "stepi 4" ".*" "record branch trace"
67
68# for debugging
69gdb_test "info record" ".*"
70
71# show the branch trace with calls indented
72gdb_test "record function-call-history /c 1" [multi_line \
73 "1\tfoo" \
74 "2\t foo_1" \
75 "3\t bar" \
76 "4\t bar_1"
77 ] "function-call-history"
78
79# We can step
80gdb_test "record goto begin" ".*foo.*"
81gdb_test "stepi" ".*foo_1.*" "step into foo_1"
82gdb_test "step" ".*bar.*" "step into bar"
83gdb_test "stepi" ".*bar_1.*" "step into bar_1"
84
85# We can neither finish nor return.
86gdb_test "finish" "Cannot find the caller frame.*"
87gdb_test_multiple "return" "return" {
88 -re "Make .* return now.*y or n. $" {
89 send_gdb "y\n"
90 exp_continue
91 }
92 -re "Cannot find the caller frame.*$gdb_prompt $" {
93 pass "return"
94 }
95}
96
97# But we can reverse-finish
98gdb_test "reverse-finish" ".*bar.*"
99gdb_test "reverse-step" ".*foo_1.*"
100
101# Info frame isn't useful but doesn't crash as it used to.
102gdb_test "up" ".*foo.*"
103gdb_test "info frame" ".*"
This page took 0.456199 seconds and 4 git commands to generate.