This is the mail archive of the gdb-patches@sourceware.cygnus.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]

Re: lib/gdb.exp: Don't loop infinitly on download attempts


Stan Shebs wrote:

> The structure of this bit is really strange - I had to go back and
> look at the Expect book, and I'm still not 100% sure of what's going
> on.  exp_continue restarts matching, which is fine, and we're inside
> an expect statement, which is fine, but we've done another send in
> between the first match and the exp_continue - so what does the
> restarted matching see exactly?  If we need to do retries, I'd rather
> write each one as a separate expect statement, rather than be punished
> for trying to get too clever with expect's pattern matching.

Here is a revied patch.  You'll notice that it now also checks the
return value from gdb_load().

	Andrew
Mon Oct 11 13:57:21 1999  Andrew Cagney  <cagney@amy.cygnus.com>

	* lib/gdb.exp (gdb_run_cmd): Break complicated gdb_expect
 	containing exp_continue into a while within an expect.  Don't
 	attempt a start more than three times.  Check return value from
 	gdb_load.

Index: ./gdb/testsuite/lib/gdb.exp
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.147
diff -p -r1.147 gdb.exp
*** gdb.exp	1999/09/07 23:19:44	1.147
--- gdb.exp	1999/10/11 04:31:58
*************** proc gdb_run_cmd {args} {
*** 180,187 ****
  
      if [target_info exists use_gdb_stub] {
  	if [target_info exists gdb,do_reload_on_run] {
! 	    # According to Stu, this will always work.
! 	    gdb_load "";
  	    send_gdb "continue\n";
  	    gdb_expect 60 {
  		-re "Continu\[^\r\n\]*\[\r\n\]" {}
--- 180,190 ----
  
      if [target_info exists use_gdb_stub] {
  	if [target_info exists gdb,do_reload_on_run] {
! 	    # Specifying no file, defaults to the executable
! 	    # currently being debugged.
! 	    if { [gdb_load ""] < 0 } {
! 		return;
! 	    }
  	    send_gdb "continue\n";
  	    gdb_expect 60 {
  		-re "Continu\[^\r\n\]*\[\r\n\]" {}
*************** proc gdb_run_cmd {args} {
*** 196,226 ****
  	    set start "start";
  	}
  	send_gdb  "jump *$start\n"
! 	gdb_expect 30 {
! 	    -re "Continuing at \[^\r\n\]*\[\r\n\]" {
! 		if ![target_info exists gdb_stub] {
! 		    return;
! 		}
! 	    }
! 	    -re "No symbol \"start\" in current.*$gdb_prompt $" {
! 		send_gdb "jump *_start\n";
! 		exp_continue;
! 	    }
! 	    -re "No symbol \"_start\" in current.*$gdb_prompt $" {
! 		perror "Can't find start symbol to run in gdb_run";
  		return;
  	    }
! 	    -re "Line.* Jump anyway.*y or n. $" {
! 		send_gdb "y\n"
! 		exp_continue;
!             }
! 	    -re "No symbol.*context.*$gdb_prompt $" {}
! 	    -re "The program is not being run.*$gdb_prompt $" {
! 		gdb_load "";
! 		send_gdb "jump *$start\n";
! 		exp_continue;
  	    }
- 	    timeout { perror "Jump to start() failed (timeout)"; return }
  	}
  	if [target_info exists gdb_stub] {
  	    gdb_expect 60 {
--- 199,242 ----
  	    set start "start";
  	}
  	send_gdb  "jump *$start\n"
! 	set start_attempt 1;
! 	while { $start_attempt } {
! 	    # Cap (re)start attempts at three to ensure that this loop
! 	    # always eventually fails.  Don't worry about trying to be
! 	    # clever and not send a command when it has failed.
! 	    if [expr $start_attempt > 3] {
! 		perror "Jump to start() failed (retry count exceeded)";
  		return;
  	    }
! 	    set start_attempt [expr $start_attempt + 1];
! 	    gdb_expect 30 {
! 		-re "Continuing at \[^\r\n\]*\[\r\n\]" {
! 		    set start_attempt 0;
! 		}
! 		-re "No symbol \"_start\" in current.*$gdb_prompt $" {
! 		    perror "Can't find start symbol to run in gdb_run";
! 		    return;
! 		}
! 		-re "No symbol \"start\" in current.*$gdb_prompt $" {
! 		    send_gdb "jump *_start\n";
! 		}
! 		-re "No symbol.*context.*$gdb_prompt $" {
! 		    set start_attempt 0;
! 		}
! 		-re "Line.* Jump anyway.*y or n. $" {
! 		    send_gdb "y\n"
! 		}
! 		-re "The program is not being run.*$gdb_prompt $" {
! 		    if { [gdb_load ""] < 0 } {
! 			return;
! 		    }
! 		    send_gdb "jump *$start\n";
! 		}
! 		timeout {
! 		    perror "Jump to start() failed (timeout)"; 
! 		    return
! 		}
  	    }
  	}
  	if [target_info exists gdb_stub] {
  	    gdb_expect 60 {

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