Update Copyright year range in all files maintained by GDB.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.btrace / function_call_history.exp
CommitLineData
2f1d9bdd
MM
1# This testcase is part of GDB, the GNU debugger.
2#
ecd75fc8 3# Copyright 2013-2014 Free Software Foundation, Inc.
2f1d9bdd
MM
4#
5# Contributed by Intel Corp. <christian.himpel@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
21if { [skip_btrace_tests] } { return -1 }
22
23# start inferior
24standard_testfile
25if [prepare_for_testing function_call_history.exp $testfile {} {debug}] {
26 return -1
27}
28if ![runto_main] {
29 return -1
30}
31
32# start btrace
33gdb_test_no_output "record btrace"
34
35# set bp after increment loop and continue
36set bp_location [gdb_get_line_number "bp.1" $testfile.c]
37gdb_breakpoint $bp_location
38gdb_continue_to_breakpoint "cont to $bp_location" ".*$testfile.c:$bp_location.*"
39
40# show function call history with unlimited size, we expect to see all 21 entries
41gdb_test_no_output "set record function-call-history-size 0"
42gdb_test "record function-call-history" "
430\tmain\r
441\tinc\r
452\tmain\r
463\tinc\r
474\tmain\r
485\tinc\r
496\tmain\r
507\tinc\r
518\tmain\r
529\tinc\r
5310\tmain\r
5411\tinc\r
5512\tmain\r
5613\tinc\r
5714\tmain\r
5815\tinc\r
5916\tmain\r
6017\tinc\r
6118\tmain\r
6219\tinc\r
6320\tmain\r" "record function-call-history - with size unlimited"
64
65# show function call history with size of 21, we expect to see all 21 entries
66gdb_test_no_output "set record function-call-history-size 21"
67# show function call history
68gdb_test "record function-call-history 0" "
690\tmain\r
701\tinc\r
712\tmain\r
723\tinc\r
734\tmain\r
745\tinc\r
756\tmain\r
767\tinc\r
778\tmain\r
789\tinc\r
7910\tmain\r
8011\tinc\r
8112\tmain\r
8213\tinc\r
8314\tmain\r
8415\tinc\r
8516\tmain\r
8617\tinc\r
8718\tmain\r
8819\tinc\r
8920\tmain\r" "record function-call-history - show all 21 entries"
90
91# show first 15 entries
92gdb_test_no_output "set record function-call-history-size 15"
93gdb_test "record function-call-history 0" "
940\tmain\r
951\tinc\r
962\tmain\r
973\tinc\r
984\tmain\r
995\tinc\r
1006\tmain\r
1017\tinc\r
1028\tmain\r
1039\tinc\r
10410\tmain\r
10511\tinc\r
10612\tmain\r
10713\tinc\r
10814\tmain\r" "record function-call-history - show first 15 entries"
109
110# show last 6 entries
111gdb_test "record function-call-history +" "
11215\tinc\r
11316\tmain\r
11417\tinc\r
11518\tmain\r
11619\tinc\r
11720\tmain\r" "record function-call-history - show last 6 entries"
118
119# moving further should not work
120gdb_test "record function-call-history +" "At the end of the branch trace record\\." "record function-call-history - at the end (1)"
121
122# make sure we cannot move any further a second time
123gdb_test "record function-call-history +" "At the end of the branch trace record\\." "record function-call-history - at the end (2)"
124
125# moving back showing the latest 15 function calls
126gdb_test "record function-call-history -" "
1276\tmain\r
1287\tinc\r
1298\tmain\r
1309\tinc\r
13110\tmain\r
13211\tinc\r
13312\tmain\r
13413\tinc\r
13514\tmain\r
13615\tinc\r
13716\tmain\r
13817\tinc\r
13918\tmain\r
14019\tinc\r
14120\tmain\r" "record function-call-history - show last 15 entries"
142
143# moving further back shows the 6 first function calls
144gdb_test "record function-call-history -" "
1450\tmain\r
1461\tinc\r
1472\tmain\r
1483\tinc\r
1494\tmain\r
1505\tinc\r" "record function-call-history - show first 6 entries"
151
152# moving further back shouldn't work
153gdb_test "record function-call-history -" "At the start of the branch trace record\\." "record function-call-history - at the start (1)"
154
155# make sure we cannot move any further back
156gdb_test "record function-call-history -" "At the start of the branch trace record\\." "record function-call-history - at the start (2)"
157
158# moving forward again, but this time with file and line number, expected to see the first 15 entries
159gdb_test "record function-call-history /l +" "
160.*$srcfile:40-41\tmain\r
161.*$srcfile:22-24\tinc\r
162.*$srcfile:40-41\tmain\r
163.*$srcfile:22-24\tinc\r
164.*$srcfile:40-41\tmain\r
165.*$srcfile:22-24\tinc\r
166.*$srcfile:40-41\tmain\r
167.*$srcfile:22-24\tinc\r
168.*$srcfile:40-41\tmain\r
169.*$srcfile:22-24\tinc\r
170.*$srcfile:40-41\tmain\r
171.*$srcfile:22-24\tinc\r
172.*$srcfile:40-41\tmain\r
173.*$srcfile:22-24\tinc\r
174.*$srcfile:40-41\tmain\r" "record function-call-history /l - show first 15 entries"
175
176# moving forward and expect to see the latest 6 entries
177gdb_test "record function-call-history /l +" "
178.*$srcfile:22-24\tinc\r
179.*$srcfile:40-41\tmain\r
180.*$srcfile:22-24\tinc\r
181.*$srcfile:40-41\tmain\r
182.*$srcfile:22-24\tinc\r
183.*$srcfile:40-43\tmain\r" "record function-call-history /l - show last 6 entries"
184
185# moving further forward shouldn't work
186gdb_test "record function-call-history /l +" "At the end of the branch trace record\\." "record function-call-history /l - at the end (1)"
187gdb_test "record function-call-history /l" "At the end of the branch trace record\\." "record function-call-history /l - at the end (2)"
188
189set expected_range "3\tinc\r
1904\tmain\r
1915\tinc\r
1926\tmain\r
1937\tinc\r
1948\tmain\r
1959\tinc\r"
196
197# show functions in instruction range
198gdb_test "record function-call-history 3,10" $expected_range "absolute instruction range"
199gdb_test "record function-call-history 3,+7" $expected_range "relative positive instruction range"
200gdb_test "record function-call-history 10,-7" $expected_range "relative negative instruction range"
201
202# set bp after fib recursion and continue
203set bp_location [gdb_get_line_number "bp.2" $testfile.c]
204gdb_breakpoint $bp_location
205gdb_continue_to_breakpoint "cont to $bp_location" ".*$testfile.c:$bp_location.*"
206
207# at this point we expect to have main, fib, ..., fib, main, where fib occurs 8 times,
208# so we limit the output to only show the latest 10 function calls
209gdb_test_no_output "set record function-call-history-size 10"
210set message "show recursive function call history"
211gdb_test_multiple "record function-call-history" $message {
212 -re "13\tmain\r\n14\tfib\r\n15\tfib\r\n16\tfib\r\n17\tfib\r\n18\tfib\r\n19\tfib\r\n20\tfib\r\n21\tfib\r\n22 main\r\n$gdb_prompt $" {
213 pass $message
214 }
215 -re "13\tinc\r\n14\tmain\r\n15\tinc\r\n16\tmain\r\n17\tinc\r\n18\tmain\r\n19\tinc\r\n20\tmain\r\n21\tfib\r\n22\tmain\r\n$gdb_prompt $" {
216 # recursive function calls appear only as 1 call
217 kfail "gdb/15240" $message
218 }
219}
This page took 0.131694 seconds and 4 git commands to generate.