Just a little cleanup. Made gdb_exit "kill" any isstip's still running

and blow away the socket. GDB now restarts beautifully.
This commit is contained in:
Rob Savoye
1993-08-31 22:50:11 +00:00
parent 9e58280a94
commit 41a85720e0

View File

@ -31,17 +31,13 @@ if ![info exists prompt] then {
set prompt "\(gdb\)" set prompt "\(gdb\)"
} }
load_lib gdb.exp
# #
# gdb_version -- extract and print the version number of gdb # gdb_version -- extract and print the version number of gdb
# #
proc gdb_version {} { proc gdb_version {} {
global GDB default_gdb_version
global GDBFLAGS
global prompt
set tmp [exec echo "q" | $GDB]
set version [lindex $tmp [lsearch $tmp "\[0-9\]*"]]
set version [string range $version 0 [expr [string length $version]-2]]
clone_output "[which $GDB] version $version $GDBFLAGS\n"
} }
# #
@ -59,27 +55,21 @@ proc gdb_load { arg } {
global expect_out global expect_out
send "load $arg\n" send "load $arg\n"
if $verbose>1 then { verbose "Loading $arg into $GDB"
send_user "Loading $arg into $GDB\n"
}
expect { expect {
-re "Loading.*\.text.*\.data.*\.bss.*Reading symbols from $arg.+done.*$prompt $" { -re "Loading.*\.text.*\.data.*\.bss.*Reading symbols from $arg.+done.*$prompt $" {
if $verbose>1 then { verbose "Loaded $arg into $GDB"
send_user "Loaded $arg into $GDB\n"
}
return 1 return 1
} }
-re "$prompt $" { -re "$prompt $" {
if $verbose>1 then { error "Couldn't load $arg into $GDB."
error "GDB couldn't load." return 0
}
} }
timeout { timeout {
if $verbose>1 then {
error "Timed out trying to load $arg." error "Timed out trying to load $arg."
} return 0
} }
} }
if [info exists expect_out(buffer)] then { if [info exists expect_out(buffer)] then {
send_log $expect_out(buffer) send_log $expect_out(buffer)
} }
@ -100,10 +90,17 @@ proc gdb_target_udi { } {
send "target udi $targetname\n" send "target udi $targetname\n"
set timeout 60 set timeout 60
expect { expect {
-re "target udi $targetname\[\r\n\]+" {
continue -expect
}
-re "TIP UDI 1.2 Conformant.*$prompt $" { -re "TIP UDI 1.2 Conformant.*$prompt $" {
if $verbose>1 then { verbose "Set target to $targetname"
send_user "Set target to $targetname\n" }
} -re "TIP-ipc WARNING,.*failed:" {
warning "$expect_out(buffer)"
}
-re "TIP-ipc ERROR,.*failed:" {
error "$expect_out(buffer)"
} }
-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"
@ -138,13 +135,16 @@ proc gdb_start { } {
} }
expect { expect {
-re "GDB.*$prompt $" { -re "GDB.*$prompt $" {
if $verbose>1 then { verbose "$GDB initialized for cross mode\n"
send_user "$GDB initialized for cross mode\n\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 }
} }
# force the height to "unlimited", so no pagers get used # force the height to "unlimited", so no pagers get used
@ -158,25 +158,28 @@ proc gdb_start { } {
send "set args main\n" send "set args main\n"
expect -re ".*$prompt $" {} expect -re ".*$prompt $" {}
if $verbose>1 then { verbose "Setting up target, Please wait..."
send_user "Setting up target, Please wait...\n"
}
gdb_target_udi gdb_target_udi
} }
expect_after { #
"<return>" { send "\n"; clone_output "ERROR: Window too small." } # gdb_exit -- exit gdb
-re "\(y or n\) " { send "n\n"; error "Got interactive prompt." } #
buffer_full { error "internal buffer is full." } proc gdb_exit { } {
eof { error "eof -- pty is hosed." } slay isstip
timeout { error "timeout." } catch default_gdb_exit
"virtual memory exhausted" { error "virtual memory exhausted." } set in [open [concat "|ls -F"] r]
"Undefined command" { error "send string probably wrong." } while {[gets $in line]>-1} {
if [regexp "=$" $line] then {
set line [string trimright $line "="]
verbose "Removing the $line named socket"
exec rm -f $line
}
}
close $in
} }
load_lib gdb.exp
gdb_start gdb_start
# make sure gdb has actually started, otherwise if the first test # make sure gdb has actually started, otherwise if the first test