]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.arch/mips-octeon-bbit.exp
Update copyright year range in all GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / mips-octeon-bbit.exp
CommitLineData
b811d2c2 1# Copyright (C) 2012-2020 Free Software Foundation, Inc.
f94363d7
AP
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
7785b880 5# the Free Software Foundation; either version 3 of the License, or
f94363d7
AP
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
7785b880 14# along with this program; if not, see <http://www.gnu.org/licenses/>.
f94363d7
AP
15
16# Test single-step on bbit.
17
18if ![istarget "*octeon*"] {
19 return -1
20}
21
22proc current_insn {} {
23 global gdb_prompt
24
25 send_gdb "x/i \$pc\n"
26 gdb_expect {
27 -re ".*?:\\s+\(.*?\)\\s*$gdb_prompt $" {
28 set insn $expect_out(1,string)
29 return $insn
30 }
31 }
32 return ""
33}
34
35proc single_step {} {
36 global gdb_prompt
37
38 send_gdb "si\n"
39 gdb_expect {
40 -re "$gdb_prompt \$" {
41 return 1
42 }
43 }
ae59b1da 44 return 0
f94363d7
AP
45}
46
47proc single_step_until { match } {
48 global timeout
49
50 set insn [current_insn]
51 set start [timestamp]
52 while { $insn != "" && [timestamp] - $start < 3*$timeout } {
53 if [regexp $match $insn] {
54 return 1
55 }
56 if {![single_step]} {
57 return 0
58 }
59 set insn [current_insn]
60 }
ae59b1da 61 return 0
f94363d7
AP
62}
63
64proc test_bbit { name taken } {
65 if {![single_step_until "bbit"]} {
66 fail "$name single-step until bbit"
67 return
68 }
69 pass "$name single-step until bbit"
70 gdb_test "si" "" "$name single-step on bbit"
71 if [regexp "li\\s+\[sv\]0,$taken" [current_insn]] {
72 pass "$name check insn after bbit"
73 } else {
74 send_log "expected: li\\s+\[sv\]0,$taken found [current_insn]\n"
75 fail "$name check insn after bbit"
76 }
77}
78
79set testfile "mips-octeon-bbit"
80set srcfile ${testfile}.c
81set binfile ${objdir}/${subdir}/${testfile}
82
83if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
84 {debug nowarnings}] != "" } {
85 fail "compilation"
86 return
87}
88
89pass "compilation"
90
91gdb_exit
92gdb_start
93gdb_reinitialize_dir $srcdir/$subdir
94gdb_load ${binfile}
95# Native needs run.
96runto_main
97
98set tests ""
99foreach n [list "0_10" "0_36" "1_20" "1_49"] {
100 lappend tests "bbit_is_taken_$n"
101}
102foreach func $tests {
103 gdb_test "break $func" "Breakpoint.*at.*" "set breakpoint on $func"
104}
105
106foreach func $tests {
107 gdb_test "continue" "Continuing.*Breakpoint.*$func.*" "hit $func first"
108 test_bbit "$func branch taken" 1
109 gdb_test "continue" "Continuing.*Breakpoint.*$func.*" "hit $func second"
110 test_bbit "$func branch not taken" 0
111}