Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 07/24] Introduce gdb_test_stdio
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
  2015-04-21 18:08 ` [PATCH 10/24] Make gdb.base/catch-gdb-caused-signals.exp use gdb_test_stdio Pedro Alves
@ 2015-04-21 18:08 ` Pedro Alves
  2015-04-21 18:08 ` [PATCH 12/24] Make gdb.base/a2-run.exp use $inferior_spawn_id and gdb_test_stdio Pedro Alves
                   ` (22 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:08 UTC (permalink / raw)
  To: gdb-patches

This adds a new helper procedure to be used by tests that rely on
stdio.

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* lib/gdb.exp (gdb_test_stdio): New procedure.
---
 gdb/testsuite/lib/gdb.exp | 67 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 73e55e3..44f41c7 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1230,6 +1230,73 @@ proc gdb_test_list_exact { cmd name elm_find_regexp elm_extract_regexp result_ma
 	}
     }
 }
+
+# gdb_test_stdio COMMAND INFERIOR_PATTERN GDB_PATTERN MESSAGE
+# Send a command to gdb; expect inferior and gdb output.
+#
+# See gdb_test_multiple for a description of the COMMAND and MESSAGE
+# parameters.
+#
+# INFERIOR_PATTERN is the pattern to match against inferior output.
+#
+# GDB_PATTERN is the pattern to match against gdb output, and must NOT
+# include the \r\n sequence immediately before the gdb prompt, nor the
+# prompt.  The default is empty.
+#
+# Both inferior and gdb patterns must match for a PASS.
+#
+# If MESSAGE is ommitted, then COMMAND will be used as the message.
+#
+# Returns:
+#    1 if the test failed,
+#    0 if the test passes,
+#   -1 if there was an internal error.
+#
+
+proc gdb_test_stdio {command inferior_pattern {gdb_pattern ""} {message ""}} {
+    global inferior_spawn_id gdb_spawn_id
+    global gdb_prompt
+
+    if {$message == ""} {
+	set message $command
+    }
+
+    set inferior_matched 0
+    set gdb_matched 0
+
+    # Use an indirect spawn id list, and remove the inferior spawn id
+    # from the expected output as soon as it matches, in case
+    # $inferior_pattern happens to be a prefix of the resulting full
+    # gdb pattern below (e.g., "\r\n").
+    global gdb_test_stdio_spawn_id_list
+    set gdb_test_stdio_spawn_id_list "$inferior_spawn_id"
+
+    # Note that if $inferior_spawn_id and $gdb_spawn_id are different,
+    # then we may see gdb's output arriving before the inferior's
+    # output.
+    set res [gdb_test_multiple $command $message {
+	-i gdb_test_stdio_spawn_id_list -re "$inferior_pattern" {
+	    set inferior_matched 1
+	    if {!$gdb_matched} {
+		set gdb_test_stdio_spawn_id_list ""
+		exp_continue
+	    }
+	}
+	-i $gdb_spawn_id -re "$gdb_pattern\r\n$gdb_prompt $" {
+	    set gdb_matched 1
+	    if {!$inferior_matched} {
+		exp_continue
+	    }
+	}
+    }]
+    if {$res == 0} {
+	pass $message
+    } else {
+	verbose -log "inferior_matched=$inferior_matched, gdb_matched=$gdb_matched"
+    }
+    return $res
+}
+
 \f
 
 # Issue a PASS and return true if evaluating CONDITION in the caller's
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 16/24] Make gdb.base/shlib-call.exp use gdb_test_stdio
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
                   ` (5 preceding siblings ...)
  2015-04-21 18:08 ` [PATCH 04/24] Don't rely on inferior I/O in gdb.base/siginfo-addr.exp Pedro Alves
@ 2015-04-21 18:08 ` Pedro Alves
  2015-04-21 18:09 ` [PATCH 24/24] Don't set gdb,noinferiorio on gdbserver boards Pedro Alves
                   ` (17 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:08 UTC (permalink / raw)
  To: gdb-patches

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* gdb.base/shlib-call.exp: Use gdb_test_stdio.
---
 gdb/testsuite/gdb.base/shlib-call.exp | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/gdb/testsuite/gdb.base/shlib-call.exp b/gdb/testsuite/gdb.base/shlib-call.exp
index b79165a..2ccaa39 100644
--- a/gdb/testsuite/gdb.base/shlib-call.exp
+++ b/gdb/testsuite/gdb.base/shlib-call.exp
@@ -79,8 +79,9 @@ gdb_test "print g" "\[0-9\]* = 1" "print g"
 
 #step -over
 if ![gdb_skip_stdio_test "next over shr1"] {
-    gdb_test "next" \
-	"address of sgs is $hex.*g = shr2\\(g\\);" \
+    gdb_test_stdio "next" \
+	"address of sgs is $hex" \
+	"g = shr2\\(g\\);" \
 	"next over shr1"
 } else {
     gdb_test "next" ".*" ""
@@ -92,15 +93,17 @@ gdb_test "print g" "\[0-9\]* = 2" "print g"
 
 #print shr1(1)
 if ![gdb_skip_stdio_test "print shr1(1)"] {
-    gdb_test "print shr1(1)" \
-	"address of sgs is $hex.*\[0-9\]* = 2" \
+    gdb_test_stdio "print shr1(1)" \
+	"address of sgs is $hex" \
+	"\[0-9\]* = 2" \
 	"print shr1(1)"
 }
 
 #print shr1(g)
 if ![gdb_skip_stdio_test "print shr1(g)"] {
-    gdb_test "print shr1(g)" \
-	"address of sgs is $hex.*\[0-9\]* = 4" \
+    gdb_test_stdio "print shr1(g)" \
+	"address of sgs is $hex" \
+	"\[0-9\]* = 4" \
 	"print shr1(g)"
 }
 
@@ -117,8 +120,9 @@ gdb_test "continue" \
 
 #print shr1(1)
 if ![gdb_skip_stdio_test "print shr1(1) 2nd time"] {
-    gdb_test "print shr1(1)" \
-	"address of sgs is $hex.*\[0-9\]* = 2" \
+    gdb_test_stdio "print shr1(1)" \
+	"address of sgs is $hex" \
+	"\[0-9\]* = 2" \
 	"print shr1(1) 2nd time"
 }
 
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 13/24] Make gdb.base/call-ar-st.exp use gdb_test_stdio
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
                   ` (2 preceding siblings ...)
  2015-04-21 18:08 ` [PATCH 12/24] Make gdb.base/a2-run.exp use $inferior_spawn_id and gdb_test_stdio Pedro Alves
@ 2015-04-21 18:08 ` Pedro Alves
  2015-04-21 18:08 ` [PATCH 01/24] gdb_test_multiple match eof of any spawn_id Pedro Alves
                   ` (20 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:08 UTC (permalink / raw)
  To: gdb-patches

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* gdb.base/call-ar-st.exp: Use gdb_test_stdio+multi_line instead
	of gdb_test_sequence.
---
 gdb/testsuite/gdb.base/call-ar-st.exp | 485 ++++++++++++++++++++--------------
 1 file changed, 284 insertions(+), 201 deletions(-)

diff --git a/gdb/testsuite/gdb.base/call-ar-st.exp b/gdb/testsuite/gdb.base/call-ar-st.exp
index 13af4aa..0f326e0 100644
--- a/gdb/testsuite/gdb.base/call-ar-st.exp
+++ b/gdb/testsuite/gdb.base/call-ar-st.exp
@@ -73,26 +73,30 @@ gdb_test continue \
 #call print_double_array(double_array)
 if {![gdb_skip_float_test "print print_double_array(double_array)"] && \
     ![gdb_skip_stdio_test "print print_double_array(double_array)"] } {
-    gdb_test_sequence "print print_double_array(double_array)" "" {
-	"\[ \t\r\n\]+array_d :"
-	"\[ \t\r\n\]+========="
-	"\[ \t\r\n\]+0.000000"
-	"\[ \t\r\n\]+23.456\[0-9\]*  46.913\[0-9\]*  70.370\[0-9\]*  93.826\[0-9\]*  117.283\[0-9\]*  140.740\[0-9\]*  164.196\[0-9\]*  187.653\[0-9\]"
-	"\[ \t\r\n\]+"
-    }
+
+    gdb_test_stdio "print print_double_array(double_array)" \
+	[multi_line \
+	     "array_d :" \
+	     "=========" \
+	     "" \
+	     "0.000000 *" \
+	     "23.456\[0-9\]*  46.913\[0-9\]*  70.370\[0-9\]*  93.826\[0-9\]*  117.283\[0-9\]*  140.740\[0-9\]*  164.196\[0-9\]*  187.653\[0-9\]"]
 }
 
 #call print_char_array(char_array)
 
+set array_c_re \
+    [multi_line \
+	 "array_c :" \
+	 "=========" \
+	 "" \
+	 "Z" \
+	 "aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ" \
+	 "aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ" \
+	 "aZaZaZaZaZaZaZaZaZa"]
+
 if ![gdb_skip_stdio_test "print_char_array(char_array)"] {
-    gdb_test_sequence "print print_char_array(char_array)" "" {
-	"\[ \t\r\n\]+array_c :"
-	"\[ \t\r\n\]+========="
-	"\[ \t\r\n\]+\[ \t\r\n\]+Z"
-	"\[ \t\r\n\]+aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ"
-	"\[ \t\r\n\]+aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ"
-	"\[ \t\r\n\]+aZaZaZaZaZaZaZaZaZa\[ \t\r\n\]+\[ \t\r\n\]+"
-    }
+    gdb_test_stdio "print print_char_array(char_array)" $array_c_re
 }
 
 set stop_line [gdb_get_line_number "-tbreak2-"]
@@ -101,16 +105,11 @@ gdb_test "tbreak $stop_line" \
 "tbreakpoint at tbreak2"
 
 if ![gdb_skip_stdio_test "continue to tbreak2"] {
-    gdb_test_sequence "continue" "continue to tbreak2" {
-	"\[ \t\r\n\]+array_c :"
-	"\[ \t\r\n\]+========="
-	"\[ \t\r\n\]+\[ \t\r\n\]+Z"
-	"\[ \t\r\n\]+aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ"
-	"\[ \t\r\n\]+aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ"
-	"\[ \t\r\n\]+aZaZaZaZaZaZaZaZaZa"
-	"\[ \t\r\n\]+main.*at.*:\[0-9\]+"
-	"\[ \t\r\n\]+\[0-9\]+.*print_double_array\\(double_array\\)"
-    }
+    set gdb_re \
+	[multi_line \
+	     "main.*at.*:\[0-9\]+" \
+	     "\[0-9\]+.*print_double_array\\(double_array\\).*"]
+    gdb_test_stdio "continue" $array_c_re $gdb_re "continue to tbreak2"
 } else {
     gdb_test "continue" ".*" ""
 }
@@ -135,18 +134,24 @@ gdb_test "tbreak $stop_line" \
 
 if {![gdb_skip_float_test "continuing to tbreak3"] && \
     ![gdb_skip_stdio_test "continuing to tbreak3"] } {
-    gdb_test_sequence "continue" "continuing to tbreak3" {
-	"Continuing\\."
-	"\[ \t\r\n\]+array_d :"
-	"\[ \t\r\n\]+========="
-	"\[ \t\r\n\]+0.000000"
-	"\[ \t\r\n\]+23.456\[0-9\]*  46.913\[0-9\]*  70.370\[0-9\]*  93.826\[0-9\]*  117.283\[0-9\]*  140.740\[0-9\]*  164.196\[0-9\]*  187.653\[0-9\]*"
-	"\[ \t\r\n\]+"
-	"array_f :"
-	"student id :\[\t \]+.*YELLOW"
-	"array_i :"
-	"main \\(\\) at .*call-ar-st.c:\[0-9\]+\[ \t\r\n\]+.*print_all_arrays\\(integer_array, char_array, float_array, double_array\\)."
-    }
+
+    gdb_test_stdio "continue" \
+	[multi_line \
+	     "array_d :" \
+	     "=========" \
+	     "" \
+	     "0.000000 *" \
+	     "23.456\[0-9\]*  46.913\[0-9\]*  70.370\[0-9\]*  93.826\[0-9\]*  117.283\[0-9\]*  140.740\[0-9\]*  164.196\[0-9\]*  187.653\[0-9\]* *" \
+	     "" \
+	     "" \
+	     "array_f :" \
+	     ".*" \
+	     "student id :\[\t \]+.*YELLOW" \
+	     "array_i :" \
+	    ] \
+	"main \\(\\) at .*call-ar-st.c:\[0-9\]+\[ \t\r\n\]+.*print_all_arrays\\(integer_array, char_array, float_array, double_array\\)..*" \
+	"continuing to tbreak3"
+
 } else {
     gdb_test "continue" ".*" ""
 }
@@ -160,8 +165,9 @@ gdb_test "step" \
 #step -over
 if ![gdb_skip_stdio_test "next over print_int_array in print_all_arrays"] {
     set stop_line [gdb_get_line_number "-next1-"]
-    gdb_test "next" \
-	"array_i :.*$stop_line.*print_char_array.*" \
+    gdb_test_stdio "next" \
+	"array_i :" \
+	"$stop_line.*print_char_array.*" \
 	"next over print_int_array in print-all_arrays"
 } else {
     gdb_test "next" ".*" ""
@@ -170,13 +176,15 @@ if ![gdb_skip_stdio_test "next over print_int_array in print_all_arrays"] {
 #call print_double_array(array_d)
 if {![gdb_skip_float_test "print print_double_array(array_d)"] && \
     ![gdb_skip_stdio_test "print print_double_array(array_d)"] } {
-    gdb_test_sequence "print print_double_array(array_d)" "" {
-	"array_d :"
-	"\[ \t\r\n\]+========="
-	"\[ \t\r\n\]+\[ \t\r\n\]+0.000000"
-	"\[ \t\r\n\]+23.456\[0-9\]*  46.913\[0-9\]*  70.370\[0-9\]*  93.826\[0-9\]*  117.283\[0-9\]*  140.740\[0-9\]*  164.196\[0-9\]*  187.653\[0-9\]*"
-	"\[ \t\r\n\]+"
-    }
+
+    gdb_test_stdio "print print_double_array(array_d)" \
+	[multi_line \
+	     "array_d :" \
+	     "=========" \
+	     "" \
+	     "0.000000 *" \
+	     "23.456\[0-9\]*  46.913\[0-9\]*  70.370\[0-9\]*  93.826\[0-9\]*  117.283\[0-9\]*  140.740\[0-9\]*  164.196\[0-9\]*  187.653\[0-9\]*" \
+	    ]
 }
 
 set stop_line [gdb_get_line_number "-tbreak4-"]
@@ -186,15 +194,17 @@ gdb_test "tbreak $stop_line" \
 
 if {![gdb_skip_float_test "continuing to tbreak4"] && \
     ![gdb_skip_stdio_test "continuing to tbreak4"] } {
-    gdb_test_sequence "continue" "continuing to tbreak4" {
-	"Continuing\\..*array_c"
-	"array_f"
-	"\[ \t\r\n\]+array_d :"
-	"\[ \t\r\n\]+========="
-	"\[ \t\r\n\]+0.000000"
-	"\[ \t\r\n\]+23.456\[0-9\]*  46.913\[0-9\]*  70.370\[0-9\]*  93.826\[0-9\]*  117.283\[0-9\]*  140.740\[0-9\]*  164.196\[0-9\]*  187.653\[0-9\]*"
-	"\[ \t\r\n\]+.*HELLO WORLD.*main \\(\\) at .*call-ar-st.c:\[0-9\]+.*printf\\(.BYE BYE FOR NOW.n.\\)."
-    }
+
+    gdb_test_stdio "continue" \
+	[multi_line \
+	     "array_d :" \
+	     "=========" \
+	     "" \
+	     "0.000000 *" \
+	     "23.456\[0-9\]*  46.913\[0-9\]*  70.370\[0-9\]*  93.826\[0-9\]*  117.283\[0-9\]*  140.740\[0-9\]*  164.196\[0-9\]*  187.653\[0-9\]*" \
+	    ] \
+	"" \
+	"continuing to tbreak4"
 } else {
     gdb_test "continue" ".*" ""
 }
@@ -203,16 +213,34 @@ if {![gdb_skip_float_test "continuing to tbreak4"] && \
 #call sum_array_print(10, *list1, *list2, *list3, *list4)
 
 if ![gdb_skip_stdio_test "print sum_array_print(...)"] {
-    gdb_test "print sum_array_print(10, *list1, *list2, *list3, *list4)" \
-	".*Sum of 4 arrays, by element \\(add in seed as well\\):\[ \t\r\n\]+Seed: 10\[ \t\r\n\]+Element Index . Sum\[ \t\r\n\]+-------------------------\[ \t\r\n\]+.*\[ \t\]+0\[ \t\]+52\[ \t\r\n\]+1\[ \t\]+60\[ \t\r\n\]+2\[ \t\]+68\[ \t\r\n\]+3\[ \t\]+76\[ \t\r\n\]+4\[ \t\]+84\[ \t\r\n\]+5\[ \t\]+92\[ \t\r\n\]+6\[ \t\]+100\[ \t\r\n\]+7\[ \t\]+108\[ \t\r\n\]+8\[ \t\]+116\[ \t\r\n\]+9\[ \t\]+124\[ \t\r\n\]+.*" \
-	"print sum_array_print(10, *list1, *list2, *list3, *list4)"
+
+    gdb_test_stdio "print sum_array_print(10, *list1, *list2, *list3, *list4)" \
+	[multi_line \
+	     "Sum of 4 arrays, by element \\(add in seed as well\\): " \
+	     "" \
+	     "Seed: 10" \
+	     "Element Index . Sum " \
+	     "-------------------------" \
+	     ".*" \
+	     "\[ \t\]+0\[ \t\]+52" \
+	     "\[ \t\]+1\[ \t\]+60" \
+	     "\[ \t\]+2\[ \t\]+68" \
+	     "\[ \t\]+3\[ \t\]+76" \
+	     "\[ \t\]+4\[ \t\]+84" \
+	     "\[ \t\]+5\[ \t\]+92" \
+	     "\[ \t\]+6\[ \t\]+100" \
+	     "\[ \t\]+7\[ \t\]+108" \
+	     "\[ \t\]+8\[ \t\]+116" \
+	     "\[ \t\]+9\[ \t\]+124" \
+	    ]
 }
 
 #step over
 set stop_line [gdb_get_line_number "-next2-"]
 if ![gdb_skip_stdio_test "next to next2"] {
-    gdb_test "next" \
-	"BYE BYE FOR NOW.*$stop_line.*printf\\(.VERY GREEN GRASS.n.\\);.*" \
+    gdb_test_stdio "next" \
+	"BYE BYE FOR NOW" \
+	"$stop_line.*printf\\(.VERY GREEN GRASS.n.\\);.*" \
 	"next to next2"
 } else {
     gdb_test "next" ".*" ""
@@ -221,9 +249,8 @@ if ![gdb_skip_stdio_test "next to next2"] {
 #call print_array_rep(\*list1, \*list2, \*list3)
 
 if ![gdb_skip_stdio_test "print print_array_rep(...)"] {
-    gdb_test "print print_array_rep(\*list1, \*list2, \*list3)" \
-	"Contents of linked list3:.*" \
-	"print print_array_rep(*list1, *list2, *list3)"
+    gdb_test_stdio "print print_array_rep(\*list1, \*list2, \*list3)" \
+	"Contents of linked list3:"
 }
 
 set stop_line [gdb_get_line_number "-tbreak5-"]
@@ -272,8 +299,9 @@ gdb_test "tbreak $stop_line" \
     "tbreakpoint at tbreak6"
 
 if ![gdb_skip_stdio_test "continuing to tbreak6"] {
-    gdb_test "continue" \
-	"Continuing\\..*Sum of 4 arrays.*Contents of linked list1.*Contents of two_floats_t.*main \\(\\) at .*$srcfile:$stop_line.*c = 0.*" \
+    gdb_test_stdio "continue" \
+	"Sum of 4 arrays.*Contents of linked list1.*Contents of two_floats_t" \
+	"main \\(\\) at .*$srcfile:$stop_line.*c = 0.*" \
 	"continue to tbreak6"
 } else {
     gdb_test "continue" ".*" ""
@@ -285,41 +313,57 @@ if ![gdb_skip_stdio_test "continuing to tbreak6"] {
 
 if {![gdb_skip_float_test "print print_small_structs(...)"] && \
     ![gdb_skip_stdio_test "print print_small_structs(...)"] } {
-    gdb_test_sequence "print print_small_structs(*struct1, *struct2, *struct3, *struct4, *flags, *flags_combo, *three_char, *five_char, *int_char_combo, *d1, *d2, *d3, *f1, *f2, *f3)" "print print_small_structs" {
-	"\[\t\r\n \]+alpha"
-	"\[\t\r\n \]+gamma"
-	"\[\t\r\n \]+epsilon"
-	"\[\t\r\n \]+alpha"
-	"\[\t\r\n \]+gamma"
-	"\[\t\r\n \]+epsilon"
-	"\[\t\r\n \]+ch1: y[ \t]*ch2: n"
-	"\[\t\r\n \]+Contents of three_char_t:"
-	"\[\t\r\n \]+a[ \t]*b[ \t]*c"
-	"\[\t\r\n \]+Contents of five_char_t:"
-	"\[\t\r\n \]+l[ \t]*m[ \t]*n[ \t]*o[ \t]*p"
-	"\[\t\r\n \]+Contents of int_char_combo_t:"
-	"\[\t\r\n \]+123[ \t]*z"
-	"\[\t\r\n \]+Sum of the 4 struct values and seed :"
-	"\[\t\r\n \]+52"
-	"\[\t\r\n \]+Contents of struct1:"
-	"\[\t\r\n \]+6[ \t]*0"
-	"\[\t\r\n \]+Contents of struct2:"
-	"\[\t\r\n \]+10[ \t]*0"
-	"\[\t\r\n \]+Contents of struct3:"
-	"\[\t\r\n \]+12[ \t]*0"
-	"\[\t\r\n \]+Contents of one_double_t:"
-	"\[\t\r\n \]+10.500000"
-	"\[\t\r\n \]+Contents of one_double_t:"
-	"\[\t\r\n \]+-3.375000"
-	"\[\t\r\n \]+Contents of one_double_t:"
-	"\[\t\r\n \]+675.093750"
-	"\[\t\r\n \]+Contents of two_floats_t:"
-	"\[\t\r\n \]+45.234001[ \t]*43.599998"
-	"\[\t\r\n \]+Contents of two_floats_t:"
-	"\[\t\r\n \]+78.010002[ \t]*122.099998"
-	"\[\t\r\n \]+Contents of two_floats_t:"
-	"\[\t\r\n \]+-1232.344971[ \t]*-199.210007"
-    }
+    gdb_test_stdio "print print_small_structs(*struct1, *struct2, *struct3, *struct4, *flags, *flags_combo, *three_char, *five_char, *int_char_combo, *d1, *d2, *d3, *f1, *f2, *f3)" \
+	[multi_line \
+	     "alpha" \
+	     "gamma" \
+	     "epsilon" \
+	     "alpha" \
+	     "gamma" \
+	     "epsilon" \
+	     "ch1: y\[ \t\]*ch2: n" \
+	     "Contents of three_char_t: " \
+	     "" \
+	     "a\[ \t\]*b\[ \t\]*c" \
+	     "Contents of five_char_t: " \
+	     "" \
+	     "l\[ \t\]*m\[ \t\]*n\[ \t\]*o\[ \t\]*p" \
+	     "Contents of int_char_combo_t: " \
+	     "" \
+	     "123\[ \t\]*z" \
+	     "Sum of the 4 struct values and seed : " \
+	     "" \
+	     "\[ \t\]*52" \
+	     "Contents of struct1: " \
+	     "" \
+	     "\[ \t\]*6\[ \t\]*0" \
+	     "Contents of struct2: " \
+	     "" \
+	     "\[ \t\]*10\[ \t\]*0" \
+	     "Contents of struct3: " \
+	     "" \
+	     "\[ \t\]*12\[ \t\]*0" \
+	     "Contents of one_double_t: " \
+	     "" \
+	     "10.500000" \
+	     "Contents of one_double_t: " \
+	     "" \
+	     "-3.375000" \
+	     "Contents of one_double_t: " \
+	     "" \
+	     "675.093750" \
+	     "Contents of two_floats_t: " \
+	     "" \
+	     "\[ \t\]*45.234001\[ \t\]*43.599998" \
+	     "Contents of two_floats_t: " \
+	     "" \
+	     "\[ \t\]*78.010002\[ \t\]*122.099998" \
+	     "Contents of two_floats_t: " \
+	     "" \
+	     "-1232.344971\[ \t\]*-199.210007" \
+	    ] \
+	"" \
+	"print print_small_structs"
 }
 
 #call compute_with_small_structs(20)
@@ -333,13 +377,14 @@ gdb_test "print compute_with_small_structs(20)" \
 
 if {![gdb_skip_float_test "print print_ten_doubles(...)"] && \
     ![gdb_skip_stdio_test "print print_ten_doubles(...)"]} {
-    gdb_test_sequence "print print_ten_doubles(123.456, 123.456, -0.12, -1.23, 343434.8, 89.098, 3.14, -5678.12345, -0.11111111, 216.97065)" "print print_ten_doubles" {
-	"\[\t\r\n \]+Two Doubles : 123.45\[0-9\]*.*123.45\[0-9\]*"
-	"\[\t\r\n \]+Two Doubles : -0.1200\[0-9\]*.*-1.2300\[0-9\]*"
-	"\[\t\r\n \]+Two Doubles : 343434.\[0-9\]*.*89.09\[0-9\]*"
-	"\[\t\r\n \]+Two Doubles : 3.1400\[0-9\]*.*-5678.123\[0-9\]*"
-	"\[\t\r\n \]+Two Doubles : -0.1111\[0-9\]*.*216.97\[0-9\]*"
-    }
+    gdb_test_stdio "print print_ten_doubles(123.456, 123.456, -0.12, -1.23, 343434.8, 89.098, 3.14, -5678.12345, -0.11111111, 216.97065)" \
+	[multi_line \
+	     "Two Doubles : 123.45\[0-9\]*.*123.45\[0-9\]*" \
+	     "Two Doubles : -0.1200\[0-9\]*.*-1.2300\[0-9\]*" \
+	     "Two Doubles : 343434.\[0-9\]*.*89.09\[0-9\]*" \
+	     "Two Doubles : 3.1400\[0-9\]*.*-5678.123\[0-9\]*" \
+	     "Two Doubles : -0.1111\[0-9\]*.*216.97\[0-9\]*" \
+	     ]
 }
 
 set stop_line [gdb_get_line_number "-tbreak7-"]
@@ -408,43 +453,59 @@ if {![gdb_skip_float_test "print_small_structs from print_long_arg_list"] && \
 	setup_kfail "gdb/1539" "sparc-*-*"
     }
 
-    gdb_test_sequence "print print_small_structs(struct1, struct2, struct3, struct4, flags, flags_combo, three_char, five_char, int_char_combo, d1, d2, d3, f1, f2, f3)" "print print_small_structs from print_long_arg_list" {
-	"\[\t\r\n \]+alpha"
-	"\[\t\r\n \]+gamma"
-	"\[\t\r\n \]+epsilon"
-	"\[\t\r\n \]+alpha"
-	"\[\t\r\n \]+gamma"
-	"\[\t\r\n \]+epsilon"
-	"\[\t\r\n \]+ch1: y[ \t]*ch2: n"
-	"\[\t\r\n \]+Contents of three_char_t:"
-	"\[\t\r\n \]+a\[ \t\]*b\[ \t\]*c"
-	"\[\t\r\n \]+Contents of five_char_t:"
-	"\[\t\r\n \]+l\[ \t\]*m\[ \t\]*n\[ \t\]*o\[ \t\]*p"
-	"\[\t\r\n \]+Contents of int_char_combo_t:"
-	"\[\t\r\n \]+123\[ \t\]*z"
-	"\[\t\r\n \]+Sum of the 4 struct values and seed :"
-	"\[\t\r\n \]+52"
-	"\[\t\r\n \]+Contents of struct1:"
-	"\[\t\r\n \]+6\[ \t\]*0"
-	"\[\t\r\n \]+Contents of struct2:"
-	"\[\t\r\n \]+10\[ \t\]*0"
-	"\[\t\r\n \]+Contents of struct3:"
-	"\[\t\r\n \]+12\[ \t\]*0"
-	"\[\t\r\n \]+Contents of one_double_t:"
-	"\[\t\r\n \]+10.500000"
-	"\[\t\r\n \]+Contents of one_double_t:"
-	"\[\t\r\n \]+-3.375000"
-	"\[\t\r\n \]+Contents of one_double_t:"
-	"\[\t\r\n \]+675.093750"
-	"\[\t\r\n \]+Contents of two_floats_t:"
-	"\[\t\r\n \]+45.234001\[ \t\]*43.599998"
-	"\[\t\r\n \]+Contents of two_floats_t:"
-	"\[\t\r\n \]+78.010002\[ \t\]*122.099998"
-	"\[\t\r\n \]+Contents of two_floats_t:"
-	"\[\t\r\n \]+-1232.344971\[ \t\]*-199.210007"
-    }
-}
 
+    gdb_test_stdio "print print_small_structs(struct1, struct2, struct3, struct4, flags, flags_combo, three_char, five_char, int_char_combo, d1, d2, d3, f1, f2, f3)" \
+	[multi_line \
+	     "alpha" \
+	     "gamma" \
+	     "epsilon" \
+	     "alpha" \
+	     "gamma" \
+	     "epsilon" \
+	     "ch1: y\[ \t\]*ch2: n" \
+	     "Contents of three_char_t: " \
+	     "" \
+	     "a\[ \t\]*b\[ \t\]*c" \
+	     "Contents of five_char_t: " \
+	     "" \
+	     "l\[ \t\]*m\[ \t\]*n\[ \t\]*o\[ \t\]*p" \
+	     "Contents of int_char_combo_t: " \
+	     "" \
+	     "123\[ \t\]*z" \
+	     "Sum of the 4 struct values and seed : " \
+	     "" \
+	     "\[ \t\]*52" \
+	     "Contents of struct1: " \
+	     "" \
+	     "\[ \t\]*6\[ \t\]*0" \
+	     "Contents of struct2: " \
+	     "" \
+	     "\[ \t\]*10\[ \t\]*0" \
+	     "Contents of struct3: " \
+	     "" \
+	     "\[ \t\]*12\[ \t\]*0" \
+	     "Contents of one_double_t: " \
+	     "" \
+	     "10.500000" \
+	     "Contents of one_double_t: " \
+	     "" \
+	     "-3.375000" \
+	     "Contents of one_double_t: " \
+	     "" \
+	     "675.093750" \
+	     "Contents of two_floats_t: " \
+	     "" \
+	     "\[ \t\]*45.234001\[ \t\]*43.599998" \
+	     "Contents of two_floats_t: " \
+	     "" \
+	     "\[ \t\]*78.010002\[ \t\]*122.099998" \
+	     "Contents of two_floats_t: " \
+	     "" \
+	     "-1232.344971\[ \t\]*-199.210007" \
+	    ] \
+	"" \
+	"print print_small_structs from print_long_arg_list"
+}
 
 set stop_line [gdb_get_line_number "-tbreak8-"]
 gdb_test "tbreak $stop_line" \
@@ -452,8 +513,10 @@ gdb_test "tbreak $stop_line" \
     "tbreakpoint at tbreak8"
 
 if ![gdb_skip_stdio_test "continuing to tbreak8"] {
-    gdb_test "continue" "Continuing\\..*Contents of two_floats_t:.*main \\(\\) at.*$srcfile:$stop_line.*$stop_line.*init_bit_flags_combo\\(flags_combo, \\(unsigned\\)1, \\(unsigned\\)0, .y.,.*" \
-	    "continue to tbreak8"
+    gdb_test_stdio "continue" \
+	"Contents of two_floats_t:" \
+	".*main \\(\\) at.*$srcfile:$stop_line.*$stop_line.*init_bit_flags_combo\\(flags_combo, \\(unsigned\\)1, \\(unsigned\\)0, .y.,.*" \
+	"continue to tbreak8"
 } else {
     gdb_test "continue" ".*" ""
 }
@@ -466,9 +529,8 @@ gdb_test "step" \
 
 #call print_bit_flags_combo(*bit_flags_combo)
 if ![gdb_skip_stdio_test "continuing at step3"] {
-    gdb_test "print print_bit_flags_combo(*bit_flags_combo)" \
-	"alpha.*gamma.*epsilon.*ch1: y.*ch2: n.*" \
-	"print print_bit_flags_combo from init_bit_flags_combo"
+    gdb_test_stdio "print print_bit_flags_combo(*bit_flags_combo)" \
+	"alpha.*gamma.*epsilon.*ch1: y.*ch2: n"
 }
 
 
@@ -490,44 +552,64 @@ if {$hp_aCC_compiler} {setup_xfail "hppa*-*-*" CLLbs16994}
 
 if {![gdb_skip_float_test "print print_long_arg_list"] && \
     ![gdb_skip_stdio_test "print print_long_arg_list"] } {
-    gdb_test_sequence "print print_long_arg_list(a, b, c, d, e, f, *struct1, *struct2, *struct3, *struct4, *flags, *flags_combo, *three_char, *five_char, *int_char_combo, *d1, *d2, *d3, *f1, *f2, *f3)" "print print_long_arg_list" {
-	"\[ \n\r\t\]+double : 22.250000"
-	"\[ \n\r\t\]+double : 33.375000"
-	"\[ \n\r\t\]+int : 0"
-	"\[ \n\r\t\]+int : -25"
-	"\[ \n\r\t\]+int : 100"
-	"\[ \n\r\t\]+int : 2345"
-	"\[ \n\r\t\]+alpha"
-	"\[ \n\r\t\]+gamma"
-	"\[ \n\r\t\]+epsilon"
-	"\[ \n\r\t\]+ch1: y\[ \t\]+ch2: n"
-	"\[ \n\r\t\]+Contents of three_char_t:"
-	"\[ \n\r\t\]+x\[ \t\]+y\[ \t\]+z"
-	"\[ \n\r\t\]+Contents of five_char_t:"
-	"\[ \n\r\t\]+h\[ \t\]+e\[ \t\]+l\[ \t\]+l\[ \t\]+o"
-	"\[ \n\r\t\]+Contents of int_char_combo_t:"
-	"\[ \n\r\t\]+123\[ \t\]+z"
-	"\[ \n\r\t\]+Sum of the 4 struct values and seed :"
-	"\[ \n\r\t\]+52"
-	"\[ \n\r\t\]+Contents of struct1:"
-	"\[ \n\r\t\]+6\[ \t\]+0"
-	"\[ \n\r\t\]+Contents of struct2:"
-	"\[ \n\r\t\]+10\[ \t\]+0"
-	"\[ \n\r\t\]+Contents of struct3:"
-	"\[ \n\r\t\]+12\[ \t\]+0"
-	"\[ \n\r\t\]+Contents of one_double_t:"
-	"\[ \n\r\t\]+1.111110"
-	"\[ \n\r\t\]+Contents of one_double_t:"
-	"\[ \n\r\t\]+-345.340000"
-	"\[ \n\r\t\]+Contents of one_double_t:"
-	"\[ \n\r\t\]+546464.200000"
-	"\[ \n\r\t\]+Contents of two_floats_t:"
-	"\[ \n\r\t\]+0.234000\[ \t\]+453.100006"
-	"\[ \n\r\t\]+Contents of two_floats_t:"
-	"\[ \n\r\t\]+78.345001\[ \t\]+23.090000"
-	"\[ \n\r\t\]+Contents of two_floats_t:"
-	"\[ \n\r\t\]+-2.345000\[ \t\]+1.000000"
-    }
+
+    gdb_test_stdio "print print_long_arg_list(a, b, c, d, e, f, *struct1, *struct2, *struct3, *struct4, *flags, *flags_combo, *three_char, *five_char, *int_char_combo, *d1, *d2, *d3, *f1, *f2, *f3)" \
+	[multi_line \
+	     "double : 22.250000" \
+	     "double : 33.375000" \
+	     "int : 0" \
+	     "int : -25" \
+	     "int : 100" \
+	     "int : 2345" \
+	     "alpha" \
+	     "gamma" \
+	     "epsilon" \
+	     "alpha" \
+	     "gamma" \
+	     "epsilon" \
+	     "ch1: y\[ \t\]*ch2: n" \
+	     "Contents of three_char_t: " \
+	     "" \
+	     "x\[ \t\]*y\[ \t\]*z" \
+	     "Contents of five_char_t: " \
+	     "" \
+	     "h\[ \t\]*e\[ \t\]*l\[ \t\]*l\[ \t\]*o" \
+	     "Contents of int_char_combo_t: " \
+	     "" \
+	     "123\[ \t\]*z" \
+	     "Sum of the 4 struct values and seed : " \
+	     "" \
+	     "\[ \t\]*52" \
+	     "Contents of struct1: " \
+	     "" \
+	     "\[ \t\]*6\[ \t\]*0" \
+	     "Contents of struct2: " \
+	     "" \
+	     "\[ \t\]*10\[ \t\]*0" \
+	     "Contents of struct3: " \
+	     "" \
+	     "\[ \t\]*12\[ \t\]*0" \
+	     "Contents of one_double_t: " \
+	     "" \
+	     "1.111110" \
+	     "Contents of one_double_t: " \
+	     "" \
+	     "-345.340000" \
+	     "Contents of one_double_t: " \
+	     "" \
+	     "546464.200000" \
+	     "Contents of two_floats_t: " \
+	     "" \
+	     "0.234000\[ \t\]*453.100006" \
+	     "Contents of two_floats_t: " \
+	     "" \
+	     "78.345001\[ \t\]*23.090000" \
+	     "Contents of two_floats_t: " \
+	     "" \
+	     "-2.345000\[ \t\]*1.000000" \
+	    ] \
+	"" \
+	"print print_long_arg_list"
 }
 
 
@@ -542,29 +624,30 @@ gdb_test continue "Continuing\\..*main \\(\\) at .*$srcfile:$stop_line\[ \t\n\r\
 
 #call sum_struct_print(10, *struct1, *struct2, *struct3, *struct4)
 if ![gdb_skip_stdio_test "print sum_struct_print(...)"] {
-    gdb_test "print sum_struct_print(10,*struct1,*struct2,*struct3,*struct4)" \
-	"Sum of the 4 struct values and seed :\[ \t\n\r\]+218.*" \
-	"print sum_struct_print(10, *struct1, *struct2, *struct3, *struct4)"
+    gdb_test_stdio "print sum_struct_print(10,*struct1,*struct2,*struct3,*struct4)" \
+	"Sum of the 4 struct values and seed :\[ \t\n\r\]+218"
 }
 
 
 #call print_struct_rep(*struct1, *struct2, *struct3)
 if ![gdb_skip_stdio_test "print print_struct_rep(...)"] {
-    gdb_test_sequence "print print_struct_rep(*struct1, *struct2, *struct3)" \
-	"print print_struct_rep(*struct1, *struct2, *struct3)" {
-	"\[ \t\n\r\]+Contents of struct1:"
-	"\[ \t\n\r\]+        22         0"
-	"\[ \t\n\r\]+Contents of struct2:"
-	"\[ \t\n\r\]+        42         0"
-	"\[ \t\n\r\]+Contents of struct3:"
-	"\[ \t\n\r\]+        62         0"
-    }
+    gdb_test_stdio "print print_struct_rep(*struct1, *struct2, *struct3)" \
+	[multi_line \
+	     "Contents of struct1: " \
+	     "" \
+	     "        22         0" \
+	     "Contents of struct2: " \
+	     "" \
+	     "        42         0" \
+	     "Contents of struct3: " \
+	     "" \
+	     "        62         0" \
+	    ]
 }
 
 if ![gdb_skip_stdio_test "print print_one_large_struct(...)"] {
-    gdb_test "print print_one_large_struct(*list1)" \
-	"         4         1.*" \
-	"print print_one_large_struct(*list1)"
+    gdb_test_stdio "print print_one_large_struct(*list1)" \
+	"         4         1"
 }
 
 set timeout $oldtimeout
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 12/24] Make gdb.base/a2-run.exp use $inferior_spawn_id and gdb_test_stdio
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
  2015-04-21 18:08 ` [PATCH 10/24] Make gdb.base/catch-gdb-caused-signals.exp use gdb_test_stdio Pedro Alves
  2015-04-21 18:08 ` [PATCH 07/24] Introduce gdb_test_stdio Pedro Alves
@ 2015-04-21 18:08 ` Pedro Alves
  2015-04-21 18:08 ` [PATCH 13/24] Make gdb.base/call-ar-st.exp use gdb_test_stdio Pedro Alves
                   ` (21 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:08 UTC (permalink / raw)
  To: gdb-patches

This one is a little more complicated than the other patches in this
series, because of the exit status wrapper handling, requiring a
little state machine.

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* gdb.base/a2-run.exp (saw_usage, saw_exit_wrapper)
	(saw_spurious_output): Expect inferior output from
	$inferior_spawn_id.  Use gdb_test_stdio.
---
 gdb/testsuite/gdb.base/a2-run.exp | 91 ++++++++++++++++++++++++++++++---------
 1 file changed, 71 insertions(+), 20 deletions(-)

diff --git a/gdb/testsuite/gdb.base/a2-run.exp b/gdb/testsuite/gdb.base/a2-run.exp
index 3e4bfdf..dd6af25 100644
--- a/gdb/testsuite/gdb.base/a2-run.exp
+++ b/gdb/testsuite/gdb.base/a2-run.exp
@@ -33,25 +33,77 @@ if { [prepare_for_testing ${testfile}.exp $testfile $srcfile] } {
 # Run with no arguments.
 gdb_run_cmd
 
+set saw_usage 0
+set saw_exit_wrapper 0
+set saw_spurious_output 0
+
 set test "run \"$testfile\" with no args"
 
-gdb_test_multiple "" $test {
-    -re ".*usage:  factorial <number>.*$inferior_exited_re with code 01.\r\n$gdb_prompt $" {
-	pass $test
-	pass "no spurious messages at program exit"
+set inferior_spawn_list "$inferior_spawn_id"
+set gdb_spawn_list "$gdb_spawn_id"
+
+set res [gdb_test_multiple "" $test {
+    -i inferior_spawn_list
+    -re "usage:  factorial <number>" {
+	set saw_usage 1
+	exp_continue
+    }
+    -re "EXIT code 1" {
+	set saw_exit_wrapper 1
+	set inferior_spawn_list ""
+	exp_continue
+    }
+    eof {
+	if {$inferior_spawn_id != $gdb_spawn_id} {
+	    # In this case we may see the server/inferior exit before
+	    # GDB's program exit output.  Remove from spawn list and
+	    # continue waiting.
+	    set inferior_spawn_list ""
+	    exp_continue
+	}
+	# GDB crash.
+	fail "$test (eof)"
+    }
+
+    -i gdb_spawn_list
+
+    -re "$inferior_exited_re with code 01.\r\n$gdb_prompt $" {
     }
-    -re ".*usage:  factorial <number>.*$inferior_exited_re with code 01.*$gdb_prompt $" {
-	pass $test
-	fail "no spurious messages at program exit"
+    -re "$inferior_exited_re with code 01.*$gdb_prompt $" {
+	set saw_spurious_output 1
     }
-    -re ".*usage:  factorial <number>.* EXIT code 1.*$inferior_exited_re normally.\r\n$gdb_prompt $" {
-	pass "$test (exit wrapper)"
-	pass "no spurious messages at program exit"
+
+    -re "$inferior_exited_re normally.\r\n$gdb_prompt $" {
+	# This is only considered a pass if we see the exit wrapper
+	# status.  Since if $inferior_spawn_id != $gdb_spawn_id the
+	# order we pick output from each spawn id isn't defined,
+	# remove gdb_spawn_id from the match lists and go back to
+	# waiting.  If we had already seen the status wrapper exit,
+	# gdb_test_multiple/expect has no spawn ids left, and thus
+	# returns.
+	set gdb_spawn_list ""
+	exp_continue
     }
-    -re ".*usage:  factorial <number>.* EXIT code 1.*$inferior_exited_re normally.*$gdb_prompt $" {
-	pass "$test (exit wrapper)"
-	fail "no spurious messages at program exit"
+    -re "$inferior_exited_re normally.*$gdb_prompt $" {
+	set saw_spurious_output 1
+
+	# See above.
+	set gdb_spawn_list ""
+	exp_continue
     }
+}]
+
+if {$res == 0} {
+    gdb_assert ${saw_usage} $test
+
+    if {$saw_exit_wrapper} {
+	set msg "$test (exit wrapper)"
+    } else {
+	set msg $test
+    }
+
+    gdb_assert !$saw_spurious_output "no spurious messages at program exit"
+
 }
 
 # The remaining tests don't work for targets can't take arguments...
@@ -64,20 +116,20 @@ if [target_info exists noargs] then {
 # Now run with some arguments
 setup_xfail "arm-*-coff"
 gdb_run_cmd 5
-gdb_test "" "120.*" "run \"$testfile\" with arg"
+gdb_test_stdio "" "120" "" "run \"$testfile\" with arg"
 
 # Run again with same arguments.
 gdb_run_cmd
 
 setup_xfail "arm-*-coff"
-gdb_test "" "120.*" "run \"$testfile\" again with same args"
+gdb_test_stdio "" "120" "" "run \"$testfile\" again with same args"
 
 # Use "set args" command to specify no arguments as default and run again.
 gdb_test_no_output "set args"
 
 gdb_run_cmd
 
-gdb_test "" "usage:  factorial <number>.*" "run after setting args to nil"
+gdb_test_stdio "" "usage:  factorial <number>" "" "run after setting args to nil"
 
 # Use "set args" command to specify an argument and run again.
 gdb_test_no_output "set args 6"
@@ -85,12 +137,11 @@ gdb_test_no_output "set args 6"
 gdb_run_cmd
 
 setup_xfail "arm-*-coff"
-gdb_test "" "720.*" "run \"$testfile\" again after setting args"
+gdb_test_stdio "" "720" "" "run \"$testfile\" again after setting args"
 
 # GOAL: Test that shell is being used with "run".  For remote debugging
 # targets, there is no guarantee that a "shell" (whatever that is) is used.
 if ![is_remote target] then {
-    gdb_test "run `echo 8`" \
-	"Starting program.*40320.*" \
-	"run \"$testfile\" with shell"
+    gdb_test_stdio "run `echo 8`" \
+	"40320" "" "run \"$testfile\" with shell"
 }
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 10/24] Make gdb.base/catch-gdb-caused-signals.exp use gdb_test_stdio
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
@ 2015-04-21 18:08 ` Pedro Alves
  2015-04-21 18:08 ` [PATCH 07/24] Introduce gdb_test_stdio Pedro Alves
                   ` (23 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:08 UTC (permalink / raw)
  To: gdb-patches

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* gdb.base/catch-gdb-caused-signals.exp: Use gdb_test_stdio.
---
 gdb/testsuite/gdb.base/catch-gdb-caused-signals.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.base/catch-gdb-caused-signals.exp b/gdb/testsuite/gdb.base/catch-gdb-caused-signals.exp
index 8ba3be5..c024477 100644
--- a/gdb/testsuite/gdb.base/catch-gdb-caused-signals.exp
+++ b/gdb/testsuite/gdb.base/catch-gdb-caused-signals.exp
@@ -59,5 +59,5 @@ if ![target_info exists gdb,noinferiorio] {
     # Also test with dprintf since the original bug was noticed using dprintf.
     gdb_test "dprintf $dp_location,\"testdprintf\\n\"" "Dprintf .*"
 
-    gdb_test "continue" "testdprintf.*"
+    gdb_test_stdio "continue" "testdprintf"
 }
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 01/24] gdb_test_multiple match eof of any spawn_id
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
                   ` (3 preceding siblings ...)
  2015-04-21 18:08 ` [PATCH 13/24] Make gdb.base/call-ar-st.exp use gdb_test_stdio Pedro Alves
@ 2015-04-21 18:08 ` Pedro Alves
  2015-04-21 18:08 ` [PATCH 04/24] Don't rely on inferior I/O in gdb.base/siginfo-addr.exp Pedro Alves
                   ` (19 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:08 UTC (permalink / raw)
  To: gdb-patches

Since silent handling of eof is usually the wrong thing to do, this
patch makes gdb_test_multiple handle it for all $any_spawn_id.

Currently, against gdbserver, interrupt.exp occasionaly fails like
this:

 FAIL: gdb.base/interrupt.exp: send end of file

gdb.log with expect debug output enabled shows:

 expect: does "\r\n\r\nChild exited with status 0\r\nGDBserver exiting\r\n" (spawn_id exp8) match regular expression "end of file"? Gate "end of file"? gate=no
 expect: read eof
 expect: set expect_out(spawn_id) "exp8"
 expect: set expect_out(buffer) "\r\n\r\nChild exited with status 0\r\nGDBserver exiting\r\n"
 FAIL: gdb.base/interrupt.exp: send end of file

Note "expect: read eof" for spawn_id=exp8.  exp8 is
inferior_spawn_id/gdbserver_spawn_id.  That means
expect/gdb_test_multiple saw gdbserver exit before we got the expected
gdb output.  Since there's no explicit pattern for "eof", expect (and
thus gdb_test_multiple) just returns.

After this commit, we get instead:

 ERROR: Process no longer exists
 UNRESOLVED: gdb.base/interrupt.exp: send end of file

Note that before we still got an FAIL because $saw_inferior_exit is 0
when we get to:

	gdb_assert { $saw_eof && $saw_inferior_exit } $msg

Fixing the fail (now unresolved) will be the subject of a separate
patch.

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* lib/gdb.exp (gdb_test_multiple): Match eof/full_buffer/timeout
	on $any_spawn_id instead of only on $gdb_spawn_id.
---
 gdb/testsuite/lib/gdb.exp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 7d8720b..73e55e3 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -692,6 +692,7 @@ proc gdb_test_multiple { command message user_code } {
     global inferior_exited_re
     upvar timeout timeout
     upvar expect_out expect_out
+    global any_spawn_id
 
     if { $message == "" } {
 	set message $command
@@ -918,6 +919,9 @@ proc gdb_test_multiple { command message user_code } {
 	    fail "$message (got breakpoint menu)"
 	    set result -1
 	}
+
+	# Patterns below apply to any spawn id specified.
+	-i $any_spawn_id
 	eof {
 	    perror "Process no longer exists"
 	    if { $message != "" } {
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 04/24] Don't rely on inferior I/O in gdb.base/siginfo-addr.exp
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
                   ` (4 preceding siblings ...)
  2015-04-21 18:08 ` [PATCH 01/24] gdb_test_multiple match eof of any spawn_id Pedro Alves
@ 2015-04-21 18:08 ` Pedro Alves
  2015-04-21 18:08 ` [PATCH 16/24] Make gdb.base/shlib-call.exp use gdb_test_stdio Pedro Alves
                   ` (18 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:08 UTC (permalink / raw)
  To: gdb-patches

No point in relying on stdio in this test.  Simply run to a breakpoint
instead.

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* gdb.base/siginfo-addr.c (pass): New function.
	(handler): Call it iff si_addr is correct.
	* gdb.base/siginfo-addr.exp: Remove gdb_skip_stdio_test check.
	Set a breakpoint at "pass" and continue to it.
---
 gdb/testsuite/gdb.base/siginfo-addr.c   |  9 ++++++---
 gdb/testsuite/gdb.base/siginfo-addr.exp | 17 +++--------------
 2 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/gdb/testsuite/gdb.base/siginfo-addr.c b/gdb/testsuite/gdb.base/siginfo-addr.c
index a074b4d..c6d8556 100644
--- a/gdb/testsuite/gdb.base/siginfo-addr.c
+++ b/gdb/testsuite/gdb.base/siginfo-addr.c
@@ -26,13 +26,16 @@
 
 static void *p;
 
+void
+pass (void)
+{
+}
+
 static void
 handler (int sig, siginfo_t *info, void *context)
 {
   if (info->si_addr == p)
-    printf ("Correct si_addr value.\n");
-  else
-    printf ("Got si_addr = %p, expected %p.\n", info->si_addr, p);
+    pass ();
   _exit (0);
 }
 
diff --git a/gdb/testsuite/gdb.base/siginfo-addr.exp b/gdb/testsuite/gdb.base/siginfo-addr.exp
index 5ac6105..e2f5914 100644
--- a/gdb/testsuite/gdb.base/siginfo-addr.exp
+++ b/gdb/testsuite/gdb.base/siginfo-addr.exp
@@ -26,11 +26,6 @@ if [target_info exists gdb,nosignals] {
     continue
 }
 
-if [gdb_skip_stdio_test "siginfo-addr.exp"] {
-    continue
-}
-
-
 standard_testfile
 if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
     untested "Couldn't compile ${srcfile}.c"
@@ -47,13 +42,7 @@ if { ![runto_main] } then {
 # Run to the signal.
 gdb_test "continue" ".*Program received signal SIGSEGV.*" "continue to signal"
 
+gdb_breakpoint "pass"
+
 # Check for correct si_addr.
-set test "program exit"
-gdb_test_multiple "continue" "${test}" {
-    -re "Correct si_addr" {
-	pass "si_addr value"
-    }
-    -re "Got si_addr" {
-	fail "si_addr value"
-    }
-}
+gdb_test "continue" "Breakpoint .* pass .*" "correct si_addr"
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards
@ 2015-04-21 18:08 Pedro Alves
  2015-04-21 18:08 ` [PATCH 10/24] Make gdb.base/catch-gdb-caused-signals.exp use gdb_test_stdio Pedro Alves
                   ` (24 more replies)
  0 siblings, 25 replies; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:08 UTC (permalink / raw)
  To: gdb-patches

This series finishes what was started here:

  https://sourceware.org/ml/gdb-patches/2015-02/msg00655.html

In a nutshell:
  
 - Make a few tests that are currently relying on inferior I/O to not
   do that anymore.

 - Convert all the remaining tests that rely on inferior I/O to use
   $inferior_spawn_id.

 - Add a gdb_test_stdio helper used by most of the above.

 - Unbuffer all tests that rely on stdio, using the same mechanism
   that ended up used in interrupt.exp, in the series in the url
   above.

 - Remove gdb,noinferiorio from our gdbserver boards, so the tests run
   (against gdbserver).

Tested on x86_64 Fedora 20, native, native-gdbserver and also against
remote gdbserver with no pseudo-tty, which requires the unbuffering.

I've pushed this to users/palves/inferior_spawn_id for review and
testing convenience.

Pedro Alves (24):
  gdb_test_multiple match eof of any spawn_id
  gdb.base/interrupt.exp: Rename saw_eof to saw_end_of_file
  Fix gdb.base/interrupt.exp racy fail against gdbserver
  Don't rely on inferior I/O in gdb.base/siginfo-addr.exp
  Don't rely on inferior I/O in {call-signal-resume, unwindonsignal}.exp
  Don't rely on inferior I/O in gdb.base/restore.exp
  Introduce gdb_test_stdio
  Make gdb.base/sizeof.exp use gdb_test_stdio
  Make gdb.base/call-strs.exp use gdb_test_stdio
  Make gdb.base/catch-gdb-caused-signals.exp use gdb_test_stdio
  Make gdb.base/dprintf.exp use gdb_test_stdio
  Make gdb.base/a2-run.exp use $inferior_spawn_id and gdb_test_stdio
  Make gdb.base/call-ar-st.exp use gdb_test_stdio
  Make gdb.base/call-rt-st.exp use $inferior_spawn_id
  Make gdb.base/ending-run.exp use gdb_test_stdio
  Make gdb.base/shlib-call.exp use gdb_test_stdio
  Make gdb.base/varargs.exp use gdb_test_stdio
  Make gdb.gdb/complaints.exp use '-i $inferior_spawn_id' and
    gdb_test_stdio
  Make gdb.gdb/selftest.exp use '-i $inferior_spawn_id'
  Adjust MI to $inferior_spawn_id
  Make gdb.mi/mi-dprintf.exp use $inferior_spawn_id
  Unbuffer all tests that rely on stdio
  interrupt.exp: Revert back to checking gdb,noinferiorio at the top
  Don't set gdb,noinferiorio on gdbserver boards

 gdb/testsuite/boards/gdbserver-base.exp            |   3 -
 gdb/testsuite/gdb.base/a2-run.exp                  |  91 +++-
 gdb/testsuite/gdb.base/call-ar-st.c                |   4 +
 gdb/testsuite/gdb.base/call-ar-st.exp              | 485 ++++++++++++---------
 gdb/testsuite/gdb.base/call-rt-st.c                |   3 +
 gdb/testsuite/gdb.base/call-rt-st.exp              |  61 ++-
 gdb/testsuite/gdb.base/call-signal-resume.exp      |  18 +-
 gdb/testsuite/gdb.base/call-signals.c              |   3 -
 gdb/testsuite/gdb.base/call-strs.c                 |   4 +
 gdb/testsuite/gdb.base/call-strs.exp               |  53 ++-
 gdb/testsuite/gdb.base/catch-gdb-caused-signals.c  |   4 +
 .../gdb.base/catch-gdb-caused-signals.exp          |   2 +-
 gdb/testsuite/gdb.base/dprintf.c                   |   4 +
 gdb/testsuite/gdb.base/dprintf.exp                 | 134 ++++--
 gdb/testsuite/gdb.base/ending-run.c                |   4 +
 gdb/testsuite/gdb.base/ending-run.exp              |  10 +-
 gdb/testsuite/gdb.base/interrupt.exp               |  33 +-
 gdb/testsuite/gdb.base/restore.exp                 |  15 +-
 gdb/testsuite/gdb.base/run.c                       |   4 +
 gdb/testsuite/gdb.base/shlib-call.exp              |  22 +-
 gdb/testsuite/gdb.base/shmain.c                    |   5 +
 gdb/testsuite/gdb.base/siginfo-addr.c              |   9 +-
 gdb/testsuite/gdb.base/siginfo-addr.exp            |  17 +-
 gdb/testsuite/gdb.base/sizeof.c                    |   4 +
 gdb/testsuite/gdb.base/sizeof.exp                  |  14 +-
 gdb/testsuite/gdb.base/unwindonsignal.c            |   3 -
 gdb/testsuite/gdb.base/unwindonsignal.exp          |  18 +-
 gdb/testsuite/gdb.base/varargs.c                   |  13 +-
 gdb/testsuite/gdb.base/varargs.exp                 |  27 +-
 gdb/testsuite/gdb.gdb/complaints.exp               | 110 +++--
 gdb/testsuite/gdb.gdb/selftest.exp                 |  14 +-
 gdb/testsuite/gdb.mi/mi-dprintf.c                  |   4 +
 gdb/testsuite/gdb.mi/mi-dprintf.exp                |  66 +--
 gdb/testsuite/lib/gdb.exp                          |  71 +++
 gdb/testsuite/lib/mi-support.exp                   |  56 +--
 35 files changed, 858 insertions(+), 530 deletions(-)

-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 14/24] Make gdb.base/call-rt-st.exp use $inferior_spawn_id
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
                   ` (12 preceding siblings ...)
  2015-04-21 18:09 ` [PATCH 06/24] Don't rely on inferior I/O in gdb.base/restore.exp Pedro Alves
@ 2015-04-21 18:09 ` Pedro Alves
  2015-04-21 18:09 ` [PATCH 09/24] Make gdb.base/call-strs.exp use gdb_test_stdio Pedro Alves
                   ` (10 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:09 UTC (permalink / raw)
  To: gdb-patches

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* gdb.base/call-rt-st.exp (print_struct_call): Split "result"
	parameter into two new parameters, "inf_result" and "gdb_result".
	Expect inferior output and gdb output from $inferior_spawn_id and
	$gdb_spawn_id, respectively.  Adjust all callers.
---
 gdb/testsuite/gdb.base/call-rt-st.exp | 61 ++++++++++++++++++++++++++---------
 1 file changed, 46 insertions(+), 15 deletions(-)

diff --git a/gdb/testsuite/gdb.base/call-rt-st.exp b/gdb/testsuite/gdb.base/call-rt-st.exp
index 36d81fb..46cdfa9 100644
--- a/gdb/testsuite/gdb.base/call-rt-st.exp
+++ b/gdb/testsuite/gdb.base/call-rt-st.exp
@@ -87,76 +87,107 @@ gdb_test_multiple "finish" "finish out from loop count" {
 # return value unknown", call that an `unsupported' test; on some
 # architectures, it's impossible to find structs returned by value
 # reliably.
-proc print_struct_call { expr result } {
+proc print_struct_call { expr inf_result gdb_result } {
     global gdb_prompt
+    global inferior_spawn_id gdb_spawn_id
+
+    set inferior_matched 0
+    set gdb_matched 0
 
     set command "print $expr"
     gdb_test_multiple "${command}" "${command}" {
-        -re "$result\[\r\n\]+$gdb_prompt $" {
-            pass "$command"
-        }
+	-i $inferior_spawn_id
+	-re "$inf_result" {
+	    set inferior_matched 1
+	    if {!$gdb_matched} {
+		exp_continue
+	    }
+	}
+
+	-i $gdb_spawn_id
+	-re "$gdb_result\r\n$gdb_prompt $" {
+	    set gdb_matched 1
+	    if {!$inferior_matched} {
+		exp_continue
+	    }
+	}
         -re "Function return value unknown.\[\r\n\]+$gdb_prompt $" {
             unsupported "$command"
+	    return
         }
     }
+
+    verbose -log "inferior_matched=$inferior_matched, gdb_matched=$gdb_matched"
+    gdb_assert {$inferior_matched && $gdb_matched} $command
 }
 
 
 if ![gdb_skip_stdio_test "print print_struct_rep(*struct1)"] {
     print_struct_call "print_struct_rep(*struct1)" \
-            ".*Contents of struct1:\[ \t\n\r\]+22\[ \t\]+0\[ \t\n\r\]+.\[0-9\]+ = \\{value = 5, head = 0\\}"
+	".*Contents of struct1:\[ \t\n\r\]+22\[ \t\]+0\[ \t\n\r\]+" \
+	".\[0-9\]+ = \\{value = 5, head = 0\\}"
 }
 
 if ![gdb_skip_stdio_test "print print_one_large_struct(...)"] {
     print_struct_call "print_one_large_struct(*list1)" \
-            ".*\[ \t\]+4\[ \t\]+1\[ \r\n\]+.\[0-9\]+ = \\{next_index = \\{1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\}, values = \\{4, 6, 8, 10, 12, 14, 16, 18, 20, 22\\}, head = 0\\}"
+	".*\[ \t\]+4\[ \t\]+1\[ \r\n\]+" \
+	".\[0-9\]+ = \\{next_index = \\{1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\}, values = \\{4, 6, 8, 10, 12, 14, 16, 18, 20, 22\\}, head = 0\\}"
 }
 
 if {![gdb_skip_float_test "print print_one_double(*d1)"] && \
         ![gdb_skip_stdio_test "print print_one_double(*d1)"] } {
     print_struct_call "print_one_double(*d1)" \
-	    ".*Contents of one_double_t:\[ \r\n\]+1\\.111110\[ \r\n\]+.\[0-9\]+ = \\{double1 = 1\\.111\[0-9\]*\\}"
+	".*Contents of one_double_t:\[ \r\n\]+1\\.111110\[ \r\n\]+" \
+	".\[0-9\]+ = \\{double1 = 1\\.111\[0-9\]*\\}"
 }
 
 if {![gdb_skip_float_test "print print_two_floats(*f3)"] && \
         ![gdb_skip_stdio_test "print print_two_floats(*f3)"] } {
     print_struct_call "print_two_floats(*f3)" \
-            ".*Contents of two_floats_t:\[ \r\n\]+-2\\.345000\[ \t]+1\\.000000\[ \r\n\]+.\[0-9\]+ = \\{float1 = -2\\.34500003, float2 = 1\\}"
+	".*Contents of two_floats_t:\[ \r\n\]+-2\\.345000\[ \t]+1\\.000000\[ \r\n\]+" \
+	".\[0-9\]+ = \\{float1 = -2\\.34500003, float2 = 1\\}"
 }
 
 if ![gdb_skip_stdio_test "print print_bit_flags_char(*cflags)"] {
     print_struct_call "print_bit_flags_char(*cflags)" \
-            ".*alpha\[ \r\n\]+gamma\[ \r\n\]+epsilon\[ \r\n\]+.\[0-9\]+ = \\{alpha = 1 '\\\\001', beta = 0 '\\\\000', gamma = 1 '\\\\001', delta = 0 '\\\\000', epsilon = 1 '\\\\001', omega = 0 '\\\\000'\\}"
+	".*alpha\[ \r\n\]+gamma\[ \r\n\]+epsilon\[ \r\n\]+" \
+	".\[0-9\]+ = \\{alpha = 1 '\\\\001', beta = 0 '\\\\000', gamma = 1 '\\\\001', delta = 0 '\\\\000', epsilon = 1 '\\\\001', omega = 0 '\\\\000'\\}"
 }
 
 if ![gdb_skip_stdio_test "print print_bit_flags_short(*sflags)"] {
     print_struct_call "print_bit_flags_short(*sflags)" \
-            ".*alpha\[ \r\n\]+gamma\[ \r\n\]+epsilon\[ \r\n\]+.\[0-9\]+ = \\{alpha = 1, beta = 0, gamma = 1, delta = 0, epsilon = 1, omega = 0\\}"
+	".*alpha\[ \r\n\]+gamma\[ \r\n\]+epsilon\[ \r\n\]+" \
+	".\[0-9\]+ = \\{alpha = 1, beta = 0, gamma = 1, delta = 0, epsilon = 1, omega = 0\\}"
 }
 
 if ![gdb_skip_stdio_test "print print_bit_flags(*flags)"] {
     print_struct_call "print_bit_flags(*flags)" \
-            ".*alpha\[ \r\n\]+gamma\[ \r\n\]+epsilon\[ \r\n\]+.\[0-9\]+ = \\{alpha = 1, beta = 0, gamma = 1, delta = 0, epsilon = 1, omega = 0\\}"
+	".*alpha\[ \r\n\]+gamma\[ \r\n\]+epsilon\[ \r\n\]+" \
+	".\[0-9\]+ = \\{alpha = 1, beta = 0, gamma = 1, delta = 0, epsilon = 1, omega = 0\\}"
 }
 
 if ![gdb_skip_stdio_test "print print_bit_flags_combo(*flags_combo)"] {
     print_struct_call "print_bit_flags_combo(*flags_combo)" \
-            ".*alpha\[ \r\n\]+gamma\[ \r\n\]+epsilon\[ \r\n\]+ch1: y\[ \t\]+ch2: n\[ \r\n\]+.\[0-9\]+ = \\{alpha = 1, beta = 0, ch1 = 121 'y', gamma = 1, delta = 0, ch2 = 110 'n', epsilon = 1, omega = 0\\}"
+	".*alpha\[ \r\n\]+gamma\[ \r\n\]+epsilon\[ \r\n\]+ch1: y\[ \t\]+ch2: n\[ \r\n\]+" \
+	".\[0-9\]+ = \\{alpha = 1, beta = 0, ch1 = 121 'y', gamma = 1, delta = 0, ch2 = 110 'n', epsilon = 1, omega = 0\\}"
 }
 
 if ![gdb_skip_stdio_test "print print_three_chars(*three_chars)"] {
     print_struct_call "print_three_chars(*three_char)" \
-            ".*Contents of three_char_t:\[ \r\n\]+x\[ \t\]+y\[ \t\]+z\[ \r\n\]+.\[0-9\]+ = \\{ch1 = 120 'x', ch2 = 121 'y', ch3 = 122 'z'\\}"
+	".*Contents of three_char_t:\[ \r\n\]+x\[ \t\]+y\[ \t\]+z\[ \r\n\]+" \
+	".\[0-9\]+ = \\{ch1 = 120 'x', ch2 = 121 'y', ch3 = 122 'z'\\}"
 }
 
 if ![gdb_skip_stdio_test "print print_five_chars(*five_chars)"] {
     print_struct_call "print_five_chars(*five_char)" \
-            ".*Contents of five_char_t:\[ \r\n\]+h\[ \t\]+e\[ \t\]+l\[ \t\]+l\[ \t\]+o\[ \r\n\]+.\[0-9\]+ = \\{ch1 = 104 'h', ch2 = 101 'e', ch3 = 108 'l', ch4 = 108 'l', ch5 = 111 'o'\\}"
+	".*Contents of five_char_t:\[ \r\n\]+h\[ \t\]+e\[ \t\]+l\[ \t\]+l\[ \t\]+o\[ \r\n\]+" \
+	".\[0-9\]+ = \\{ch1 = 104 'h', ch2 = 101 'e', ch3 = 108 'l', ch4 = 108 'l', ch5 = 111 'o'\\}"
 }
 
 if ![gdb_skip_stdio_test "print print_int_char_combo(*int_char_combo)"] {
     print_struct_call "print_int_char_combo(*int_char_combo)" \
-            ".*Contents of int_char_combo_t:\[ \r\n\]+13\[ \t\]+!\[ \r\n\]+.\[0-9\]+ = \\{int1 = 13, ch1 = 33 '!'\\}"
+	".*Contents of int_char_combo_t:\[ \r\n\]+13\[ \t\]+!\[ \r\n\]+" \
+	".\[0-9\]+ = \\{int1 = 13, ch1 = 33 '!'\\}"
 }
 
 return
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 17/24] Make gdb.base/varargs.exp use gdb_test_stdio
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
                   ` (14 preceding siblings ...)
  2015-04-21 18:09 ` [PATCH 09/24] Make gdb.base/call-strs.exp use gdb_test_stdio Pedro Alves
@ 2015-04-21 18:09 ` Pedro Alves
  2015-04-21 18:09 ` [PATCH 20/24] Adjust MI to $inferior_spawn_id Pedro Alves
                   ` (8 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:09 UTC (permalink / raw)
  To: gdb-patches

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* gdb.base/varargs.exp: Use gdb_test_stdio.
---
 gdb/testsuite/gdb.base/varargs.exp | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/gdb/testsuite/gdb.base/varargs.exp b/gdb/testsuite/gdb.base/varargs.exp
index 0e895c1..96933bb 100644
--- a/gdb/testsuite/gdb.base/varargs.exp
+++ b/gdb/testsuite/gdb.base/varargs.exp
@@ -84,25 +84,30 @@ if { $hp_aCC_compiler } {
     gdb_test_no_output "set overload-resolution 0"
 }
 
-gdb_test "print find_max1(5,1,2,3,4,5)" \
-    "find_max\\(5, 1, 2, 3, 4, 5\\) returns 5\[ \r\n\]+.\[0-9\]+ = 5" \
+gdb_test_stdio "print find_max1(5,1,2,3,4,5)" \
+    "find_max\\(5, 1, 2, 3, 4, 5\\) returns 5\[ \r\n\]+" \
+    ".\[0-9\]+ = 5" \
     "print find_max1(5,1,2,3,4,5)"
 
-gdb_test "print find_max1(1,3)" \
-    ".*find_max\\(1, 3\\) returns 3\[ \r\n\]+.\[0-9\]+ = 3" \
+gdb_test_stdio "print find_max1(1,3)" \
+    "find_max\\(1, 3\\) returns 3\[ \r\n\]+" \
+    ".\[0-9\]+ = 3" \
     "print find_max1(1,3)"
 
-gdb_test "print find_max1(10,1,2,3,4,5,6,7,8,29,0)" \
-    ".*find_max\\(10, 1, 2, 3, 4, 5, 6, 7, 8, 29, 0\\) returns 29\[ \r\n\]+.\[0-9\]+ = 29" \
+gdb_test_stdio "print find_max1(10,1,2,3,4,5,6,7,8,29,0)" \
+    "find_max\\(10, 1, 2, 3, 4, 5, 6, 7, 8, 29, 0\\) returns 29\[ \r\n\]+" \
+    ".\[0-9\]+ = 29" \
     "print find_max1(10,1,2,3,4,5,6,7,8,29,0)"
 
-gdb_test "print find_max2(3,1,2,3)" \
-    ".*find_max\\(3, 1, 2, 3\\) returns 3\[ \r\n\]+.\[0-9\]+ = 3" \
+gdb_test_stdio "print find_max2(3,1,2,3)" \
+    "find_max\\(3, 1, 2, 3\\) returns 3\[ \r\n\]+" \
+    ".\[0-9\]+ = 3" \
     "print find_max2(3,1,2,3)"
 
 if {![target_info exists gdb,skip_float_tests]} {
-    gdb_test "print find_max_double(5,1.0,17.0,2.0,3.0,4.0)" \
-	".*find_max\\(.*\\) returns 17\\.000000\[ \r\n\]+.\[0-9\]+ = 17" \
+    gdb_test_stdio "print find_max_double(5,1.0,17.0,2.0,3.0,4.0)" \
+	"find_max\\(.*\\) returns 17\\.000000\[ \r\n\]+" \
+	".\[0-9\]+ = 17" \
 	"print find_max_double(5,1.0,17.0,2.0,3.0,4.0)"
 }
 
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 19/24] Make gdb.gdb/selftest.exp use '-i $inferior_spawn_id'
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
                   ` (7 preceding siblings ...)
  2015-04-21 18:09 ` [PATCH 24/24] Don't set gdb,noinferiorio on gdbserver boards Pedro Alves
@ 2015-04-21 18:09 ` Pedro Alves
  2015-04-21 18:09 ` [PATCH 11/24] Make gdb.base/dprintf.exp use gdb_test_stdio Pedro Alves
                   ` (15 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:09 UTC (permalink / raw)
  To: gdb-patches

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* gdb.gdb/selftest.exp (test_with_self): Update comment.  Use
	send_inferior and $inferior_spawn_id.
---
 gdb/testsuite/gdb.gdb/selftest.exp | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/gdb/testsuite/gdb.gdb/selftest.exp b/gdb/testsuite/gdb.gdb/selftest.exp
index 9f25a48..a170f73 100644
--- a/gdb/testsuite/gdb.gdb/selftest.exp
+++ b/gdb/testsuite/gdb.gdb/selftest.exp
@@ -257,6 +257,7 @@ proc test_with_self { executable } {
     global decimal
     global timeout
     global INTERNAL_GDBFLAGS
+    global inferior_spawn_id gdb_spawn_id
 
     # load yourself into the debugger
     # This can take a relatively long time, particularly for testing where
@@ -406,24 +407,27 @@ proc test_with_self { executable } {
 
     # start the "xgdb" process
     if [target_info exists gdb,noinferiorio] {
-	# Maybe testing with a local extended-remote gdbserver.  With
-	# no way to interact with inferior GDB, all we can do is let
-	# it run.
+	# With no way to interact with the inferior GDB, all we can do
+	# is let it run.
 	send_gdb "continue\n"
 	# Wait a bit while the inferior gdb gets to its prompt.
 	sleep 1
     } else {
 	set test "xgdb is at prompt"
 	gdb_test_multiple "continue" $test {
+	    -i "$inferior_spawn_id"
 	    -re "GNU gdb \[0-9\.\]*.*Copyright \\(C\\) \[0-9\]* Free Software Foundation, Inc.*License GPLv3\\+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.*This is free software: you are free to change and redistribute it.*There is NO WARRANTY, to the extent permitted by law.  Type \"show copying\".*and \"show warranty\" for details.*This GDB was configured as .*$gdb_prompt $" {
 		pass $test
 	    }
 	}
 
 	# set xgdb prompt so we can tell which is which
-	gdb_test_multiple "set prompt (xgdb) " "Set xgdb_prompt" {
+	send_inferior "set prompt (xgdb) \n"
+	set msg "Set xgdb_prompt"
+	gdb_test_multiple "" $msg {
+	    -i "$inferior_spawn_id"
 	    -re "\[(\]xgdb\[)\].*\[(\]xgdb\[)\] $" {
-		pass "Set xgdb prompt"
+		pass $msg
 	    }
 	}
     }
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 06/24] Don't rely on inferior I/O in gdb.base/restore.exp
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
                   ` (11 preceding siblings ...)
  2015-04-21 18:09 ` [PATCH 03/24] Fix gdb.base/interrupt.exp racy fail against gdbserver Pedro Alves
@ 2015-04-21 18:09 ` Pedro Alves
  2015-04-21 18:09 ` [PATCH 14/24] Make gdb.base/call-rt-st.exp use $inferior_spawn_id Pedro Alves
                   ` (11 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:09 UTC (permalink / raw)
  To: gdb-patches

There seems to be no point in relying on stdio here.  Simply use
gdb_continue_to_end instead.

(not removing the printf calls, as the .c file is half generated.)

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* gdb.base/restore.exp (restore_tests): Use gdb_continue_to_end.
---
 gdb/testsuite/gdb.base/restore.exp | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/gdb/testsuite/gdb.base/restore.exp b/gdb/testsuite/gdb.base/restore.exp
index a02ba4f..bd9dfbf 100644
--- a/gdb/testsuite/gdb.base/restore.exp
+++ b/gdb/testsuite/gdb.base/restore.exp
@@ -79,20 +79,7 @@ proc restore_tests { } {
         }
     }
 
-    if ![gdb_skip_stdio_test "run to completion"] {
-	send_gdb "continue\n"
-
-	gdb_expect {
-	    -re "exiting" {
-		pass "run to completion"
-	    }
-	    timeout { 
-		fail "(timeout) run to completion"
-	    }
-	}
-    } else {
-	gdb_test "continue" ".*" ""
-    }
+    gdb_continue_to_end "" continue 1
 }
 
 set prev_timeout $timeout
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 20/24] Adjust MI to $inferior_spawn_id
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
                   ` (15 preceding siblings ...)
  2015-04-21 18:09 ` [PATCH 17/24] Make gdb.base/varargs.exp " Pedro Alves
@ 2015-04-21 18:09 ` Pedro Alves
  2015-04-21 18:09 ` [PATCH 21/24] Make gdb.mi/mi-dprintf.exp use $inferior_spawn_id Pedro Alves
                   ` (7 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:09 UTC (permalink / raw)
  To: gdb-patches

Rather than trying to determine where (which spawn id) the inferior
output comes out from, which depends on e.g., remote that supports
file i/o remote protocol extension, vs remote that sends inferior
output through a separate $inferior_spawn_id, vs native debugging,
which sends output through $gdb_spawn_id, vs native debugging with a
test that uses "separate-inferior-tty" (like mi-console.exp does),
always expect inferior output from both $inferior_spawn_id and
$gdb_spawn_id.

mi-console.exp itself already copes with different possible outputs in
a similar way:

 # Combine both outputs in a single pattern.
 set output "($semihosted_output|$native_output)"

Fixes:

 FAIL: gdb.mi/mi-console.exp: Testing console output inferior output (timeout)

when testing against local gdbserver with gdb,noinferiorio removed
from the board file.

gdb/testsuite/ChangeLog:
2015-04-21  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
	gdb_spawn_id.
	(mi_gdb_test): Always expect inferior output from both
	$inferior_spawn_id and $gdb_spawn_id.
---
 gdb/testsuite/lib/mi-support.exp | 56 +++++++++++++++-------------------------
 1 file changed, 21 insertions(+), 35 deletions(-)

diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index 6827ef9..27b2ebc 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -26,7 +26,6 @@ if ![info exists mi_gdb_prompt] then {
     set mi_gdb_prompt "\[(\]gdb\[)\] \r\n"
 }
 
-global mi_inferior_spawn_id
 global mi_inferior_tty_name
 
 set MIFLAGS "-i=mi"
@@ -104,7 +103,7 @@ proc default_mi_gdb_start { args } {
     global gdb_prompt
     global mi_gdb_prompt
     global timeout
-    global gdb_spawn_id
+    global gdb_spawn_id inferior_spawn_id
     global MIFLAGS
 
     gdb_stop_suppressing_tests
@@ -138,15 +137,6 @@ proc default_mi_gdb_start { args } {
 	}
     }
 
-    # Create the new PTY for the inferior process.
-    if { $separate_inferior_pty } {
-	spawn -pty
-	global mi_inferior_spawn_id
-	global mi_inferior_tty_name
-	set mi_inferior_spawn_id $spawn_id
-	set mi_inferior_tty_name $spawn_out(slave,name)
-    }
-
     set res [remote_spawn host "$GDB $INTERNAL_GDBFLAGS $GDBFLAGS $MIFLAGS [host_info gdb_opts]"]
     if { $res < 0 || $res == "" } {
 	perror "Spawning $GDB failed."
@@ -214,9 +204,14 @@ proc default_mi_gdb_start { args } {
 	    warning "Couldn't set the width to 0."
 	}
     }
-    # If allowing the inferior to have its own PTY then assign the inferior
-    # its own terminal device here.
+
+    # Create the new PTY for the inferior process.
     if { $separate_inferior_pty } {
+	spawn -pty
+	global mi_inferior_tty_name
+	set inferior_spawn_id $spawn_id
+	set mi_inferior_tty_name $spawn_out(slave,name)
+
 	send_gdb "102-inferior-tty-set $mi_inferior_tty_name\n"
 	gdb_expect 10 {
 	    -re ".*102\\\^done\r\n$mi_gdb_prompt$" {
@@ -228,6 +223,10 @@ proc default_mi_gdb_start { args } {
 	}
     }
 
+    if {![info exists inferior_spawn_id]} {
+	set inferior_spawn_id $gdb_spawn_id
+    }
+
     mi_detect_async
 
     return 0
@@ -770,29 +769,16 @@ proc mi_gdb_test { args } {
     if { $result == 0 } {
 	if [ info exists ipattern ] {
 	    if { ![target_info exists gdb,noinferiorio] } {
-		if { [target_info gdb_protocol] == "remote"
-		    || [target_info gdb_protocol] == "extended-remote"
-		    || [target_info protocol] == "sim"} {
-
-		    gdb_expect {
-			-re "$ipattern" {
-			    pass "$message inferior output"
-			}
-			timeout {
-			    fail "$message inferior output (timeout)"
-			    set result 1
-			}
+		global gdb_spawn_id inferior_spawn_id
+
+		set sid "$inferior_spawn_id $gdb_spawn_id"
+		gdb_expect {
+		    -i "$sid" -re "$ipattern" {
+			pass "$message inferior output"
 		    }
-		} else {
-		    global mi_inferior_spawn_id
-		    expect {
-			-i $mi_inferior_spawn_id -re "$ipattern" {
-			    pass "$message inferior output"
-			}
-			timeout {
-			    fail "$message inferior output (timeout)"
-			    set result 1
-			}
+		    timeout {
+			fail "$message inferior output (timeout)"
+			set result 1
 		    }
 		}
 	    } else {
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 21/24] Make gdb.mi/mi-dprintf.exp use $inferior_spawn_id
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
                   ` (16 preceding siblings ...)
  2015-04-21 18:09 ` [PATCH 20/24] Adjust MI to $inferior_spawn_id Pedro Alves
@ 2015-04-21 18:09 ` Pedro Alves
  2015-04-21 18:09 ` [PATCH 05/24] Don't rely on inferior I/O in {call-signal-resume, unwindonsignal}.exp Pedro Alves
                   ` (6 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:09 UTC (permalink / raw)
  To: gdb-patches

gdb/testsuite/ChangeLog:
2015-04-21  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.
---
 gdb/testsuite/gdb.mi/mi-dprintf.exp | 66 +++++++++++++++++++------------------
 1 file changed, 34 insertions(+), 32 deletions(-)

diff --git a/gdb/testsuite/gdb.mi/mi-dprintf.exp b/gdb/testsuite/gdb.mi/mi-dprintf.exp
index ea198bd..c205724 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
     }
 }
 
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 22/24] Unbuffer all tests that rely on stdio
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
                   ` (9 preceding siblings ...)
  2015-04-21 18:09 ` [PATCH 11/24] Make gdb.base/dprintf.exp use gdb_test_stdio Pedro Alves
@ 2015-04-21 18:09 ` Pedro Alves
  2015-04-21 18:09 ` [PATCH 03/24] Fix gdb.base/interrupt.exp racy fail against gdbserver Pedro Alves
                   ` (13 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:09 UTC (permalink / raw)
  To: gdb-patches

This forces all tests that rely on stdio to be unbuffered, like
interrupt.exp was adjusted in 6f98576f.

To recap, in some scenarios, GDB or GDBserver can be spawned with
input _not_ connected to a tty, and then tests that rely on stdio fail
with timeouts, because the inferior's stdout and stderr streams end up
fully buffered.  Calling gdb_unbuffer_output forces output to be
unbuffered.

See https://sourceware.org/ml/gdb-patches/2015-02/msg00809.html and
https://sourceware.org/ml/gdb-patches/2015-02/msg00819.html.

Tested on x86_64 Fedora 20, native, and against a remote gdbserver
board file that connects to the target with ssh, with and without -t
(create pty).

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* gdb.base/call-ar-st.c: Include "../lib/unbuffer_output.c".
	(main): Call gdb_unbuffer_output.
	* gdb.base/call-rt-st.c: Include "../lib/unbuffer_output.c".
	(main): Call gdb_unbuffer_output.
	* gdb.base/call-strs.c: Include "../lib/unbuffer_output.c".
	(main): Call gdb_unbuffer_output.
	* gdb.base/call-strs.exp: Adjust to step over the
	gdb_unbuffer_output call.
	* gdb.base/catch-gdb-caused-signals.c: Include
	"../lib/unbuffer_output.c".
	(main): Call gdb_unbuffer_output.
	* gdb.base/dprintf.c: Include "../lib/unbuffer_output.c".
	(main): Call gdb_unbuffer_output.
	* gdb.base/ending-run.c: Include "../lib/unbuffer_output.c".
	(main): Call gdb_unbuffer_output.
	* gdb.base/run.c: Include "../lib/unbuffer_output.c".
	(main): Call gdb_unbuffer_output.
	* gdb.base/shlib-call.exp: Adjust to step over the
	gdb_unbuffer_output call.
	* gdb.base/shmain.c: Include "../lib/unbuffer_output.c".
	(main): Call gdb_unbuffer_output.
	* gdb.base/sizeof.c: Include "../lib/unbuffer_output.c".
	(main): Call gdb_unbuffer_output.
	* gdb.base/varargs.c: Include "../lib/unbuffer_output.c".
	(main): Rename to ...
	(test): ... this.
	(main): Reimplement.
	* gdb.base/varargs.exp: Run to test instead of to main.
	* gdb.mi/mi-dprintf.c: Include "../lib/unbuffer_output.c".
	(main): Call gdb_unbuffer_output.
---
 gdb/testsuite/gdb.base/call-ar-st.c               |  4 ++++
 gdb/testsuite/gdb.base/call-rt-st.c               |  3 +++
 gdb/testsuite/gdb.base/call-strs.c                |  4 ++++
 gdb/testsuite/gdb.base/call-strs.exp              |  3 +--
 gdb/testsuite/gdb.base/catch-gdb-caused-signals.c |  4 ++++
 gdb/testsuite/gdb.base/dprintf.c                  |  4 ++++
 gdb/testsuite/gdb.base/ending-run.c               |  4 ++++
 gdb/testsuite/gdb.base/run.c                      |  4 ++++
 gdb/testsuite/gdb.base/shlib-call.exp             |  2 +-
 gdb/testsuite/gdb.base/shmain.c                   |  5 +++++
 gdb/testsuite/gdb.base/sizeof.c                   |  4 ++++
 gdb/testsuite/gdb.base/sizeof.exp                 |  2 +-
 gdb/testsuite/gdb.base/varargs.c                  | 13 ++++++++++++-
 gdb/testsuite/gdb.base/varargs.exp                |  2 +-
 gdb/testsuite/gdb.mi/mi-dprintf.c                 |  4 ++++
 15 files changed, 56 insertions(+), 6 deletions(-)

diff --git a/gdb/testsuite/gdb.base/call-ar-st.c b/gdb/testsuite/gdb.base/call-ar-st.c
index 4b2ffb4..497af84 100644
--- a/gdb/testsuite/gdb.base/call-ar-st.c
+++ b/gdb/testsuite/gdb.base/call-ar-st.c
@@ -3,6 +3,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "../lib/unbuffer_output.c"
+
 /**************************************************************************
  * TESTS :
  *   -- function arguments that are enumerated types
@@ -912,6 +914,8 @@ int main ()  {
    static struct two_floats_t      *f2;
    static struct two_floats_t      *f3;
 
+  gdb_unbuffer_output ();
+
   /* Initialize arrays
    */
   for (index = 0; index < 120; index++) {
diff --git a/gdb/testsuite/gdb.base/call-rt-st.c b/gdb/testsuite/gdb.base/call-rt-st.c
index 944f1af..072ea86 100644
--- a/gdb/testsuite/gdb.base/call-rt-st.c
+++ b/gdb/testsuite/gdb.base/call-rt-st.c
@@ -2,6 +2,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "../lib/unbuffer_output.c"
+
 /**************************************************************************
  * TESTS :
  * function returning large structures, which go on the stack
@@ -562,6 +564,7 @@ int main ()  {
    struct one_double_t      *d1;
    struct two_floats_t      *f3;
 
+  gdb_unbuffer_output ();
 
   /* Allocate space for large structures 
    */
diff --git a/gdb/testsuite/gdb.base/call-strs.c b/gdb/testsuite/gdb.base/call-strs.c
index c0b1823..03a8064 100644
--- a/gdb/testsuite/gdb.base/call-strs.c
+++ b/gdb/testsuite/gdb.base/call-strs.c
@@ -2,6 +2,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "../lib/unbuffer_output.c"
+
 char buf[100];
 char bigbuf[1000];
 char * s;
@@ -47,6 +49,8 @@ link_malloc ()
 
 int main()
 {
+  gdb_unbuffer_output ();
+
   s = &buf[0];
   strcpy(buf, "test string");
   str_func("abcd", "efgh", "ijkl", "mnop", "qrst", "uvwx", "yz12");
diff --git a/gdb/testsuite/gdb.base/call-strs.exp b/gdb/testsuite/gdb.base/call-strs.exp
index e11296f..96641e5 100644
--- a/gdb/testsuite/gdb.base/call-strs.exp
+++ b/gdb/testsuite/gdb.base/call-strs.exp
@@ -57,8 +57,7 @@ if ![runto_main] then {
 set prev_timeout $timeout
 set timeout 120
 
-#step
-gdb_test "step" \
+gdb_test "next 2" \
     "strcpy\\(buf, \"test string\"\\);" \
     "step after assignment to s"
 
diff --git a/gdb/testsuite/gdb.base/catch-gdb-caused-signals.c b/gdb/testsuite/gdb.base/catch-gdb-caused-signals.c
index 769858c..a2cdcb0 100644
--- a/gdb/testsuite/gdb.base/catch-gdb-caused-signals.c
+++ b/gdb/testsuite/gdb.base/catch-gdb-caused-signals.c
@@ -20,11 +20,15 @@
 #include <unistd.h>
 #include <stdio.h>
 
+#include "../lib/unbuffer_output.c"
+
 int
 main (void)
 {
   int i = 0;
 
+  gdb_unbuffer_output ();
+
   i++; /* set dprintf here */
   return 0; /* set breakpoint here */
 }
diff --git a/gdb/testsuite/gdb.base/dprintf.c b/gdb/testsuite/gdb.base/dprintf.c
index 3fd3b3a..c0c3ce3 100644
--- a/gdb/testsuite/gdb.base/dprintf.c
+++ b/gdb/testsuite/gdb.base/dprintf.c
@@ -17,6 +17,8 @@
 
 #include <stdio.h>
 
+#include "../lib/unbuffer_output.c"
+
 static int g;
 
 void
@@ -32,6 +34,8 @@ main (int argc, char *argv[])
 {
   int loc = 1234;
 
+  gdb_unbuffer_output ();
+
   /* Ensure these functions are available.  */
   printf ("kickoff %d\n", loc);
   fprintf (stderr, "also to stderr %d\n", loc);
diff --git a/gdb/testsuite/gdb.base/ending-run.c b/gdb/testsuite/gdb.base/ending-run.c
index 42f12c0..1e09f16 100644
--- a/gdb/testsuite/gdb.base/ending-run.c
+++ b/gdb/testsuite/gdb.base/ending-run.c
@@ -4,6 +4,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "../lib/unbuffer_output.c"
+
 int callee (int x)
 {
     int y = x * x;		/* -break1- */
@@ -16,6 +18,8 @@ int main()
     int *p;
     int i;
 
+    gdb_unbuffer_output ();
+
     p = (int *) malloc( 4 );
 
     for (i = 1; i < 10; i++)
diff --git a/gdb/testsuite/gdb.base/run.c b/gdb/testsuite/gdb.base/run.c
index 0c62002..614b018 100644
--- a/gdb/testsuite/gdb.base/run.c
+++ b/gdb/testsuite/gdb.base/run.c
@@ -6,11 +6,15 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "../lib/unbuffer_output.c"
+
 int factorial (int);
 
 int
 main (int argc, char **argv, char **envp)
 {
+  gdb_unbuffer_output ();
+
 #ifdef FAKEARGV
     printf ("%d\n", factorial (1)); /* commands.exp: hw local_var out of scope */
 #else    
diff --git a/gdb/testsuite/gdb.base/shlib-call.exp b/gdb/testsuite/gdb.base/shlib-call.exp
index 2ccaa39..f48b6fb 100644
--- a/gdb/testsuite/gdb.base/shlib-call.exp
+++ b/gdb/testsuite/gdb.base/shlib-call.exp
@@ -71,7 +71,7 @@ if ![runto_main] then {
 
 #step -over
 
-gdb_test "next" "g = shr1\\(g\\);" "next to shr1"
+gdb_test "next 2" "g = shr1\\(g\\);" "next to shr1"
 
 #print g
 
diff --git a/gdb/testsuite/gdb.base/shmain.c b/gdb/testsuite/gdb.base/shmain.c
index e36f84f..932b834 100644
--- a/gdb/testsuite/gdb.base/shmain.c
+++ b/gdb/testsuite/gdb.base/shmain.c
@@ -3,6 +3,8 @@
 #include "ss.h"
 #include <stdio.h>
 
+#include "../lib/unbuffer_output.c"
+
 extern int structarg(struct s);
 extern int pstructarg(struct s*);
 extern int shr1(int);
@@ -31,6 +33,9 @@ int mainshr1(int g)
 int main()
 {
   struct s y;
+
+  gdb_unbuffer_output ();
+
   g = 1;
   g = shr1(g);
   g = shr2(g);
diff --git a/gdb/testsuite/gdb.base/sizeof.c b/gdb/testsuite/gdb.base/sizeof.c
index 9c67c03..eb21f22 100644
--- a/gdb/testsuite/gdb.base/sizeof.c
+++ b/gdb/testsuite/gdb.base/sizeof.c
@@ -1,5 +1,7 @@
 #include <stdio.h>
 
+#include "../lib/unbuffer_output.c"
+
 typedef char padding[16];
 
 struct {
@@ -98,6 +100,8 @@ fill_structs (void)
 int
 main ()
 {
+  gdb_unbuffer_output ();
+
   fill_structs ();
 
   printf ("sizeof (char) == %d\n", (int) sizeof (char));
diff --git a/gdb/testsuite/gdb.base/sizeof.exp b/gdb/testsuite/gdb.base/sizeof.exp
index a237ee3..ce6b7ed 100644
--- a/gdb/testsuite/gdb.base/sizeof.exp
+++ b/gdb/testsuite/gdb.base/sizeof.exp
@@ -48,7 +48,7 @@ if ![runto_main] then {
 # Query GDB for the size of various types
 #
 
-gdb_test "next"
+gdb_test "next 2"
 
 set sizeof_char [get_sizeof "char" 1]
 set sizeof_short [get_sizeof "short" 2]
diff --git a/gdb/testsuite/gdb.base/varargs.c b/gdb/testsuite/gdb.base/varargs.c
index 1ad2ffc..4c0f165 100644
--- a/gdb/testsuite/gdb.base/varargs.c
+++ b/gdb/testsuite/gdb.base/varargs.c
@@ -8,6 +8,8 @@
 #include <stdio.h>
 #include <stdarg.h>
 
+#include "../lib/unbuffer_output.c"
+
 int find_max1(int, ...);
 int find_max2(int, int, ...);
 double find_max_double(int, double, ...);
@@ -45,7 +47,9 @@ long double _Complex ldc4 = 4.0L + 4.0Li;
 
 #endif
 
-int main() {
+int
+test (void)
+{
   c = -1;
   uc = 1;
   s = -2;
@@ -70,6 +74,13 @@ int main() {
   return 0;
 }
 
+int
+main (void)
+{
+  gdb_unbuffer_output ();
+  test ();
+}
+
 /* Integer varargs, 1 declared arg */
 
 int find_max1(int num_vals, ...) {
diff --git a/gdb/testsuite/gdb.base/varargs.exp b/gdb/testsuite/gdb.base/varargs.exp
index 96933bb..fe54314 100644
--- a/gdb/testsuite/gdb.base/varargs.exp
+++ b/gdb/testsuite/gdb.base/varargs.exp
@@ -66,7 +66,7 @@ if [gdb_skip_stdio_test "varargs.exp"] {
     return
 }
 
-if ![runto_main] then {
+if ![runto test] then {
     perror "couldn't run to breakpoint"
     continue
 }
diff --git a/gdb/testsuite/gdb.mi/mi-dprintf.c b/gdb/testsuite/gdb.mi/mi-dprintf.c
index 0b8fc82..2571e50 100644
--- a/gdb/testsuite/gdb.mi/mi-dprintf.c
+++ b/gdb/testsuite/gdb.mi/mi-dprintf.c
@@ -19,6 +19,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "../lib/unbuffer_output.c"
+
 static int g;
 
 void
@@ -34,6 +36,8 @@ main (int argc, char *argv[])
 {
   int loc = 1234;
 
+  gdb_unbuffer_output ();
+
   /* Ensure these functions are available.  */
   printf ("kickoff %d\n", loc);
   fprintf (stderr, "also to stderr %d\n", loc);
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 11/24] Make gdb.base/dprintf.exp use gdb_test_stdio
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
                   ` (8 preceding siblings ...)
  2015-04-21 18:09 ` [PATCH 19/24] Make gdb.gdb/selftest.exp use '-i $inferior_spawn_id' Pedro Alves
@ 2015-04-21 18:09 ` Pedro Alves
  2015-04-21 18:09 ` [PATCH 22/24] Unbuffer all tests that rely on stdio Pedro Alves
                   ` (14 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:09 UTC (permalink / raw)
  To: gdb-patches

This one needed a larger revamp.  The issue is that the "info
breakpoints" test at the bottom of the file is broken on targets that
can do both server-side dprintf, and inferior I/O, because then
neither the breakpoint numbers match nor the "already hit N times"
output.

Address that by making the test restart gdb from scratch when
switching between dprintf styles.  Test groups are factored into
procedures, and we now use with_test_prefix.  While we're changing
test messages, lowercase a few test messages, and then while at it,
modernize a couple things here and there.

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* gdb.base/dprintf.exp: Use standard_testfile.  Change
	prepare_for_testing call.
	(srcfile): Don't set.
	(restart): New procedure.
	(test_dprintf): New procecure, use to continue over dprintfs.
	(test_call, test_agent): New procedures, tests moved here.
	Restart gdb and recreate dprintfs.  Adjust expected output.
---
 gdb/testsuite/gdb.base/dprintf.exp | 134 +++++++++++++++++++++++++------------
 1 file changed, 90 insertions(+), 44 deletions(-)

diff --git a/gdb/testsuite/gdb.base/dprintf.exp b/gdb/testsuite/gdb.base/dprintf.exp
index 0cd31aa..23905e4 100644
--- a/gdb/testsuite/gdb.base/dprintf.exp
+++ b/gdb/testsuite/gdb.base/dprintf.exp
@@ -13,13 +13,12 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+standard_testfile
 
-if { [prepare_for_testing dprintf.exp "dprintf" {} {debug}] } {
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
     return -1
 }
 
-set srcfile dprintf.c
-
 set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
 set dp_location1 [gdb_get_line_number "set dprintf 1 here"]
 
@@ -65,65 +64,108 @@ gdb_test "continue" "arg=1234, g=1234.*" "1st dprintf, gdb"
 
 gdb_test "continue" "At foo entry.*arg=1235, g=2222.*" "2nd dprintf, gdb"
 
-# The "call" style depends on having I/O functions available, so test.
+# Restart GDB and set set up for testing.
 
-if ![target_info exists gdb,noinferiorio] {
+proc restart {} {
+    global binfile
+    global bp_location1 dp_location1
 
-    # Now switch styles and rerun; in the absence of redirection the
-    # output should be the same.
+    clean_restart $binfile
 
-    gdb_test_no_output "set dprintf-style call" "Set dprintf style to call"
+    if ![runto main] {
+	return -1
+    }
 
-    gdb_run_cmd
+    gdb_test "dprintf foo,\"At foo entry\\n\"" \
+	"Dprintf .*"
 
-    gdb_test "" "Breakpoint"
+    gdb_test "dprintf $dp_location1,\"arg=%d, g=%d\\n\", arg, g" \
+	"Dprintf .*"
 
-    gdb_test "continue" "At foo entry.*arg=1234, g=1234.*" "1st dprintf, call"
+    gdb_test "break $bp_location1" "Breakpoint .*"
+}
 
-    gdb_test "continue" "At foo entry.*arg=1235, g=2222.*" "2nd dprintf, call"
+# Test continuing across a dprintf.  PATTERN matches the output
+# generated by the dprintf.  MSG is used as test message.
 
-    gdb_test_no_output "set dprintf-function fprintf" "Set dprintf function"
-    gdb_test_no_output "set dprintf-channel stderr" "Set dprintf channel"
+proc test_dprintf {pattern msg} {
+    gdb_test_stdio "continue" $pattern "" "$msg"
+}
 
-    gdb_run_cmd
+# Test the "call" style.
 
-    gdb_test "" "Breakpoint"
+proc test_call {} {
+    global binfile
+    global bp_location1
 
-    gdb_test "continue" "At foo entry.*arg=1234, g=1234.*" \
-	"1st dprintf, fprintf"
+    # Now switch styles and rerun; in the absence of redirection the
+    # output should be the same.
 
-    gdb_test "continue" "At foo entry.*arg=1235, g=2222.*" \
-	"2nd dprintf, fprintf"
-}
+    with_test_prefix "printf" {
+	restart
 
-# Now test the "agent" style.
+	gdb_test_no_output "set dprintf-style call" "set dprintf style to call"
 
-set target_can_dprintf 1
-set msg "set dprintf style to agent"
-gdb_test_multiple "set dprintf-style agent" $msg {
-    -re "warning: Target cannot run dprintf commands.*\r\n$gdb_prompt $" {
+	test_dprintf "At foo entry.*arg=1234, g=1234\r\n" "1st dprintf"
 
-	# The target reports that it doesn't support target side
-	# commands at all.
-	set target_can_dprintf 0
-	unsupported "$msg"
+	test_dprintf "At foo entry.*arg=1235, g=2222\r\n" "2nd dprintf"
     }
-    -re ".*$gdb_prompt $" {
-	pass "$msg"
+
+    with_test_prefix "fprintf" {
+	restart
+
+	gdb_test_no_output "set dprintf-function fprintf" "set dprintf function"
+	gdb_test_no_output "set dprintf-channel stderr" "set dprintf channel"
+
+	gdb_test_no_output "set dprintf-style call" "set dprintf style to call"
+
+	test_dprintf "At foo entry.*arg=1234, g=1234\r\n" "1st dprintf"
+
+	test_dprintf "At foo entry.*arg=1235, g=2222\r\n" "2nd dprintf"
+    }
+}
+
+# The "call" style depends on having I/O functions available.
+
+if ![target_info exists gdb,noinferiorio] {
+    with_test_prefix "call" {
+	test_call
     }
 }
 
-if $target_can_dprintf {
-    gdb_run_cmd
+# Test the "agent" style.
 
-    gdb_test "" "Breakpoint"
+proc test_agent {} {
+    global binfile
+    global gdb_prompt
+
+    restart
+
+    set target_can_dprintf 1
+    set msg "set dprintf style to agent"
+    gdb_test_multiple "set dprintf-style agent" $msg {
+	-re "warning: Target cannot run dprintf commands.*\r\n$gdb_prompt $" {
+
+	    # The target reports that it doesn't support target side
+	    # commands at all.
+	    set target_can_dprintf 0
+	    unsupported "$msg"
+	}
+	-re ".*$gdb_prompt $" {
+	    pass "$msg"
+	}
+    }
+
+    if !$target_can_dprintf {
+	return
+    }
 
     # Even if the the target reports that it does support target side
     # commands, we can only tell that it supports them in combination
     # with a particular breakpoint type (Z0, Z1, etc.) when we try to
     # insert the breakpoint.  When "set breakpoint always-inserted is
     # off", that'll be on next continue.
-    set msg "1st dprintf, agent"
+    set msg "1st dprintf"
     gdb_test_multiple "continue" $msg {
 	-re "Warning:.*Target doesn't support breakpoints that have target side commands.*\r\n$gdb_prompt $" {
 	    set target_can_dprintf 0
@@ -135,22 +177,26 @@ if $target_can_dprintf {
     }
 
     if $target_can_dprintf {
-	gdb_test "continue" "Breakpoint \[0-9\]+, foo .*" "2nd dprintf, agent"
+	gdb_test "continue" "Breakpoint \[0-9\]+, foo .*" "2nd dprintf"
 
-	gdb_test_sequence "info breakpoints" "dprintf info 2" {
+	gdb_test_sequence "info breakpoints" "dprintf info" {
 	    "\[\r\n\]Num     Type           Disp Enb Address +What"
-	    "\[\r\n\]2       breakpoint"
-	    "\[\r\n\]\tbreakpoint already hit 2 times"
-	    "\[\r\n\]3       dprintf"
-	    "\[\r\n\]\tbreakpoint already hit 2 times"
+	    "\[\r\n\]1       breakpoint"
+	    "\[\r\n\]\tbreakpoint already hit 1 time"
+	    "\[\r\n\]2       dprintf"
 	    "\[\r\n\]        agent-printf \"At foo entry\\\\n\""
-	    "\[\r\n\]4       dprintf"
-	    "\[\r\n\]\tbreakpoint already hit 2 times"
+	    "\[\r\n\]3       dprintf"
 	    "\[\r\n\]        agent-printf \"arg=%d, g=%d\\\\n\", arg, g"
+	    "\[\r\n\]4       breakpoint"
+	    "\[\r\n\]\tbreakpoint already hit 2 times"
 	}
     }
 }
 
+with_test_prefix "agent" {
+    test_agent
+}
+
 gdb_test "set dprintf-style foobar" "Undefined item: \"foobar\"." \
     "Set dprintf style to an unrecognized type"
 
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 24/24] Don't set gdb,noinferiorio on gdbserver boards
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
                   ` (6 preceding siblings ...)
  2015-04-21 18:08 ` [PATCH 16/24] Make gdb.base/shlib-call.exp use gdb_test_stdio Pedro Alves
@ 2015-04-21 18:09 ` Pedro Alves
  2015-04-23 15:09   ` Yao Qi
  2015-04-21 18:09 ` [PATCH 19/24] Make gdb.gdb/selftest.exp use '-i $inferior_spawn_id' Pedro Alves
                   ` (16 subsequent siblings)
  24 siblings, 1 reply; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:09 UTC (permalink / raw)
  To: gdb-patches

As all tests that check gdb,noinferiorio have been adjusted to expect
inferior output with "-i $inferior_spawn_id", we can remove this now,
and thus enable those tests against gdbserver.

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* boards/gdbserver-base.exp: Don't set gdb,noinferiorio.
---
 gdb/testsuite/boards/gdbserver-base.exp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/gdb/testsuite/boards/gdbserver-base.exp b/gdb/testsuite/boards/gdbserver-base.exp
index c77dc6e..ec24d5a 100644
--- a/gdb/testsuite/boards/gdbserver-base.exp
+++ b/gdb/testsuite/boards/gdbserver-base.exp
@@ -24,9 +24,6 @@ set_board_info compiler "[find_gcc]"
 # Test the copy of gdbserver in the build directory.
 set_board_info gdb_server_prog "../gdbserver/gdbserver"
 
-# Can't do input (or output) in the current gdbserver.
-set_board_info gdb,noinferiorio 1
-
 # gdbserver does not intercept target file operations and perform them
 # on the host.
 set_board_info gdb,nofileio 1
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 03/24] Fix gdb.base/interrupt.exp racy fail against gdbserver
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
                   ` (10 preceding siblings ...)
  2015-04-21 18:09 ` [PATCH 22/24] Unbuffer all tests that rely on stdio Pedro Alves
@ 2015-04-21 18:09 ` Pedro Alves
  2015-04-23 14:28   ` Yao Qi
  2015-04-21 18:09 ` [PATCH 06/24] Don't rely on inferior I/O in gdb.base/restore.exp Pedro Alves
                   ` (12 subsequent siblings)
  24 siblings, 1 reply; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:09 UTC (permalink / raw)
  To: gdb-patches

Currently, against gdbserver, interrupt.exp occasionaly fails like
this:

 ERROR: Process no longer exists
 UNRESOLVED: gdb.base/interrupt.exp: send end of file

The problem is that we see gdbserver exiting before we match gdb's
output:

 expect: does "\r\n\r\nChild exited with status 0\r\nGDBserver exiting\r\n" (spawn_id exp8) match regular expression "end of file"? Gate "end of file"? gate=no
 expect: read eof
 expect: set expect_out(spawn_id) "exp8"
 expect: set expect_out(buffer) "\r\n\r\nChild exited with status 0\r\nGDBserver exiting\r\n"

Fix this by removing $inferior_spawn_id from the set of spawn ids
expect is watching as soon as we see the "end of file" string out of
the inferior spawn id, using an indirect spawn id list.

Tested on x86-64 Fedora 20, native and gdbserver (both target remote
and extended-remote).

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* gdb.base/interrupt.exp: Rename saw_eof to saw_end_of_file.  Use
	an indirect spawn id list holding $inferior_spawn_id instead of
	$inferior_spawn_id directly.  On "of of file", remove
	$inferior_spawn_id from the indirect list.
---
 gdb/testsuite/gdb.base/interrupt.exp | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.base/interrupt.exp b/gdb/testsuite/gdb.base/interrupt.exp
index 17a9bad..f594ba4 100644
--- a/gdb/testsuite/gdb.base/interrupt.exp
+++ b/gdb/testsuite/gdb.base/interrupt.exp
@@ -205,12 +205,21 @@ if ![file exists $binfile] then {
 
 	set msg "send end of file"
 	send_inferior "\004"
+
+	set spawn_list "$inferior_spawn_id"
+
 	gdb_test_multiple "" $msg {
-	    -i $inferior_spawn_id -re "end of file" {
-		verbose -log "saw \"end of file\": $saw_end_of_file"
+	    -i spawn_list -re "end of file" {
 		set saw_end_of_file 1
 		verbose -log "saw \"end of file\""
 		if {!$saw_inferior_exit} {
+		    # When $inferior_spawn_id != $gdb_spawn_id, such
+		    # as when testing with gdbserver, we may see the
+		    # eof (the process exit, not the string just
+		    # matched) for $inferior_spawn_id before the
+		    # expected gdb output.  Clear this so we no longer
+		    # expect anything out of $inferior_spawn_id.
+		    set spawn_list ""
 		    exp_continue
 		}
 	    }
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 09/24] Make gdb.base/call-strs.exp use gdb_test_stdio
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
                   ` (13 preceding siblings ...)
  2015-04-21 18:09 ` [PATCH 14/24] Make gdb.base/call-rt-st.exp use $inferior_spawn_id Pedro Alves
@ 2015-04-21 18:09 ` Pedro Alves
  2015-04-21 18:09 ` [PATCH 17/24] Make gdb.base/varargs.exp " Pedro Alves
                   ` (9 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:09 UTC (permalink / raw)
  To: gdb-patches

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* gdb.base/call-strs.exp: Use gdb_test_stdio instead of gdb_test.
---
 gdb/testsuite/gdb.base/call-strs.exp | 50 +++++++++++++++++++++---------------
 1 file changed, 30 insertions(+), 20 deletions(-)

diff --git a/gdb/testsuite/gdb.base/call-strs.exp b/gdb/testsuite/gdb.base/call-strs.exp
index 5aab943..e11296f 100644
--- a/gdb/testsuite/gdb.base/call-strs.exp
+++ b/gdb/testsuite/gdb.base/call-strs.exp
@@ -77,62 +77,72 @@ gdb_test "print s" \
 
 #print str_func1(s)
 if ![gdb_skip_stdio_test "print str_func1(s)"] {
-    gdb_test "print str_func1(s)" \
-	"first string arg is: test string.*\"test string\".*"
+    gdb_test_stdio "print str_func1(s)" \
+	"first string arg is: test string" \
+	"\"test string\".*"
 }
 
 #print str_func1("test string")
 if ![gdb_skip_stdio_test "print str_func1(teststring)"] {
-    gdb_test "print str_func1(\"test string\")" \
-	"first string arg is: test string.*\"test string\".*"
+    gdb_test_stdio "print str_func1(\"test string\")" \
+	"first string arg is: test string" \
+	"\"test string\".*"
 }
 
 #call str_func1(s)
 if ![gdb_skip_stdio_test "call str_func1(s)"] {
-    gdb_test "call str_func1(s)" \
-	"first string arg is: test string.*\"test string\".*"
+    gdb_test_stdio "call str_func1(s)" \
+	"first string arg is: test string" \
+	"\"test string\".*"
 }
 
 #call str_func1("test string")
 if ![gdb_skip_stdio_test "call str_func1 (...)"] {
-    gdb_test "call str_func1(\"test string\")" \
-	"first string arg is: test string.*\"test string\".*"
+    gdb_test_stdio "call str_func1(\"test string\")" \
+	"first string arg is: test string" \
+	"\"test string\".*"
 }
 
 #print str_func1(buf)
 if ![gdb_skip_stdio_test "print str_func1(buf)"] {
-    gdb_test "print str_func1(buf)" \
-	"first string arg is: test string.*\"test string\".*"
+    gdb_test_stdio "print str_func1(buf)" \
+	"first string arg is: test string" \
+	"\"test string\".*"
 }
 
 #call str_func1(buf)
 if ![gdb_skip_stdio_test "call str_func1(buf)"] {
-    gdb_test "call str_func1(buf)" \
-	"first string arg is: test string.*\"test string\".*"
+    gdb_test_stdio "call str_func1(buf)" \
+	"first string arg is: test string" \
+	"\"test string\".*"
 }
 
 #print str_func("a","b","c","d","e","f","g")
 if ![gdb_skip_stdio_test "print str_func(a,b,c,d,e,f,g)"] {
-    gdb_test "print str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")" \
-	"first string arg is: a\[ \t\r\n\]+second string arg is: b\[ \t\r\n\]+third string arg is: c\[ \t\r\n\]+fourth string arg is: d\[ \t\r\n\]+fifth string arg is: e\[ \t\r\n\]+sixth string arg is: f\[ \t\r\n\]+seventh string arg is: g\[ \t\r\n\]+.*= \"abcdefg\".*"
+    gdb_test_stdio "print str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")" \
+	"first string arg is: a\[ \t\r\n\]+second string arg is: b\[ \t\r\n\]+third string arg is: c\[ \t\r\n\]+fourth string arg is: d\[ \t\r\n\]+fifth string arg is: e\[ \t\r\n\]+sixth string arg is: f\[ \t\r\n\]+seventh string arg is: g\[ \t\r\n\]+" \
+	"= \"abcdefg\".*"
 }
 
 #call str_func("a","b","c","d","e","f","g")
 if ![gdb_skip_stdio_test "call str_func(a,b,c,d,e,f,g)"] {
-    gdb_test "call str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")" \
-	"first string arg is: a\[ \t\r\n\]+second string arg is: b\[ \t\r\n\]+third string arg is: c\[ \t\r\n\]+fourth string arg is: d\[ \t\r\n\]+fifth string arg is: e\[ \t\r\n\]+sixth string arg is: f\[ \t\r\n\]+seventh string arg is: g\[ \t\r\n\]+.*= \"abcdefg\".*"
+    gdb_test_stdio "call str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")" \
+	"first string arg is: a\[ \t\r\n\]+second string arg is: b\[ \t\r\n\]+third string arg is: c\[ \t\r\n\]+fourth string arg is: d\[ \t\r\n\]+fifth string arg is: e\[ \t\r\n\]+sixth string arg is: f\[ \t\r\n\]+seventh string arg is: g\[ \t\r\n\]+" \
+	"= \"abcdefg\".*"
 }
 
 #print str_func(s,s,s,s,s,s,s)
 if ![gdb_skip_stdio_test "print str_func(s,s,s,s,s,s,s,s)"] {
-    gdb_test "print str_func(s,s,s,s,s,s,s)" \
-	"first string arg is: test string\[ \t\r\n\]+second string arg is: test string\[ \t\r\n\]+third string arg is: test string\[ \t\r\n\]+fourth string arg is: test string\[ \t\r\n\]+fifth string arg is: test string\[ \t\r\n\]+sixth string arg is: test string\[ \t\r\n\]+seventh string arg is: test string\[ \t\r\n\]+.*\"test stringtest stringtest stringtest stringtest stringtest stringtest string\".*"
+    gdb_test_stdio "print str_func(s,s,s,s,s,s,s)" \
+	"first string arg is: test string\[ \t\r\n\]+second string arg is: test string\[ \t\r\n\]+third string arg is: test string\[ \t\r\n\]+fourth string arg is: test string\[ \t\r\n\]+fifth string arg is: test string\[ \t\r\n\]+sixth string arg is: test string\[ \t\r\n\]+seventh string arg is: test string\[ \t\r\n\]+" \
+    "\"test stringtest stringtest stringtest stringtest stringtest stringtest string\".*"
 }
 
 #call str_func(s,s,s,s,s,s,s)
 if ![gdb_skip_stdio_test "call str_func(s,s,s,s,s,s,s,s)"] {
-    gdb_test "call str_func(s,s,s,s,s,s,s)" \
-	"first string arg is: test string\[ \t\r\n\]+second string arg is: test string\[ \t\r\n\]+third string arg is: test string\[ \t\r\n\]+fourth string arg is: test string\[ \t\r\n\]+fifth string arg is: test string\[ \t\r\n\]+sixth string arg is: test string\[ \t\r\n\]+seventh string arg is: test string\[ \t\r\n\]+.*\"test stringtest stringtest stringtest stringtest stringtest stringtest string\".*"
+    gdb_test_stdio "call str_func(s,s,s,s,s,s,s)" \
+	"first string arg is: test string\[ \t\r\n\]+second string arg is: test string\[ \t\r\n\]+third string arg is: test string\[ \t\r\n\]+fourth string arg is: test string\[ \t\r\n\]+fifth string arg is: test string\[ \t\r\n\]+sixth string arg is: test string\[ \t\r\n\]+seventh string arg is: test string\[ \t\r\n\]+" \
+	"\"test stringtest stringtest stringtest stringtest stringtest stringtest string\".*"
 }
 
 gdb_exit
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 05/24] Don't rely on inferior I/O in {call-signal-resume, unwindonsignal}.exp
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
                   ` (17 preceding siblings ...)
  2015-04-21 18:09 ` [PATCH 21/24] Make gdb.mi/mi-dprintf.exp use $inferior_spawn_id Pedro Alves
@ 2015-04-21 18:09 ` Pedro Alves
  2015-04-21 18:09 ` [PATCH 02/24] gdb.base/interrupt.exp: Rename saw_eof to saw_end_of_file Pedro Alves
                   ` (5 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:09 UTC (permalink / raw)
  To: gdb-patches

These tests rely on inferior I/O, but that seems pointless and
unrelated here.  Simply remove the printf calls, and don't expect
them.

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* gdb.base/call-signal-resume.exp: Remove check for
	gdb,noinferiorio.  Don't expect "no signal".  Use gdb_test.
	* gdb.base/unwindonsignal.exp: Likewise.
	* gdb.base/call-signals.c (gen_signal): Remove printf call.
	* gdb.base/unwindonsignal.c (gen_signal): Likewise.
---
 gdb/testsuite/gdb.base/call-signal-resume.exp | 18 ++++--------------
 gdb/testsuite/gdb.base/call-signals.c         |  3 ---
 gdb/testsuite/gdb.base/unwindonsignal.c       |  3 ---
 gdb/testsuite/gdb.base/unwindonsignal.exp     | 18 ++++--------------
 4 files changed, 8 insertions(+), 34 deletions(-)

diff --git a/gdb/testsuite/gdb.base/call-signal-resume.exp b/gdb/testsuite/gdb.base/call-signal-resume.exp
index a4e6bd0..a8b0585 100644
--- a/gdb/testsuite/gdb.base/call-signal-resume.exp
+++ b/gdb/testsuite/gdb.base/call-signal-resume.exp
@@ -20,11 +20,6 @@
 # 2) Inferior is stopped at a signal.  Upon resumption it should continue
 #    with that signal, regardless of whatever the hand-called function did.
 
-if [target_info exists gdb,noinferiorio] {
-    verbose "Skipping call-signal-resume.exp because of no fileio capabilities."
-    continue
-}
-
 if [target_info exists gdb,nosignals] {
     verbose "Skipping call-signal-resume.exp because of nosignals."
     continue
@@ -72,15 +67,10 @@ gdb_test "continue" "Continuing.*Breakpoint \[0-9\]*, stop_one.*" \
 
 # Call function (causing the program to get a signal), and see if gdb handles
 # it properly.
-gdb_test_multiple "call gen_signal ()" \
-	"inferior function call signaled" {
-    -re "\[\r\n\]*no signal\[\r\n\]+$gdb_prompt $" {
-	unsupported "inferior function call signaled"
-	return 0
-    }
-    -re "\[\r\n\]*The program being debugged was signaled.*\[\r\n\]+$gdb_prompt $" {
-	pass "inferior function call signaled"
-    }
+if {[gdb_test "call gen_signal ()"  \
+	 "\[\r\n\]*The program being debugged was signaled.*" \
+	 "inferior function call signaled"] != 0} {
+    return 0
 }
 
 set frame_number [get_dummy_frame_number]
diff --git a/gdb/testsuite/gdb.base/call-signals.c b/gdb/testsuite/gdb.base/call-signals.c
index 2c5b770..c166649 100644
--- a/gdb/testsuite/gdb.base/call-signals.c
+++ b/gdb/testsuite/gdb.base/call-signals.c
@@ -18,7 +18,6 @@
 /* Support program for testing handling of inferior function calls
    in the presence of signals.  */
 
-#include <stdio.h>
 #include <signal.h>
 #include <unistd.h>
 
@@ -32,8 +31,6 @@ gen_signal ()
 {
   /* According to sigall.exp, SIGABRT is always supported.  */
   kill (getpid (), SIGABRT);
-  /* If we get here we couldn't generate a signal, tell dejagnu.  */
-  printf ("no signal\n");
 }
 
 /* Easy place to set a breakpoint.  */
diff --git a/gdb/testsuite/gdb.base/unwindonsignal.c b/gdb/testsuite/gdb.base/unwindonsignal.c
index 92d8ba4..e1b2094 100644
--- a/gdb/testsuite/gdb.base/unwindonsignal.c
+++ b/gdb/testsuite/gdb.base/unwindonsignal.c
@@ -17,7 +17,6 @@
 
 /* Support program for testing unwindonsignal.  */
 
-#include <stdio.h>
 #include <signal.h>
 #include <unistd.h>
 
@@ -26,8 +25,6 @@ gen_signal ()
 {
   /* According to sigall.exp, SIGABRT is always supported.  */
   kill (getpid (), SIGABRT);
-  /* If we get here we couldn't generate a signal, tell dejagnu.  */
-  printf ("no signal\n");
 }
 
 /* Easy place to set a breakpoint.  */
diff --git a/gdb/testsuite/gdb.base/unwindonsignal.exp b/gdb/testsuite/gdb.base/unwindonsignal.exp
index 2014e8d..dd53cfe 100644
--- a/gdb/testsuite/gdb.base/unwindonsignal.exp
+++ b/gdb/testsuite/gdb.base/unwindonsignal.exp
@@ -13,11 +13,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-if [target_info exists gdb,noinferiorio] {
-    verbose "Skipping unwindonsignal.exp because of no fileio capabilities."
-    continue
-}
-
 if [target_info exists gdb,nosignals] {
     verbose "Skipping unwindonsignal.exp because of nosignals."
     continue
@@ -58,15 +53,10 @@ gdb_test "show unwindonsignal" \
 
 # Call function (causing the program to get a signal), and see if gdb handles
 # it properly.
-gdb_test_multiple "call gen_signal ()" \
-	"unwindonsignal, inferior function call signaled" {
-    -re "\[\r\n\]*no signal\[\r\n\]+$gdb_prompt $" {
-	unsupported "unwindonsignal, inferior function call signaled"
-	return 0
-    }
-    -re "\[\r\n\]*The program being debugged was signaled.*\[\r\n\]+$gdb_prompt $" {
-	pass "unwindonsignal, inferior function call signaled"
-    }
+if {[gdb_test "call gen_signal ()"  \
+	 "\[\r\n\]*The program being debugged was signaled.*" \
+	 "unwindonsignal, inferior function call signaled"] != 0} {
+    return 0
 }
 
 # Verify the stack got unwound.
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 02/24] gdb.base/interrupt.exp: Rename saw_eof to saw_end_of_file
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
                   ` (18 preceding siblings ...)
  2015-04-21 18:09 ` [PATCH 05/24] Don't rely on inferior I/O in {call-signal-resume, unwindonsignal}.exp Pedro Alves
@ 2015-04-21 18:09 ` Pedro Alves
  2015-04-21 18:09 ` [PATCH 23/24] interrupt.exp: Revert back to checking gdb,noinferiorio at the top Pedro Alves
                   ` (4 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:09 UTC (permalink / raw)
  To: gdb-patches

To avoid confusion between "end of file" string matching and eof
matching, as in process exit.

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* gdb.base/interrupt.exp: Rename saw_eof to saw_end_of_file.
---
 gdb/testsuite/gdb.base/interrupt.exp | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/gdb/testsuite/gdb.base/interrupt.exp b/gdb/testsuite/gdb.base/interrupt.exp
index d093ff5..17a9bad 100644
--- a/gdb/testsuite/gdb.base/interrupt.exp
+++ b/gdb/testsuite/gdb.base/interrupt.exp
@@ -200,16 +200,16 @@ if ![file exists $binfile] then {
 	    }
 	}
 
-	set saw_eof 0
+	set saw_end_of_file 0
 	set saw_inferior_exit 0
 
 	set msg "send end of file"
 	send_inferior "\004"
 	gdb_test_multiple "" $msg {
-	    -i "$inferior_spawn_id" -re "end of file" {
-		verbose -log "saw eof: $saw_eof"
-		set saw_eof 1
-		verbose -log "saw eof"
+	    -i $inferior_spawn_id -re "end of file" {
+		verbose -log "saw \"end of file\": $saw_end_of_file"
+		set saw_end_of_file 1
+		verbose -log "saw \"end of file\""
 		if {!$saw_inferior_exit} {
 		    exp_continue
 		}
@@ -217,13 +217,13 @@ if ![file exists $binfile] then {
 	    -i "$gdb_spawn_id" -re "$inferior_exited_re normally.*$gdb_prompt " {
 		set saw_inferior_exit 1
 		verbose -log "saw inferior exit"
-		if {!$saw_eof} {
+		if {!$saw_end_of_file} {
 		    exp_continue
 		}
 	    }
 	}
 
-	gdb_assert { $saw_eof && $saw_inferior_exit } $msg
+	gdb_assert { $saw_end_of_file && $saw_inferior_exit } $msg
     }
 }
 return 0
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 23/24] interrupt.exp: Revert back to checking gdb,noinferiorio at the top
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
                   ` (19 preceding siblings ...)
  2015-04-21 18:09 ` [PATCH 02/24] gdb.base/interrupt.exp: Rename saw_eof to saw_end_of_file Pedro Alves
@ 2015-04-21 18:09 ` Pedro Alves
  2015-04-21 18:15 ` [PATCH 08/24] Make gdb.base/sizeof.exp use gdb_test_stdio Pedro Alves
                   ` (3 subsequent siblings)
  24 siblings, 0 replies; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:09 UTC (permalink / raw)
  To: gdb-patches

The following patch will remove the gdb,noinferiorio setting from the
gdbserver boards, so this bit can be reverted.

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* gdb.base/interrupt.exp: Revert back to checking gdb,noinferiorio
	at the top.
---
 gdb/testsuite/gdb.base/interrupt.exp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gdb/testsuite/gdb.base/interrupt.exp b/gdb/testsuite/gdb.base/interrupt.exp
index f594ba4..426c2a6 100644
--- a/gdb/testsuite/gdb.base/interrupt.exp
+++ b/gdb/testsuite/gdb.base/interrupt.exp
@@ -18,6 +18,11 @@ if [target_info exists gdb,nointerrupts] {
     continue
 }
 
+if [target_info exists gdb,noinferiorio] {
+    verbose "Skipping interrupt.exp because of noinferiorio."
+    return
+}
+
 standard_testfile
 
 set options { debug }
@@ -45,11 +50,6 @@ if ![file exists $binfile] then {
     if [runto_main] then {
 	global inferior_spawn_id gdb_spawn_id
 
-	if {[target_info exists gdb,noinferiorio] && $inferior_spawn_id == $gdb_spawn_id} {
-	    verbose "Skipping interrupt.exp because of noinferiorio."
-	    return
-	}
-
 	set msg "process is alive"
 	gdb_test_multiple "continue" $msg {
 	    -i "$inferior_spawn_id" -re "talk to me baby\r\n" {
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 08/24] Make gdb.base/sizeof.exp use gdb_test_stdio
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
                   ` (20 preceding siblings ...)
  2015-04-21 18:09 ` [PATCH 23/24] interrupt.exp: Revert back to checking gdb,noinferiorio at the top Pedro Alves
@ 2015-04-21 18:15 ` Pedro Alves
  2015-04-23 15:36   ` Antoine Tremblay
  2015-04-21 18:18 ` [PATCH 18/24] Make gdb.gdb/complaints.exp use '-i $inferior_spawn_id' and gdb_test_stdio Pedro Alves
                   ` (2 subsequent siblings)
  24 siblings, 1 reply; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:15 UTC (permalink / raw)
  To: gdb-patches

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* gdb.base/sizeof.exp (check_sizeof, check_valueof): Use
	gdb_test_stdio.
---
 gdb/testsuite/gdb.base/sizeof.exp | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/gdb/testsuite/gdb.base/sizeof.exp b/gdb/testsuite/gdb.base/sizeof.exp
index 7fda76e..a237ee3 100644
--- a/gdb/testsuite/gdb.base/sizeof.exp
+++ b/gdb/testsuite/gdb.base/sizeof.exp
@@ -70,8 +70,10 @@ set sizeof_long_double [get_sizeof "long double" 8]
 proc check_sizeof { type size } {
     global gdb_prompt
 
-    set pat [string_to_regexp "sizeof (${type}) == ${size}"]
-    gdb_test "next" "${pat}\[\r\n\]+\[0-9\].*"  "check sizeof \"$type\""
+    set pat [string_to_regexp "sizeof (${type}) == ${size}\r\n"]
+    gdb_test_stdio "next" "${pat}" \
+	"\[0-9\].*" \
+	"check sizeof \"$type\""
 }
 
 check_sizeof "char" ${sizeof_char}
@@ -90,8 +92,10 @@ check_sizeof "long double" ${sizeof_long_double}
 proc check_valueof { exp val } {
     global gdb_prompt
 
-    set pat [string_to_regexp "valueof (${exp}) == ${val}"]
-    gdb_test "next" "${pat}\[\r\n\]+\[0-9\].*" "check valueof \"$exp\""
+    set pat [string_to_regexp "valueof (${exp}) == ${val}\r\n"]
+    gdb_test_stdio "next" "${pat}" \
+	"\[0-9\].*" \
+	"check valueof \"$exp\""
 }
 
 # Check that GDB and the target agree over the sign of a character.
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 18/24] Make gdb.gdb/complaints.exp use '-i $inferior_spawn_id' and gdb_test_stdio
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
                   ` (21 preceding siblings ...)
  2015-04-21 18:15 ` [PATCH 08/24] Make gdb.base/sizeof.exp use gdb_test_stdio Pedro Alves
@ 2015-04-21 18:18 ` Pedro Alves
  2015-04-21 18:43 ` [PATCH 15/24] Make gdb.base/ending-run.exp use gdb_test_stdio Pedro Alves
  2015-07-29 11:41 ` [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
  24 siblings, 0 replies; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:18 UTC (permalink / raw)
  To: gdb-patches

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* gdb.gdb/complaints.exp (test_initial_complaints, test_serial_complaints)
	(test_short_complaints): Use gdb_test_stdio.
	(test_empty_complaint): Handle $inferior_spawn_id !=
	$gdb_spawn_id.
---
 gdb/testsuite/gdb.gdb/complaints.exp | 110 ++++++++++++++++++++---------------
 1 file changed, 64 insertions(+), 46 deletions(-)

diff --git a/gdb/testsuite/gdb.gdb/complaints.exp b/gdb/testsuite/gdb.gdb/complaints.exp
index 707b2a5..24843c0 100644
--- a/gdb/testsuite/gdb.gdb/complaints.exp
+++ b/gdb/testsuite/gdb.gdb/complaints.exp
@@ -24,15 +24,41 @@ if [target_info exists gdb,noinferiorio] {
     return
 }
 
-proc test_initial_complaints { } {
+# Similar to gdb_test_stdio, except no \r\n is expected before
+# $gdb_prompt in the $gdb_spawn_id.
 
+proc test_complaint {test inferior_io_re msg} {
+    global inferior_spawn_id gdb_spawn_id
     global gdb_prompt
 
+    set inferior_matched 0
+    set gdb_matched 0
+
+    gdb_test_multiple $test $msg {
+	-i $inferior_spawn_id -re "$inferior_io_re" {
+	    set inferior_matched 1
+	    if {!$gdb_matched} {
+		exp_continue
+	    }
+	}
+	-i $gdb_spawn_id -re "$gdb_prompt $" {
+	    set gdb_matched 1
+	    if {!$inferior_matched} {
+		exp_continue
+	    }
+	}
+    }
+
+    verbose -log "inferior_matched=$inferior_matched, gdb_matched=$gdb_matched"
+    gdb_assert {$inferior_matched && $gdb_matched} $msg
+}
+
+proc test_initial_complaints { } {
     # Unsupress complaints
     gdb_test "set stop_whining = 2"
 
     # Prime the system
-    gdb_test "call complaint (&symfile_complaints, \"Register a complaint\")" \
+    gdb_test_stdio "call complaint (&symfile_complaints, \"Register a complaint\")" \
 	    "During symbol reading, Register a complaint."
 
     # Check that the complaint was inserted and where
@@ -40,7 +66,7 @@ proc test_initial_complaints { } {
 	    ".\[0-9\]+ =.*\"Register a complaint\""
 
     # Re-issue the first message #1
-    gdb_test "call complaint (&symfile_complaints, symfile_complaints->root->fmt)" \
+    gdb_test_stdio "call complaint (&symfile_complaints, symfile_complaints->root->fmt)" \
 	    "During symbol reading, Register a complaint."
 
     # Check that there is only one thing in the list.  How the boolean
@@ -50,37 +76,29 @@ proc test_initial_complaints { } {
 	    ".\[0-9\]+ = \(1|true\)" "list has one entry"
 
     # Add a second complaint, expect it
-    gdb_test "call complaint (&symfile_complaints, \"Testing! Testing! Testing!\")" \
+    gdb_test_stdio "call complaint (&symfile_complaints, \"Testing! Testing! Testing!\")" \
 	    "During symbol reading, Testing. Testing. Testing.."
 
     return 0
 }
 
 proc test_serial_complaints { } {
-
-    global gdb_prompt
-
     gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 0)" "" "serial start"
 
     # Prime the system
-    gdb_test_multiple "call complaint (&symfile_complaints, \"serial line  1\")" "serial line 1" {
-	-re "During symbol reading...serial line  1...$gdb_prompt $" {
-	    pass "serial line 1"
-	}
-    }
+    test_complaint "call complaint (&symfile_complaints, \"serial line 1\")" \
+	"During symbol reading...serial line 1..." \
+	"serial line 1"
 
     # Add a second complaint, expect it
-    gdb_test_multiple "call complaint (&symfile_complaints, \"serial line 2\")" "serial line 2" {
-	-re "serial line 2...$gdb_prompt " {
-	    pass "serial line 2"
-	}
-    }
+    test_complaint "call complaint (&symfile_complaints, \"serial line 2\")" \
+	"serial line 2..." \
+	"serial line 2"
 
-    gdb_test_multiple "call clear_complaints (&symfile_complaints, 1, 0)" "serial end" {
-	-re "\r\n\r\n$gdb_prompt " {
-	    pass "serial end"
-	}
-    }
+    gdb_test_stdio "call clear_complaints (&symfile_complaints, 1, 0)" \
+	"\r\n" \
+	"" \
+	"serial end"
 
     return 0
 }
@@ -88,30 +106,22 @@ proc test_serial_complaints { } {
 # For short complaints, all are the same
 
 proc test_short_complaints { } {
-
-    global gdb_prompt
-
     gdb_test_exact "call clear_complaints (&symfile_complaints, 1, 1)" "" "short start"
 
     # Prime the system
-    gdb_test_multiple "call complaint (&symfile_complaints, \"short line 1\")" "short line 1" {
-	-re "short line 1...$gdb_prompt " {
-	    pass "short line 1"
-	}
-    }
+    test_complaint "call complaint (&symfile_complaints, \"short line 1\")" \
+	"short line 1..." \
+	"short line 1"
 
     # Add a second complaint, expect it
-    gdb_test_multiple "call complaint (&symfile_complaints, \"short line 2\")" "short line 2" {
-	-re "short line 2...$gdb_prompt " {
-	    pass "short line 2"
-	}
-    }
+    test_complaint "call complaint (&symfile_complaints, \"short line 2\")" \
+	"short line 2..." \
+	"short line 2"
 
-    gdb_test_multiple "call clear_complaints (&symfile_complaints, 1, 0)" "short end" {
-	-re "\r\n\r\n$gdb_prompt " {
-	    pass "short end"
-	}
-    }
+    gdb_test_stdio "call clear_complaints (&symfile_complaints, 1, 0)" \
+	"\r\n" \
+	"" \
+	"short end"
 
     return 0
 }
@@ -122,12 +132,20 @@ proc test_short_complaints { } {
 
 proc test_empty_complaint { cmd msg } {
     global gdb_prompt
-    gdb_test_multiple $cmd $msg {
-	-re "\r\n\r\n$gdb_prompt $" {
-	    fail $msg
-	}
-	"\r\n$gdb_prompt $" {
-	    pass $msg
+    global inferior_spawn_id gdb_spawn_id
+
+    if {$gdb_spawn_id == $inferior_spawn_id} {
+	gdb_test_no_output $cmd $msg
+    } else {
+	set seen_output 0
+	gdb_test_multiple $cmd $msg {
+	    -i $inferior_spawn_id -re "." {
+		set seen_output 1
+		exp_continue
+	    }
+	    -i $gdb_spawn_id "$gdb_prompt $" {
+		gdb_assert !$seen_output $msg
+	    }
 	}
     }
 }
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 15/24] Make gdb.base/ending-run.exp use gdb_test_stdio
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
                   ` (22 preceding siblings ...)
  2015-04-21 18:18 ` [PATCH 18/24] Make gdb.gdb/complaints.exp use '-i $inferior_spawn_id' and gdb_test_stdio Pedro Alves
@ 2015-04-21 18:43 ` Pedro Alves
  2015-07-29 11:41 ` [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
  24 siblings, 0 replies; 36+ messages in thread
From: Pedro Alves @ 2015-04-21 18:43 UTC (permalink / raw)
  To: gdb-patches

gdb/testsuite/ChangeLog:
2015-04-21  Pedro Alves  <palves@redhat.com>

	* gdb.base/ending-run.exp: Use gdb_test_stdio.
---
 gdb/testsuite/gdb.base/ending-run.exp | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/gdb/testsuite/gdb.base/ending-run.exp b/gdb/testsuite/gdb.base/ending-run.exp
index 7d37a48..dceebcd 100644
--- a/gdb/testsuite/gdb.base/ending-run.exp
+++ b/gdb/testsuite/gdb.base/ending-run.exp
@@ -99,14 +99,18 @@ gdb_test_multiple "i b" "all set to continue" {
 # is output from the program.
 #
 if ![gdb_skip_stdio_test "cont"] {
-    gdb_test "cont" ".*1 2 7 14 23 34 47 62 79.*Breakpoint.*$break2_line.*"
+    gdb_test_stdio "cont" \
+	"1 2 7 14 23 34 47 62 79" \
+	"Breakpoint.*$break2_line.*"
 } else {
     gdb_test "cont" ".*Breakpoint.*$break2_line.*"
 }
 
 if ![gdb_skip_stdio_test "Step to return"] {
-    gdb_test "next" ".*Goodbye!.*[expr {$break2_line + 1}].*" \
-	    "Step to return"
+    gdb_test_stdio "next" \
+	"Goodbye!" \
+	"[expr {$break2_line + 1}].*" \
+	"Step to return"
 } else {
     gdb_test "next" ".*" ""
 }
-- 
1.9.3


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 03/24] Fix gdb.base/interrupt.exp racy fail against gdbserver
  2015-04-21 18:09 ` [PATCH 03/24] Fix gdb.base/interrupt.exp racy fail against gdbserver Pedro Alves
@ 2015-04-23 14:28   ` Yao Qi
  2015-04-23 14:58     ` Pedro Alves
  0 siblings, 1 reply; 36+ messages in thread
From: Yao Qi @ 2015-04-23 14:28 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Pedro Alves <palves@redhat.com> writes:

> Fix this by removing $inferior_spawn_id from the set of spawn ids
> expect is watching as soon as we see the "end of file" string out of
> the inferior spawn id, using an indirect spawn id list.
>

Yeah, it is clever to use indirect spawn ids here...

> Tested on x86-64 Fedora 20, native and gdbserver (both target remote
> and extended-remote).
>
> gdb/testsuite/ChangeLog:
> 2015-04-21  Pedro Alves  <palves@redhat.com>
>
> 	* gdb.base/interrupt.exp: Rename saw_eof to saw_end_of_file.  Use

The first sentence can be removed, it is in 02/24.

> 	an indirect spawn id list holding $inferior_spawn_id instead of
> 	$inferior_spawn_id directly.  On "of of file", remove

On "end of file".

> 	$inferior_spawn_id from the indirect list.

Patch is good to me.

-- 
Yao (齐尧)


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 03/24] Fix gdb.base/interrupt.exp racy fail against gdbserver
  2015-04-23 14:28   ` Yao Qi
@ 2015-04-23 14:58     ` Pedro Alves
  0 siblings, 0 replies; 36+ messages in thread
From: Pedro Alves @ 2015-04-23 14:58 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

On 04/23/2015 03:28 PM, Yao Qi wrote:
> Pedro Alves <palves@redhat.com> writes:
> 
>> Fix this by removing $inferior_spawn_id from the set of spawn ids
>> expect is watching as soon as we see the "end of file" string out of
>> the inferior spawn id, using an indirect spawn id list.
>>
> 
> Yeah, it is clever to use indirect spawn ids here...
> 
>> Tested on x86-64 Fedora 20, native and gdbserver (both target remote
>> and extended-remote).
>>
>> gdb/testsuite/ChangeLog:
>> 2015-04-21  Pedro Alves  <palves@redhat.com>
>>
>> 	* gdb.base/interrupt.exp: Rename saw_eof to saw_end_of_file.  Use
> 
> The first sentence can be removed, it is in 02/24.
> 
>> 	an indirect spawn id list holding $inferior_spawn_id instead of
>> 	$inferior_spawn_id directly.  On "of of file", remove
> 
> On "end of file".
> 
>> 	$inferior_spawn_id from the indirect list.
> 
> Patch is good to me.

Thanks Yao, I fixed ChangeLog and went ahead and pushed in
patches 1-3, in order to plug the race in the buildbots.

Thanks,
Pedro Alves


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 24/24] Don't set gdb,noinferiorio on gdbserver boards
  2015-04-21 18:09 ` [PATCH 24/24] Don't set gdb,noinferiorio on gdbserver boards Pedro Alves
@ 2015-04-23 15:09   ` Yao Qi
  2015-04-23 15:24     ` Pedro Alves
  0 siblings, 1 reply; 36+ messages in thread
From: Yao Qi @ 2015-04-23 15:09 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Pedro Alves <palves@redhat.com> writes:

> As all tests that check gdb,noinferiorio have been adjusted to expect
> inferior output with "-i $inferior_spawn_id", we can remove this now,
> and thus enable those tests against gdbserver.

We can also remove noinferiorio from testsuite/README.

-- 
Yao (齐尧)


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 24/24] Don't set gdb,noinferiorio on gdbserver boards
  2015-04-23 15:09   ` Yao Qi
@ 2015-04-23 15:24     ` Pedro Alves
  2015-04-24  9:19       ` Yao Qi
  0 siblings, 1 reply; 36+ messages in thread
From: Pedro Alves @ 2015-04-23 15:24 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

On 04/23/2015 04:08 PM, Yao Qi wrote:
> Pedro Alves <palves@redhat.com> writes:
> 
>> As all tests that check gdb,noinferiorio have been adjusted to expect
>> inferior output with "-i $inferior_spawn_id", we can remove this now,
>> and thus enable those tests against gdbserver.
> 
> We can also remove noinferiorio from testsuite/README.

That actually should stay.  The checks for noinferiorio in the testsuite
will still exist and we must continue to make sure that new tests that rely
on inferior i/o are skipped if noinferiorio is set, and avoid relying on
inferior i/o if not really necessary.  There are non-gdbserver setups that
neither forward inferior i/o through gdb, nor through ssh (that is, through
a separate $inferior_spawn_id channel), e.g., boards that test embedded stubs
that don't do semihosting.

Thanks,
Pedro Alves


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 08/24] Make gdb.base/sizeof.exp use gdb_test_stdio
  2015-04-21 18:15 ` [PATCH 08/24] Make gdb.base/sizeof.exp use gdb_test_stdio Pedro Alves
@ 2015-04-23 15:36   ` Antoine Tremblay
  2015-04-23 15:38     ` Antoine Tremblay
  0 siblings, 1 reply; 36+ messages in thread
From: Antoine Tremblay @ 2015-04-23 15:36 UTC (permalink / raw)
  To: Pedro Alves, gdb-patches



On 04/21/2015 02:08 PM, Pedro Alves wrote:
> gdb/testsuite/ChangeLog:
> 2015-04-21  Pedro Alves  <palves@redhat.com>
>
> 	* gdb.base/sizeof.exp (check_sizeof, check_valueof): Use
> 	gdb_test_stdio.
> ---
>   gdb/testsuite/gdb.base/sizeof.exp | 12 ++++++++----
>   1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/gdb/testsuite/gdb.base/sizeof.exp b/gdb/testsuite/gdb.base/sizeof.exp
> index 7fda76e..a237ee3 100644
> --- a/gdb/testsuite/gdb.base/sizeof.exp
> +++ b/gdb/testsuite/gdb.base/sizeof.exp
> @@ -70,8 +70,10 @@ set sizeof_long_double [get_sizeof "long double" 8]
>   proc check_sizeof { type size } {
>       global gdb_prompt
>
> -    set pat [string_to_regexp "sizeof (${type}) == ${size}"]
> -    gdb_test "next" "${pat}\[\r\n\]+\[0-9\].*"  "check sizeof \"$type\""
> +    set pat [string_to_regexp "sizeof (${type}) == ${size}\r\n"]
> +    gdb_test_stdio "next" "${pat}" \
> +	"\[0-9\].*" \
> +	"check sizeof \"$type\""
>   }
>
>   check_sizeof "char" ${sizeof_char}
> @@ -90,8 +92,10 @@ check_sizeof "long double" ${sizeof_long_double}
>   proc check_valueof { exp val } {
>       global gdb_prompt
>
> -    set pat [string_to_regexp "valueof (${exp}) == ${val}"]
> -    gdb_test "next" "${pat}\[\r\n\]+\[0-9\].*" "check valueof \"$exp\""
> +    set pat [string_to_regexp "valueof (${exp}) == ${val}\r\n"]
> +    gdb_test_stdio "next" "${pat}" \
> +	"\[0-9\].*" \
> +	"check valueof \"$exp\""
>   }
>
>   # Check that GDB and the target agree over the sign of a character.
>

It's not part of the patch but should we replace :

# Test depends on printf, which the sparclet stub doesn't support.
if { [istarget "sparclet-*-*"] } {
     return 0
}

With :if [target_info exists gdb,noinferiorio] { ?

This is present in other tests too...

Thanks,
Antoine


And add that option to the sparclet target ? ( I could not find that 
target in the tree even if config/m32r-stub.exp references it...



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 08/24] Make gdb.base/sizeof.exp use gdb_test_stdio
  2015-04-23 15:36   ` Antoine Tremblay
@ 2015-04-23 15:38     ` Antoine Tremblay
  2015-04-23 15:49       ` Pedro Alves
  0 siblings, 1 reply; 36+ messages in thread
From: Antoine Tremblay @ 2015-04-23 15:38 UTC (permalink / raw)
  To: Pedro Alves, gdb-patches



On 04/23/2015 11:36 AM, Antoine Tremblay wrote:
>
>
> On 04/21/2015 02:08 PM, Pedro Alves wrote:
>> gdb/testsuite/ChangeLog:
>> 2015-04-21  Pedro Alves  <palves@redhat.com>
>>
>>     * gdb.base/sizeof.exp (check_sizeof, check_valueof): Use
>>     gdb_test_stdio.
>> ---
>>   gdb/testsuite/gdb.base/sizeof.exp | 12 ++++++++----
>>   1 file changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/gdb/testsuite/gdb.base/sizeof.exp
>> b/gdb/testsuite/gdb.base/sizeof.exp
>> index 7fda76e..a237ee3 100644
>> --- a/gdb/testsuite/gdb.base/sizeof.exp
>> +++ b/gdb/testsuite/gdb.base/sizeof.exp
>> @@ -70,8 +70,10 @@ set sizeof_long_double [get_sizeof "long double" 8]
>>   proc check_sizeof { type size } {
>>       global gdb_prompt
>>
>> -    set pat [string_to_regexp "sizeof (${type}) == ${size}"]
>> -    gdb_test "next" "${pat}\[\r\n\]+\[0-9\].*"  "check sizeof \"$type\""
>> +    set pat [string_to_regexp "sizeof (${type}) == ${size}\r\n"]
>> +    gdb_test_stdio "next" "${pat}" \
>> +    "\[0-9\].*" \
>> +    "check sizeof \"$type\""
>>   }
>>
>>   check_sizeof "char" ${sizeof_char}
>> @@ -90,8 +92,10 @@ check_sizeof "long double" ${sizeof_long_double}
>>   proc check_valueof { exp val } {
>>       global gdb_prompt
>>
>> -    set pat [string_to_regexp "valueof (${exp}) == ${val}"]
>> -    gdb_test "next" "${pat}\[\r\n\]+\[0-9\].*" "check valueof \"$exp\""
>> +    set pat [string_to_regexp "valueof (${exp}) == ${val}\r\n"]
>> +    gdb_test_stdio "next" "${pat}" \
>> +    "\[0-9\].*" \
>> +    "check valueof \"$exp\""
>>   }
>>
>>   # Check that GDB and the target agree over the sign of a character.
>>
>
> It's not part of the patch but should we replace :
>
> # Test depends on printf, which the sparclet stub doesn't support.
> if { [istarget "sparclet-*-*"] } {
>      return 0
> }
>
> With :if [target_info exists gdb,noinferiorio] { ?
>
> This is present in other tests too...
>
> Thanks,
> Antoine
>
>
> And add that option to the sparclet target ? ( I could not find that
> target in the tree even if config/m32r-stub.exp references it...
>

Oops I've hit send by mistake this was meant for [PATCH 09/24] Make 
gdb.base/call-strs.exp use gdb_test_stdio and others like it...

Sorry about that

Antoine


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 08/24] Make gdb.base/sizeof.exp use gdb_test_stdio
  2015-04-23 15:38     ` Antoine Tremblay
@ 2015-04-23 15:49       ` Pedro Alves
  2015-04-23 16:04         ` Pedro Alves
  0 siblings, 1 reply; 36+ messages in thread
From: Pedro Alves @ 2015-04-23 15:49 UTC (permalink / raw)
  To: Antoine Tremblay, gdb-patches

On 04/23/2015 04:38 PM, Antoine Tremblay wrote:

>> It's not part of the patch but should we replace :
>>
>> # Test depends on printf, which the sparclet stub doesn't support.
>> if { [istarget "sparclet-*-*"] } {
>>      return 0
>> }
>>
>> With :if [target_info exists gdb,noinferiorio] { ?
>>

Yes, though...

>> This is present in other tests too...
>>
>> Thanks,
>> Antoine
>>
>>
>> And add that option to the sparclet target ? ( I could not find that
>> target in the tree even if config/m32r-stub.exp references it...

... I had never heard of sparclet before, until I noticed that line too.
I had assumed it was a Sun SPARC cpu variant, and ignored it.

But now I notice that it's something else.  We still have a chapter
about it in the manual:

  https://sourceware.org/gdb/onlinedocs/gdb/Sparclet.html

But, NEWS says the support was removed in gdb 6.1...

* REMOVED configurations and files

...
Tsqware Sparclet                                sparclet-*-*
...


ChangeLog-2003 has:

...
        * sparclet-stub.c, sparclet-rom.c: Delete obsolete file.
...

etc.


So the remaining bits are just waiting for someone to garbage
collect them.


>>
> 
> Oops I've hit send by mistake this was meant for [PATCH 09/24] Make 
> gdb.base/call-strs.exp use gdb_test_stdio and others like it...
> 
> Sorry about that
> 

No worries.  :-)


Thanks,
Pedro Alves


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 08/24] Make gdb.base/sizeof.exp use gdb_test_stdio
  2015-04-23 15:49       ` Pedro Alves
@ 2015-04-23 16:04         ` Pedro Alves
  2015-04-23 16:25           ` Antoine Tremblay
  0 siblings, 1 reply; 36+ messages in thread
From: Pedro Alves @ 2015-04-23 16:04 UTC (permalink / raw)
  To: Antoine Tremblay, gdb-patches

On 04/23/2015 04:49 PM, Pedro Alves wrote:
> On 04/23/2015 04:38 PM, Antoine Tremblay wrote:
> 
>>> It's not part of the patch but should we replace :
>>>
>>> # Test depends on printf, which the sparclet stub doesn't support.
>>> if { [istarget "sparclet-*-*"] } {
>>>      return 0
>>> }
>>>
>>> With :if [target_info exists gdb,noinferiorio] { ?
>>>
> 
> Yes, though...

TBC, the tests in question already check gdb_skip_stdio_test,
so adding a gdb,noinferiorio check would not be necessary.

(But yes to the rest.)

Thanks,
Pedro Alves


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 08/24] Make gdb.base/sizeof.exp use gdb_test_stdio
  2015-04-23 16:04         ` Pedro Alves
@ 2015-04-23 16:25           ` Antoine Tremblay
  0 siblings, 0 replies; 36+ messages in thread
From: Antoine Tremblay @ 2015-04-23 16:25 UTC (permalink / raw)
  To: Pedro Alves, gdb-patches



On 04/23/2015 12:04 PM, Pedro Alves wrote:
> On 04/23/2015 04:49 PM, Pedro Alves wrote:
>> On 04/23/2015 04:38 PM, Antoine Tremblay wrote:
>>
>>>> It's not part of the patch but should we replace :
>>>>
>>>> # Test depends on printf, which the sparclet stub doesn't support.
>>>> if { [istarget "sparclet-*-*"] } {
>>>>       return 0
>>>> }
>>>>
>>>> With :if [target_info exists gdb,noinferiorio] { ?
>>>>
>>
>> Yes, though...
>
> TBC, the tests in question already check gdb_skip_stdio_test,
> so adding a gdb,noinferiorio check would not be necessary.
>

Indeed, the whole test doesn't always need to be skipped..

Thanks!

Antoine


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 24/24] Don't set gdb,noinferiorio on gdbserver boards
  2015-04-23 15:24     ` Pedro Alves
@ 2015-04-24  9:19       ` Yao Qi
  0 siblings, 0 replies; 36+ messages in thread
From: Yao Qi @ 2015-04-24  9:19 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Yao Qi, gdb-patches

Pedro Alves <palves@redhat.com> writes:

> That actually should stay.  The checks for noinferiorio in the testsuite
> will still exist and we must continue to make sure that new tests that rely
> on inferior i/o are skipped if noinferiorio is set, and avoid relying on
> inferior i/o if not really necessary.  There are non-gdbserver setups that
> neither forward inferior i/o through gdb, nor through ssh (that is, through
> a separate $inferior_spawn_id channel), e.g., boards that test embedded stubs
> that don't do semihosting.

Ah, you are right.  My brain was in a mess yesterday afternoon, sorry
about that.

-- 
Yao (齐尧)


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards
  2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
                   ` (23 preceding siblings ...)
  2015-04-21 18:43 ` [PATCH 15/24] Make gdb.base/ending-run.exp use gdb_test_stdio Pedro Alves
@ 2015-07-29 11:41 ` Pedro Alves
  24 siblings, 0 replies; 36+ messages in thread
From: Pedro Alves @ 2015-07-29 11:41 UTC (permalink / raw)
  To: gdb-patches

On 04/21/2015 07:08 PM, Pedro Alves wrote:
> This series finishes what was started here:
> 
>   https://sourceware.org/ml/gdb-patches/2015-02/msg00655.html
> 
> In a nutshell:
>   
>  - Make a few tests that are currently relying on inferior I/O to not
>    do that anymore.
> 
>  - Convert all the remaining tests that rely on inferior I/O to use
>    $inferior_spawn_id.
> 
>  - Add a gdb_test_stdio helper used by most of the above.
> 
>  - Unbuffer all tests that rely on stdio, using the same mechanism
>    that ended up used in interrupt.exp, in the series in the url
>    above.
> 
>  - Remove gdb,noinferiorio from our gdbserver boards, so the tests run
>    (against gdbserver).
> 
> Tested on x86_64 Fedora 20, native, native-gdbserver and also against
> remote gdbserver with no pseudo-tty, which requires the unbuffering.
> 
> I've pushed this to users/palves/inferior_spawn_id for review and
> testing convenience.
> 
> Pedro Alves (24):
>   gdb_test_multiple match eof of any spawn_id
>   gdb.base/interrupt.exp: Rename saw_eof to saw_end_of_file
>   Fix gdb.base/interrupt.exp racy fail against gdbserver
>   Don't rely on inferior I/O in gdb.base/siginfo-addr.exp
>   Don't rely on inferior I/O in {call-signal-resume, unwindonsignal}.exp
>   Don't rely on inferior I/O in gdb.base/restore.exp
>   Introduce gdb_test_stdio
>   Make gdb.base/sizeof.exp use gdb_test_stdio
>   Make gdb.base/call-strs.exp use gdb_test_stdio
>   Make gdb.base/catch-gdb-caused-signals.exp use gdb_test_stdio
>   Make gdb.base/dprintf.exp use gdb_test_stdio
>   Make gdb.base/a2-run.exp use $inferior_spawn_id and gdb_test_stdio
>   Make gdb.base/call-ar-st.exp use gdb_test_stdio
>   Make gdb.base/call-rt-st.exp use $inferior_spawn_id
>   Make gdb.base/ending-run.exp use gdb_test_stdio
>   Make gdb.base/shlib-call.exp use gdb_test_stdio
>   Make gdb.base/varargs.exp use gdb_test_stdio
>   Make gdb.gdb/complaints.exp use '-i $inferior_spawn_id' and
>     gdb_test_stdio
>   Make gdb.gdb/selftest.exp use '-i $inferior_spawn_id'
>   Adjust MI to $inferior_spawn_id
>   Make gdb.mi/mi-dprintf.exp use $inferior_spawn_id
>   Unbuffer all tests that rely on stdio
>   interrupt.exp: Revert back to checking gdb,noinferiorio at the top
>   Don't set gdb,noinferiorio on gdbserver boards

I finally pushed this in, after another round of testing.

Thanks,
Pedro Alves


^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2015-07-29 11:41 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-21 18:08 [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves
2015-04-21 18:08 ` [PATCH 10/24] Make gdb.base/catch-gdb-caused-signals.exp use gdb_test_stdio Pedro Alves
2015-04-21 18:08 ` [PATCH 07/24] Introduce gdb_test_stdio Pedro Alves
2015-04-21 18:08 ` [PATCH 12/24] Make gdb.base/a2-run.exp use $inferior_spawn_id and gdb_test_stdio Pedro Alves
2015-04-21 18:08 ` [PATCH 13/24] Make gdb.base/call-ar-st.exp use gdb_test_stdio Pedro Alves
2015-04-21 18:08 ` [PATCH 01/24] gdb_test_multiple match eof of any spawn_id Pedro Alves
2015-04-21 18:08 ` [PATCH 04/24] Don't rely on inferior I/O in gdb.base/siginfo-addr.exp Pedro Alves
2015-04-21 18:08 ` [PATCH 16/24] Make gdb.base/shlib-call.exp use gdb_test_stdio Pedro Alves
2015-04-21 18:09 ` [PATCH 24/24] Don't set gdb,noinferiorio on gdbserver boards Pedro Alves
2015-04-23 15:09   ` Yao Qi
2015-04-23 15:24     ` Pedro Alves
2015-04-24  9:19       ` Yao Qi
2015-04-21 18:09 ` [PATCH 19/24] Make gdb.gdb/selftest.exp use '-i $inferior_spawn_id' Pedro Alves
2015-04-21 18:09 ` [PATCH 11/24] Make gdb.base/dprintf.exp use gdb_test_stdio Pedro Alves
2015-04-21 18:09 ` [PATCH 22/24] Unbuffer all tests that rely on stdio Pedro Alves
2015-04-21 18:09 ` [PATCH 03/24] Fix gdb.base/interrupt.exp racy fail against gdbserver Pedro Alves
2015-04-23 14:28   ` Yao Qi
2015-04-23 14:58     ` Pedro Alves
2015-04-21 18:09 ` [PATCH 06/24] Don't rely on inferior I/O in gdb.base/restore.exp Pedro Alves
2015-04-21 18:09 ` [PATCH 14/24] Make gdb.base/call-rt-st.exp use $inferior_spawn_id Pedro Alves
2015-04-21 18:09 ` [PATCH 09/24] Make gdb.base/call-strs.exp use gdb_test_stdio Pedro Alves
2015-04-21 18:09 ` [PATCH 17/24] Make gdb.base/varargs.exp " Pedro Alves
2015-04-21 18:09 ` [PATCH 20/24] Adjust MI to $inferior_spawn_id Pedro Alves
2015-04-21 18:09 ` [PATCH 21/24] Make gdb.mi/mi-dprintf.exp use $inferior_spawn_id Pedro Alves
2015-04-21 18:09 ` [PATCH 05/24] Don't rely on inferior I/O in {call-signal-resume, unwindonsignal}.exp Pedro Alves
2015-04-21 18:09 ` [PATCH 02/24] gdb.base/interrupt.exp: Rename saw_eof to saw_end_of_file Pedro Alves
2015-04-21 18:09 ` [PATCH 23/24] interrupt.exp: Revert back to checking gdb,noinferiorio at the top Pedro Alves
2015-04-21 18:15 ` [PATCH 08/24] Make gdb.base/sizeof.exp use gdb_test_stdio Pedro Alves
2015-04-23 15:36   ` Antoine Tremblay
2015-04-23 15:38     ` Antoine Tremblay
2015-04-23 15:49       ` Pedro Alves
2015-04-23 16:04         ` Pedro Alves
2015-04-23 16:25           ` Antoine Tremblay
2015-04-21 18:18 ` [PATCH 18/24] Make gdb.gdb/complaints.exp use '-i $inferior_spawn_id' and gdb_test_stdio Pedro Alves
2015-04-21 18:43 ` [PATCH 15/24] Make gdb.base/ending-run.exp use gdb_test_stdio Pedro Alves
2015-07-29 11:41 ` [PATCH 00/24] Remove gdb,noinferiorio from gdbserver boards Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox