record-btrace: optionally indent function call history
[external/binutils.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\tfoo" \
53   "2\tbar" \
54   "3\tmain" \
55   ] "\r\n"] "flat"
56
57 # show the branch trace with calls indented
58 gdb_test "record function-call-history /c 1" [join [list \
59   "1\t  foo" \
60   "2\t    bar" \
61   "3\tmain" \
62   ] "\r\n"] "indented"