This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] setvar, shlib-call, shreloc, sigall, sigbpt, signull, so-impl-ld.exp: send_gdb vs. gdb_test


2010-05-19  Michael Snyder  <msnyder@vmware.com>

	* gdb.base/setvar.exp: Replace send_gdb with gdb_test.
	* gdb.base/shlib-call.exp: Replace send_gdb with gdb_test.
	* gdb.base/shreloc.exp: Replace send_gdb with gdb_test.
	* gdb.base/sigall.exp: Replace send_gdb with gdb_test.
	* gdb.base/sigbpt.exp: Replace send_gdb with gdb_test.
	* gdb.base/signull.exp: Replace send_gdb with gdb_test.
	* gdb.base/so-impl-ld.exp:Replace send_gdb with gdb_test.

Index: setvar.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/setvar.exp,v
retrieving revision 1.20
diff -u -p -r1.20 setvar.exp
--- setvar.exp	5 May 2010 18:06:58 -0000	1.20
+++ setvar.exp	19 May 2010 21:40:13 -0000
@@ -51,7 +51,8 @@ gdb_load $binfile
 #
 # set it up at a breakpoint so we canplay with the variable values
 #
-send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $"
+gdb_test "set print sevenbit-strings" "" \
+    "set print sevenbit-strings; ${testfile}"
 
 if ![runto_main] then {
     perror "couldn't run to breakpoint"
@@ -61,20 +62,16 @@ if ![runto_main] then {
 # Determine expected output for unsigned long variables,
 # the output varies with sizeof (unsigned long).
 
-set ulong_minus_1 4294967295
-set ulong_minus_456 4294966840
-send_gdb "print sizeof (unsigned long)\n"
-gdb_expect {
-    -re ".\[0-9\]* = 4.*$gdb_prompt $" {}
+gdb_test_multiple "print sizeof (unsigned long)" "sizeof ulong" {
+    -re ".\[0-9\]* = 4.*$gdb_prompt $" {
+	set ulong_minus_1 4294967295
+	set ulong_minus_456 4294966840
+    }
     -re ".\[0-9\]* = 8.*$gdb_prompt $" {
 	set ulong_minus_1 18446744073709551615
 	set ulong_minus_456 18446744073709551160
     }
-    -re ".*$gdb_prompt $" {
-	 fail "getting sizeof unsigned long"
-    }
-    default	{ fail "(timeout) getting sizeof unsigned long" }
-}
+}    
 
 proc test_set { args } {
     global gdb_prompt
Index: shlib-call.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/shlib-call.exp,v
retrieving revision 1.18
diff -u -p -r1.18 shlib-call.exp
--- shlib-call.exp	5 May 2010 18:06:58 -0000	1.18
+++ shlib-call.exp	19 May 2010 21:40:13 -0000
@@ -70,9 +70,12 @@ gdb_reinitialize_dir $srcdir/$subdir
 gdb_load ${binfile}
 gdb_load_shlibs $lib1 $lib2
 
-send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $"
-send_gdb "set print address off\n" ; gdb_expect -re "$gdb_prompt $"
-send_gdb "set width 0\n" ; gdb_expect -re "$gdb_prompt $"
+gdb_test "set print sevenbit-strings" "" \
+    "set print sevenbit-strings; ${testfile}"
+gdb_test "set print address off" "" \
+    "set print address off; ${testfile}"
+gdb_test "set width 0" "" \
+    "set width 0; ${testfile}"
 
 
 if ![runto_main] then {
@@ -82,74 +85,38 @@ if ![runto_main] then {
 
 #step -over
 
-    send_gdb "next\n"
-    gdb_expect {
-        -re ".*g = shr1\\(g\\).*$gdb_prompt $" {pass "next to shr1"}
-        -re ".*$gdb_prompt $" { fail "next to shr1" }
-        timeout { fail "next to shr1 (timeout)" }
-    }
-
-
+gdb_test "next" "g = shr1\\(g\\);" "next to shr1"
 
 #print g
 
-send_gdb "print g\n"
-gdb_expect {
-    -re ".*\[0-9\]* = 1.*$gdb_prompt $" {
-        pass "print g"
-      }
-    -re ".*$gdb_prompt $" { fail "print  g" }
-    timeout           { fail "(timeout) print g" }
-  }
-
+gdb_test "print g" "\[0-9\]* = 1" "print g"
 
 #step -over
-  if ![gdb_skip_stdio_test "next over shr1"] {
-      send_gdb "next\n"
-      gdb_expect {
-	  -re ".*address of sgs is $hex.*g = shr2\\(g\\).*$gdb_prompt $" {
-	      pass "next over shr1" 
-	  }
-	  -re ".*$gdb_prompt $" { fail "next over shr1" }
-	  timeout { fail "next over shr1 (timeout)" }
-      }
-  } else {
-      gdb_test "next" "" ""
-  }
+if ![gdb_skip_stdio_test "next over shr1"] {
+    gdb_test "next" \
+	"address of sgs is $hex.*g = shr2\\(g\\);" \
+	"next over shr1"
+} else {
+    gdb_test "next" "" ""
+}
 
 
 #print g
-send_gdb "print g\n"
-gdb_expect {
-    -re ".*\[0-9\]* = 2.*$gdb_prompt $" {
-        pass "print g" }
-    -re ".*$gdb_prompt $" { fail "print  g" }
-    timeout           { fail "(timeout) print g" }
-  }
+gdb_test "print g" "\[0-9\]* = 2" "print g"
 
 #print shr1(1)
-  if ![gdb_skip_stdio_test "print shr1(1)"] {
-      send_gdb "print shr1(1)\n"
-      gdb_expect {
-	  -re ".*address of sgs is $hex.*\[0-9\]* = 2.*$gdb_prompt $" {
-	      pass "print shr1(1)" 
-	  }
-	  -re ".*$gdb_prompt $" { fail "print shr1(1)" }
-	  timeout               { fail "(timeout) print shr1(1)" }
-      }
-  }
+if ![gdb_skip_stdio_test "print shr1(1)"] {
+    gdb_test "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)"] {
-      send_gdb "print shr1(g)\n"
-      gdb_expect {
-	  -re ".*address of sgs is $hex.*\[0-9\]* = 4.*$gdb_prompt $" {
-	      pass "print shr1(g)" 
-	  }
-	  -re ".*$gdb_prompt $" { fail "print shr1(g)" }
-	  timeout               { fail "(timeout) print shr1(g)" }
-      }
-  }
+if ![gdb_skip_stdio_test "print shr1(g)"] {
+    gdb_test "print shr1(g)" \
+	"address of sgs is $hex.*\[0-9\]* = 4" \
+	"print shr1(g)"
+}
 
 #break shr2
 #go
@@ -164,67 +131,38 @@ gdb_test "continue" \
 
 #print shr1(1)
 if ![gdb_skip_stdio_test "print shr1(1) 2nd time"] {
-    send_gdb "print shr1(1)\n"
-    gdb_expect {
-	-re ".*address of sgs is $hex.*\[0-9\]* = 2.*$gdb_prompt $" {
-	    pass "print shr1(1) 2nd time"
-	}
-	-re ".*$gdb_prompt $" { fail "print shr1(1) 2nd time" }
-	timeout               { fail "(timeout) print shr1(1) 2nd time" }
-    }
+    gdb_test "print shr1(1)" \
+	"address of sgs is $hex.*\[0-9\]* = 2" \
+	"print shr1(1) 2nd time"
 }
 
 #print mainshr1(1)
-send_gdb "print mainshr1(1)\n"
-gdb_expect {
-    -re ".*\[0-9\]* = 2.*$gdb_prompt $" {
-        pass "print mainshr1(1) from shlib func"
-      }
-    -re ".*$gdb_prompt $" { fail "print  mainshr1(1) from shlib func" }
-    timeout           { fail "(timeout) print mainshr1(1) from shlib func" }
-  }
+gdb_test "print mainshr1(1)" "\[0-9\]* = 2" \
+    "print mainshr1(1) from shlib func"
 
 #step -return
-    send_gdb "step\n"
-    # A step at this point will either take us entirely out of
-    # the function or into the function's epilogue.  The exact
-    # behavior will differ depending upon upon whether or not
-    # the compiler emits line number information for the epilogue.
-    gdb_expect {
-        -re "main \\(\\) at.*g = mainshr1\\(g\\);.*$gdb_prompt $" { 
-	    pass "step out of shr2 to main"
-	}
-        -re ".*\\\}.*$gdb_prompt $" {
-	    pass "step out of shr2 to main (stopped in shr2 epilogue)"
-	    send_gdb "step\n"
-	    gdb_expect {
-		-re "main \\(\\) at.*g = mainshr1\\(g\\);.*$gdb_prompt $" { pass "step out of shr2 epilogue to main"}
-		-re ".*$gdb_prompt $" { fail "step out of shr2 epilogue to main" }
-		timeout { fail "step out of shr2 epilogue to main (timeout)" }
-	    }
-	}
-        -re ".*$gdb_prompt $" { fail "step out of shr2" }
-        timeout { fail "step out of shr2 to main (timeout)" }
+# A step at this point will either take us entirely out of
+# the function or into the function's epilogue.  The exact
+# behavior will differ depending upon upon whether or not
+# the compiler emits line number information for the epilogue.
+gdb_test_multiple "step" "step out of shr2 to main" {
+    -re "main \\(\\) at.*g = mainshr1\\(g\\);.*$gdb_prompt $" { 
+	pass "step out of shr2 to main"
+    }
+    -re ".*\\\}.*$gdb_prompt $" {
+	pass "step out of shr2 to main (stopped in shr2 epilogue)"
+	gdb_test "step" \
+	    "main \\(\\) at.*g = mainshr1\\(g\\);" \
+	    "step out of shr2 epilogue to main"
     }
+}
     
-
 #print mainshr1(1)
-send_gdb "print mainshr1(1)\n"
-gdb_expect {
-    -re ".*\[0-9\]* = 2.*$gdb_prompt $" {
-        pass "print mainshr1(1)"
-      }
-    -re ".*$gdb_prompt $" { fail "print  mainshr1(1) from main" }
-    timeout           { fail "(timeout) print mainshr1(1) from main" }
-  }
+gdb_test "print mainshr1(1)" "\[0-9\]* = 2" "print mainshr1(1)"
 
 #step
-    send_gdb "step\n"
-    gdb_expect {
-        -re ".*mainshr1 \\(g=4\\) at.*return 2.g;.*$gdb_prompt $" { pass "step into mainshr1"}
-        -re ".*$gdb_prompt $" { fail "step into mainshr1" }
-        timeout { fail "step into mainshr1 (timeout)" }
-    }
+gdb_test "step" "mainshr1 \\(g=4\\) at.*return 2.g;" \
+    "step into mainshr1"
 
 # Start with a fresh gdb.
 
@@ -232,9 +170,13 @@ gdb_exit
 gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_load ${binfile}
-send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $"
-send_gdb "set print address off\n" ; gdb_expect -re "$gdb_prompt $"
-send_gdb "set width 0\n" ; gdb_expect -re "$gdb_prompt $"
+gdb_test "set print sevenbit-strings" "" \
+    "set print sevenbit-strings; ${testfile} 2"
+gdb_test "set print address off" "" \
+    "set print address off; ${testfile} 2"
+gdb_test "set width 0" "" \
+    "set width 0; ${testfile} 2"
+
 
 # PR's 16495, 18213
 # test that we can re-set breakpoints in shared libraries
Index: shreloc.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/shreloc.exp,v
retrieving revision 1.12
diff -u -p -r1.12 shreloc.exp
--- shreloc.exp	5 May 2010 18:06:58 -0000	1.12
+++ shreloc.exp	19 May 2010 21:40:13 -0000
@@ -91,29 +91,25 @@ if ![runto_main] then {
 }
 
 proc get_var_address { var } {
-  global gdb_prompt hex
+    global gdb_prompt hex
+
+    # Match output like:
+    # $1 = (int *) 0x0
+    # $5 = (int (*)()) 0
+    # $6 = (int (*)()) 0x24 <function_bar>
 
-  send_gdb "print &${var}\n"
-  # Match output like:
-  # $1 = (int *) 0x0
-  # $5 = (int (*)()) 0
-  # $6 = (int (*)()) 0x24 <function_bar>
-  gdb_expect {
-    -re "\\\$\[0-9\]+ = \\(.*\\) (0|$hex)( <${var}>)?\[\r\n\]+${gdb_prompt} $"
+    gdb_test_multiple "print &${var}" "get address of ${var}" {
+	-re "\\\$\[0-9\]+ = \\(.*\\) (0|$hex)( <${var}>)?\[\r\n\]+${gdb_prompt} $"
 	{
-	  pass "get address of ${var}"
-	  if { $expect_out(1,string) == "0" } {
-	    return "0x0"
-	  } else {
-	    return $expect_out(1,string)
-	  }
+	    pass "get address of ${var}"
+	    if { $expect_out(1,string) == "0" } {
+		return "0x0"
+	    } else {
+		return $expect_out(1,string)
+	    }
 	}
-    -re "${gdb_prompt} $"
-	{ fail "get address of ${var} (unknown output)" }
-    timeout
-	{ fail "get address of ${var} (timeout)" }
-  }
-  return ""
+    }
+    return ""
 }
 
 #
@@ -159,10 +155,8 @@ proc send_gdb_discard { command } {
 
     global gdb_prompt
 
-    send_gdb "${command}\n"
-
     # Discard output
-    gdb_expect {
+    gdb_test_multiple "${command}" "${command}" {
 	-re ".*\[\r\n]+${gdb_prompt} $" {
 	    return 1
 	}
Index: sigall.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/sigall.exp,v
retrieving revision 1.9
diff -u -p -r1.9 sigall.exp
--- sigall.exp	5 May 2010 18:06:58 -0000	1.9
+++ sigall.exp	19 May 2010 21:40:13 -0000
@@ -54,22 +54,12 @@ proc test_one_sig {nextsig} {
     set need_another_continue 1
     set missed_handler 0
     if $this_sig_supported then {
-	send_gdb "continue\n"
 	if { $thissig == "IO" } {
 	    setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu"
 	}
-	gdb_expect {
-	    -re "Continuing.*Program received signal SIG$thissig.*$gdb_prompt $" {
-		pass "get signal $thissig"
-	    }
-	    -re ".*$gdb_prompt $" {
-		fail "get signal $thissig"
-		set need_another_continue 0
-	    }
-	    default {
-		fail "get signal $thissig (eof or timeout)"
-	    }
-	}
+	gdb_test "continue" \
+	    "Continuing.*Program received signal SIG$thissig.*" \
+	    "get signal $thissig"
     }
     if [ istarget "alpha-dec-osf3*" ] then {
 	# OSF/1-3.x is unable to continue with a job control stop signal.
@@ -84,7 +74,6 @@ proc test_one_sig {nextsig} {
     }
 
     if $need_another_continue then {
-	send_gdb "continue\n"
 	if { $thissig == "URG" } {
 	    setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu"
 	}
@@ -92,7 +81,7 @@ proc test_one_sig {nextsig} {
 	if { $thissig == "PRIO" } {
 	    setup_xfail "*-*-*lynx*"
 	}
-	gdb_expect {
+	gdb_test_multiple "continue" "send signal $thissig" {
 	    -re "Breakpoint.*handle_$thissig.*$gdb_prompt $" {
 		pass "send signal $thissig"
 	    }
@@ -104,8 +93,7 @@ proc test_one_sig {nextsig} {
     }
 
     if { $missed_handler == "0" } then {
-        send_gdb "signal 0\n"
-        gdb_expect {
+	gdb_test_multiple "signal 0" "advance to $nextsig" {
 	    -re "Breakpoint.*gen_$nextsig.*kill.*$gdb_prompt $" {
 	        pass "advance to $nextsig"
 	        set sig_supported 1
@@ -114,8 +102,6 @@ proc test_one_sig {nextsig} {
 	        pass "advance to $nextsig"
 	        set sig_supported 0
 	    }
-	    -re ".*$gdb_prompt $" { fail "advance to $nextsig" }
-	    default { fail "advance to $nextsig (eof or timeout)" }
         }
     }
     set thissig $nextsig
Index: sigbpt.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/sigbpt.exp,v
retrieving revision 1.18
diff -u -p -r1.18 sigbpt.exp
--- sigbpt.exp	5 May 2010 18:06:58 -0000	1.18
+++ sigbpt.exp	19 May 2010 21:40:13 -0000
@@ -65,8 +65,7 @@ if ![runto_main] then {
 # especially on targets without an MMU.  Don't run the tests in that
 # case.
 
-send_gdb "x 0\n"
-gdb_expect {
+gdb_test_multiple "x 0" "memory at address 0" {
     -re "0x0:.*Cannot access memory at address 0x0.*$gdb_prompt $" { }
     -re "0x0:.*Error accessing memory address 0x0.*$gdb_prompt $" { }
     -re ".*$gdb_prompt $" {
Index: signull.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/signull.exp,v
retrieving revision 1.14
diff -u -p -r1.14 signull.exp
--- signull.exp	5 May 2010 18:06:58 -0000	1.14
+++ signull.exp	19 May 2010 21:40:13 -0000
@@ -64,8 +64,7 @@ if ![runto_main] then {
 # especially on targets without an MMU.  Don't run the tests in that
 # case.
 
-send_gdb "x 0\n"
-gdb_expect {
+gdb_test_multiple "x 0" "memory at address 0" {
     -re "0x0:.*Cannot access memory at address 0x0.*$gdb_prompt $" { }
     -re "0x0:.*Error accessing memory address 0x0.*$gdb_prompt $" { }
     -re ".*$gdb_prompt $" {
Index: so-impl-ld.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/so-impl-ld.exp,v
retrieving revision 1.14
diff -u -p -r1.14 so-impl-ld.exp
--- so-impl-ld.exp	5 May 2010 18:06:58 -0000	1.14
+++ so-impl-ld.exp	19 May 2010 21:40:13 -0000
@@ -65,59 +65,30 @@ if ![runto_main] then { fail "implicit s
 
 # Verify that we can step over the first shlib call.
 #
-send_gdb "next\n"
-gdb_expect {
-  -re "21\[ \t\]*result = solib_main .result.*$gdb_prompt $"\
-          {pass "step over solib call"}
-  -re "$gdb_prompt $"\
-          {fail "step over solib call"}
-  timeout {fail "(timeout) step over solib call"}
-}
+gdb_test "next" "21\[ \t\]*result = solib_main .result.;" \
+    "step over solib call"
 
 # Verify that we can step into the second shlib call.
 #
-send_gdb "step\n"
-gdb_expect {
-  -re "solib_main .arg=10000. at.*${libfile}.c:17.*$gdb_prompt $"\
-          {pass "step into solib call"}
-  -re "$gdb_prompt $"\
-          {fail "step into solib call"}
-  timeout {fail "(timeout) step into solib call"}
-}
+gdb_test "step" "solib_main .arg=10000. at.*${libfile}.c:17.*" \
+    "step into solib call"
 
 # Verify that we can step within the shlib call.
 #
-send_gdb "next\n"
-gdb_expect {
-  -re "18\[ \t\]*\}.*$gdb_prompt $"\
-          {pass "step in solib call"}
-  -re "$gdb_prompt $"\
-          {fail "step in solib call"}
-  timeout {fail "(timeout) step in solib call"}
-}
+gdb_test "next" "18\[ \t\]*\}" "step in solib call"
 
 # Verify that we can step out of the shlib call, and back out into
 # the caller.
 #
-send_gdb "next\n"
-gdb_expect {
+gdb_test_multiple "next" "step out of solib call" {
     -re "0x\[0-9a-f\]*\[ \t\]*9\[ \t\]*.*$gdb_prompt $" {
-	# we haven't left the callee yet, so do another next
-	send_gdb "next\n"
-	gdb_expect {
-	    -re "main .. at.*so-impl-ld.c:22.*$gdb_prompt $"\
-		{pass "step out of solib call"}
-	    -re "$gdb_prompt $"\
-		{fail "step out of solib call"}
-	    timeout {fail "(timeout) step out of solib call"}
-	}
+	gdb_test "next" \
+	    "main .. at.*so-impl-ld.c:22.*" \
+	    "step out of solib call"
+    }
+    -re "main .. at.*so-impl-ld.c:22.*$gdb_prompt $" {
+	pass "step out of solib call"
     }
-
-    -re "main .. at.*so-impl-ld.c:22.*$gdb_prompt $"\
-	{pass "step out of solib call"}
-    -re "$gdb_prompt $"\
-	{fail "step out of solib call"}
-    timeout {fail "(timeout) step out of solib call"}
 }
 
 gdb_exit

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]