1 # This testcase is part of GDB, the GNU debugger.
3 # Copyright 2013 Free Software Foundation, Inc.
5 # Contributed by Intel Corp. <markus.t.metzger@intel.com>
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.
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.
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/>.
20 # check for btrace support
21 if { [skip_btrace_tests] } { return -1 }
24 standard_testfile x86-record_goto.S
27 if [info exists COMPILE] {
28 # make check RUNTESTFLAGS="gdb.btrace/record_goto.exp COMPILE=1"
29 standard_testfile record_goto.c
31 } elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
32 verbose "Skipping ${testfile}."
36 if [prepare_for_testing record_goto.exp $testfile $srcfile $opts] {
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"
47 # trace the call to the test function
48 gdb_test_no_output "record btrace"
51 # start by listing all functions
52 gdb_test "record function-call-history /ci 1, +20" [join [list \
54 "2\t fun1\tinst 4,7" \
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" \
70 # let's see if we can go back in history
71 gdb_test "record goto 18" ".*fun4 \\(\\) at record_goto.c:43.*"
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"
80 # the instruction history should start at the new location
81 gdb_test "record instruction-history" [join [list \
85 ] "\r\n"] "instruction-history from 18 forwards"
87 # let's go to another place in the history
88 gdb_test "record goto 26" ".*fun3 \\(\\) at record_goto.c:35.*"
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"
97 # the instruction history should start at the new location
98 gdb_test "record instruction-history -" [join [list \
102 ] "\r\n"] "instruction-history from 26 backwards"
104 # test that we can go to the begin of the trace
105 gdb_test "record goto begin" ".*fun4 \\(\\) at record_goto.c:40.*"
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"
114 # check that we're filling up the context correctly
115 gdb_test "record instruction-history -" [join [list \
119 ] "\r\n"] "instruction-history from begin backwards"
121 # we should get the exact same history from the first instruction
122 gdb_test "record goto 2" ".*fun4 \\(\\) at record_goto.c:40.*"
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"
131 # check that we're filling up the context correctly
132 gdb_test "record instruction-history -" [join [list \
136 ] "\r\n"] "instruction-history from 2 backwards"
138 # check that we can go to the end of the trace
139 gdb_test "record goto end" ".*main \\(\\) at record_goto.c:50.*"
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"
148 # check that we're filling up the context correctly
149 gdb_test "record instruction-history" [join [list \
153 ] "\r\n"] "instruction-history from end forwards"
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.*"
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"
165 # check that we're filling up the context correctly
166 gdb_test "record instruction-history" [join [list \
170 ] "\r\n"] "instruction-history from 38 forwards"