Fixed a bunch of missing return codes, misc bugs.

This commit is contained in:
Rob Savoye
1993-03-22 04:30:50 +00:00
parent 3d0bd7d39a
commit a309ee82f3

View File

@ -15,7 +15,7 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
# Please email any bugs, comments, and/or additions to this file to: # Please email any bugs, comments, and/or additions to this file to:
# DejaGnu@cygnus.com # bug-dejagnu@prep.ai.mit.edu
# This file was written by Rob Savoye. (rob@cygnus.com) # This file was written by Rob Savoye. (rob@cygnus.com)
@ -91,37 +91,49 @@ proc gdb_load { arg } {
set loadpath [file dirname $arg] set loadpath [file dirname $arg]
send "file $arg\n" send "file $arg\n"
expect { expect {
-re "Reading symbols from.*done.*$prompt $"\ -re "Reading symbols from.*done.*$prompt $" {
{ if $verbose>1 then { if $verbose>1 then {
send_user "\t\tLoaded $arg into the $GDB\n" send_user "\t\tLoaded $arg into the $GDB\n"
} }
} }
-re "has no symbol-table.*$prompt $" { -re "has no symbol-table.*$prompt $" {
error "$arg wasn't compiled with \"-g\"\n" error "$arg wasn't compiled with \"-g\""
return -1 return -1
} }
-re "A program is being debugged already..*Kill it\? \(y or n\) $"\ -re "A program is being debugged already..*Kill it\? \(y or n\) $" {
{ send "y\n" send "y\n"
if $verbose>1 then { if $verbose>1 then {
send_user "\t\tKilling previous program being debugged\n" send_user "\t\tKilling previous program being debugged\n"
} }
continue -expect continue -expect
} }
-re "Load new symbol table from.*\? \(y or n\) $"\ -re "Load new symbol table from.*\? \(y or n\) $" {
{ send "y\n" send "y\n"
expect { expect {
-re "Reading symbols from.*done.*$prompt $" -re "Reading symbols from.*done.*$prompt $" {
{ if $verbose>1 then { if $verbose>1 then {
send_user "\t\tLoaded $arg with new symbol table into $GDB\n" send_user "\t\tLoaded $arg with new symbol table into $GDB\n"
} }
return 0
} }
timeout { error "(timeout) Couldn't load $arg, other program already loaded."; return -1 } timeout {
error "(timeout) Couldn't load $arg, other program already loaded."
return -1
} }
} }
-re ".*No such file or directory.*$prompt $"\ }
{ error "($arg) No such file or directory\n"; return -1 } -re ".*No such file or directory.*$prompt $" {
-re "$prompt $" { error "couldn't load $arg into $GDB."; return -1 } error "($arg) No such file or directory\n"
timeout { error "couldn't load $arg into $GDB (timed out)."; return -1 } return -1
}
-re "$prompt $" {
error "couldn't load $arg into $GDB."
return -1
}
timeout {
error "couldn't load $arg into $GDB (timed out)."
return -1
}
} }
} }
@ -138,10 +150,11 @@ proc gdb_exit {} {
send_user "Quitting $GDB $GDBFLAGS\n" send_user "Quitting $GDB $GDBFLAGS\n"
} }
catch "send \"quit\n\"" result catch "send \"quit\n\"" result
if [string match "write\(spawn_id=\[0-9\]+\): Bad file number" $result] then { if [string match "write\(spawn_id=\[0-9\]+\):" $result] then {
catch "close" catch "close"
return 0 return -1
} }
catch {
expect { expect {
eof { eof {
if $verbose>1 then { if $verbose>1 then {
@ -154,14 +167,15 @@ proc gdb_exit {} {
} }
close close
} }
-re "The program is running. Quit anyway? (y or n) $"\ -re "The program is running. Quit anyway? (y or n) $" {
{ send "y\n" send "y\n"
if $verbose>1 then { if $verbose>1 then {
send_user "\t\tKilling program being debugged\n" send_user "\t\tKilling program being debugged\n"
} }
close close
} }
} }
}
catch "close" catch "close"
if $verbose>1 then { if $verbose>1 then {
@ -189,33 +203,65 @@ proc gdb_start {} {
if [ llength $GDBFLAGS ] then { if [ llength $GDBFLAGS ] then {
spawn $GDB $GDBFLAGS spawn $GDB $GDBFLAGS
} else { } else {
if {[which $GDB] != 0} then {
spawn $GDB spawn $GDB
} else {
error "Can't find $GDB"
}
} }
expect { expect {
-re ".*$prompt $" { if $verbose>1 then { -re ".*$prompt $" {
send_user "GDB initialized for native mode\n" } if $verbose>1 then {
send_user "GDB initialized for native mode\n"
}
}
-re "$prompt $" {
error "GDB never initialized."
return -1
}
timeout {
error "(timeout) GDB never initialized."
return -1
} }
-re "$prompt $" { error "GDB never initialized."; return -1 }
timeout { error "(timeout) GDB never initialized."; return -1 }
} }
set timeout $oldtimeout set timeout $oldtimeout
# force the height to "unlimited", so no pagers get used # force the height to "unlimited", so no pagers get used
send "set height 0\n" send "set height 0\n"
expect -re ".*$prompt $" {} expect {
-re ".*$prompt $" {
if $verbose>2 then {
send_user "Seting height to 0.\n"
}
}
timeout {
warning "Couldn't set the height to 0."
}
}
# force the width to "unlimited", so no wraparound occurs # force the width to "unlimited", so no wraparound occurs
send "set width 0\n" send "set width 0\n"
expect -re ".*$prompt $" {} expect {
-re ".*$prompt $" {
if $verbose>2 then {
send_user "Seting width to 0.\n"
}
}
timeout {
warning "Couldn't set the width to 0."
}
}
} }
expect_after { # These only need to be uncommented for debugging test cases. They exist
"<return>" { send "\n"; error "Window too small." } # mainly to catch programming errors
-re "\(y or n\) " { send "n\n"; error "Got interactive prompt." } #expect_after {
buffer_full { error "internal buffer is full." } # "<return>" { send "\n"; error "Window too small." }
eof { error "eof -- pty is hosed." } # -re "\(y or n\) " { send "n\n"; error "Got interactive prompt." }
timeout { error "timeout." } # buffer_full { error "internal buffer is full." }
"virtual memory exhausted" { error "virtual memory exhausted." } # eof { error "eof -- there is no child process" ; alldone}
"Undefined command" { error "send string probably wrong." } # timeout { error "timeout." }
} # "virtual memory exhausted" { error "virtual memory exhausted." }
# "Undefined command" { error "send string probably wrong." }
#}
load_lib gdb.exp load_lib gdb.exp
@ -224,3 +270,9 @@ set bin $GDB
gdb_start gdb_start