2004-09-09 Michael Chastain <mec.gnu@mindspring.com>

* lib/gdb.exp (gdb_file_cmd): Revert the return value to
	previous simple convention.  Use a global variable to store
	information about what was found.
	(gdb_run_cmd): Adapt to reverted return value.
	* gdb.base/remote.exp: Adapt to reverted return value.
	* gdb.gdb/complaints.exp: Likewise.
	* gdb.gdb/observer.exp: Likewise.
	* gdb.gdb/selftest.exp: Likewise.
	* gdb.gdb/xfullpath.exp: Likewise.
This commit is contained in:
Michael Chastain
2004-09-10 01:04:59 +00:00
parent e0638f7007
commit 2db8e78e67
6 changed files with 76 additions and 67 deletions

View File

@ -119,7 +119,7 @@ proc gdb_load_timed {executable downloadsize class writesize} {
set load_begin_time [clock clicks] set load_begin_time [clock clicks]
set result [gdb_load $executable] set result [gdb_load $executable]
set load_end_time [clock clicks] set load_end_time [clock clicks]
if { [lindex $result 0] != "" } then { if { $result != 0 } then {
fail "$test - loading executable" fail "$test - loading executable"
return return
} }

View File

@ -49,17 +49,20 @@ proc setup_test { executable } {
set timeout 600 set timeout 600
verbose "Timeout is now $timeout seconds" 2 verbose "Timeout is now $timeout seconds" 2
global gdb_file_cmd_debug_info
set gdb_file_cmd_debug_info "unset"
set result [gdb_load $executable] set result [gdb_load $executable]
set timeout $oldtimeout set timeout $oldtimeout
verbose "Timeout is now $timeout seconds" 2 verbose "Timeout is now $timeout seconds" 2
if { [lindex $result 0] != "" } then { if { $result != 0 } then {
return -1
} else {
if { [lsearch -exact [lrange $result 1 end] "nodebug"] >= 0 } then {
untested "No debug information, skipping testcase."
return -1 return -1
} }
if { $gdb_file_cmd_debug_info != "debug" } then {
untested "No debug information, skipping testcase."
return -1
} }
# Set a breakpoint at main # Set a breakpoint at main

View File

@ -47,17 +47,20 @@ proc setup_test { executable } {
set timeout 600 set timeout 600
verbose "Timeout is now $timeout seconds" 2 verbose "Timeout is now $timeout seconds" 2
global gdb_file_cmd_debug_info
set gdb_file_cmd_debug_info "unset"
set result [gdb_load $executable] set result [gdb_load $executable]
set timeout $oldtimeout set timeout $oldtimeout
verbose "Timeout is now $timeout seconds" 2 verbose "Timeout is now $timeout seconds" 2
if { [lindex $result 0] != "" } then { if { $result != 0 } then {
return -1
} else {
if { [lsearch -exact [lrange $result 1 end] "nodebug"] >= 0 } then {
untested "No debug information, skipping testcase."
return -1 return -1
} }
if { $gdb_file_cmd_debug_info != "debug" } then {
untested "No debug information, skipping testcase."
return -1
} }
# Set a breakpoint at main # Set a breakpoint at main

View File

@ -241,17 +241,20 @@ proc test_with_self { executable } {
set timeout 600 set timeout 600
verbose "Timeout is now $timeout seconds" 2 verbose "Timeout is now $timeout seconds" 2
global gdb_file_cmd_debug_info
set gdb_file_cmd_debug_info "unset"
set result [gdb_load $executable] set result [gdb_load $executable]
set timeout $oldtimeout set timeout $oldtimeout
verbose "Timeout is now $timeout seconds" 2 verbose "Timeout is now $timeout seconds" 2
if { [lindex $result 0] != "" } then { if { $result != 0 } then {
return -1
} else {
if { [lsearch -exact [lrange $result 1 end] "nodebug"] >= 0 } then {
untested "No debug information, skipping testcase."
return -1 return -1
} }
if { $gdb_file_cmd_debug_info != "debug" } then {
untested "No debug information, skipping testcase."
return -1
} }
# disassemble yourself # disassemble yourself

View File

@ -48,17 +48,20 @@ proc setup_test { executable } {
set timeout 600 set timeout 600
verbose "Timeout is now $timeout seconds" 2 verbose "Timeout is now $timeout seconds" 2
global gdb_file_cmd_debug_info
set gdb_file_cmd_debug_info "unset"
set result [gdb_load $executable] set result [gdb_load $executable]
set timeout $oldtimeout set timeout $oldtimeout
verbose "Timeout is now $timeout seconds" 2 verbose "Timeout is now $timeout seconds" 2
if { [lindex $result 0] != "" } then { if { $result != 0 } then {
return -1
} else {
if { [lsearch -exact [lrange $result 1 end] "nodebug"] >= 0 } then {
untested "No debug information, skipping testcase."
return -1 return -1
} }
if { $gdb_file_cmd_debug_info != "debug" } then {
untested "No debug information, skipping testcase."
return -1
} }
# Set a breakpoint at main # Set a breakpoint at main

View File

@ -180,8 +180,7 @@ proc gdb_run_cmd {args} {
if [target_info exists gdb,do_reload_on_run] { if [target_info exists gdb,do_reload_on_run] {
# Specifying no file, defaults to the executable # Specifying no file, defaults to the executable
# currently being debugged. # currently being debugged.
set status [gdb_load ""] if { [gdb_load ""] != 0 } {
if { [lindex $status 0] != "" } {
return; return;
} }
send_gdb "continue\n"; send_gdb "continue\n";
@ -226,8 +225,7 @@ proc gdb_run_cmd {args} {
send_gdb "y\n" send_gdb "y\n"
} }
-re "The program is not being run.*$gdb_prompt $" { -re "The program is not being run.*$gdb_prompt $" {
set status [gdb_load ""] if { [gdb_load ""] != 0 } {
if { [lindex $status 0] != ""] } {
return; return;
} }
send_gdb "jump *$start\n"; send_gdb "jump *$start\n";
@ -249,8 +247,7 @@ proc gdb_run_cmd {args} {
} }
if [target_info exists gdb,do_reload_on_run] { if [target_info exists gdb,do_reload_on_run] {
set status [gdb_load ""] if { [gdb_load ""] != 0 } {
if { [lindex $status 0] != "" } {
return; return;
} }
} }
@ -957,36 +954,37 @@ proc default_gdb_exit {} {
} }
# Load a file into the debugger. # Load a file into the debugger.
# The return value is a list with the following information: # The return value is 0 for success, -1 for failure.
# #
# { message word ... } # This procedure also set the global variable GDB_FILE_CMD_DEBUG_INFO
# to one of these values:
# #
# MESSAGE has the following values: # debug file was loaded successfully and has debug information
# nodebug file was loaded successfully and has no debug information
# fail file was not loaded
# #
# "" file was loaded successfully # I tried returning this information as part of the return value,
# "..." file was not loaded successfully. # but ran into a mess because of the many re-implementations of
# A perror has been generated with MESSAGE. # gdb_load in config/*.exp.
# #
# If the MESSAGE is "", then there is an optional set of words. # TODO: gdb.base/sepdebug.exp and gdb.stabs/weird.exp might be able to use
# The words may be: # this if they can get more information set.
#
# nodebug this file does not contain debug information
#
# TODO: gdb.base/sepdebug.exp and gdb.stabs/weird.exp might
# be able to use this if they can get more information
# in the return value.
proc gdb_file_cmd { arg } { proc gdb_file_cmd { arg } {
global gdb_prompt global gdb_prompt
global verbose global verbose
global GDB global GDB
# Set whether debug info was found.
# Default to "fail".
global gdb_file_cmd_debug_info
set gdb_file_cmd_debug_info "fail"
if [is_remote host] { if [is_remote host] {
set arg [remote_download host $arg] set arg [remote_download host $arg]
if { $arg == "" } { if { $arg == "" } {
set message "download failed" perror "download failed"
perror $message return -1
return { $message }
} }
} }
@ -994,11 +992,13 @@ proc gdb_file_cmd { arg } {
gdb_expect 120 { gdb_expect 120 {
-re "Reading symbols from.*no debugging symbols found.*done.*$gdb_prompt $" { -re "Reading symbols from.*no debugging symbols found.*done.*$gdb_prompt $" {
verbose "\t\tLoaded $arg into the $GDB with no debugging symbols" verbose "\t\tLoaded $arg into the $GDB with no debugging symbols"
return { "" nodebug } set gdb_file_cmd_debug_info "nodebug"
return 0
} }
-re "Reading symbols from.*done.*$gdb_prompt $" { -re "Reading symbols from.*done.*$gdb_prompt $" {
verbose "\t\tLoaded $arg into the $GDB" verbose "\t\tLoaded $arg into the $GDB"
return { "" } set gdb_file_cmd_debug_info "debug"
return 0
} }
-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_gdb "y\n" send_gdb "y\n"
@ -1010,37 +1010,33 @@ proc gdb_file_cmd { arg } {
gdb_expect 120 { gdb_expect 120 {
-re "Reading symbols from.*done.*$gdb_prompt $" { -re "Reading symbols from.*done.*$gdb_prompt $" {
verbose "\t\tLoaded $arg with new symbol table into $GDB" verbose "\t\tLoaded $arg with new symbol table into $GDB"
return { "" } set gdb_file_cmd_debug_info "debug"
return 0
} }
timeout { timeout {
set message "(timeout) Couldn't load $arg, other program already loaded." perror "(timeout) Couldn't load $arg, other program already loaded."
perror $message return -1
return { $message }
} }
} }
} }
-re "No such file or directory.*$gdb_prompt $" { -re "No such file or directory.*$gdb_prompt $" {
set message "($arg) No such file or directory" perror "($arg) No such file or directory"
perror $message return -1
return { $message }
} }
-re "$gdb_prompt $" { -re "$gdb_prompt $" {
set message "couldn't load $arg into $GDB." perror "couldn't load $arg into $GDB."
perror $message return -1
return { $message }
} }
timeout { timeout {
set message "couldn't load $arg into $GDB (timed out)." perror "couldn't load $arg into $GDB (timed out)."
perror $message return -1
return { $message }
} }
eof { eof {
# This is an attempt to detect a core dump, but seems not to # This is an attempt to detect a core dump, but seems not to
# work. Perhaps we need to match .* followed by eof, in which # work. Perhaps we need to match .* followed by eof, in which
# gdb_expect does not seem to have a way to do that. # gdb_expect does not seem to have a way to do that.
set message "couldn't load $arg into $GDB (end of file)." perror "couldn't load $arg into $GDB (end of file)."
perror $message return -1
return { $message }
} }
} }
} }
@ -1655,6 +1651,7 @@ proc gdb_exit { } {
# #
# gdb_load -- load a file into the debugger. # gdb_load -- load a file into the debugger.
# Many files in config/*.exp override this procedure.
# #
proc gdb_load { arg } { proc gdb_load { arg } {
return [gdb_file_cmd $arg] return [gdb_file_cmd $arg]