aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base/cond-eval-mode.exp
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2014-04-10 19:22:23 +0100
committerPedro Alves <palves@redhat.com>2014-04-10 17:14:12 +0100
commitd708bcd102465e520c56e8be3ca4c9097dd389cc (patch)
tree01b77a9534e8be1c4952c07f5e4a8be22a9c6ec7 /gdb/testsuite/gdb.base/cond-eval-mode.exp
parente4ef1b6c3fee295ab41138bf77a82dff16f1d7c3 (diff)
downloadgdb-d708bcd102465e520c56e8be3ca4c9097dd389cc.zip
gdb-d708bcd102465e520c56e8be3ca4c9097dd389cc.tar.gz
gdb-d708bcd102465e520c56e8be3ca4c9097dd389cc.tar.bz2
Conditional Z1 breakpoint hangs GDBserver.
While trying to fix hbreak2.exp against GDBserver I noticed this... (gdb) hbreak main if 1 Sending packet: $m400580,40#2e...Packet received: e8d2ffffff5dc3554889e54883ec10c745fc00000000eb0eb800000000e8c1ffffff8345fc01817dfce70300007ee9b800000000c9c3662e0f1f840000000000 Sending packet: $m40058f,1#31...Packet received: c7 Hardware assisted breakpoint 1 at 0x40058f: file ../../../src/gdb/testsuite/gdb.base/break-idempotent.c, line 46. Sending packet: $Z1,40058f,1;X3,220127#9b... *hangs forever* The issue is that nothing advances the packet pointer if add_breakpoint_condition either fails to parse the agent expression, or fails to find the breakpoint, resulting in an infinite loop in process_point_options. The latter case should really be fixed by GDBserver tracking GDB Z1 breakpoints in its breakpoint structures like Z0 breakpoints are, but the latter case still needs handling. add_breakpoint_commands has the same issue, though at present I don't know any way to trigger it other than sending a manually cooked packet. Unbelievably, it doesn't look like we have any test that tries setting a conditional hardware breakpoint. Looking at cond-eval-mode.exp, it looks like the file was meant to actually test something, but it's mostly empty today. This patch adds tests that tries all sorts of conditional breakpoints and watchpoints. The test hangs/fails without the GDBserver fix. Tested on x86_64 Fedora 17. gdb/gdbserver/ 2014-04-10 Pedro Alves <palves@redhat.com> * mem-break.c (add_breakpoint_condition, add_breakpoint_commands): Check if the condition or command is NULL before checking if the breakpoint is known. On success, return true. * mem-break.h (add_breakpoint_condition): Document return. (add_breakpoint_commands): Add describing comment. * server.c (skip_to_semicolon): New function. (process_point_options): Use it. gdb/testsuite/ 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.
Diffstat (limited to 'gdb/testsuite/gdb.base/cond-eval-mode.exp')
-rw-r--r--gdb/testsuite/gdb.base/cond-eval-mode.exp112
1 files changed, 110 insertions, 2 deletions
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
+}