Fix test names starting with uppercase output by basic functions
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.reverse / insn-reverse.exp
CommitLineData
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
16if ![supports_reverse] {
17 return
18}
19
f6bb7db3
YQ
20standard_testfile
21
22if {[prepare_for_testing $testfile.exp $testfile $srcfile \
23 [list debug]]} {
24 untested ${testfile}.exp
25 return -1
26}
27if { ![runto main] } then {
28 fail "run to main"
29 return
30}
31
3263bceb
YQ
32# Read function name from testcases[N].
33
34proc read_testcase { n } {
35 global gdb_prompt
36
37 set result -1
38 gdb_test_multiple "print testcases\[${n}\]" "read name of test case ${n}" {
39 -re "\[$\].*= .*<(.*)>.*$gdb_prompt $" {
40 set result $expect_out(1,string)
41 }
42 -re "$gdb_prompt $" { }
43 }
44
45 return $result
46}
47
f6bb7db3
YQ
48# In each function FUNC, GDB turns on process record, and single step
49# until program goes to the end of the function. Then, single step
50# backward. In each of forward single step and backward single step,
51# the contents of registers are saved, and test compares them. If
52# there is any differences, a FAIL is emitted.
53
54proc test { func } {
55 global hex decimal
56 global gdb_prompt
57
58 with_test_prefix "$func" {
59 gdb_breakpoint $func
60 gdb_test "continue"
61
62 set last_insn ""
63 set test "disassemble $func"
64 gdb_test_multiple $test $test {
65 -re ".*($hex) <\\+$decimal>:\[^\r\n\]+\r\nEnd of assembler dump\.\r\n$gdb_prompt $" {
66 set last_insn $expect_out(1,string)
67 }
68 }
69 if { $last_insn == "" } {
70 fail "find the last instruction of function $func"
71 }
72
73 # Activate process record/replay
74 gdb_test_no_output "record" "Turn on process record"
75
76 # Registers contents before each forward single step.
77 set count 0
78 for {} {$count < 500} {incr count} {
79 gdb_test_multiple "x/i \$pc" "" {
80 -re ".* ($hex) <.*>:\[ \t\]*(.*)\r\n$gdb_prompt $" {
81 set insn_addr $expect_out(1,string)
82
83 if [expr {$last_insn == $insn_addr}] {
84 break
85 }
86
87 set insn_array($count) $expect_out(2,string)
88 }
89 }
90
91 set pre_regs($count) [capture_command_output "info all-registers" ""]
92 gdb_test "si" "" ""
93 }
94
95 incr count -1
96 # Registers contents after each backward single step.
97 for {set i $count} {$i >= 0} {incr i -1} {
98 gdb_test "reverse-stepi" "" ""
99 set post_regs($i) [capture_command_output "info all-registers" ""]
100 }
101
102 # Compare the register contents.
103 for {set i 0} {$i < $count} {incr i} {
104 if { ![gdb_assert { [string compare $pre_regs($i) $post_regs($i)] == 0 } \
105 "compare registers on insn $i:$insn_array($i)"] } {
106
107 foreach pre_line [split $pre_regs($i) \n] post_line [split $post_regs($i) \n] {
108 if { [string compare $pre_line $post_line] } {
109 verbose -log " -:$pre_line"
110 verbose -log " +:$post_line"
111 }
112 }
113 }
114 }
115 gdb_test "record stop"
116 }
117}
118
3263bceb
YQ
119set n_testcases [get_integer_valueof "n_testcases" 0]
120
121if { ${n_testcases} == 0 } {
bc6c7af4 122 untested "no test"
3263bceb
YQ
123 return 1
124}
125
126for { set i 0 } { ${i} < ${n_testcases} } { incr i } {
127 set testcase [read_testcase $i]
128
129 test $testcase
130}
This page took 0.200443 seconds and 4 git commands to generate.