xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.btrace/stepi.exp (revision a24efa7dea9f1f56c3bdb15a927d3516792ace1c)
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
21if { [skip_btrace_tests] } { return -1 }
22
23# start inferior
24standard_testfile x86-record_goto.S
25if [prepare_for_testing stepi.exp $testfile $srcfile] {
26    return -1
27}
28
29global gdb_prompt
30
31if ![runto_main] {
32    return -1
33}
34
35proc check_replay_at { insn } {
36  gdb_test "info record" [join [list \
37    "Active record target: record-btrace" \
38    "Recorded 40 instructions in 16 functions for .*" \
39    "Replay in progress\.  At instruction $insn\." \
40    ] "\r\n"]
41}
42
43# trace the call to the test function
44gdb_test_no_output "record btrace"
45gdb_test "next"
46
47# we start with stepping to make sure that the trace is fetched automatically
48gdb_test "reverse-stepi" ".*fun4\.5.*"
49gdb_test "reverse-stepi" ".*fun4\.5.*"
50
51# let's check where we are in the trace
52with_test_prefix "reverse-stepi to 39" { check_replay_at 39 }
53
54# let's step forward and check again
55gdb_test "stepi" ".*fun4\.5.*"
56with_test_prefix "stepi to 40" { check_replay_at 40 }
57
58# with the next step, we stop replaying
59gdb_test "stepi" ".*main\.3.*"
60gdb_test "info record" [join [list \
61  "Active record target: record-btrace" \
62  "Recorded 40 instructions in 16 functions for \[^\\\r\\\n\]*" \
63  ] "\r\n"] "stepi to live"
64
65# let's step from a goto position somewhere in the middle
66gdb_test "record goto 22" ".*fun3\.2.*"
67with_test_prefix "goto 22" { check_replay_at 22 }
68
69gdb_test "stepi" ".*fun1\.1.*"
70with_test_prefix "stepi to 23" { check_replay_at 23 }
71
72# and back again
73gdb_test "reverse-stepi" ".*fun3\.2.*"
74gdb_test "reverse-stepi" ".*fun3\.1.*"
75with_test_prefix "reverse-stepi to 21" { check_replay_at 21 }
76
77# let's try to step off the left end
78gdb_test "record goto begin" ".*main\.2.*"
79with_test_prefix "goto begin" { check_replay_at 1 }
80
81gdb_test "reverse-stepi" "No more reverse-execution history\.\r\n.*main\.2.*"
82gdb_test "reverse-stepi" "No more reverse-execution history\.\r\n.*main\.2.*"
83with_test_prefix "reverse-stepi at begin" { check_replay_at 1 }
84
85# we can step forward, though
86gdb_test "stepi" ".*fun4\.1.*"
87with_test_prefix "stepi to 2" { check_replay_at 2 }
88
89# let's try to step off the left end again
90gdb_test "reverse-stepi" ".*main\.2.*"
91gdb_test "reverse-stepi" "No more reverse-execution history\.\r\n.*main\.2.*"
92gdb_test "reverse-stepi" "No more reverse-execution history\.\r\n.*main\.2.*"
93with_test_prefix "reverse-stepi at begin" { check_replay_at 1 }
94