]>
Commit | Line | Data |
---|---|---|
52834460 MM |
1 | # This testcase is part of GDB, the GNU debugger. |
2 | # | |
213516ef | 3 | # Copyright 2013-2023 Free Software Foundation, Inc. |
52834460 MM |
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 | ||
b5ac99b0 MM |
20 | if { [skip_btrace_tests] } { |
21 | unsupported "target does not support record-btrace" | |
22 | return -1 | |
23 | } | |
52834460 | 24 | |
66849923 MM |
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. | |
e0461dbb MM |
32 | if [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 | } | |
66849923 | 42 | } else { |
b5ac99b0 | 43 | unsupported "target architecture not supported" |
e0461dbb | 44 | return -1 |
66849923 MM |
45 | } |
46 | ||
26ed1478 | 47 | if [prepare_for_testing "failed to prepare" $testfile $srcfile {}] { |
52834460 MM |
48 | return -1 |
49 | } | |
50 | ||
52834460 MM |
51 | if ![runto_main] { |
52 | return -1 | |
53 | } | |
54 | ||
b5ac99b0 MM |
55 | global gdb_prompt |
56 | ||
52834460 | 57 | proc check_replay_at { insn } { |
3c724c8c | 58 | gdb_test "info record" [multi_line \ |
52834460 | 59 | "Active record target: record-btrace" \ |
66849923 | 60 | ".*" \ |
31fd9caa | 61 | "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for .*" \ |
52834460 | 62 | "Replay in progress\. At instruction $insn\." \ |
1a1c0afc | 63 | ] "check replay at $insn" |
52834460 MM |
64 | } |
65 | ||
66 | # trace the call to the test function | |
1a1c0afc MM |
67 | with_test_prefix "record" { |
68 | gdb_test_no_output "record btrace" | |
69 | gdb_test "next" ".*" "next.1" | |
70 | } | |
52834460 MM |
71 | |
72 | # we start with stepping to make sure that the trace is fetched automatically | |
1a1c0afc MM |
73 | with_test_prefix "fetch" { |
74 | gdb_test "reverse-stepi" ".*fun4\.5.*" "reverse-stepi.1" | |
75 | gdb_test "reverse-stepi" ".*fun4\.5.*" "reverse-stepi.2" | |
52834460 | 76 | |
1a1c0afc MM |
77 | # let's check where we are in the trace |
78 | check_replay_at 39 | |
79 | } | |
52834460 MM |
80 | |
81 | # let's step forward and check again | |
1a1c0afc MM |
82 | with_test_prefix "stepi" { |
83 | gdb_test "stepi" ".*fun4\.5.*" | |
84 | check_replay_at 40 | |
85 | } | |
52834460 MM |
86 | |
87 | # with the next step, we stop replaying | |
1a1c0afc MM |
88 | with_test_prefix "end" { |
89 | gdb_test "stepi" ".*main\.3.*" | |
90 | gdb_test "info record" [multi_line \ | |
91 | "Active record target: record-btrace" \ | |
92 | ".*" \ | |
93 | "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \ | |
94 | ] | |
95 | } | |
52834460 | 96 | |
66849923 | 97 | # let's try nexti |
1a1c0afc MM |
98 | with_test_prefix "reverse-nexti.1" { |
99 | gdb_test "reverse-nexti" ".*main\.2.*" | |
100 | check_replay_at 1 | |
101 | } | |
66849923 MM |
102 | |
103 | # we can't reverse-nexti any further | |
1a1c0afc MM |
104 | with_test_prefix "reverse-nexti.2" { |
105 | gdb_test "reverse-nexti" \ | |
106 | "No more reverse-execution history\.\r\n.*main\.2.*" \ | |
107 | "reverse-nexti.2" | |
108 | check_replay_at 1 | |
109 | } | |
66849923 MM |
110 | |
111 | # but we can step back again | |
1a1c0afc MM |
112 | with_test_prefix "nexti" { |
113 | gdb_test "nexti" ".*main\.3.*" | |
114 | gdb_test "info record" [multi_line \ | |
115 | "Active record target: record-btrace" \ | |
116 | ".*" \ | |
117 | "Recorded 40 instructions in 16 functions \\\(0 gaps\\\) for \[^\\\r\\\n\]*" \ | |
118 | ] | |
119 | } | |
66849923 | 120 | |
52834460 | 121 | # let's step from a goto position somewhere in the middle |
1a1c0afc MM |
122 | with_test_prefix "goto" { |
123 | gdb_test "record goto 22" ".*fun3\.2.*" | |
124 | with_test_prefix "goto 22" { check_replay_at 22 } | |
52834460 | 125 | |
1a1c0afc MM |
126 | gdb_test "stepi" ".*fun1\.1.*" "stepi.3" |
127 | with_test_prefix "stepi to 23" { check_replay_at 23 } | |
52834460 | 128 | |
1a1c0afc MM |
129 | gdb_test "reverse-stepi" ".*fun3\.2.*" "reverse-stepi.3" |
130 | with_test_prefix "reverse-stepi to 22" { check_replay_at 22 } | |
66849923 | 131 | |
1a1c0afc MM |
132 | gdb_test "nexti" ".*fun3\.3.*" |
133 | with_test_prefix "nexti to 27" { check_replay_at 27 } | |
66849923 | 134 | |
1a1c0afc MM |
135 | gdb_test "reverse-nexti" ".*fun3\.2.*" "reverse-nexti.3" |
136 | with_test_prefix "reverse-nexti to 22" { check_replay_at 22 } | |
137 | } | |
52834460 MM |
138 | |
139 | # let's try to step off the left end | |
1a1c0afc MM |
140 | with_test_prefix "goto begin" { |
141 | gdb_test "record goto begin" ".*main\.2.*" | |
142 | check_replay_at 1 | |
143 | ||
144 | with_test_prefix "reverse-stepi" { | |
145 | gdb_test "reverse-stepi" \ | |
146 | "No more reverse-execution history\.\r\n.*main\.2.*" \ | |
147 | "reverse-stepi.1" | |
148 | gdb_test "reverse-stepi" \ | |
149 | "No more reverse-execution history\.\r\n.*main\.2.*" \ | |
150 | "reverse-stepi.2" | |
151 | check_replay_at 1 | |
152 | } | |
153 | ||
154 | with_test_prefix "reverse-nexti" { | |
155 | gdb_test "reverse-nexti" \ | |
156 | "No more reverse-execution history\.\r\n.*main\.2.*" \ | |
157 | "reverse-nexti.1" | |
158 | gdb_test "reverse-nexti" \ | |
159 | "No more reverse-execution history\.\r\n.*main\.2.*" \ | |
160 | "reverse-nexti.2" | |
161 | check_replay_at 1 | |
162 | } | |
163 | ||
164 | # we can step forward, though | |
165 | with_test_prefix "stepi" { | |
166 | gdb_test "stepi" ".*fun4\.1.*" | |
167 | check_replay_at 2 | |
168 | } | |
169 | } | |
52834460 MM |
170 | |
171 | # let's try to step off the left end again | |
1a1c0afc MM |
172 | with_test_prefix "reverse-stepi" { |
173 | gdb_test "reverse-stepi" ".*main\.2.*" "reverse-stepi.1" | |
174 | gdb_test "reverse-stepi" \ | |
175 | "No more reverse-execution history\.\r\n.*main\.2.*" \ | |
176 | "reverse-stepi.2" | |
177 | gdb_test "reverse-stepi" \ | |
178 | "No more reverse-execution history\.\r\n.*main\.2.*" \ | |
179 | "reverse-stepi.3" | |
180 | check_replay_at 1 | |
181 | } |