This is the mail archive of the gdb-patches@sources.redhat.com 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]

PATCH: gdbserver test harness improvements


As approved by Elena earlier.  Gdbserver testsuites can now run on either a
local or a remote machine; it requires some voodoo in one's baseboard file
to do it, though.  Particularly, to run it on the local machine you'll want
to override _download and you must override _spawn.

Committed.  I'll get back to the MI patches next week sometime, and figure
out why gcore times out over gdbserver.

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer

2002-07-19  Daniel Jacobowitz  <drow@mvista.com>

	* config/gdbserver.exp (gdb_load): Don't use TCL varargs.
	Improve support for reusing an exec file.  Copy exec file
	to target, and run gdbserver on the target instead of on the host.

Index: gdbserver.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/config/gdbserver.exp,v
retrieving revision 1.4
diff -u -p -r1.4 gdbserver.exp
--- gdbserver.exp	10 May 2001 19:33:13 -0000	1.4
+++ gdbserver.exp	19 Jul 2002 19:31:27 -0000
@@ -2,7 +2,7 @@
 # ie. a debug agent running as a native process on the same or
 # a different host.
 
-#   Copyright 2000 Free Software Foundation, Inc.
+#   Copyright 2000, 2002 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -89,7 +89,8 @@ global server_exec;
 global portnum;
 set portnum "2345";
 
-proc gdb_load { args } {
+proc gdb_load { arg } {
+    global host_exec;
     global server_exec;
     global portnum;
     global verbose;
@@ -133,49 +134,62 @@ proc gdb_load { args } {
     # Export the host:port pair.
     set gdbport $debughost$portnum;
 
-    if { $args == "" || $args == "{}" } {
-	if [info exists server_exec] {
-	    set args $server_exec;
-	} else {
+    # Remember new exec file.
+    if { $arg == "" } {
+	if { ! [info exists host_exec] } {
 	    send_gdb "info files\n";
 	    gdb_expect 30 {
 		-re "Symbols from \"(\[^\"\]+)\"" {
-		    set args $expect_out(1,string);
+		    set host_exec $expect_out(1,string);
 		    exp_continue;
 		}
 		-re "Local exec file:\[\r\n\]+\[ \t\]*`(\[^'\]+)'," {
-		    set args $expect_out(1,string);
+		    set host_exec $expect_out(1,string);
 		    exp_continue;
 		}
 		-re "$gdb_prompt $" { }
 	    }
 	}
+    } else {
+	set host_exec $arg
+	if [info exists server_exec] { unset server_exec }
     }
 
-    # remember new exec file 
-    set server_exec $args;
+    if { ! [info exists server_exec] } {
+	if [is_remote target] {
+	    set server_exec [remote_download target $host_exec]
+	} else {
+	    set server_exec $host_exec
+	}
+    }
 
     # Fire off the debug agent
     if [target_info exists gdb_server_args] {
         # This flavour of gdbserver takes as arguments those specified
         # in the board configuration file
         set custom_args [target_info gdb_server_args];
-        remote_spawn host \
-               "$gdbserver $custom_args >& /dev/null < /dev/null &" \
-               writeonly
+	set server_spawn_id [remote_spawn target \
+               "$gdbserver $custom_args"]
     } else {
         # This flavour of gdbserver takes as arguments the port information
         # and the name of the executable file to be debugged.
-        remote_spawn host \
-	    "$gdbserver $sockethost$portnum $args >& /dev/null < /dev/null &" \
-	    writeonly 
+	set server_spawn_id [remote_spawn target \
+	    "$gdbserver $sockethost$portnum $server_exec"]
     } 
+
+    # We can't call close, because if gdbserver is local then that means
+    # that it will get a SIGHUP.
+    ## close -i $server_spawn_id
+    wait -nowait -i $server_spawn_id
+
     # Give it a little time to establish
-    sleep 2
+    sleep 1
 
     # tell gdb what file we are debugging
-    if [gdb_file_cmd $args] {
-	return -1;
+    if { $arg != "" } {
+	if [gdb_file_cmd $arg] {
+	    return -1;
+	}
     }
 
     # attach to the "serial port"


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