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]

[commit] [patch] Forbid "run" etc. for use_gdb_stub targets


On Sat, 03 Dec 2011 20:14:52 +0100, Pedro Alves wrote:
> > --- a/gdb/testsuite/gdb.base/valgrind-db-attach.exp
> > +++ b/gdb/testsuite/gdb.base/valgrind-db-attach.exp
> > +# This value applies to GDB spawned by valgrind --db-attach=yes.
> > +set use_gdb_stub 1
> 
> Why?

Used now:

+# GDB spawned by `valgrind --db-attach=yes' stops already after the startup
is
+# executed, like with non-extended gdbserver.  It is also not correct to
+# run/attach the inferior.
+set use_gdb_stub 1


> > --- a/gdb/testsuite/lib/gdbserver-support.exp
> > +++ b/gdb/testsuite/lib/gdbserver-support.exp
> > @@ -22,6 +22,14 @@
> > +#   set_board_info use_gdb_stub
> > +#      Flag the inferior is already started after connecting and run/attach
> > +#      are not supported.  This is used for the "remote" protocol.
> > +#      After GDB starts you should check global $use_gdb_stub instead as the
> > +#      testfile may force a specific different target protocol itself.
> 
> This is the wrong place to document this.  use_gdb_stub is not
> really gdbserver-specific.  Please document it in the common
> framework, somewhere in gdb.exp?

OK, moved to default_gdb_start:

+    # Set the default value, it may be overriden later by specific testfile.
+    #
+    # Use `set_board_info use_gdb_stub' for the board file to flag the inferior
+    # is already started after connecting and run/attach are not supported.
+    # This is used for the "remote" protocol.  After GDB starts you should
+    # check global $use_gdb_stub instead of the board as the testfile may force
+    # a specific different target protocol itself.
+    set use_gdb_stub [target_info exists use_gdb_stub]


> I suggest instead:

Used.


> Otherwise looks good to me.

And checked in.


Thanks,
Jan


http://sourceware.org/ml/gdb-cvs/2011-12/msg00022.html

--- src/gdb/testsuite/ChangeLog	2011/12/03 18:01:49	1.2961
+++ src/gdb/testsuite/ChangeLog	2011/12/03 20:20:28	1.2962
@@ -1,3 +1,30 @@
+2011-12-03  Jan Kratochvil  <jan.kratochvil@redhat.com>
+	    Pedro Alves  <pedro@codesourcery.com>
+
+	* gdb.base/break-entry.exp: Move the target use_gdb_stub test before
+	starting GDB.
+	* gdb.base/default.exp: Replace target use_gdb_stub checks by global
+	$use_gdb_stub.
+	* gdb.base/display.exp: Likewise.
+	* gdb.base/ending-run.exp: Likewise.
+	* gdb.base/list.exp (test_listsize): Likewise.
+	* gdb.base/setshow.exp: Likewise.
+	* gdb.base/valgrind-db-attach.exp: Set global use_gdb_stub to 1.
+	* lib/gdb.exp (gdb_run_cmd, gdb_start_cmd): Replace target use_gdb_stub
+	check by global $use_gdb_stub.
+	(gdb_test_multiple): Forbid run, start or attach for !$use_gdb_stub.
+	(default_gdb_start): Set global use_gdb_stub from target use_gdb_stub.
+	(default_gdb_init): Unset global $use_gdb_stub.
+	(gdb_continue_to_end, rerun_to_main): Replace target use_gdb_stub check
+	by global $use_gdb_stub.
+	* lib/gdbserver-support.exp: Extend comments for set_board_info
+	gdb_protocol and gdb,socketport.
+	(gdbserver_start_extended): Set global gdbserver_protocol and
+	gdbserver_gdbport.  Clear global use_gdb_stub.
+	* lib/mi-support.exp (default_mi_gdb_start): Set global use_gdb_stub
+	from target use_gdb_stub.
+	(mi_run_cmd): Replace target use_gdb_stub check by global $use_gdb_stub.
+
 2011-12-03  Doug Evans  <dje@google.com>
 
 	* lib/gdb.exp (gdb_run_cmd, gdb_start_cmd, run_to_main): Add comments.
--- src/gdb/testsuite/gdb.base/break-entry.exp	2011/01/01 15:33:40	1.4
+++ src/gdb/testsuite/gdb.base/break-entry.exp	2011/12/03 20:20:28	1.5
@@ -16,11 +16,6 @@
 # Test inferior can stop at its very first instruction, usually "_start".
 # Dynamic executables have first instruction in ld.so.
 
-set testfile break-entry
-if { [prepare_for_testing ${testfile}.exp ${testfile} start.c {additional_flags=-static}] } {
-    return -1
-}
-
 # If we're using a stub, we'll already be debugging a live program and
 # stopped at the entry point when we connect, and so the runto below
 # will issue a "continue", which always skips any breakpoint at PC.
@@ -30,11 +25,17 @@
 # continues the process with the equivalent of "jump *$PC", which
 # triggers any breakpoint at $PC.  The latter is what we want to test.
 
+set testfile break-entry
+
 if [target_info exists use_gdb_stub] {
     untested ${testfile}.exp
     return
 }
 
+if { [prepare_for_testing ${testfile}.exp ${testfile} start.c {additional_flags=-static}] } {
+    return -1
+}
+
 set test "info files"
 set entry ""
 gdb_test_multiple $test $test {
--- src/gdb/testsuite/gdb.base/default.exp	2011/10/28 17:32:30	1.50
+++ src/gdb/testsuite/gdb.base/default.exp	2011/12/03 20:20:29	1.51
@@ -39,7 +39,7 @@
 gdb_test "append binary memory" "Missing filename\." 
 gdb_test "append binary value"  "Missing filename\." 
 
-if ![target_info exists use_gdb_stub] {
+if !$use_gdb_stub {
     setup_xfail "mips-idt-*"
     gdb_test_multiple "attach" "attach" {
 	-re "Argument required .(process-id|program) to attach.*$gdb_prompt $"\
@@ -420,7 +420,7 @@
 gdb_test "pwd" "Working directory .*" "pwd"
 
 #test run "r" abbreviation
-if [target_info exists use_gdb_stub] {
+if $use_gdb_stub {
     # Only extended-remote supports "run".
 } elseif [istarget "*-*-vxworks*"] then {
     gdb_test "set args" ".*" "" 
@@ -448,7 +448,7 @@
 }
 
 #test run
-if [target_info exists use_gdb_stub] {
+if $use_gdb_stub {
     # Only extended-remote supports "run".
 } elseif [istarget "*-*-vxworks*"] then {
     gdb_test "set args" ".*" "" 
--- src/gdb/testsuite/gdb.base/display.exp	2011/08/09 16:21:18	1.26
+++ src/gdb/testsuite/gdb.base/display.exp	2011/12/03 20:20:29	1.27
@@ -51,7 +51,7 @@
 
 # Some coverage stuff
 #
-if ![target_info exists use_gdb_stub] {
+if !$use_gdb_stub {
     gdb_test "kill" ".*The program is not being run.*"
     gdb_test "detach" ".*"
     gdb_test "run" ".*"
--- src/gdb/testsuite/gdb.base/ending-run.exp	2011/06/01 15:55:55	1.46
+++ src/gdb/testsuite/gdb.base/ending-run.exp	2011/12/03 20:20:29	1.47
@@ -208,7 +208,7 @@
 set program_exited_normally 0
 set program_not_exited 0
 set program_in_exit 0
-if {! [target_info exists use_gdb_stub]
+if {!$use_gdb_stub
     && (! [target_info exists use_cygmon] || ! [target_info use_cygmon])} {
     global program_exited;
     if {[eval expr $program_exited == 0]} {
--- src/gdb/testsuite/gdb.base/list.exp	2011/01/01 15:33:42	1.24
+++ src/gdb/testsuite/gdb.base/list.exp	2011/12/03 20:20:29	1.25
@@ -81,7 +81,7 @@
 #
 
 proc test_listsize {} {
-    global gdb_prompt
+    global gdb_prompt use_gdb_stub
     global hp_cc_compiler
     global hp_aCC_compiler
 
@@ -94,7 +94,7 @@
     # list the lines there instead of main, so we skip this test for remote targets.
     # The second case is for optimized code, it is still correct.
     
-    if [target_info exists use_gdb_stub] {
+    if $use_gdb_stub {
 	runto_main;
 	unsupported "list default lines around main";
     } else {
--- src/gdb/testsuite/gdb.base/setshow.exp	2011/04/20 14:56:49	1.21
+++ src/gdb/testsuite/gdb.base/setshow.exp	2011/12/03 20:20:29	1.22
@@ -97,7 +97,7 @@
 gdb_test "show args" "Argument list to give program being debugged when it is started is \"foo bar blup baz bubble\"..*" "show args"
 
 # Don't test if we can't pass args or if we're using a stub.
-if { ![target_info exists use_gdb_stub] && ![target_info exists noargs] } {
+if { !$use_gdb_stub && ![target_info exists noargs] } {
     #test passing args
     gdb_test "cont" "Continuing.*" "continuing"
     delete_breakpoints
--- src/gdb/testsuite/gdb.base/valgrind-db-attach.exp	2011/09/08 14:56:34	1.8
+++ src/gdb/testsuite/gdb.base/valgrind-db-attach.exp	2011/12/03 20:20:29	1.9
@@ -41,6 +41,11 @@
 # Declare GDB now as running.
 set gdb_spawn_id -1
 
+# GDB spawned by `valgrind --db-attach=yes' stops already after the startup is
+# executed, like with non-extended gdbserver.  It is also not correct to
+# run/attach the inferior.
+set use_gdb_stub 1
+
 set test "valgrind started"
 # The trailing '.' differs for different memcheck versions.
 gdb_test_multiple "" $test {
--- src/gdb/testsuite/lib/gdb.exp	2011/12/03 18:01:50	1.195
+++ src/gdb/testsuite/lib/gdb.exp	2011/12/03 20:20:29	1.196
@@ -197,7 +197,7 @@
 # that is the caller's responsibility.
 
 proc gdb_run_cmd {args} {
-    global gdb_prompt
+    global gdb_prompt use_gdb_stub
 
     if [target_info exists gdb_init_command] {
 	send_gdb "[target_info gdb_init_command]\n";
@@ -210,7 +210,7 @@
 	}
     }
 
-    if [target_info exists use_gdb_stub] {
+    if $use_gdb_stub {
 	if [target_info exists gdb,do_reload_on_run] {
 	    if { [gdb_reload] != 0 } {
 		return;
@@ -306,7 +306,7 @@
 # that is the caller's responsibility.
 
 proc gdb_start_cmd {args} {
-    global gdb_prompt
+    global gdb_prompt use_gdb_stub
 
     if [target_info exists gdb_init_command] {
 	send_gdb "[target_info gdb_init_command]\n";
@@ -319,7 +319,7 @@
 	}
     }
 
-    if [target_info exists use_gdb_stub] {
+    if $use_gdb_stub {
 	return -1
     }
 
@@ -587,7 +587,7 @@
 # ...", all being implicitly appended to that list.
 #
 proc gdb_test_multiple { command message user_code } {
-    global verbose
+    global verbose use_gdb_stub
     global gdb_prompt
     global GDB
     global inferior_exited_re
@@ -606,6 +606,12 @@
 	error "Invalid newline in \"$message\" test"
     }
 
+    if {$use_gdb_stub
+        && [regexp -nocase {^\s*(r|run|star|start|at|att|atta|attac|attach)\M} \
+	    $command]} {
+	error "gdbserver does not support $command without extended-remote"
+    }
+
     # TCL/EXPECT WART ALERT
     # Expect does something very strange when it receives a single braced
     # argument.  It splits it along word separators and performs substitutions.
@@ -1317,7 +1323,7 @@
 # get really slow.  Give gdb at least 3 minutes to start up.
 #
 proc default_gdb_start { } {
-    global verbose
+    global verbose use_gdb_stub
     global GDB
     global INTERNAL_GDBFLAGS GDBFLAGS
     global gdb_prompt
@@ -1326,6 +1332,15 @@
 
     gdb_stop_suppressing_tests;
 
+    # Set the default value, it may be overriden later by specific testfile.
+    #
+    # Use `set_board_info use_gdb_stub' for the board file to flag the inferior
+    # is already started after connecting and run/attach are not supported.
+    # This is used for the "remote" protocol.  After GDB starts you should
+    # check global $use_gdb_stub instead of the board as the testfile may force
+    # a specific different target protocol itself.
+    set use_gdb_stub [target_info exists use_gdb_stub]
+
     verbose "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS"
 
     if [info exists gdb_spawn_id] {
@@ -2978,6 +2993,10 @@
     } else {
 	set gdb_prompt "\\(gdb\\)"
     }
+    global use_gdb_stub
+    if [info exists use_gdb_stub] {
+	unset use_gdb_stub
+    }
 }
 
 # The default timeout used when testing GDB commands.  We want to use
@@ -3350,7 +3369,7 @@
 #	is accepted.
 
 proc gdb_continue_to_end {{mssg ""} {command continue} {allow_extra 0}} {
-  global inferior_exited_re
+  global inferior_exited_re use_gdb_stub
 
   if {$mssg == ""} {
       set text "continue until exit"
@@ -3362,7 +3381,7 @@
   } else {
       set extra ""
   }
-  if [target_info exists use_gdb_stub] {
+  if $use_gdb_stub {
     if {![gdb_breakpoint "exit"]} {
       return 0
     }
@@ -3379,9 +3398,9 @@
 }
 
 proc rerun_to_main {} {
-  global gdb_prompt
+  global gdb_prompt use_gdb_stub
 
-  if [target_info exists use_gdb_stub] {
+  if $use_gdb_stub {
     gdb_run_cmd
     gdb_expect {
       -re ".*Breakpoint .*main .*$gdb_prompt $"\
--- src/gdb/testsuite/lib/gdbserver-support.exp	2011/11/20 23:59:49	1.20
+++ src/gdb/testsuite/lib/gdbserver-support.exp	2011/12/03 20:20:29	1.21
@@ -22,6 +22,8 @@
 #
 #   set_board_info gdb_protocol "remote"
 #	Unles you have a gdbserver that uses a different protocol...
+#	After GDB starts you should check global $gdbserver_protocol instead as
+#	the testfile may force a specific different target protocol itself.
 #
 #   set_board_info gdb_server_prog
 #	This will be the path to the gdbserver program you want to test.
@@ -35,6 +37,8 @@
 #   set_board_info gdb,socketport
 #	Port id to use for socket connection.  If not set explicitly,
 #	it will start at "2345" and increment for each use.
+#	After GDB starts you should check global $gdbserver_gdbport for the
+#	real port used.  It is not useful if $gdbserver_reconnect_p was not set.
 #
 
 #
@@ -338,9 +342,18 @@
 
 # Start and connect to a gdbserver in extended mode.
 proc gdbserver_start_extended { } {
+    global gdbserver_protocol
+    global gdbserver_gdbport
+    global use_gdb_stub
+
     set res [gdbserver_start "--multi" ""]
     set gdbserver_protocol "extended-[lindex $res 0]"
     set gdbserver_gdbport [lindex $res 1]
 
+    # Even if the board file is testing with target remote, our caller
+    # wants to test against gdbserver in extended-remote mode.  Make sure to
+    # disable stub-like techniques.
+    set use_gdb_stub 0
+
     return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
 }
--- src/gdb/testsuite/lib/mi-support.exp	2011/12/02 22:35:17	1.105
+++ src/gdb/testsuite/lib/mi-support.exp	2011/12/03 20:20:29	1.106
@@ -96,7 +96,7 @@
 # get really slow.  Give gdb at least 3 minutes to start up.
 #
 proc default_mi_gdb_start { args } {
-    global verbose
+    global verbose use_gdb_stub
     global GDB
     global INTERNAL_GDBFLAGS GDBFLAGS
     global gdb_prompt
@@ -108,6 +108,9 @@
     gdb_stop_suppressing_tests;
     set inferior_pty no-tty
 
+    # Set the default value, it may be overriden later by specific testfile.
+    set use_gdb_stub [target_info exists use_gdb_stub]
+
     if { [llength $args] == 1} {
 	set inferior_pty [lindex $args 0]
     }
@@ -793,7 +796,7 @@
     if { $suppress_flag } {
 	return -1
     }
-    global mi_gdb_prompt
+    global mi_gdb_prompt use_gdb_stub
     global thread_selected_re
     global library_loaded_re
 
@@ -820,7 +823,7 @@
 	return -1
     }
 
-    if [target_info exists use_gdb_stub] {
+    if $use_gdb_stub {
 	if [target_info exists gdb,do_reload_on_run] {
 	    send_gdb "${run_prefix}continue\n";
 	    gdb_expect 60 {


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