Commit | Line | Data |
---|---|---|
066ce621 MM |
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 | ||
0b722aec MM |
90 | # check the back trace at that location |
91 | gdb_test "backtrace" [join [list \ | |
92 | "#0.*fun3.*at record_goto.c:35.*" \ | |
93 | "#1.*fun4.*at record_goto.c:43.*" \ | |
94 | "#2.*main.*at record_goto.c:49.*" \ | |
95 | "Backtrace stopped: not enough registers or memory available to unwind further" \ | |
96 | ] "\r\n"] | |
97 | ||
98 | # walk the backtrace | |
99 | gdb_test "up" ".*fun4.*at record_goto.c:43.*" "up to fun4" | |
100 | gdb_test "up" ".*main.*at record_goto.c:49.*" "up to main" | |
101 | ||
066ce621 MM |
102 | # the function call history should start at the new location |
103 | gdb_test "record function-call-history /ci -" [join [list \ | |
104 | "8\t fun3\tinst 19,21" \ | |
105 | "9\t fun1\tinst 22,25" \ | |
106 | "10\t fun3\tinst 26,26\r" \ | |
107 | ] "\r\n"] "function-call-history from 26 backwards" | |
108 | ||
109 | # the instruction history should start at the new location | |
110 | gdb_test "record instruction-history -" [join [list \ | |
111 | "24.*" \ | |
112 | "25.*" \ | |
113 | "26.*\r" \ | |
114 | ] "\r\n"] "instruction-history from 26 backwards" | |
115 | ||
116 | # test that we can go to the begin of the trace | |
117 | gdb_test "record goto begin" ".*fun4 \\(\\) at record_goto.c:40.*" | |
118 | ||
119 | # check that we're filling up the context correctly | |
120 | gdb_test "record function-call-history /ci -" [join [list \ | |
121 | "1\tfun4\tinst 1,3" \ | |
122 | "2\t fun1\tinst 4,7" \ | |
123 | "3\tfun4\tinst 8,8" \ | |
124 | ] "\r\n"] "function-call-history from begin backwards" | |
125 | ||
126 | # check that we're filling up the context correctly | |
127 | gdb_test "record instruction-history -" [join [list \ | |
128 | "1.*" \ | |
129 | "2.*" \ | |
130 | "3.*" \ | |
131 | ] "\r\n"] "instruction-history from begin backwards" | |
132 | ||
133 | # we should get the exact same history from the first instruction | |
134 | gdb_test "record goto 2" ".*fun4 \\(\\) at record_goto.c:40.*" | |
135 | ||
136 | # check that we're filling up the context correctly | |
137 | gdb_test "record function-call-history /ci -" [join [list \ | |
138 | "1\tfun4\tinst 1,3" \ | |
139 | "2\t fun1\tinst 4,7" \ | |
140 | "3\tfun4\tinst 8,8" \ | |
141 | ] "\r\n"] "function-call-history from 2 backwards" | |
142 | ||
143 | # check that we're filling up the context correctly | |
144 | gdb_test "record instruction-history -" [join [list \ | |
145 | "1.*" \ | |
146 | "2.*" \ | |
147 | "3.*" \ | |
148 | ] "\r\n"] "instruction-history from 2 backwards" | |
149 | ||
150 | # check that we can go to the end of the trace | |
151 | gdb_test "record goto end" ".*main \\(\\) at record_goto.c:50.*" | |
152 | ||
153 | # check that we're filling up the context correctly | |
154 | gdb_test "record function-call-history /ci" [join [list \ | |
155 | "13\t fun2\tinst 34,35" \ | |
156 | "14\t fun3\tinst 36,37" \ | |
157 | "15\tfun4\tinst 38,39" \ | |
158 | ] "\r\n"] "function-call-history from end forwards" | |
159 | ||
160 | # check that we're filling up the context correctly | |
161 | gdb_test "record instruction-history" [join [list \ | |
162 | "37.*" \ | |
163 | "38.*" \ | |
164 | "39.*" \ | |
165 | ] "\r\n"] "instruction-history from end forwards" | |
166 | ||
167 | # we should get the exact same history from the second to last instruction | |
168 | gdb_test "record goto 38" ".*fun4 \\(\\) at record_goto.c:44.*" | |
169 | ||
170 | # check that we're filling up the context correctly | |
171 | gdb_test "record function-call-history /ci" [join [list \ | |
172 | "13\t fun2\tinst 34,35" \ | |
173 | "14\t fun3\tinst 36,37" \ | |
174 | "15\tfun4\tinst 38,39" \ | |
175 | ] "\r\n"] "function-call-history from 38 forwards" | |
176 | ||
177 | # check that we're filling up the context correctly | |
178 | gdb_test "record instruction-history" [join [list \ | |
179 | "37.*" \ | |
180 | "38.*" \ | |
181 | "39.*" \ | |
182 | ] "\r\n"] "instruction-history from 38 forwards" |