de6db0fca5b040cede52df06aaca32183a82ec0e
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.arch / mips-octeon-bbit.exp
1 # Copyright 2007 Cavium Networks, Inc.
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 2 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, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17 # Test single-step on bbit.
18
19 if ![istarget "*octeon*"] {
20 return -1
21 }
22
23 proc current_insn {} {
24 global gdb_prompt
25
26 send_gdb "x/i \$pc\n"
27 gdb_expect {
28 -re ".*?:\\s+\(.*?\)\\s*$gdb_prompt $" {
29 set insn $expect_out(1,string)
30 return $insn
31 }
32 }
33 return ""
34 }
35
36 proc single_step {} {
37 global gdb_prompt
38
39 send_gdb "si\n"
40 gdb_expect {
41 -re "$gdb_prompt \$" {
42 return 1
43 }
44 }
45 return 0;
46 }
47
48 proc single_step_until { match } {
49 global timeout
50
51 set insn [current_insn]
52 set start [timestamp]
53 while { $insn != "" && [timestamp] - $start < 3*$timeout } {
54 if [regexp $match $insn] {
55 return 1
56 }
57 if {![single_step]} {
58 return 0
59 }
60 set insn [current_insn]
61 }
62 return 0;
63 }
64
65 proc test_bbit { name taken } {
66 if {![single_step_until "bbit"]} {
67 fail "$name single-step until bbit"
68 return
69 }
70 pass "$name single-step until bbit"
71 gdb_test "si" "" "$name single-step on bbit"
72 if [regexp "li\\s+\[sv\]0,$taken" [current_insn]] {
73 pass "$name check insn after bbit"
74 } else {
75 send_log "expected: li\\s+\[sv\]0,$taken found [current_insn]\n"
76 fail "$name check insn after bbit"
77 }
78 }
79
80 set testfile "mips-octeon-bbit"
81 set srcfile ${testfile}.c
82 set binfile ${objdir}/${subdir}/${testfile}
83
84 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
85 {debug nowarnings}] != "" } {
86 fail "compilation"
87 return
88 }
89
90 pass "compilation"
91
92 gdb_exit
93 gdb_start
94 gdb_reinitialize_dir $srcdir/$subdir
95 gdb_load ${binfile}
96 # Native needs run.
97 runto_main
98
99 set tests ""
100 foreach n [list "0_10" "0_36" "1_20" "1_49"] {
101 lappend tests "bbit_is_taken_$n"
102 }
103 foreach func $tests {
104 gdb_test "break $func" "Breakpoint.*at.*" "set breakpoint on $func"
105 }
106
107 foreach func $tests {
108 gdb_test "continue" "Continuing.*Breakpoint.*$func.*" "hit $func first"
109 test_bbit "$func branch taken" 1
110 gdb_test "continue" "Continuing.*Breakpoint.*$func.*" "hit $func second"
111 test_bbit "$func branch not taken" 0
112 }
This page took 0.036453 seconds and 3 git commands to generate.