Update copyright year range in all GDB files
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.btrace / stepi.exp
... / ...
CommitLineData
1# This testcase is part of GDB, the GNU debugger.
2#
3# Copyright 2013-2021 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
20if { [skip_btrace_tests] } {
21 unsupported "target does not support record-btrace"
22 return -1
23}
24
25# This test is stepping on instruction level. To guarantee that we always
26# get the same execution trace, we use an assembly source file.
27#
28# We use different assembly sources based on the target architecture.
29#
30# Luckily, they are similar enough that a single test script can handle
31# both.
32if [info exists COMPILE] {
33 # make check RUNTESTFLAGS="gdb.btrace/stepi.exp COMPILE=1"
34 standard_testfile record_goto.c
35 lappend opts debug
36} elseif {[istarget "i?86-*-*"] || [istarget "x86_64-*-*"]} {
37 if {[is_amd64_regs_target]} {
38 standard_testfile x86_64-record_goto.S
39 } else {
40 standard_testfile i686-record_goto.S
41 }
42} else {
43 unsupported "target architecture not supported"
44 return -1
45}
46
47if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
48 return -1
49}
50
51if ![runto_main] {
52 untested "failed to run to main"
53 return -1
54}
55
56global gdb_prompt
57
58proc check_replay_at { insn } {
59 gdb_test "info record" [multi_line \
60 "Active record target: record-btrace" \
61 ".*" \
62 "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for .*" \
63 "Replay in progress\. At instruction $insn\." \
64 ] "check replay at $insn"
65}
66
67# trace the call to the test function
68with_test_prefix "record" {
69 gdb_test_no_output "record btrace"
70 gdb_test "next" ".*" "next.1"
71}
72
73# we start with stepping to make sure that the trace is fetched automatically
74with_test_prefix "fetch" {
75 gdb_test "reverse-stepi" ".*fun4\.5.*" "reverse-stepi.1"
76 gdb_test "reverse-stepi" ".*fun4\.5.*" "reverse-stepi.2"
77
78 # let's check where we are in the trace
79 check_replay_at 39
80}
81
82# let's step forward and check again
83with_test_prefix "stepi" {
84 gdb_test "stepi" ".*fun4\.5.*"
85 check_replay_at 40
86}
87
88# with the next step, we stop replaying
89with_test_prefix "end" {
90 gdb_test "stepi" ".*main\.3.*"
91 gdb_test "info record" [multi_line \
92 "Active record target: record-btrace" \
93 ".*" \
94 "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \
95 ]
96}
97
98# let's try nexti
99with_test_prefix "reverse-nexti.1" {
100 gdb_test "reverse-nexti" ".*main\.2.*"
101 check_replay_at 1
102}
103
104# we can't reverse-nexti any further
105with_test_prefix "reverse-nexti.2" {
106 gdb_test "reverse-nexti" \
107 "No more reverse-execution history\.\r\n.*main\.2.*" \
108 "reverse-nexti.2"
109 check_replay_at 1
110}
111
112# but we can step back again
113with_test_prefix "nexti" {
114 gdb_test "nexti" ".*main\.3.*"
115 gdb_test "info record" [multi_line \
116 "Active record target: record-btrace" \
117 ".*" \
118 "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \
119 ]
120}
121
122# let's step from a goto position somewhere in the middle
123with_test_prefix "goto" {
124 gdb_test "record goto 22" ".*fun3\.2.*"
125 with_test_prefix "goto 22" { check_replay_at 22 }
126
127 gdb_test "stepi" ".*fun1\.1.*" "stepi.3"
128 with_test_prefix "stepi to 23" { check_replay_at 23 }
129
130 gdb_test "reverse-stepi" ".*fun3\.2.*" "reverse-stepi.3"
131 with_test_prefix "reverse-stepi to 22" { check_replay_at 22 }
132
133 gdb_test "nexti" ".*fun3\.3.*"
134 with_test_prefix "nexti to 27" { check_replay_at 27 }
135
136 gdb_test "reverse-nexti" ".*fun3\.2.*" "reverse-nexti.3"
137 with_test_prefix "reverse-nexti to 22" { check_replay_at 22 }
138}
139
140# let's try to step off the left end
141with_test_prefix "goto begin" {
142 gdb_test "record goto begin" ".*main\.2.*"
143 check_replay_at 1
144
145 with_test_prefix "reverse-stepi" {
146 gdb_test "reverse-stepi" \
147 "No more reverse-execution history\.\r\n.*main\.2.*" \
148 "reverse-stepi.1"
149 gdb_test "reverse-stepi" \
150 "No more reverse-execution history\.\r\n.*main\.2.*" \
151 "reverse-stepi.2"
152 check_replay_at 1
153 }
154
155 with_test_prefix "reverse-nexti" {
156 gdb_test "reverse-nexti" \
157 "No more reverse-execution history\.\r\n.*main\.2.*" \
158 "reverse-nexti.1"
159 gdb_test "reverse-nexti" \
160 "No more reverse-execution history\.\r\n.*main\.2.*" \
161 "reverse-nexti.2"
162 check_replay_at 1
163 }
164
165 # we can step forward, though
166 with_test_prefix "stepi" {
167 gdb_test "stepi" ".*fun4\.1.*"
168 check_replay_at 2
169 }
170}
171
172# let's try to step off the left end again
173with_test_prefix "reverse-stepi" {
174 gdb_test "reverse-stepi" ".*main\.2.*" "reverse-stepi.1"
175 gdb_test "reverse-stepi" \
176 "No more reverse-execution history\.\r\n.*main\.2.*" \
177 "reverse-stepi.2"
178 gdb_test "reverse-stepi" \
179 "No more reverse-execution history\.\r\n.*main\.2.*" \
180 "reverse-stepi.3"
181 check_replay_at 1
182}
This page took 0.024443 seconds and 4 git commands to generate.