Fix more cases of improper test names
[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-2016 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 # The "record goto" command jumps to a specific instruction in the execution
24 # trace. To guarantee that we always get the same execution trace, we use
25 # an assembly source file.
26 #
27 # We use different assembly sources based on the target architecture.
28 #
29 # Luckily, they are similar enough that a single test script can handle
30 # both.
31 set opts {}
32 if [info exists COMPILE] {
33 # make check RUNTESTFLAGS="gdb.btrace/record_goto.exp COMPILE=1"
34 standard_testfile record_goto.c
35 lappend opts debug
36 } elseif {[istarget "i?86-*-*"] || [istarget "x86_64-*-*"]} {
37 if {[is_amd64_regs_target]} {
38 standard_testfile x86_64-record_goto.S
39 } else {
40 standard_testfile i686-record_goto.S
41 }
42 } else {
43 verbose "Skipping ${testfile}."
44 return -1
45 }
46
47 if [prepare_for_testing "failed to prepare" $testfile $srcfile $opts] {
48 return -1
49 }
50 if ![runto_main] {
51 return -1
52 }
53
54 # we want a small context sizes to simplify the test
55 gdb_test_no_output "set record instruction-history-size 3"
56 gdb_test_no_output "set record function-call-history-size 3"
57
58 # trace the call to the test function
59 gdb_test_no_output "record btrace"
60 gdb_test "next"
61
62 # start by listing all functions
63 gdb_test "record function-call-history /ci 1, +20" [multi_line \
64 "1\tmain\tinst 1,1" \
65 "2\t fun4\tinst 2,4" \
66 "3\t fun1\tinst 5,8" \
67 "4\t fun4\tinst 9,9" \
68 "5\t fun2\tinst 10,12" \
69 "6\t fun1\tinst 13,16" \
70 "7\t fun2\tinst 17,18" \
71 "8\t fun4\tinst 19,19" \
72 "9\t fun3\tinst 20,22" \
73 "10\t fun1\tinst 23,26" \
74 "11\t fun3\tinst 27,27" \
75 "12\t fun2\tinst 28,30" \
76 "13\t fun1\tinst 31,34" \
77 "14\t fun2\tinst 35,36" \
78 "15\t fun3\tinst 37,38" \
79 "16\t fun4\tinst 39,40" \
80 ]
81
82 # let's see if we can go back in history
83 gdb_test "record goto 19" ".*fun4 \\(\\) at record_goto.c:43.*"
84
85 # the function call history should start at the new location
86 gdb_test "record function-call-history /ci" [multi_line \
87 "8\t fun4\tinst 19,19" \
88 "9\t fun3\tinst 20,22" \
89 "10\t fun1\tinst 23,26" \
90 ] "function-call-history from 19 forwards"
91
92 # the instruction history should start at the new location
93 gdb_test "record instruction-history" [multi_line \
94 "19.*" \
95 "20.*" \
96 "21.*" \
97 ] "instruction-history from 19 forwards"
98
99 # let's go to another place in the history
100 gdb_test "record goto 27" ".*fun3 \\(\\) at record_goto.c:35.*"
101
102 # check the back trace at that location
103 gdb_test "backtrace" [multi_line \
104 "#0.*fun3.*at record_goto.c:35.*" \
105 "#1.*fun4.*at record_goto.c:43.*" \
106 "#2.*main.*at record_goto.c:49.*" \
107 "Backtrace stopped: not enough registers or memory available to unwind further" \
108 ]
109
110 # walk the backtrace
111 gdb_test "up" ".*fun4.*at record_goto.c:43.*" "up to fun4"
112 gdb_test "up" ".*main.*at record_goto.c:49.*" "up to main"
113
114 # the function call history should start at the new location
115 gdb_test "record function-call-history /ci -" [multi_line \
116 "9\t fun3\tinst 20,22" \
117 "10\t fun1\tinst 23,26" \
118 "11\t fun3\tinst 27,27" \
119 ] "function-call-history from 27 backwards"
120
121 # the instruction history should start at the new location
122 gdb_test "record instruction-history -" [multi_line \
123 "25.*" \
124 "26.*" \
125 "27.*" \
126 ] "instruction-history from 27 backwards"
127
128 # test that we can go to the begin of the trace
129 gdb_test "record goto begin" ".*main \\(\\) at record_goto.c:49.*"
130
131 # check that we're filling up the context correctly
132 gdb_test "record function-call-history /ci -" [multi_line \
133 "1\tmain\tinst 1,1" \
134 "2\t fun4\tinst 2,4" \
135 "3\t fun1\tinst 5,8" \
136 ] "function-call-history from begin backwards"
137
138 # check that we're filling up the context correctly
139 gdb_test "record instruction-history -" [multi_line \
140 "1.*" \
141 "2.*" \
142 "3.*" \
143 ] "instruction-history from begin backwards"
144
145 # we should get the exact same history from the first instruction
146 gdb_test "record goto 2" ".*fun4 \\(\\) at record_goto.c:40.*"
147
148 # check that we're filling up the context correctly
149 gdb_test "record function-call-history /ci -" [multi_line \
150 "1\tmain\tinst 1,1" \
151 "2\t fun4\tinst 2,4" \
152 "3\t fun1\tinst 5,8\r" \
153 ] "function-call-history from 2 backwards"
154
155 # check that we're filling up the context correctly
156 gdb_test "record instruction-history -" [multi_line \
157 "1.*" \
158 "2.*" \
159 "3.*" \
160 ] "instruction-history from 2 backwards"
161
162 # check that we can go to the end of the trace
163 gdb_test "record goto end" ".*main \\(\\) at record_goto.c:50.*"
164
165 # check that we're filling up the context correctly
166 gdb_test "record function-call-history /ci" [multi_line \
167 "14\t fun2\tinst 35,36" \
168 "15\t fun3\tinst 37,38" \
169 "16\t fun4\tinst 39,40" \
170 ] "function-call-history from end forwards"
171
172 # check that we're filling up the context correctly
173 gdb_test "record instruction-history" [multi_line \
174 "38.*" \
175 "39.*" \
176 "40.*\r" \
177 ] "instruction-history from end forwards"
178
179 # we should get the exact same history from the second to last instruction
180 gdb_test "record goto 39" ".*fun4 \\(\\) at record_goto.c:44.*"
181
182 # check that we're filling up the context correctly
183 gdb_test "record function-call-history /ci" [multi_line \
184 "14\t fun2\tinst 35,36" \
185 "15\t fun3\tinst 37,38" \
186 "16\t fun4\tinst 39,40\r" \
187 ] "function-call-history from 39 forwards"
188
189 # check that we're filling up the context correctly
190 gdb_test "record instruction-history" [multi_line \
191 "38.*" \
192 "39.*" \
193 "40.*\r" \
194 ] "instruction-history from 39 forwards"
This page took 0.035539 seconds and 5 git commands to generate.