summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2015-07-29 11:09:45 +0100
committerPedro Alves <palves@redhat.com>2015-07-29 11:09:45 +0100
commit58789a917b7eed57c5200ec0a4d8a2fc44efc64c (patch)
treed691db39d4d84d8ae990727febcd989aad1f8e4b
parente8376742bdba233d14cfbff91776be065ae27587 (diff)
downloadbinutils-gdb-58789a917b7eed57c5200ec0a4d8a2fc44efc64c.tar.gz
Make gdb.mi/mi-dprintf.exp use $inferior_spawn_id
gdb/testsuite/ChangeLog: 2015-07-29 Pedro Alves <palves@redhat.com> * gdb.mi/mi-dprintf.exp (mi_expect_dprintf): New procedure, factore out from mi_continue_dprintf. For call-style dprintfs, expect dprintf output out of $inferior_spawn_id. (mi_continue_dprintf): Use mi_expect_dprintf. * gdb.mi/mi-dprintf.c: Include "../lib/unbuffer_output.c". (main): Call gdb_unbuffer_output.
-rw-r--r--gdb/testsuite/ChangeLog9
-rw-r--r--gdb/testsuite/gdb.mi/mi-dprintf.exp66
2 files changed, 43 insertions, 32 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 6eeb98037eb..9b4bf6bc6c0 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,14 @@
2015-07-29 Pedro Alves <palves@redhat.com>
+ * gdb.mi/mi-dprintf.exp (mi_expect_dprintf): New procedure,
+ factore out from mi_continue_dprintf. For call-style dprintfs,
+ expect dprintf output out of $inferior_spawn_id.
+ (mi_continue_dprintf): Use mi_expect_dprintf.
+ * gdb.mi/mi-dprintf.c: Include "../lib/unbuffer_output.c".
+ (main): Call gdb_unbuffer_output.
+
+2015-07-29 Pedro Alves <palves@redhat.com>
+
* lib/mi-support.exp (mi_inferior_spawn_id): Delete.
(default_mi_gdb_start): Set inferior_spawn_id instead of
mi_inferior_spawn_id. If $inferior_spawn_id is not set, set it to
diff --git a/gdb/testsuite/gdb.mi/mi-dprintf.exp b/gdb/testsuite/gdb.mi/mi-dprintf.exp
index ea198bdf904..c2057244ed3 100644
--- a/gdb/testsuite/gdb.mi/mi-dprintf.exp
+++ b/gdb/testsuite/gdb.mi/mi-dprintf.exp
@@ -72,45 +72,47 @@ mi_gdb_test "[incr i]-break-info" \
mi_gdb_test "-break-insert $bp_location1" ".*" "mi insert breakpoint bp_location1"
-proc mi_continue_dprintf {args} {
- with_test_prefix $args {
- global mi_gdb_prompt
+# Helper for mi_continue_dprintf.
+
+proc mi_expect_dprintf {args where msg} {
+ global mi_gdb_prompt
+ global inferior_spawn_id gdb_spawn_id
+
+ if { $args == "call" || $args == "fprintf" } {
+ set foobarbazqux "\"foobarbazqux\""
+ set sid $inferior_spawn_id
+ } else {
+ set foobarbazqux "\\\\\"foobarbazqux\\\\\""
+ set sid $gdb_spawn_id
+ }
- if { $args == "call" || $args == "fprintf" } {
- set foobarbazqux "\"foobarbazqux\""
- } else {
- set foobarbazqux "\\\\\"foobarbazqux\\\\\""
+ # Don't expect the prompt here to avoid a race with mi_expect_stop
+ # in case $inferior_spawn_id != $gdb_spawn_id. Otherwise, in that
+ # case, we could see the gdb prompt before the inferior output.
+ gdb_expect {
+ -i $sid
+ -re ".*$foobarbazqux $where" {
+ pass $msg
}
+ eof {
+ fail "$msg (eof)"
+ }
+ timeout {
+ fail "$msg (timeout)"
+ }
+ }
+ mi_expect_stop ".*" ".*" ".*" ".*" ".*" "" "$msg stop"
+}
- mi_run_cmd
+proc mi_continue_dprintf {args} {
+ with_test_prefix $args {
set msg "mi 1st dprintf"
- gdb_expect {
- -re ".*$foobarbazqux At foo entry.*arg=1234, g=1234" {
- pass $msg
- }
- -re ".*$mi_gdb_prompt$" {
- fail $msg
- }
- timeout {
- fail $msg
- }
- }
- mi_expect_stop ".*" ".*" ".*" ".*" ".*" "" "$msg stop"
+ mi_run_cmd
+ mi_expect_dprintf $args "At foo entry.*arg=1234, g=1234" $msg
set msg "mi 2nd dprintf"
mi_send_resuming_command "exec-continue" "$msg continue"
- gdb_expect {
- -re ".*$foobarbazqux At foo entry.*arg=1235, g=2222" {
- pass $msg
- }
- -re ".*$mi_gdb_prompt$" {
- fail $msg
- }
- timeout {
- fail $msg
- }
- }
- mi_expect_stop ".*" ".*" ".*" ".*" ".*" "" "$msg 2nd stop"
+ mi_expect_dprintf $args "At foo entry.*arg=1235, g=2222" $msg
}
}