# we need to set -notransfer expect option so that
# command output is not lost for pattern matching
# - guo
- gdb_expect -notransfer 2 {
- -re "\[\r\n\]" { }
- timeout { }
+ gdb_expect 2 {
+ -notransfer -re "\[\r\n\]" { verbose "partial: match" 3 }
+ timeout { verbose "partial: timeout" 3 }
}
set string [string range "$string" [expr $foo + 1] end];
} else {
}
fail "$errmsg"
return -1
+ }
+ -re "EXIT code \[0-9\r\n\]+Program exited normally.*$gdb_prompt $" {
+ if ![string match "" $message] then {
+ set errmsg "$message: the program exited"
+ } else {
+ set errmsg "$command: the program exited"
+ }
+ fail "$errmsg"
+ return -1
}
-re "The program is not being run.*$gdb_prompt $" {
if ![string match "" $message] then {
return $result;
}
+set gdb_wrapper_initialized 0
+
+proc gdb_wrapper_init { args } {
+ global gdb_wrapper_initialized;
+ global gdb_wrapper_file;
+ global gdb_wrapper_flags;
+
+ if { $gdb_wrapper_initialized == 1 } { return; }
+
+ if {[target_info exists needs_status_wrapper] && \
+ [target_info needs_status_wrapper] != "0" && \
+ ![info exists gdb_wrapper_file]} {
+ set result [build_wrapper "testglue.o"];
+ if { $result != "" } {
+ set gdb_wrapper_file [lindex $result 0];
+ set gdb_wrapper_flags [lindex $result 1];
+ } else {
+ warning "Status wrapper failed to build."
+ }
+ }
+ set gdb_wrapper_initialized 1
+}
+
proc gdb_compile {source dest type options} {
global GDB_TESTCASE_OPTIONS;
+ global gdb_wrapper_file;
+ global gdb_wrapper_flags;
+ global gdb_wrapper_initialized;
if [target_info exists gdb_stub] {
set options2 { "additional_flags=-Dusestubs" }
verbose "options are $options"
verbose "source is $source $dest $type $options"
+ if { $gdb_wrapper_initialized == 0 } { gdb_wrapper_init }
+
+ if {[target_info exists needs_status_wrapper] && \
+ [target_info needs_status_wrapper] != "0" && \
+ [info exists gdb_wrapper_file]} {
+ lappend options "libs=${gdb_wrapper_file}"
+ lappend options "ldflags=${gdb_wrapper_flags}"
+ }
+
set result [target_compile $source $dest $type $options];
regsub "\[\r\n\]*$" "$result" "" result;
regsub "^\[\r\n\]*" "$result" "" result;
#
proc gdb_expect { args } {
- # allow -notransfer expect flag specification,
- # used by gdb_test routine for multi-line commands.
- # packed with gtimeout when fed to remote_expect routine,
- # which is a hack but due to what looks like a res and orig
- # parsing problem in remote_expect routine (dejagnu/lib/remote.exp):
- # what's fed into res is not removed from orig.
- # - guo
- if { [lindex $args 0] == "-notransfer" } {
- set notransfer -notransfer;
- set args [lrange $args 1 end];
- } else {
- set notransfer "";
- }
-
if { [llength $args] == 2 && [lindex $args 0] != "-re" } {
set gtimeout [lindex $args 0];
set expcode [list [lindex $args 1]];
}
}
set code [catch \
- {uplevel remote_expect host "$gtimeout $notransfer" $expcode} string];
+ {uplevel remote_expect host $gtimeout $expcode} string];
if [info exists old_val] {
set remote_suppress_flag $old_val;
} else {
}
}
+# Return true if FORMAT matches the debug format the current test was
+# compiled with. FORMAT is a shell-style globbing pattern; it can use
+# `*', `[...]', and so on.
+#
+# This function depends on variables set by `get_debug_format', above.
+
+proc test_debug_format {format} {
+ global debug_format
+
+ return [expr [string match $format $debug_format] != 0]
+}
+
# Like setup_xfail, but takes the name of a debug format (DWARF 1,
# COFF, stabs, etc). If that format matches the format that the
# current test was compiled with, then the next test is expected to
# fail for any target. Returns 1 if the next test or set of tests is
# expected to fail, 0 otherwise (or if it is unknown). Must have
# previously called get_debug_format.
-
proc setup_xfail_format { format } {
- global debug_format
+ set ret [test_debug_format $format];
- if [string match $debug_format $format] then {
+ if {$ret} then {
setup_xfail "*-*-*"
- return 1;
}
- return 0
-}
+ return $ret;
+}
proc gdb_step_for_stub { } {
global gdb_prompt;
# Don't bother to check the output of the program, that may be
# extremely tough for some remote systems.
gdb_test "continue"\
- "Continuing.\[\r\n0-9\]+Program exited normally\\..*"\
+ "Continuing.\[\r\n0-9\]+(... EXIT code 0\[\r\n\]+|)Program exited normally\\..*"\
"continue until exit at $mssg"
}
}
}
}
-# Initializes the display for gdbtk testing.
-# Returns 1 if tests should run, 0 otherwise.
-proc gdbtk_initialize_display {} {
- global _using_windows
-
- # This is hacky, but, we don't have much choice. When running
- # expect under Windows, tcl_platform(platform) is "unix".
- if {![info exists _using_windows]} {
- set _using_windows [expr {![catch {exec cygpath --help}]}]
- }
-
- if {![_gdbtk_xvfb_init]} {
- if {$_using_windows} {
- untested "No GDB_DISPLAY -- skipping tests"
- } else {
- untested "No GDB_DISPLAY or Xvfb -- skipping tests"
- }
-
- return 0
- }
-
- return 1
-}
-
-# From dejagnu:
-# srcdir = testsuite src dir (e.g., devo/gdb/testsuite)
-# objdir = testsuite obj dir (e.g., gdb/testsuite)
-# subdir = subdir of testsuite (e.g., gdb.gdbtk)
-#
-# To gdbtk:
-# env(DEFS)=the "defs" files (e.g., devo/gdb/testsuite/gdb.gdbtk/defs)
-# env(SRCDIR)=directory containing the test code (e.g., *.test)
-# env(OBJDIR)=directory which contains any executables
-# (e.g., gdb/testsuite/gdb.gdbtk)
-proc gdbtk_start {test} {
- global verbose
- global GDB
- global GDBFLAGS
- global env srcdir subdir objdir
-
- gdb_stop_suppressing_tests;
-
- verbose "Starting $GDB -nx -q --tclcommand=$test"
-
- set real_test [which $test]
- if {$real_test == 0} {
- perror "$test is not found"
- exit 1
- }
-
- if {![is_remote host]} {
- if { [which $GDB] == 0 } {
- perror "$GDB does not exist."
- exit 1
- }
- }
-
- set wd [pwd]
-
- # Find absolute path to test
- set test [to_tcl_path -abs $test]
-
- # Set environment variables for tcl libraries and such
- cd $srcdir
- set abs_srcdir [pwd]
- set env(GDBTK_LIBRARY) [to_tcl_path -abs [file join $abs_srcdir .. gdbtk library]]
- set env(TCL_LIBRARY) [to_tcl_path -abs [file join $abs_srcdir .. .. tcl library]]
- set env(TK_LIBRARY) [to_tcl_path -abs [file join $abs_srcdir .. .. tk library]]
- set env(TIX_LIBRARY) [to_tcl_path -abs [file join $abs_srcdir .. .. tix library]]
- set env(ITCL_LIBRARY) [to_tcl_path -abs [file join $abs_srcdir .. .. itcl itcl library]]
- set env(CYGNUS_GUI_LIBRARY) [to_tcl_path -abs [file join .. $abs_srcdir .. .. libgui library]]
- set env(DEFS) [to_tcl_path -abs [file join $abs_srcdir $subdir defs]]
-
- cd $wd
- cd [file join $objdir $subdir]
- set env(OBJDIR) [pwd]
- cd $wd
-
- # Set info about target into env
- _gdbtk_export_target_info
-
- set env(SRCDIR) $abs_srcdir
- set env(GDBTK_VERBOSE) 1
- set env(GDBTK_LOGFILE) [to_tcl_path [file join $objdir gdb.log]]
-
- set err [catch {exec $GDB -nx -q --tclcommand=$test} res]
- if { $err } {
- perror "Execing $GDB failed: $res"
- exit 1;
- }
- return $res
-}
-
-# Start xvfb when using it.
-# The precedence is:
-# 1. If GDB_DISPLAY is set, use it
-# 2. If Xvfb exists, use it (not on cygwin)
-# 3. Skip tests
-proc _gdbtk_xvfb_init {} {
- global env spawn_id _xvfb_spawn_id _using_windows
-
- if {[info exists env(GDB_DISPLAY)]} {
- set env(DISPLAY) $env(GDB_DISPLAY)
- } elseif {!$_using_windows && [which Xvfb] != 0} {
- set screen ":[getpid]"
- set pid [spawn Xvfb $screen]
- set _xvfb_spawn_id $spawn_id
- set env(DISPLAY) $screen
- } else {
- # No Xvfb found -- skip test
- return 0
- }
-
- return 1
-}
-
-# Kill xvfb
-proc _gdbtk_xvfb_exit {} {
- global objdir subdir env _xvfb_spawn_id
-
- if {[info exists _xvfb_spawn_id]} {
- exec kill [exp_pid -i $_xvfb_spawn_id]
- wait -i $_xvfb_spawn_id
- }
-}
-
-# help proc for setting tcl-style paths from unix-style paths
-# pass "-abs" to make it an absolute path
-proc to_tcl_path {unix_path {arg {}}} {
- global _using_windows
-
- if {[string compare $unix_path "-abs"] == 0} {
- set unix_path $arg
- set wd [pwd]
- cd [file dirname $unix_path]
- set dirname [pwd]
- set unix_name [file join $dirname [file tail $unix_path]]
- cd $wd
- }
-
- if {$_using_windows} {
- set unix_path [exec cygpath -aw $unix_path]
- set unix_path [join [split $unix_path \\] /]
- }
-
- return $unix_path
-}
-
-# Set information about the target into the environment
-# variable TARGET_INFO. This array will contain a list
-# of commands that are necessary to run a target.
-#
-# This is mostly devined from how dejagnu works, what
-# procs are defined, and analyzing unix.exp, monitor.exp,
-# and sim.exp.
-#
-# Array elements exported:
-# Index Meaning
-# ----- -------
-# init list of target/board initialization commands
-# target target command for target/board
-# load load command for target/board
-# run run command for target_board
-proc _gdbtk_export_target_info {} {
- global env
-
- # Figure out what "target class" the testsuite is using,
- # i.e., sim, monitor, native
- if {[string compare [info proc gdb_target_monitor] gdb_target_monitor] == 0} {
- # Using a monitor/remote target
- set target monitor
- } elseif {[string compare [info proc gdb_target_sim] gdb_target_sim] == 0} {
- # Using a simulator target
- set target simulator
- } else {
- # Assume native
- set target native
- }
-
- # Now setup the array to be exported.
- set info(init) {}
- set info(target) {}
- set info(load) {}
- set info(run) {}
-
- switch $target {
- simulator {
- set opts "[target_info gdb,target_sim_options]"
- set info(target) "target sim $opts"
- set info(load) "load"
- set info(run) "run"
- }
-
- monitor {
- # Setup options for the connection
- if {[target_info exists baud]} {
- lappend info(init) "set remotebaud [target_info baud]"
- }
- if {[target_info exists binarydownload]} {
- lappend info(init) "set remotebinarydownload [target_info binarydownload]"
- }
- if {[target_info exists disable_x_packet]} {
- lappend info(init) "set remote X-packet disable"
- }
- if {[target_info exists disable_z_packet]} {
- lappend info(init) "set remote Z-packet disable"
- }
-
- # Get target name and connection info
- if {[target_info exists gdb_protocol]} {
- set targetname "[target_info gdb_protocol]"
- } else {
- set targetname "not_specified"
- }
- if {[target_info exists gdb_serial]} {
- set serialport "[target_info gdb_serial]"
- } elseif {[target_info exists netport]} {
- set serialport "[target_info netport]"
- } else {
- set serialport "[target_info serial]"
- }
-
- set info(target) "target $targetname $serialport"
- set info(load) "load"
- set info(run) "continue"
- }
-
- native {
- set info(run) "run"
- }
- }
-
- # Export the array to the environment
- set env(TARGET_INFO) [array get info]
-}
-
-# gdbtk tests call this function to print out the results of the
-# tests. The argument is a proper list of lists of the form:
-# {status name description msg}. All of these things typically
-# come from the testsuite harness.
-proc gdbtk_analyze_results {results} {
- foreach test $results {
- set status [lindex $test 0]
- set name [lindex $test 1]
- set description [lindex $test 2]
- set msg [lindex $test 3]
-
- switch $status {
- PASS {
- pass "$description ($name)"
- }
-
- FAIL {
- fail "$description ($name)"
- }
-
- ERROR {
- perror "$name"
- }
-
- XFAIL {
- xfail "$description ($name)"
- }
-
- XPASS {
- xpass "$description ($name)"
- }
- }
- }
-}
-
-proc gdbtk_done {{results {}}} {
- global _xvfb_spawn_id
- gdbtk_analyze_results $results
-
- # Kill off xvfb if using it
- if {[info exists _xvfb_spawn_id]} {
- _gdbtk_xvfb_exit
- }
-}
-
# Print a message and return true if a test should be skipped
# due to lack of floating point suport.