* lib/gdb.exp: Transform tool name.

* gdb.t*/*.exp: Change error to perror so it works with DejaGnu
	1.1's new error handling system.
This commit is contained in:
Rob Savoye 1993-11-03 18:28:22 +00:00
parent 73e1e09b8e
commit 85174909de
4 changed files with 127 additions and 62 deletions

View File

@ -1,3 +1,9 @@
Wed Nov 3 11:23:11 1993 Rob Savoye (rob@darkstar.cygnus.com)
* lib/gdb.exp: Transform tool name.
* gdb.t*/*.exp: Change error to perror so it works with DejaGnu
1.1's new error handling system.
Mon Nov 1 10:36:29 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
* Makefile.in, gdb.t2*/Makefile.in: Add -O to CXXFLAGS.

View File

@ -67,7 +67,7 @@ proc gdb_unload {} {
}
-re "$prompt $" {}
timeout {
error "Couldn't unload file in $GDB (timed out)."
perror "Couldn't unload file in $GDB (timed out)."
return -1
}
}
@ -108,14 +108,14 @@ proc gdb_start {} {
if {[which $GDB] != 0} then {
spawn $GDB $GDBFLAGS
} else {
error "$GDB does not exist."
perror "$GDB does not exist."
exit 1
}
} else {
if {[which $GDB] != 0} then {
spawn $GDB
} else {
error "$GDB does not exist."
perror "$GDB does not exist."
exit 1
}
}
@ -126,11 +126,11 @@ proc gdb_start {} {
}
}
-re "$prompt $" {
error "GDB never initialized."
perror "GDB never initialized."
return -1
}
timeout {
error "(timeout) GDB never initialized."
perror "(timeout) GDB never initialized."
return -1
}
}
@ -139,9 +139,7 @@ proc gdb_start {} {
send "set height 0\n"
expect {
-re ".*$prompt $" {
if $verbose>2 then {
send_user "Seting height to 0.\n"
}
verbose "Seting height to 0."
}
timeout {
warning "Couldn't set the height to 0."
@ -165,19 +163,6 @@ proc gdb_exit { } {
catch default_gdb_exit
}
# These only need to be uncommented for debugging test cases. They exist
# mainly to catch programming errors
#expect_after {
# "<return>" { send "\n"; error "Window too small." }
# -re "\(y or n\) " { send "n\n"; error "Got interactive prompt." }
# buffer_full { error "internal buffer is full." }
# eof { error "eof -- there is no child process" ; cleanup ; exit $exit_status}
# timeout { error "timeout." }
# "virtual memory exhausted" { error "virtual memory exhausted." }
# "Undefined command" { error "send string probably wrong." }
#}
set binpath /s1/users/rob/vxworks/bin/somewhere-bogus-that-needs-configuring
set bin $GDB

View File

@ -19,6 +19,25 @@ proc do_tests {} {
clear_xfail "rs*-*-aix*"
gdb_test "ptype red" "type = enum \{red, green, blue\}" "ptype unnamed enum"
# Mips/alpha targets that use gcc with mips-tfile put out the stabs
# assembler directives embedded in comments. If the assembler
# file is then processed with native cc, all stabs directives
# will be lost.
# Skip the rest of the stabs tests for this case.
send "ptype inttype\n"
expect {
-re "^ptype inttype\r*\ntype = inttype.*$prompt $" {
pass "stabs found"
}
-re ".*$prompt $" {
setup_xfail "mips-*-*"
setup_xfail "alpha-*-*"
fail "stabs not found"
return
}
default { fail "checking for stabs" }
}
print_weird_var var0
print_weird_var var1
print_weird_var var2
@ -244,7 +263,7 @@ if ![file exists $binfile] then {
fail "Errors reading weird.o"
}
timeout {
error "couldn't load $binfile into $GDB (timed out)."
perror "couldn't load $binfile into $GDB (timed out)."
return -1
}
eof { fail "(eof) cannot read weird.o" }

View File

@ -23,6 +23,13 @@
# need to be modified for any target, it can be done with a variable
# or by passing arguments.
if ![info exists GDB] then {
set GDB [transform gdb]
}
if ![info exists GDBFLAGS] then {
set GDBFLAGS ""
}
#
# gdb_version -- extract and print the version number of gcc
#
@ -31,9 +38,8 @@ proc default_gdb_version {} {
global GDBFLAGS
if {[which $GDB] != 0} then {
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"
regexp " \[0-9\.\]+" $tmp version
clone_output "[which $GDB] version$version $GDBFLAGS\n"
} else {
warning "$GDB does not exist"
}
@ -53,9 +59,7 @@ proc gdb_unload {} {
-re "No symbol file now\.\r" { continue -expect }
-re "A program is being debugged already..*Kill it\? \(y or n\) $"\
{ send "y\n"
if $verbose>1 then {
send_user "\t\tKilling previous program being debugged\n"
}
verbose "\t\tKilling previous program being debugged"
continue -expect
}
-re "Discard symbol table from .*\? \(y or n\) $" {
@ -64,7 +68,7 @@ proc gdb_unload {} {
}
-re "$prompt $" {}
timeout {
error "couldn't unload file in $GDB (timed out)."
perror "couldn't unload file in $GDB (timed out)."
return -1
}
}
@ -187,7 +191,7 @@ proc gdb_test { args } {
# trap the send so any problems don't crash things
catch "send \"$command\n\"" errmess
if [string match "write\(spawn_id=\[0-9\]+\):" $errmess] then {
error "sent \"$command\" got expect error \"$errmess\""
perror "sent \"$command\" got expect error \"$errmess\""
catch "close"
gdb_start
return -1
@ -209,11 +213,11 @@ proc gdb_test { args } {
set result 0
}
-re "Undefined command:.*$prompt" {
error "Undefined command \"$command\"."
perror "Undefined command \"$command\"."
set result 1
}
-re "Ambiguous command.*$prompt $" {
error "\"$command\" is not a unique command name."
perror "\"$command\" is not a unique command name."
set result 1
}
-re ".*$prompt $" {
@ -224,18 +228,18 @@ proc gdb_test { args } {
}
"<return>" {
send "\n"
error "Window too small."
perror "Window too small."
}
-re "\(y or n\) " {
send "n\n"
error "Got interactive prompt."
perror "Got interactive prompt."
}
eof {
error "Process no longer exists"
perror "Process no longer exists"
return -1
}
buffer_full {
error "internal buffer is full."
perror "internal buffer is full."
}
timeout {
fail "(timeout) $message"
@ -247,9 +251,8 @@ proc gdb_test { args } {
proc gdb_reinitialize_dir { subdir } {
global prompt
global verbose
send "dir\n"
send "dir\n"
expect {
-re "Reinitialize source path to empty.*" {
send "y\n"
@ -258,27 +261,24 @@ proc gdb_reinitialize_dir { subdir } {
send "dir $subdir\n"
expect {
-re "Source directories searched.*$prompt $" {
if $verbose>1 then {
send_user "Dir set to $subdir\n"
}
verbose "Dir set to $subdir"
}
-re ".*$prompt $" {
error "Dir \"$subdir\" failed."
perror "Dir \"$subdir\" failed."
}
}
}
-re ".*$prompt $" {
error "Dir \"$subdir\" failed."
perror "Dir \"$subdir\" failed."
}
}
}
-re ".*$prompt $" {
error "Dir \"$subdir\" failed."
perror "Dir \"$subdir\" failed."
}
}
}
#
# gdb_exit -- exit the GDB, killing the target program if necessary
#
@ -302,25 +302,19 @@ proc default_gdb_exit {} {
# FIXME: What is this catch statement doing here? Won't it prevent us
# from getting errors that we'd rather see?
catch {
expect {
eof {
verbose "Got EOF from $GDB" 2
}
timeout {
verbose "Got TIMEOUT from $GDB" 2
}
-re "The program is running. Quit anyway.*(y or n) $" {
send "y\n"
verbose "Killing program being debugged" 2
expect {
eof {
verbose "Got EOF from $GDB" 2
}
timeout {
verbose "Got TIMEOUT from $GDB" 2
}
-re "The program is running. Quit anyway.*(y or n) $" {
send "y\n"
verbose "Killing program being debugged" 2
}
}
}
}
# FIXME: Does the catch prevent us from getting errors that we'd rather
# see? the old gdb_exit in unix-gdb.exp had "close" without catch
# in the above expect statement (for the timeout and -re "The
# program... cases) (as well as a catch "close" here).
catch "close"
# Before this was here sometimes "uit" would get sent to the next GDB
# (assuming this is immediately followed by gdb_start), which would
@ -329,6 +323,67 @@ proc default_gdb_exit {} {
wait
}
#
# gdb_load -- load a file into the debugger.
# return a -1 if anything goes wrong.
#
proc gdb_file_cmd { arg } {
global verbose
global loadpath
global loadfile
global GDB
global prompt
send "file $arg\n"
expect {
-re "Reading symbols from.*done.*$prompt $" {
verbose "\t\tLoaded $arg into the $GDB"
return 0
}
-re "has no symbol-table.*$prompt $" {
perror "$arg wasn't compiled with \"-g\""
return -1
}
-re "A program is being debugged already..*Kill it\? \(y or n\) $" {
send "y\n"
verbose "\t\tKilling previous program being debugged"
continue -expect
}
-re "Load new symbol table from.*\? \(y or n\) $" {
send "y\n"
expect {
-re "Reading symbols from.*done.*$prompt $" {
verbose "\t\tLoaded $arg with new symbol table into $GDB"
return 0
}
timeout {
perror "(timeout) Couldn't load $arg, other program already l
oaded."
return -1
}
}
}
-re ".*No such file or directory.*$prompt $" {
perror "($arg) No such file or directory\n"
return -1
}
-re "$prompt $" {
perror "couldn't load $arg into $GDB."
return -1
}
timeout {
error "couldn't load $arg into $GDB (timed out)."
return -1
}
eof {
# This is an attempt to detect a core dump, but seems not to
# work. Perhaps we need to match .* followed by eof, in which
# expect does not seem to have a way to do that.
error "couldn't load $arg into $GDB (end of file)."
return -1
}
}
}