[RFA/testsuite]: Don't exit when `target sim' fails

Corinna Vinschen vinschen@redhat.com
Wed Apr 25 11:23:00 GMT 2007


Hi,

Newer GCC linkers unlink the output file before trying to open it.  This
results in a sharing violation under Cygwin/Windows if the file is still
in use by GDB, as in the gdb.base/chng-syms.exp testcase.  As a result,
the `target sim' command prints an error message that the executable
can't be opened by GDB.

Unfortunately, the gdb_target_sim function in config/sim.exp reacts in a
very unfriendly way when `target sim' fails: It just exits instead of
returning with an error code.  In turn, the testrun exits entirely, and
one instance of GDB keeps potentially running, because the testcase has
no chance to clean up properly.

Another situation in which the exit is very annoying is, when running the
testsuite on remote harware over a not-always-reliable connection.  If
`target sim' fails once, the whole testsuite exits instead of just skipping
this one testcase.

The below patch changes gdb_target_sim to return with -1 instead of
just exiting.  This allows the testsuite to run further along, instead
of just exiting.

Ok to apply?


Corinna


	* config/sim.exp (gdb_target_sim): Just return with -1 when setting
	target sim fails.  Return 0 otherwise.
	(gdb_load): Return prematurely if gdb_target_sim fails.

Index: config/sim.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/config/sim.exp,v
retrieving revision 1.4
diff -u -p -r1.4 sim.exp
--- config/sim.exp	9 Jan 2007 17:59:08 -0000	1.4
+++ config/sim.exp	25 Apr 2007 10:09:18 -0000
@@ -23,7 +23,6 @@ load_lib gdb.exp
 #
 proc gdb_target_sim { } {
     global gdb_prompt
-    global exit_status
     
     set target_sim_options "[board_info target gdb,target_sim_options]";
 
@@ -37,11 +36,12 @@ proc gdb_target_sim { } {
 	timeout { 
 	    perror "Couldn't set target for simulator."
 	    cleanup
-	    exit $exit_status
+	    return -1
 	}
     }
     set timeout 10
     verbose "Timeout is now $timeout seconds" 2
+    return 0
 }
 
 #
@@ -59,7 +59,7 @@ proc gdb_load { arg } {
 	if [gdb_file_cmd $arg] then { return -1 }
     }
 
-    gdb_target_sim
+    if [gdb_target_sim] then { return -1 }
 
     send_gdb "load\n"
     set timeout 2400

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat



More information about the Gdb-patches mailing list