23988f2235938de638cb23e4f58289e1388db032
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.btrace / tailcall.exp
1 # This testcase is part of GDB, the GNU debugger.
2 #
3 # Copyright 2013 Free Software Foundation, Inc.
4 #
5 # Contributed by Intel Corp. <markus.t.metzger@intel.com>
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20 # check for btrace support
21 if { [skip_btrace_tests] } { return -1 }
22
23 # start inferior
24 standard_testfile x86-tailcall.S
25
26 set opts {}
27 if [info exists COMPILE] {
28 # make check RUNTESTFLAGS="gdb.btrace/tailcall.exp COMPILE=1"
29 standard_testfile x86-tailcall.c
30 lappend opts debug optimize=-O2
31 } elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
32 verbose "Skipping ${testfile}."
33 return
34 }
35
36 if [prepare_for_testing tailcall.exp $testfile $srcfile $opts] {
37 return -1
38 }
39 if ![runto_main] {
40 return -1
41 }
42
43 # we want to see the full trace for this test
44 gdb_test_no_output "set record function-call-history-size 0"
45
46 # trace the call to foo
47 gdb_test_no_output "record btrace"
48 gdb_test "next"
49
50 # show the flat branch trace
51 gdb_test "record function-call-history 1" [join [list \
52 "1\tmain" \
53 "2\tfoo" \
54 "3\tbar" \
55 "4\tmain" \
56 ] "\r\n"] "flat"
57
58 # show the branch trace with calls indented
59 gdb_test "record function-call-history /c 1" [join [list \
60 "1\tmain" \
61 "2\t foo" \
62 "3\t bar" \
63 "4\tmain" \
64 ] "\r\n"] "indented"
65
66 # go into bar
67 gdb_test "record goto 4" ".*bar \\(\\) at .*x86-tailcall.c:24\r\n.*"
68
69 # check the backtrace
70 gdb_test "backtrace" [join [list \
71 "#0.*bar \\(\\) at x86-tailcall.c:24" \
72 "#1.*foo \\(\\) at x86-tailcall.c:29" \
73 "#2.*main \\(\\) at x86-tailcall.c:37" \
74 "Backtrace stopped: not enough registers or memory available to unwind further" \
75 ] "\r\n"]
76
77 # walk the backtrace
78 gdb_test "up" "#1\[^\r\n\]*foo \\(\\) at x86-tailcall.c:29\r\n.*" "up to foo"
79 gdb_test "up" "#2\[^\r\n\]*main \\(\\) at x86-tailcall.c:37\r\n.*" "up to main"
This page took 0.031942 seconds and 4 git commands to generate.