| 1 | # This testcase is part of GDB, the GNU debugger. |
| 2 | # |
| 3 | # Copyright 2016-2017 Free Software Foundation, Inc. |
| 4 | # |
| 5 | # This program is free software; you can redistribute it and/or modify |
| 6 | # it under the terms of the GNU General Public License as published by |
| 7 | # the Free Software Foundation; either version 3 of the License, or |
| 8 | # (at your option) any later version. |
| 9 | # |
| 10 | # This program is distributed in the hope that it will be useful, |
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | # GNU General Public License for more details. |
| 14 | # |
| 15 | # You should have received a copy of the GNU General Public License |
| 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | if [target_info exists gdb,nosignals] { |
| 19 | verbose "Skipping branch-to-self.exp because of nosignals." |
| 20 | continue |
| 21 | } |
| 22 | |
| 23 | standard_testfile |
| 24 | |
| 25 | if { [build_executable ${testfile}.exp ${testfile} $srcfile {debug}] == -1 } { |
| 26 | return -1 |
| 27 | } |
| 28 | |
| 29 | with_test_prefix "single-step" { |
| 30 | global testfile |
| 31 | |
| 32 | clean_restart ${testfile} |
| 33 | if ![runto_main] { |
| 34 | return -1 |
| 35 | } |
| 36 | set line_num [gdb_get_line_number "loop-line" ${testfile}.c] |
| 37 | |
| 38 | gdb_test "break ${testfile}.c:${line_num}" "Breakpoint .*" \ |
| 39 | "set breakpoint" |
| 40 | gdb_continue_to_breakpoint "hit breakpoint" |
| 41 | gdb_test "si" ".*${testfile}.c:${line_num}.*" |
| 42 | } |
| 43 | |
| 44 | with_test_prefix "break-cond" { |
| 45 | global testfile |
| 46 | |
| 47 | foreach_with_prefix side {"host" "target"} { |
| 48 | |
| 49 | clean_restart ${testfile} |
| 50 | |
| 51 | if ![runto_main] { |
| 52 | return -1 |
| 53 | } |
| 54 | |
| 55 | set test "set breakpoint condition-evaluation $side" |
| 56 | gdb_test_multiple $test $test { |
| 57 | -re "warning: Target does not support breakpoint condition evaluation.\r\nUsing host evaluation mode instead.\r\n$gdb_prompt $" { |
| 58 | # Target doesn't support breakpoint condition |
| 59 | # evaluation on its side. Skip the test. |
| 60 | continue |
| 61 | } |
| 62 | -re "^$test\r\n$gdb_prompt $" { |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | set line_num [gdb_get_line_number "loop-line" ${testfile}.c] |
| 67 | gdb_test "break ${testfile}.c:${line_num} if counter > 3" \ |
| 68 | "Breakpoint .*" "set breakpoint with condition" |
| 69 | |
| 70 | gdb_continue_to_breakpoint "continue to break" |
| 71 | |
| 72 | gdb_test "p counter" ".* = 5" |
| 73 | } |
| 74 | } |