summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.reverse/ppc_record_test_isa_3_1.exp
blob: b4cddfac8fed3e758859fd96944dc4aa0e373de0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# Copyright 2008-2022 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Test instruction record for PowerPC, ISA 3.1.
#

# The basic flow of the record tests are:
#    1) Stop before executing the instructions of interest.  Record
#       the initial value of the registers that the instruction will
#       change, i.e. the destination register.
#    2) Execute the instructions.  Record the new value of the
#       registers that changed.
#    3) Reverse the direction of the execution and execute back to
#       just before the instructions of interest.  Record the final
#       value of the registers of interest.
#    4) Check that the initial and new values of the registers are
#       different, i.e. the instruction changed the registers as expected.
#    5) Check that the initial and final values of the registers are
#       the same, i.e. gdb record restored the registers to their
#       original values.


standard_testfile

set gen_src record_test_isa_3_1.c
set executable record_test_isa_3_1

if {![istarget "powerpc*"] || [skip_power_isa_3_1_tests]}  {
    verbose "Skipping PowerPC ISA 3.1 instruction record_test."
    return
}

set options [list additional_flags=-mcpu=power10 debug]
if {[build_executable "failed to prepare" $executable $srcfile $options] == -1} {
    return -1
}

clean_restart $executable

if {![runto_main]} {
    untested "could not run to main"
    return
}

gdb_test_no_output "record"

######  Test 1:  Test an ISA 3.1 byte reverse word instruction (brd) and a
######  prefixed load double (pld) instruction.
set stop1 [gdb_get_line_number "stop 1"]
set stop2 [gdb_get_line_number "stop 2"]

gdb_test "break $stop1" ".*Breakpoint .*" "about to execute test 1"
gdb_test "continue"  ".*Breakpoint .*" "at stop 1"

# Record the initial values in r0, r1
# Load the argument into r1, result of byte reverse is put into r0.
set r0_initial [capture_command_output "info register r0" ""]
set r1_initial [capture_command_output "info register r1" ""]

gdb_test "break $stop2" ".*Breakpoint .*" "executed test 1"
gdb_test "continue"  ".*Breakpoint .*" "at stop 2"

# Record the new values of r0 and r1
set r0_new [capture_command_output "info register r0" ""]
set r1_new [capture_command_output "info register r1" ""]

# Execute in reverse to before test 1
gdb_test_no_output "set exec-direction reverse"

gdb_test "break $stop1" ".*Breakpoint .*" "reverse stop at test 1 start"
gdb_test "continue"  ".*Breakpoint.*" "at stop 1 in reverse"

# Record the final values of r0, r1
set r0_final [capture_command_output "info register r0" ""]
set r1_final [capture_command_output "info register r1" ""]

# Check initial and new of r0 are different.
gdb_assert [string compare $r0_initial $r0_new] \
    "check r0 initial versus r0 new"

# Check initial and new of r1 are different.
gdb_assert [string compare $r1_initial $r1_new] \
    "check r0 initial versus r1 new"

# Check initial and final are the same.
gdb_assert ![string compare $r0_initial $r0_final] \
    "check r0 initial versus r0 final"

# Check initial and final are the same.
gdb_assert ![string compare $r1_initial $r1_final] \
    "check r1 initial versus r1 final"


# Change execution direction to forward for next test.
gdb_test_no_output "set exec-direction forward" "start forward test3"
gdb_test "record stop" ".*Process record is stopped.*" "stopped recording 2"
set test_del_bkpts "delete breakpoints, answer prompt 2"

# Delete all breakpoints and catchpoints.
delete_breakpoints

gdb_test_no_output "record" "start recording test2"


######  Test 2:  Test the ISA 3.1 MMA instructions xxsetaccz, xvi4ger8,
######  xvf16ger2pn, pmxvi8ger4, and pmxvf32gerpp.  Goal here is to hit all
######  the places where ppc_record_ACC_fpscr() gets called.
##
##       xxsetaccz    - ACC[3], vs[12] to vs[15]
##       xvi4ger8     - ACC[4], vs[16] to vs[19]
##       xvf16ger2pn  - ACC[5], vs[20] to vs[23]
##       pmxvi8ger4   - ACC[6], vs[21] to vs[27]
##       pmxvf32gerpp - ACC[7], vs[28] to vs[31] and fpscr

## Note the names for pmxvi8ger4 and pmxvf32gerpp have been officially
## changed to pmdmxvi8ger4 and pmdmxvf32gerpp respectively.  The older
## names are still supported by the assembler as extended mnemonics.  The
## older names are used in this test for backward compatibility.

set stop3 [gdb_get_line_number "stop 3"]
set stop4 [gdb_get_line_number "stop 4"]

gdb_test "break $stop3" ".*Breakpoint .*" "about to execute test 2"
gdb_test "continue"  ".*Breakpoint .*" "at stop 3"

# Record the initial values of vs's that correspond to the ACC entries,
# and fpscr.
set acc_3_0_initial [capture_command_output "info register vs12" ""]
set acc_3_1_initial [capture_command_output "info register vs13" ""]
set acc_3_2_initial [capture_command_output "info register vs14" ""]
set acc_3_3_initial [capture_command_output "info register vs15" ""]
set acc_4_0_initial [capture_command_output "info register vs16" ""]
set acc_4_1_initial [capture_command_output "info register vs17" ""]
set acc_4_2_initial [capture_command_output "info register vs18" ""]
set acc_4_3_initial [capture_command_output "info register vs19" ""]
set acc_5_0_initial [capture_command_output "info register vs20" ""]
set acc_5_1_initial [capture_command_output "info register vs21" ""]
set acc_5_2_initial [capture_command_output "info register vs22" ""]
set acc_5_3_initial [capture_command_output "info register vs23" ""]
set acc_6_0_initial [capture_command_output "info register vs24" ""]
set acc_6_1_initial [capture_command_output "info register vs25" ""]
set acc_6_2_initial [capture_command_output "info register vs26" ""]
set acc_6_3_initial [capture_command_output "info register vs27" ""]
set acc_7_0_initial [capture_command_output "info register vs28" ""]
set acc_7_1_initial [capture_command_output "info register vs29" ""]
set acc_7_2_initial [capture_command_output "info register vs30" ""]
set acc_7_3_initial [capture_command_output "info register vs31" ""]
set fpscr_initial [capture_command_output "info register fpscr" ""]

gdb_test "break $stop4" ".*Breakpoint .*" "executed test 2"
gdb_test "continue"  ".*Breakpoint .*" "at stop 4"

# Record the new values of the ACC entries and fpscr.
set acc_3_0_new [capture_command_output "info register vs12" ""]
set acc_3_1_new [capture_command_output "info register vs13" ""]
set acc_3_2_new [capture_command_output "info register vs14" ""]
set acc_3_3_new [capture_command_output "info register vs15" ""]
set acc_4_0_new [capture_command_output "info register vs16" ""]
set acc_4_1_new [capture_command_output "info register vs17" ""]
set acc_4_2_new [capture_command_output "info register vs18" ""]
set acc_4_3_new [capture_command_output "info register vs19" ""]
set acc_5_0_new [capture_command_output "info register vs20" ""]
set acc_5_1_new [capture_command_output "info register vs21" ""]
set acc_5_2_new [capture_command_output "info register vs22" ""]
set acc_5_3_new [capture_command_output "info register vs23" ""]
set acc_6_0_new [capture_command_output "info register vs24" ""]
set acc_6_1_new [capture_command_output "info register vs25" ""]
set acc_6_2_new [capture_command_output "info register vs26" ""]
set acc_6_3_new [capture_command_output "info register vs27" ""]
set acc_7_0_new [capture_command_output "info register vs28" ""]
set acc_7_1_new [capture_command_output "info register vs29" ""]
set acc_7_2_new [capture_command_output "info register vs30" ""]
set acc_7_3_new [capture_command_output "info register vs31" ""]
set fpscr_new [capture_command_output "info register fpscr" ""]

# Execute in reverse to before test 2.
gdb_test_no_output "set exec-direction reverse" "reverse to start of test 2"

gdb_test "break $stop3" ".*Breakpoint .*" "reverse stop at test 2 start"
gdb_test "continue"  ".*Breakpoint.*" "at stop 3 in reverse"

# Record the final values of the ACC entries and fpscr.
set acc_3_0_final [capture_command_output "info register vs12" ""]
set acc_3_1_final [capture_command_output "info register vs13" ""]
set acc_3_2_final [capture_command_output "info register vs14" ""]
set acc_3_3_final [capture_command_output "info register vs15" ""]
set acc_4_0_final [capture_command_output "info register vs16" ""]
set acc_4_1_final [capture_command_output "info register vs17" ""]
set acc_4_2_final [capture_command_output "info register vs18" ""]
set acc_4_3_final [capture_command_output "info register vs19" ""]
set acc_5_0_final [capture_command_output "info register vs20" ""]
set acc_5_1_final [capture_command_output "info register vs21" ""]
set acc_5_2_final [capture_command_output "info register vs22" ""]
set acc_5_3_final [capture_command_output "info register vs23" ""]
set acc_6_0_final [capture_command_output "info register vs24" ""]
set acc_6_1_final [capture_command_output "info register vs25" ""]
set acc_6_2_final [capture_command_output "info register vs26" ""]
set acc_6_3_final [capture_command_output "info register vs27" ""]
set acc_7_0_final [capture_command_output "info register vs28" ""]
set acc_7_1_final [capture_command_output "info register vs29" ""]
set acc_7_2_final [capture_command_output "info register vs30" ""]
set acc_7_3_final [capture_command_output "info register vs31" ""]
set fpscr_final [capture_command_output "info register fpscr" ""]

# check initial and new ACC entries are different.
gdb_assert [string compare $acc_3_0_initial $acc_3_0_new] \
    "check vs12 initial versus new"

gdb_assert [string compare $acc_3_1_initial $acc_3_1_new] \
    "check vs13 initial versus new"

gdb_assert [string compare $acc_3_2_initial $acc_3_2_new] \
    "check vs14 initial versus new"

gdb_assert [string compare $acc_3_3_initial $acc_3_3_new] \
    "check vs15 initial versus new"

gdb_assert [string compare $acc_4_0_initial $acc_4_0_new] \
    "check vs16 initial versus new"

gdb_assert [string compare $acc_4_1_initial $acc_4_1_new] \
    "check vs17 initial versus new"

gdb_assert [string compare $acc_4_2_initial $acc_4_2_new] \
    "check vs18 initial versus new"

gdb_assert [string compare $acc_4_3_initial $acc_4_3_new] \
    "check vs19 initial versus new"

gdb_assert [string compare $acc_5_0_initial $acc_5_0_new] \
    "check vs20 initial versus new"

gdb_assert [string compare $acc_5_1_initial $acc_5_1_new] \
    "check vs21 initial versus new"

gdb_assert [string compare $acc_5_2_initial $acc_5_2_new] \
    "check vs22 initial versus new"

gdb_assert [string compare $acc_5_3_initial $acc_5_3_new] \
    "check vs23 initial versus new"

gdb_assert [string compare $acc_6_0_initial $acc_6_0_new] \
    "check vs24 initial versus new"

gdb_assert [string compare $acc_6_1_initial $acc_6_1_new] \
    "check vs25 initial versus new"

gdb_assert [string compare $acc_6_2_initial $acc_6_2_new] \
    "check vs26 initial versus new"

gdb_assert [string compare $acc_6_3_initial $acc_6_3_new] \
    "check vs27 initial versus new"

gdb_assert [string compare $acc_7_0_initial $acc_7_0_new] \
    "check vs28 initial versus new"

gdb_assert [string compare $acc_7_1_initial $acc_7_1_new] \
    "check vs29 initial versus new"

gdb_assert [string compare $acc_7_2_initial $acc_7_2_new] \
    "check vs30 initial versus new"

gdb_assert [string compare $acc_7_3_initial $acc_7_3_new] \
    "check vs31 initial versus new"

gdb_assert [string compare $fpscr_initial $fpscr_new] \
    "check fpscr initial versus new"


# Check initial and final ACC entries are the same.
gdb_assert ![string compare $acc_3_0_initial $acc_3_0_final] \
    "check vs12 initial versus final"

gdb_assert ![string compare $acc_3_1_initial $acc_3_1_final] \
    "check vs13 initial versus final"

gdb_assert ![string compare $acc_3_2_initial $acc_3_2_final] \
    "check vs14 initial versus final"

gdb_assert ![string compare $acc_3_3_initial $acc_3_3_final] \
    "check vs15 initial versus final"

gdb_assert ![string compare $acc_4_0_initial $acc_4_0_final] \
    "check vs16 initial versus final"

gdb_assert ![string compare $acc_4_1_initial $acc_4_1_final] \
    "check vs17 initial versus final"

gdb_assert ![string compare $acc_4_2_initial $acc_4_2_final] \
    "check vs18 initial versus final"

gdb_assert ![string compare $acc_4_3_initial $acc_4_3_final] \
    "check vs19 initial versus final"

gdb_assert ![string compare $acc_5_0_initial $acc_5_0_final] \
    "check vs20 initial versus final"

gdb_assert ![string compare $acc_5_1_initial $acc_5_1_final] \
    "check vs21 initial versus final"

gdb_assert ![string compare $acc_5_2_initial $acc_5_2_final] \
    "check vs22 initial versus final"

gdb_assert ![string compare $acc_5_3_initial $acc_5_3_final] \
    "check vs23 initial versus final"

gdb_assert ![string compare $acc_6_0_initial $acc_6_0_final] \
    "check vs24 initial versus final"

gdb_assert ![string compare $acc_6_1_initial $acc_6_1_final] \
    "check vs25 initial versus final"

gdb_assert ![string compare $acc_6_2_initial $acc_6_2_final] \
    "check vs26 initial versus final"

gdb_assert ![string compare $acc_6_3_initial $acc_6_3_final] \
    "check vs27 initial versus final"

gdb_assert ![string compare $acc_7_0_initial $acc_7_0_final] \
    "check vs28 initial versus final"

gdb_assert ![string compare $acc_7_1_initial $acc_7_1_final] \
    "check vs29 initial versus final"

gdb_assert ![string compare $acc_7_2_initial $acc_7_2_final] \
    "check !vs30 initial versus final"

gdb_assert ![string compare $acc_7_3_initial $acc_7_3_final] \
    "check !vs31 initial versus final"

gdb_assert ![string compare $fpscr_initial $fpscr_final] \
    "check fpscr initial versus final"