This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 3/3] Match output in async mode.
This patch is to match the program's output when in async mode. It is
hard to match output in a unique way to handle both sync mode and
async mode, so I have to handle them separately.
The reason I choose send_gdb/gdb_expect, instead of gdb_test_multiple,
is gdb_test_multiple matches ""\r\n$gdb_prompt $", and return false.
However, "(gdb) " may appear in somewhere in the output, and trigger
fail for test.
With this patch, I run py-finish-breakpoint.exp 40 times in both
sync mode and async mode, no fail show up.
gdb/testsuite:
2012-05-25 Yao Qi <yao@codesourcery.com>
Fix PR 14135.
* gdb.python/py-finish-breakpoint.exp: Match output in async
mode.
---
gdb/testsuite/gdb.python/py-finish-breakpoint.exp | 69 ++++++++++++++++++--
1 files changed, 62 insertions(+), 7 deletions(-)
diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint.exp b/gdb/testsuite/gdb.python/py-finish-breakpoint.exp
index c601e85..4ab15e7 100644
--- a/gdb/testsuite/gdb.python/py-finish-breakpoint.exp
+++ b/gdb/testsuite/gdb.python/py-finish-breakpoint.exp
@@ -65,6 +65,22 @@ if ![runto_main] then {
}
gdb_test_no_output "set confirm off" "disable confirmation"
+
+set async "unknown"
+global gdb_prompt
+send_gdb "show target-async\n"
+gdb_expect {
+ -re ".*Controlling the inferior in asynchronous mode is on.*$gdb_prompt $" {
+ set async 1
+ }
+ -re ".*$gdb_prompt $" {
+ set async 0
+ }
+ timeout {
+ set async 0
+ }
+}
+
gdb_test "source $python_file" "Python script imported.*" \
"import python scripts"
gdb_breakpoint "increase_1"
@@ -169,9 +185,22 @@ gdb_test "break ${cond_line} if test_1(i,8)" "Breakpoint .* at .*" \
"set a conditional BP"
gdb_test "python TestBreakpoint()" "TestBreakpoint init" \
"set FinishBP in a breakpoint condition"
-gdb_test "continue" \
- "\"FinishBreakpoint\" cannot be set on a dummy frame.*" \
- "don't allow FinishBreakpoint on dummy frames"
+
+set test "don't allow FinishBreakpoint on dummy frames"
+
+if {$async} {
+ send_gdb "continue\n"
+ gdb_expect {
+ -re "\"FinishBreakpoint\" cannot be set on a dummy frame\\..* Condition Break\. " {
+ pass $test
+ }
+ }
+} else {
+ gdb_test "continue" \
+ "\"FinishBreakpoint\" cannot be set on a dummy frame.*" \
+ $test
+}
+
gdb_test "print i" "8" "check stopped location"
#
@@ -194,12 +223,38 @@ gdb_test "break ${cond_line} if test(i,8)" \
"Breakpoint .* at .*" "set conditional BP"
gdb_test "python TestBreakpoint()" "TestBreakpoint init" "set BP in condition"
-gdb_test "continue" \
- "test don't stop: 1.*test don't stop: 2.*test stop.*Error in testing breakpoint condition.*The program being debugged stopped while in a function called from GDB.*" \
- "stop in condition function"
+set test "stop in condition function"
+
+if {$async} {
+
+ send_gdb "continue\n"
+ gdb_expect {
+ -re "continue.*Continuing\\..*test don't stop: 1.*test don't stop: 2.*test stop.*Error in testing breakpoint condition.*The program being debugged stopped while in a function called from GDB.*Breakpoint " {
+ pass $test
+ }
+
+ timeout { fail "$test (timeout)" }
+ }
+} else {
+ gdb_test "continue" \
+ "test don't stop: 1.*test don't stop: 2.*test stop.*Error in testing breakpoint condition.*The program being debugged stopped while in a function called from GDB.*" \
+ $test
+}
gdb_test "continue" "Continuing.*" "finish condition evaluation"
-gdb_test "continue" "Breakpoint.*" "stop at conditional breakpoint"
+
+set test "stop at conditional breakpoint"
+if {$async} {
+ send_gdb "continue\n"
+ gdb_expect {
+ -re "continue.*Breakpoint.* Condition Break\\. " {
+ pass $test
+ }
+ }
+} else {
+ gdb_test "continue" "Breakpoint.*" $test
+}
+
gdb_test "print i" "8" "check stopped location"
#
--
1.7.0.4