Commit | Line | Data |
---|---|---|
618f726f | 1 | # Copyright (C) 2015-2016 Free Software Foundation, Inc. |
f6bb7db3 YQ |
2 | # |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation; either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | if ![supports_reverse] { | |
17 | return | |
18 | } | |
19 | ||
20 | # Test aarch64 instruction recording. | |
21 | ||
4931af25 | 22 | if {![is_aarch64_target]} then { |
f6bb7db3 YQ |
23 | verbose "Skipping aarch64 instruction recording tests." |
24 | return | |
25 | } | |
26 | ||
27 | standard_testfile | |
28 | ||
29 | if {[prepare_for_testing $testfile.exp $testfile $srcfile \ | |
30 | [list debug]]} { | |
31 | untested ${testfile}.exp | |
32 | return -1 | |
33 | } | |
34 | if { ![runto main] } then { | |
35 | fail "run to main" | |
36 | return | |
37 | } | |
38 | ||
39 | # In each function FUNC, GDB turns on process record, and single step | |
40 | # until program goes to the end of the function. Then, single step | |
41 | # backward. In each of forward single step and backward single step, | |
42 | # the contents of registers are saved, and test compares them. If | |
43 | # there is any differences, a FAIL is emitted. | |
44 | ||
45 | proc test { func } { | |
46 | global hex decimal | |
47 | global gdb_prompt | |
48 | ||
49 | with_test_prefix "$func" { | |
50 | gdb_breakpoint $func | |
51 | gdb_test "continue" | |
52 | ||
53 | set last_insn "" | |
54 | set test "disassemble $func" | |
55 | gdb_test_multiple $test $test { | |
56 | -re ".*($hex) <\\+$decimal>:\[^\r\n\]+\r\nEnd of assembler dump\.\r\n$gdb_prompt $" { | |
57 | set last_insn $expect_out(1,string) | |
58 | } | |
59 | } | |
60 | if { $last_insn == "" } { | |
61 | fail "find the last instruction of function $func" | |
62 | } | |
63 | ||
64 | # Activate process record/replay | |
65 | gdb_test_no_output "record" "Turn on process record" | |
66 | ||
67 | # Registers contents before each forward single step. | |
68 | set count 0 | |
69 | for {} {$count < 500} {incr count} { | |
70 | gdb_test_multiple "x/i \$pc" "" { | |
71 | -re ".* ($hex) <.*>:\[ \t\]*(.*)\r\n$gdb_prompt $" { | |
72 | set insn_addr $expect_out(1,string) | |
73 | ||
74 | if [expr {$last_insn == $insn_addr}] { | |
75 | break | |
76 | } | |
77 | ||
78 | set insn_array($count) $expect_out(2,string) | |
79 | } | |
80 | } | |
81 | ||
82 | set pre_regs($count) [capture_command_output "info all-registers" ""] | |
83 | gdb_test "si" "" "" | |
84 | } | |
85 | ||
86 | incr count -1 | |
87 | # Registers contents after each backward single step. | |
88 | for {set i $count} {$i >= 0} {incr i -1} { | |
89 | gdb_test "reverse-stepi" "" "" | |
90 | set post_regs($i) [capture_command_output "info all-registers" ""] | |
91 | } | |
92 | ||
93 | # Compare the register contents. | |
94 | for {set i 0} {$i < $count} {incr i} { | |
95 | if { ![gdb_assert { [string compare $pre_regs($i) $post_regs($i)] == 0 } \ | |
96 | "compare registers on insn $i:$insn_array($i)"] } { | |
97 | ||
98 | foreach pre_line [split $pre_regs($i) \n] post_line [split $post_regs($i) \n] { | |
99 | if { [string compare $pre_line $post_line] } { | |
100 | verbose -log " -:$pre_line" | |
101 | verbose -log " +:$post_line" | |
102 | } | |
103 | } | |
104 | } | |
105 | } | |
106 | gdb_test "record stop" | |
107 | } | |
108 | } | |
109 | ||
110 | test "load" | |
111 | test "move" | |
112 | test "adv_simd_mod_imm" | |
113 | test "adv_simd_scalar_index" | |
114 | test "adv_simd_smlal" | |
115 | test "adv_simd_vect_shift" |