c9329009ae655c74df03ad1ad0a743aa2de16565
[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-2015 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\tmain\tinst 1,1" \
54 "2\t fun4\tinst 2,4" \
55 "3\t fun1\tinst 5,8" \
56 "4\t fun4\tinst 9,9" \
57 "5\t fun2\tinst 10,12" \
58 "6\t fun1\tinst 13,16" \
59 "7\t fun2\tinst 17,18" \
60 "8\t fun4\tinst 19,19" \
61 "9\t fun3\tinst 20,22" \
62 "10\t fun1\tinst 23,26" \
63 "11\t fun3\tinst 27,27" \
64 "12\t fun2\tinst 28,30" \
65 "13\t fun1\tinst 31,34" \
66 "14\t fun2\tinst 35,36" \
67 "15\t fun3\tinst 37,38" \
68 "16\t fun4\tinst 39,40" \
69 ] "\r\n"]
70
71 # let's see if we can go back in history
72 gdb_test "record goto 19" ".*fun4 \\(\\) at record_goto.c:43.*"
73
74 # the function call history should start at the new location
75 gdb_test "record function-call-history /ci" [join [list \
76 "8\t fun4\tinst 19,19" \
77 "9\t fun3\tinst 20,22" \
78 "10\t fun1\tinst 23,26" \
79 ] "\r\n"] "function-call-history from 19 forwards"
80
81 # the instruction history should start at the new location
82 gdb_test "record instruction-history" [join [list \
83 "19.*" \
84 "20.*" \
85 "21.*" \
86 ] "\r\n"] "instruction-history from 19 forwards"
87
88 # let's go to another place in the history
89 gdb_test "record goto 27" ".*fun3 \\(\\) at record_goto.c:35.*"
90
91 # check the back trace at that location
92 gdb_test "backtrace" [join [list \
93 "#0.*fun3.*at record_goto.c:35.*" \
94 "#1.*fun4.*at record_goto.c:43.*" \
95 "#2.*main.*at record_goto.c:49.*" \
96 "Backtrace stopped: not enough registers or memory available to unwind further" \
97 ] "\r\n"]
98
99 # walk the backtrace
100 gdb_test "up" ".*fun4.*at record_goto.c:43.*" "up to fun4"
101 gdb_test "up" ".*main.*at record_goto.c:49.*" "up to main"
102
103 # the function call history should start at the new location
104 gdb_test "record function-call-history /ci -" [join [list \
105 "9\t fun3\tinst 20,22" \
106 "10\t fun1\tinst 23,26" \
107 "11\t fun3\tinst 27,27" \
108 ] "\r\n"] "function-call-history from 27 backwards"
109
110 # the instruction history should start at the new location
111 gdb_test "record instruction-history -" [join [list \
112 "25.*" \
113 "26.*" \
114 "27.*" \
115 ] "\r\n"] "instruction-history from 27 backwards"
116
117 # test that we can go to the begin of the trace
118 gdb_test "record goto begin" ".*main \\(\\) at record_goto.c:49.*"
119
120 # check that we're filling up the context correctly
121 gdb_test "record function-call-history /ci -" [join [list \
122 "1\tmain\tinst 1,1" \
123 "2\t fun4\tinst 2,4" \
124 "3\t fun1\tinst 5,8" \
125 ] "\r\n"] "function-call-history from begin backwards"
126
127 # check that we're filling up the context correctly
128 gdb_test "record instruction-history -" [join [list \
129 "1.*" \
130 "2.*" \
131 "3.*" \
132 ] "\r\n"] "instruction-history from begin backwards"
133
134 # we should get the exact same history from the first instruction
135 gdb_test "record goto 2" ".*fun4 \\(\\) at record_goto.c:40.*"
136
137 # check that we're filling up the context correctly
138 gdb_test "record function-call-history /ci -" [join [list \
139 "1\tmain\tinst 1,1" \
140 "2\t fun4\tinst 2,4" \
141 "3\t fun1\tinst 5,8\r" \
142 ] "\r\n"] "function-call-history from 2 backwards"
143
144 # check that we're filling up the context correctly
145 gdb_test "record instruction-history -" [join [list \
146 "1.*" \
147 "2.*" \
148 "3.*" \
149 ] "\r\n"] "instruction-history from 2 backwards"
150
151 # check that we can go to the end of the trace
152 gdb_test "record goto end" ".*main \\(\\) at record_goto.c:50.*"
153
154 # check that we're filling up the context correctly
155 gdb_test "record function-call-history /ci" [join [list \
156 "14\t fun2\tinst 35,36" \
157 "15\t fun3\tinst 37,38" \
158 "16\t fun4\tinst 39,40" \
159 ] "\r\n"] "function-call-history from end forwards"
160
161 # check that we're filling up the context correctly
162 gdb_test "record instruction-history" [join [list \
163 "38.*" \
164 "39.*" \
165 "40.*\r" \
166 ] "\r\n"] "instruction-history from end forwards"
167
168 # we should get the exact same history from the second to last instruction
169 gdb_test "record goto 39" ".*fun4 \\(\\) at record_goto.c:44.*"
170
171 # check that we're filling up the context correctly
172 gdb_test "record function-call-history /ci" [join [list \
173 "14\t fun2\tinst 35,36" \
174 "15\t fun3\tinst 37,38" \
175 "16\t fun4\tinst 39,40\r" \
176 ] "\r\n"] "function-call-history from 39 forwards"
177
178 # check that we're filling up the context correctly
179 gdb_test "record instruction-history" [join [list \
180 "38.*" \
181 "39.*" \
182 "40.*\r" \
183 ] "\r\n"] "instruction-history from 39 forwards"
This page took 0.032618 seconds and 3 git commands to generate.