| 1 | # Copyright 2013-2016 Free Software Foundation, 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 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 | # Execute command CMD and check that GDB sends the expected number of |
| 17 | # vCont;r packet. Returns 0 if the test passes, otherwise returns 1. |
| 18 | |
| 19 | proc exec_cmd_expect_vCont_count { cmd exp_vCont_r } { |
| 20 | global gdb_prompt |
| 21 | |
| 22 | gdb_test_no_output "set debug remote 1" "" |
| 23 | |
| 24 | set test "${cmd}: vCont;r=${exp_vCont_r}" |
| 25 | set r_counter 0 |
| 26 | set s_counter 0 |
| 27 | set ret 1 |
| 28 | # We either get a stop reply in all-stop mode, or an OK in |
| 29 | # non-stop mode. |
| 30 | set vcont_reply "(T\[\[:xdigit:\]\]\[\[:xdigit:\]\]|OK)" |
| 31 | gdb_test_multiple $cmd $test { |
| 32 | -re "vCont;s\[^\r\n\]*Packet received: $vcont_reply" { |
| 33 | incr s_counter |
| 34 | exp_continue |
| 35 | } |
| 36 | -re "vCont;r\[^\r\n\]*Packet received: $vcont_reply" { |
| 37 | incr r_counter |
| 38 | exp_continue |
| 39 | } |
| 40 | -re "\r\n" { |
| 41 | # Prevent overflowing the expect buffer. |
| 42 | exp_continue |
| 43 | } |
| 44 | -re "$gdb_prompt $" { |
| 45 | if { $r_counter == ${exp_vCont_r} } { |
| 46 | pass $test |
| 47 | set ret 0 |
| 48 | } else { |
| 49 | fail $test |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | gdb_test_no_output "set debug remote 0" "" |
| 55 | return $ret |
| 56 | } |
| 57 | |
| 58 | # Check whether range stepping is supported by the target. |
| 59 | |
| 60 | proc gdb_range_stepping_enabled { } { |
| 61 | global gdb_prompt |
| 62 | |
| 63 | set command "set range-stepping on" |
| 64 | set message "probe range-stepping support" |
| 65 | gdb_test_multiple $command $message { |
| 66 | -re "Range stepping is not supported.*\r\n$gdb_prompt $" { |
| 67 | pass $message |
| 68 | return 0 |
| 69 | } |
| 70 | -re "^$command\r\n$gdb_prompt $" { |
| 71 | pass $message |
| 72 | return 1 |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | return 0 |
| 77 | } |