diff options
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/cond-eval-mode.c | 53 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/cond-eval-mode.exp | 112 |
3 files changed, 172 insertions, 2 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 5fca9d2..12ed4f9 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2014-04-10 Pedro Alves <palves@redhat.com> + + * gdb.base/cond-eval-mode.c: New file. + * gdb.base/cond-eval-mode.exp: Use standard_testfile. Adjust + prepare_for_testing to build the new file. Check result of + runto_main. + (test_break, test_watch): New procedures. + (top level): Use them. + 2014-04-08 Pierre Muller <muller@sourceware.org> * gdb.base/printcmds.exp (test_artificial_arrays): Disable diff --git a/gdb/testsuite/gdb.base/cond-eval-mode.c b/gdb/testsuite/gdb.base/cond-eval-mode.c new file mode 100644 index 0000000..b6bbe30 --- /dev/null +++ b/gdb/testsuite/gdb.base/cond-eval-mode.c @@ -0,0 +1,53 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2014 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +int global; + +int cond_global; + + +int +foo (int i) +{ + global++; + return i; +} + +int +bar (int i) +{ + return i; +} + +void +test () +{ + foo (1); + foo (2); + bar (3); +} + +int +main () +{ + int i; + + for (i = 0; i < 1000; i++) + test (); + + return 0; +} diff --git a/gdb/testsuite/gdb.base/cond-eval-mode.exp b/gdb/testsuite/gdb.base/cond-eval-mode.exp index fd45499..dad7194 100644 --- a/gdb/testsuite/gdb.base/cond-eval-mode.exp +++ b/gdb/testsuite/gdb.base/cond-eval-mode.exp @@ -15,11 +15,16 @@ # Test 'set breakpoint condition-evaluation' settings -if { [prepare_for_testing break.exp "break" {break.c break1.c}] } { +standard_testfile + +if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { return -1 } -runto main +if ![runto_main] then { + fail "Can't run to main" + return 0 +} set test_host "set breakpoint condition-evaluation host" set test_auto "set breakpoint condition-evaluation auto" @@ -42,3 +47,106 @@ gdb_test_multiple $test_target $test_target { pass $test_target } } + +# Test setting a condition in a breakpoint. BREAK_COMMAND is the +# break/hwatch command to test. +# +proc test_break { break_command } { + global gdb_prompt + + with_test_prefix "$break_command" { + delete_breakpoints + + gdb_test "$break_command foo" "reakpoint.* at .*" + + # A condition that evals true. + gdb_test "condition \$bpnum cond_global==0" ".*" + + set can_do_cmd 0 + + set test "continue" + gdb_test_multiple $test $test { + -re "You may have requested too many.*$gdb_prompt $" { + pass $test + } + -re "Breakpoint .*, foo .*$gdb_prompt $" { + pass $test + set can_do_cmd 1 + } + } + + if { !$can_do_cmd } { + unsupported "no target support" + return + } + + delete_breakpoints + + gdb_test "$break_command foo" ".*reakpoint .* at .*" + + # A condition that evals false. + gdb_test "condition \$bpnum cond_global==1" ".*" + + gdb_test "b bar" "Breakpoint .* at .*" + + gdb_test "continue" "Breakpoint .*, bar .*" + } +} + +# Test setting conditions in watchpoints. WATCH_COMMAND is the watch +# command to test. +# +proc test_watch { watch_command } { + global gdb_prompt + + with_test_prefix "$watch_command" { + if [target_info exists gdb,no_hardware_watchpoints] { + unsupported "no target support" + return + } + + delete_breakpoints + + gdb_test "$watch_command global" ".*atchpoint .*: global.*" + + # A condition that evals true. + gdb_test "condition \$bpnum cond_global==0" ".*" + + set can_do_cmd 0 + + set test "continue" + gdb_test_multiple $test $test { + -re "You may have requested too many.*$gdb_prompt $" { + pass $test + } + -re "atchpoint .*: global.*$gdb_prompt $" { + pass $test + set can_do_cmd 1 + } + } + + if { !$can_do_cmd } { + unsupported "no target support" + return + } + + delete_breakpoints + + gdb_test "$watch_command global" ".*atchpoint .*: global.*" + + # A condition that evals false. + gdb_test "condition \$bpnum cond_global==1" ".*" + + gdb_test "b bar" "Breakpoint .* at .*" + + gdb_test "continue" "Breakpoint .*, bar .*" + } +} + +foreach break_command { "break" "hbreak" } { + test_break $break_command +} + +foreach watch_command { "watch" "rwatch" "awatch" } { + test_watch $watch_command +} |