1 # This testcase is part of GDB, the GNU debugger.
3 # Copyright 2016 Free Software Foundation, Inc.
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.
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.
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/>.
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.
23 # check for btrace support
24 if { [skip_btrace_tests] } { return -1 }
26 # This test requires the compiler to generate a tail call. To guarantee that
27 # we always get one, we use an assembly source file.
29 # We use different assembly sources based on the target architecture.
31 # Luckily, they are similar enough that a single test script can handle
34 if [info exists COMPILE] {
35 # make check RUNTESTFLAGS="gdb.btrace/tailcall-only.exp COMPILE=1"
36 standard_testfile tailcall-only.c
37 lappend opts debug optimize=-O2
38 } elseif {[istarget "x86_64-*-*"] && [is_lp64_target]} {
39 standard_testfile x86_64-tailcall-only.S
40 } elseif {[istarget "i?86-*-*"] || [istarget "x86_64-*-*"]} {
41 standard_testfile i686-tailcall-only.S
43 verbose "Skipping ${testfile}."
47 if [prepare_for_testing tailcall-only.exp $testfile $srcfile $opts] {
54 # we want to see the full trace for this test
55 gdb_test_no_output "set record function-call-history-size 0"
58 gdb_test "step" ".*" "prepare for recording"
59 gdb_test_no_output "record btrace"
60 gdb_test "stepi 4" ".*" "record branch trace"
63 gdb_test "info record" ".*"
65 # show the branch trace with calls indented
66 gdb_test "record function-call-history /c 1" [multi_line \
71 ] "function-call-history"
74 gdb_test "record goto begin" ".*foo.*"
75 gdb_test "stepi" ".*foo_1.*" "step into foo_1"
76 gdb_test "step" ".*bar.*" "step into bar"
77 gdb_test "stepi" ".*bar_1.*" "step into bar_1"
79 # We can neither finish nor return.
80 gdb_test "finish" "Cannot find the caller frame.*"
81 gdb_test_multiple "return" "return" {
82 -re "Make .* return now.*y or n. $" {
86 -re "Cannot find the caller frame.*$gdb_prompt $" {
91 # But we can reverse-finish
92 gdb_test "reverse-finish" ".*bar.*"
93 gdb_test "reverse-step" ".*foo_1.*"
95 # Info frame isn't useful but doesn't crash as it used to.
96 gdb_test "up" ".*foo.*"
97 gdb_test "info frame" ".*"