diff options
Diffstat (limited to 'gdb/testsuite/gdb.base/condbreak-bad.exp')
-rw-r--r-- | gdb/testsuite/gdb.base/condbreak-bad.exp | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.base/condbreak-bad.exp b/gdb/testsuite/gdb.base/condbreak-bad.exp index a01ba2a..84d32a0 100644 --- a/gdb/testsuite/gdb.base/condbreak-bad.exp +++ b/gdb/testsuite/gdb.base/condbreak-bad.exp @@ -38,3 +38,91 @@ gdb_test "info break" \ "${decimal}${fill}breakpoint${fill}keep y${fill}:${bp_location}"] \ "breakpoint is unconditional" +# Now define a valid condition. Attempt to override that with a 'bad' +# condition again. The condition should be preserved. +with_test_prefix "with run" { + gdb_test_no_output "cond $bpnum a == 10" + + gdb_test "cond $bpnum gibberish" \ + "No symbol \"gibberish\" in current context." \ + "attempt a bad condition" + + gdb_test "info break" \ + [multi_line \ + "Num${fill}What" \ + "${decimal}${fill}breakpoint${fill}keep y${fill}:${bp_location}" \ + "${fill}stop only if a == 10${fill}"] \ + "breakpoint condition is preserved" + + # Run the code. We should hit the breakpoint, because the + # condition evaluates to true. + + gdb_run_cmd + gdb_test "" ".*reakpoint .*, main .*${srcfile}.*" "run to the bp" +} + +# Restart. Repeat the test above after the program has started. +# This is needed to check a scenario where the breakpoints are no +# longer re-inserted due to solib events. Note that runto_main +# deletes the breakpoints. +with_test_prefix "with continue 1" { + if {![runto_main]} { + fail "could not run to main" + return -1 + } + + gdb_breakpoint "$bp_location" + set bpnum [get_integer_valueof "\$bpnum" 0 "get bpnum"] + + gdb_test_no_output "cond $bpnum a == 10" + + gdb_test "cond $bpnum gibberish" \ + "No symbol \"gibberish\" in current context." \ + "attempt a bad condition" + + # Resume. We should hit the breakpoint, because the + # condition evaluates to true. + gdb_continue_to_breakpoint "${srcfile}:${bp_location}" +} + +# Repeat with a condition that evaluates to false. +with_test_prefix "with continue 2" { + if {![runto_main]} { + fail "could not run to main" + return -1 + } + + gdb_breakpoint "$bp_location" + set bpnum [get_integer_valueof "\$bpnum" 0 "get bpnum"] + + gdb_test_no_output "cond $bpnum a == 999" + + gdb_test "cond $bpnum gibberish" \ + "No symbol \"gibberish\" in current context." \ + "attempt a bad condition" + + # Resume. We should *not* hit the breakpoint, because the + # condition evaluates to false. + gdb_continue_to_end +} + +# Repeat with a condition that contains junk at the end. +with_test_prefix "with junk" { + if {![runto_main]} { + fail "could not run to main" + return -1 + } + + gdb_breakpoint "$bp_location" + set bpnum [get_integer_valueof "\$bpnum" 0 "get bpnum"] + + gdb_test_no_output "cond $bpnum a == 999" + + gdb_test "cond $bpnum a == 10 if" \ + "Junk at end of expression" \ + "attempt a bad condition" + + # Resume. We should *not* hit the breakpoint, because the + # condition evaluates to false. + gdb_continue_to_end +} |