record-btrace: add record goto target methods
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.btrace / record_goto.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-record_goto.S
25
26 set opts {}
27 if [info exists COMPILE] {
28 # make check RUNTESTFLAGS="gdb.btrace/record_goto.exp COMPILE=1"
29 standard_testfile record_goto.c
30 lappend opts debug
31 } elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
32 verbose "Skipping ${testfile}."
33 return
34 }
35
36 if [prepare_for_testing record_goto.exp $testfile $srcfile $opts] {
37 return -1
38 }
39 if ![runto_main] {
40 return -1
41 }
42
43 # we want a small context sizes to simplify the test
44 gdb_test_no_output "set record instruction-history-size 3"
45 gdb_test_no_output "set record function-call-history-size 3"
46
47 # trace the call to the test function
48 gdb_test_no_output "record btrace"
49 gdb_test "next"
50
51 # start by listing all functions
52 gdb_test "record function-call-history /ci 1, +20" [join [list \
53 "1\tfun4\tinst 1,3" \
54 "2\t fun1\tinst 4,7" \
55 "3\tfun4\tinst 8,8" \
56 "4\t fun2\tinst 9,11" \
57 "5\t fun1\tinst 12,15" \
58 "6\t fun2\tinst 16,17" \
59 "7\tfun4\tinst 18,18" \
60 "8\t fun3\tinst 19,21" \
61 "9\t fun1\tinst 22,25" \
62 "10\t fun3\tinst 26,26" \
63 "11\t fun2\tinst 27,29" \
64 "12\t fun1\tinst 30,33" \
65 "13\t fun2\tinst 34,35" \
66 "14\t fun3\tinst 36,37" \
67 "15\tfun4\tinst 38,39" \
68 ] "\r\n"]
69
70 # let's see if we can go back in history
71 gdb_test "record goto 18" ".*fun4 \\(\\) at record_goto.c:43.*"
72
73 # the function call history should start at the new location
74 gdb_test "record function-call-history /ci" [join [list \
75 "7\tfun4\tinst 18,18" \
76 "8\t fun3\tinst 19,21" \
77 "9\t fun1\tinst 22,25" \
78 ] "\r\n"] "function-call-history from 18 forwards"
79
80 # the instruction history should start at the new location
81 gdb_test "record instruction-history" [join [list \
82 "18.*" \
83 "19.*" \
84 "20.*" \
85 ] "\r\n"] "instruction-history from 18 forwards"
86
87 # let's go to another place in the history
88 gdb_test "record goto 26" ".*fun3 \\(\\) at record_goto.c:35.*"
89
90 # the function call history should start at the new location
91 gdb_test "record function-call-history /ci -" [join [list \
92 "8\t fun3\tinst 19,21" \
93 "9\t fun1\tinst 22,25" \
94 "10\t fun3\tinst 26,26\r" \
95 ] "\r\n"] "function-call-history from 26 backwards"
96
97 # the instruction history should start at the new location
98 gdb_test "record instruction-history -" [join [list \
99 "24.*" \
100 "25.*" \
101 "26.*\r" \
102 ] "\r\n"] "instruction-history from 26 backwards"
103
104 # test that we can go to the begin of the trace
105 gdb_test "record goto begin" ".*fun4 \\(\\) at record_goto.c:40.*"
106
107 # check that we're filling up the context correctly
108 gdb_test "record function-call-history /ci -" [join [list \
109 "1\tfun4\tinst 1,3" \
110 "2\t fun1\tinst 4,7" \
111 "3\tfun4\tinst 8,8" \
112 ] "\r\n"] "function-call-history from begin backwards"
113
114 # check that we're filling up the context correctly
115 gdb_test "record instruction-history -" [join [list \
116 "1.*" \
117 "2.*" \
118 "3.*" \
119 ] "\r\n"] "instruction-history from begin backwards"
120
121 # we should get the exact same history from the first instruction
122 gdb_test "record goto 2" ".*fun4 \\(\\) at record_goto.c:40.*"
123
124 # check that we're filling up the context correctly
125 gdb_test "record function-call-history /ci -" [join [list \
126 "1\tfun4\tinst 1,3" \
127 "2\t fun1\tinst 4,7" \
128 "3\tfun4\tinst 8,8" \
129 ] "\r\n"] "function-call-history from 2 backwards"
130
131 # check that we're filling up the context correctly
132 gdb_test "record instruction-history -" [join [list \
133 "1.*" \
134 "2.*" \
135 "3.*" \
136 ] "\r\n"] "instruction-history from 2 backwards"
137
138 # check that we can go to the end of the trace
139 gdb_test "record goto end" ".*main \\(\\) at record_goto.c:50.*"
140
141 # check that we're filling up the context correctly
142 gdb_test "record function-call-history /ci" [join [list \
143 "13\t fun2\tinst 34,35" \
144 "14\t fun3\tinst 36,37" \
145 "15\tfun4\tinst 38,39" \
146 ] "\r\n"] "function-call-history from end forwards"
147
148 # check that we're filling up the context correctly
149 gdb_test "record instruction-history" [join [list \
150 "37.*" \
151 "38.*" \
152 "39.*" \
153 ] "\r\n"] "instruction-history from end forwards"
154
155 # we should get the exact same history from the second to last instruction
156 gdb_test "record goto 38" ".*fun4 \\(\\) at record_goto.c:44.*"
157
158 # check that we're filling up the context correctly
159 gdb_test "record function-call-history /ci" [join [list \
160 "13\t fun2\tinst 34,35" \
161 "14\t fun3\tinst 36,37" \
162 "15\tfun4\tinst 38,39" \
163 ] "\r\n"] "function-call-history from 38 forwards"
164
165 # check that we're filling up the context correctly
166 gdb_test "record instruction-history" [join [list \
167 "37.*" \
168 "38.*" \
169 "39.*" \
170 ] "\r\n"] "instruction-history from 38 forwards"
This page took 0.035644 seconds and 5 git commands to generate.