diff options
author | Ben Elliston <bje@gnu.org> | 2003-08-07 03:42:42 +0000 |
---|---|---|
committer | Ben Elliston <bje@gnu.org> | 2003-08-07 03:42:42 +0000 |
commit | d7b7156075df25716082174f6baf2ac0e163e939 (patch) | |
tree | e2c4f9afdb89cf1e6f082acf7c1a0aae0fd423a8 /lib | |
parent | 8f0d1b58dbfb8b4e7ad5c14f21d65da05a364200 (diff) | |
download | dejagnu-d7b7156075df25716082174f6baf2ac0e163e939.zip dejagnu-d7b7156075df25716082174f6baf2ac0e163e939.tar.gz dejagnu-d7b7156075df25716082174f6baf2ac0e163e939.tar.bz2 |
Strip trailing semicolons from Tcl source files.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/debugger.exp | 2 | ||||
-rwxr-xr-x | lib/dejagnu.exp | 10 | ||||
-rw-r--r-- | lib/dg.exp | 10 | ||||
-rw-r--r-- | lib/framework.exp | 114 | ||||
-rw-r--r-- | lib/ftp.exp | 136 | ||||
-rw-r--r-- | lib/kermit.exp | 54 | ||||
-rw-r--r-- | lib/libgloss.exp | 244 | ||||
-rw-r--r-- | lib/mondfe.exp | 56 | ||||
-rw-r--r-- | lib/remote.exp | 746 | ||||
-rw-r--r-- | lib/rlogin.exp | 32 | ||||
-rw-r--r-- | lib/rsh.exp | 40 | ||||
-rw-r--r-- | lib/standard.exp | 8 | ||||
-rw-r--r-- | lib/target.exp | 128 | ||||
-rw-r--r-- | lib/targetdb.exp | 38 | ||||
-rw-r--r-- | lib/telnet.exp | 78 | ||||
-rw-r--r-- | lib/tip.exp | 12 | ||||
-rw-r--r-- | lib/xsh.exp | 26 |
17 files changed, 867 insertions, 867 deletions
diff --git a/lib/debugger.exp b/lib/debugger.exp index b9fc27f..6e41552 100644 --- a/lib/debugger.exp +++ b/lib/debugger.exp @@ -193,7 +193,7 @@ proc print { var } { } proc quit { } { - log_and_exit; + log_and_exit } proc bt { } { diff --git a/lib/dejagnu.exp b/lib/dejagnu.exp index 680716e..5cf6f20 100755 --- a/lib/dejagnu.exp +++ b/lib/dejagnu.exp @@ -76,21 +76,21 @@ proc host_compile {compline} { # execute the compiler verbose "Compiling for the host using: $CC $INCLUDES $LIBS $compline" 2 - set status [catch "exec $CC $INCLUDES $LIBS $compline" comp_output]; + set status [catch "exec $CC $INCLUDES $LIBS $compline" comp_output] verbose "Compiler returned $comp_output" 2 # prune common warnings and other stuff we can safely ignore - set comp_output [prune_warnings $comp_output]; + set comp_output [prune_warnings $comp_output] # Trim multiple CR/LF pairs out to keep things consistant - regsub "^\[\r\n\]+" $comp_output "" comp_output; + regsub "^\[\r\n\]+" $comp_output "" comp_output # if we got a compiler error, log it if { [lindex $status 0] != 0 } { - verbose -log "compiler exited with status [lindex $status 0]"; + verbose -log "compiler exited with status [lindex $status 0]" } if { [lindex $status 1] != "" } { - verbose -log "output is:\n[lindex $status 1]" 2; + verbose -log "output is:\n[lindex $status 1]" 2 } # return the filtered output @@ -719,10 +719,10 @@ proc dg-test { args } { # No intention is made (at this point) to preserve upward compatibility # (though at some point we'll have to). - set results [${tool}-dg-test $prog [lindex ${dg-do-what} 0] "$tool_flags ${dg-extra-tool-flags}"]; + set results [${tool}-dg-test $prog [lindex ${dg-do-what} 0] "$tool_flags ${dg-extra-tool-flags}"] - set comp_output [lindex $results 0]; - set output_file [lindex $results 1]; + set comp_output [lindex $results 0] + set output_file [lindex $results 1] #send_user "\nold_dejagnu.exp: comp_output1 = :$comp_output:\n\n" #send_user "\nold_dejagnu.exp: message = :$message:\n\n" @@ -836,8 +836,8 @@ proc dg-test { args } { } else { set status -1 set result [${tool}_load $output_file] - set status [lindex $result 0]; - set output [lindex $result 1]; + set status [lindex $result 0] + set output [lindex $result 1] #send_user "After exec, status: $status\n" if { [lindex ${dg-do-what} 2] == "F" } { setup_xfail "*-*-*" diff --git a/lib/framework.exp b/lib/framework.exp index e4fe609..ced1283 100644 --- a/lib/framework.exp +++ b/lib/framework.exp @@ -135,35 +135,35 @@ proc isbuild { pattern } { # Is $board remote? Return a non-zero value if so. # proc is_remote { board } { - global host_board; - global target_list; + global host_board + global target_list - verbose "calling is_remote $board" 3; + verbose "calling is_remote $board" 3 # Remove any target variant specifications from the name. - set board [lindex [split $board "/"] 0]; + set board [lindex [split $board "/"] 0] # Map the host or build back into their short form. if { [board_info build name] == $board } { - set board "build"; + set board "build" } elseif { [board_info host name] == $board } { - set board "host"; + set board "host" } # We're on the "build". The check for the empty string is just for # paranoia's sake--we shouldn't ever get one. "unix" is a magic # string that should really go away someday. if { $board == "build" || $board == "unix" || $board == "" } { - verbose "board is $board, not remote" 3; - return 0; + verbose "board is $board, not remote" 3 + return 0 } if { $board == "host" } { if { [info exists host_board] && $host_board != "" } { - verbose "board is $board, is remote" 3; - return 1; + verbose "board is $board, is remote" 3 + return 1 } else { - verbose "board is $board, host is local" 3; - return 0; + verbose "board is $board, host is local" 3 + return 0 } } @@ -173,16 +173,16 @@ proc is_remote { board } { if [info exists current_target_name] { # This shouldn't happen, but we'll be paranoid anyway. if { $current_target_name != "target" } { - return [is_remote $current_target_name]; + return [is_remote $current_target_name] } } - return 0; + return 0 } if [board_info $board exists isremote] { - verbose "board is $board, isremote is [board_info $board isremote]" 3; - return [board_info $board isremote]; + verbose "board is $board, isremote is [board_info $board isremote]" 3 + return [board_info $board isremote] } - return 1; + return 1 } # # If this is a canadian (3 way) cross. This means the tools are @@ -285,8 +285,8 @@ proc unknown { args } { send_error "The info on the error is:\n$errorInfo\n" } - set exit_status 1; - log_and_exit; + set exit_status 1 + log_and_exit } # @@ -307,7 +307,7 @@ proc clone_output { message } { puts $sum_file "$message" } - regsub "^\[ \t\]*(\[^ \t\]+).*$" "$message" "\\1" firstword; + regsub "^\[ \t\]*(\[^ \t\]+).*$" "$message" "\\1" firstword case "$firstword" in { {"PASS:" "XFAIL:" "KFAIL:" "UNRESOLVED:" "UNSUPPORTED:" "UNTESTED:"} { if $all_flag { @@ -332,20 +332,20 @@ proc clone_output { message } { # Reset a few counters. # proc reset_vars {} { - global test_names test_counts; - global warncnt errcnt; + global test_names test_counts + global warncnt errcnt # other miscellaneous variables global prms_id global bug_id # reset them all - set prms_id 0; - set bug_id 0; - set warncnt 0; - set errcnt 0; + set prms_id 0 + set bug_id 0 + set warncnt 0 + set errcnt 0 foreach x $test_names { - set test_counts($x,count) 0; + set test_counts($x,count) 0 } # Variables local to this file. @@ -355,10 +355,10 @@ proc reset_vars {} { } proc log_and_exit {} { - global exit_status; - global tool mail_logs outdir mailing_list; + global exit_status + global tool mail_logs outdir mailing_list - log_summary total; + log_summary total # extract version number if {[info procs ${tool}_version] != ""} { if {[catch "${tool}_version" output]} { @@ -396,13 +396,13 @@ proc log_summary { args } { global outdir global mailing_list global current_target_name - global test_counts; - global testcnt; + global test_counts + global testcnt if { [llength $args] == 0 } { - set which "count"; + set which "count" } else { - set which [lindex $args 0]; + set which [lindex $args 0] } if { [llength $args] == 0 } { @@ -417,12 +417,12 @@ proc log_summary { args } { # so it's not clear how often this will be used. if [info exists testcnt] { if { $testcnt > 0 } { - set totlcnt 0; + set totlcnt 0 # total all the testcases reported foreach x { FAIL PASS XFAIL KFAIL XPASS KPASS UNTESTED UNRESOLVED UNSUPPORTED } { - incr totlcnt test_counts($x,$which); + incr totlcnt test_counts($x,$which) } - set testcnt test_counts(total,$which); + set testcnt test_counts(total,$which) if { $testcnt>$totlcnt || $testcnt<$totlcnt } { if { $testcnt > $totlcnt } { @@ -444,9 +444,9 @@ proc log_summary { args } { } } foreach x { PASS FAIL XPASS XFAIL KPASS KFAIL UNRESOLVED UNTESTED UNSUPPORTED } { - set val $test_counts($x,$which); + set val $test_counts($x,$which) if { $val > 0 } { - set mess "# of $test_counts($x,name)"; + set mess "# of $test_counts($x,name)" if { $xml } { xml_output " <summary>" xml_output " <result>$x</result>" @@ -455,9 +455,9 @@ proc log_summary { args } { xml_output " </summary>" } if { [string length $mess] < 24 } { - append mess "\t"; + append mess "\t" } - clone_output "$mess\t$val"; + clone_output "$mess\t$val" } } } @@ -698,12 +698,12 @@ proc record_test { type message args } { global pf_prefix if { [llength $args] > 0 } { - set count [lindex $args 0]; + set count [lindex $args 0] } else { - set count 1; + set count 1 } if [info exists pf_prefix] { - set message [concat $pf_prefix " " $message]; + set message [concat $pf_prefix " " $message] } # If we have too many warnings or errors, @@ -715,7 +715,7 @@ proc record_test { type message args } { set type UNRESOLVED } - incr_count $type; + incr_count $type if { $xml } { global errorInfo @@ -1033,7 +1033,7 @@ proc unsupported { message } { # Set up the values in the test_counts array (name and initial totals). # proc init_testcounts { } { - global test_counts test_names; + global test_counts test_names set test_counts(TOTAL,name) "testcases run" set test_counts(PASS,name) "expected passes" set test_counts(FAIL,name) "unexpected failures" @@ -1046,16 +1046,16 @@ proc init_testcounts { } { set test_counts(UNSUPPORTED,name) "unsupported tests" set test_counts(UNRESOLVED,name) "unresolved testcases" set test_counts(UNTESTED,name) "untested testcases" - set j ""; + set j "" foreach i [lsort [array names test_counts]] { - regsub ",.*$" "$i" "" i; + regsub ",.*$" "$i" "" i if { $i == $j } { - continue; + continue } - set test_counts($i,total) 0; - lappend test_names $i; - set j $i; + set test_counts($i,total) 0 + lappend test_names $i + set j $i } } @@ -1064,16 +1064,16 @@ proc init_testcounts { } { # is optional (defaults to 1). # proc incr_count { name args } { - global test_counts; + global test_counts if { [llength $args] == 0 } { - set count 1; + set count 1 } else { - set count [lindex $args 0]; + set count [lindex $args 0] } if [info exists test_counts($name,count)] { - incr test_counts($name,count) $count; - incr test_counts($name,total) $count; + incr test_counts($name,count) $count + incr test_counts($name,total) $count } else { perror "$name doesn't exist in incr_count" } diff --git a/lib/ftp.exp b/lib/ftp.exp index c9f5629..9259a67 100644 --- a/lib/ftp.exp +++ b/lib/ftp.exp @@ -29,57 +29,57 @@ proc ftp_open { host } { global board_info if [board_info $host exists name] { - set host [board_info $host name]; + set host [board_info $host name] } if [board_info $host exists ftp_fileid] { - return [board_info $host ftp_fileid]; + return [board_info $host ftp_fileid] } if [board_info $host exists hostname] { - set remotehost [board_info $host hostname]; + set remotehost [board_info $host hostname] } else { - set remotehost $host; + set remotehost $host } # LoseQVT tends to get stuck sometimes; we'll loop around a few million # times when it gets a "connection refused". - set spawn_id -1; - set count 3; + set spawn_id -1 + set count 3 while { $spawn_id < 0 && $count >= 0 } { - spawn ftp -n $remotehost; + spawn ftp -n $remotehost expect { -i $spawn_id -re ".*220.*$prompt" { } -i $spawn_id -re ".*Connection refused.*$prompt" { - sleep 2; - send "open $remotehost\n"; + sleep 2 + send "open $remotehost\n" exp_continue } -i $spawn_id default { - close -i $spawn_id; - wait -i $spawn_id; - set spawn_id -1; + close -i $spawn_id + wait -i $spawn_id + set spawn_id -1 } } - incr count -1; + incr count -1 } if { $spawn_id < 0 } { - return -1; + return -1 } - set board_info($host,ftp_fileid) $spawn_id; + set board_info($host,ftp_fileid) $spawn_id if [board_info $host exists ftp_username] { if [board_info $host exists ftp_password] { - set command "user [board_info $host ftp_username] [board_info $host ftp_password]\n"; + set command "user [board_info $host ftp_username] [board_info $host ftp_password]\n" } else { - set command "user [board_info $host ftp_username]\n"; + set command "user [board_info $host ftp_username]\n" } send "$command" expect { -i $spawn_id -re ".*230.*$prompt" { } -i $spawn_id default { - close -i $spawn_id; - wait -i $spawn_id; - return -1; + close -i $spawn_id + wait -i $spawn_id + return -1 } } } @@ -88,37 +88,37 @@ proc ftp_open { host } { expect { -i $spawn_id -re "200.*$prompt" { } -i $spawn_id timeout { - close -i $spawn_id; - wait -i $spawn_id; + close -i $spawn_id + wait -i $spawn_id return -1 } } if [board_info $host exists ftp_directory] { - send "cd [board_info $host ftp_directory]\n"; + send "cd [board_info $host ftp_directory]\n" expect { -i $spawn_id -re "250.*$prompt" { } -i $spawn_id default { - close -i $spawn_id; - wait -i $spawn_id; - return -1; + close -i $spawn_id + wait -i $spawn_id + return -1 } } } if [board_info $host exists ftp_no_passive] { - send "passive\n"; + send "passive\n" expect { -i $spawn_id -re "Passive mode off.*$prompt" { } -i $spawn_id -re "Passive mode on.*$prompt" { - send "passive\n"; - exp_continue; + send "passive\n" + exp_continue } -i $spawn_id -re ".*$prompt" { } } } - set board_info($host,ftp_fileid) $spawn_id; - return $spawn_id; + set board_info($host,ftp_fileid) $spawn_id + return $spawn_id } # @@ -129,39 +129,39 @@ proc ftp_upload { host remotefile localfile } { verbose "ftping $remotefile from $host to $localfile" set timeout 15 - set spawn_id [ftp_open $host]; + set spawn_id [ftp_open $host] if { $spawn_id < 0 } { - return ""; + return "" } - set loop 1; + set loop 1 while { $loop } { - send -i $spawn_id "get $remotefile $localfile\n"; + send -i $spawn_id "get $remotefile $localfile\n" expect { -i $spawn_id -re ".*Too many open files.*$prompt" { - ftp_close $host; + ftp_close $host } -i $spawn_id -re ".*No such file or directory.*$prompt" { - set loop 0; - set remotefile ""; + set loop 0 + set remotefile "" } -i $spawn_id -re "(^|\[\r\n\])226.*$prompt" { set loop 0; } -i $spawn_id -re "(^|\[\r\n\])\[0-9\]\[0-9\]\[0-9\].*$prompt" { - set loop 0; - set remotefile ""; + set loop 0 + set remotefile "" } -i $spawn_id default { - ftp_close $host; + ftp_close $host } } if { $loop } { - set spawn_id [ftp_open $host]; + set spawn_id [ftp_open $host] if { $spawn_id < 0 } { - return ""; + return "" } } } - return $localfile; + return $localfile } # @@ -173,53 +173,53 @@ proc ftp_download { host localfile remotefile } { verbose "putting $localfile $remotefile" if [board_info $host exists hostname] { - set remotehost [board_info $host hostname]; + set remotehost [board_info $host hostname] } else { - set remotehost $host; + set remotehost $host } - set spawn_id [ftp_open $host]; + set spawn_id [ftp_open $host] if { $spawn_id < 0 } { - return ""; + return "" } - set loop 1; + set loop 1 while { $loop } { send -i $spawn_id "put $localfile $remotefile\n" expect { -i $spawn_id -re ".*Too many open files.*$prompt" { - ftp_close $host; + ftp_close $host } -i $spawn_id -re ".*No such file or directory.*$prompt" { - set loop 0; - set remotefile ""; + set loop 0 + set remotefile "" } -re "(^|\[\r\n\])150.*connection for (.*) \[(\]\[0-9.,\]+\\)\[\r\n\]" { - set remotefile $expect_out(2,string); - exp_continue; + set remotefile $expect_out(2,string) + exp_continue } -i $spawn_id -re "(^|\[\r\n\])226.*$prompt" { - set loop 0; + set loop 0 } -i $spawn_id -re "Timeout.*$prompt" { - ftp_close $host; + ftp_close $host } -i $spawn_id -re "(^|\[\r\n\])\[0-9\]\[0-9\]\[0-9\].*$prompt" { - set loop 0; - set remotefile ""; + set loop 0 + set remotefile "" } -i $spawn_id default { - ftp_close $host; + ftp_close $host } } if { $loop } { - set spawn_id [ftp_open $host]; + set spawn_id [ftp_open $host] if { $spawn_id < 0 } { - return ""; + return "" } } } - return $remotefile; + return $remotefile } # @@ -229,18 +229,18 @@ proc ftp_close { host } { global board_info if [board_info $host exists name] { - set host [board_info $host name]; + set host [board_info $host name] } if ![board_info $host exists ftp_fileid] { - return ""; + return "" } - set spawn_id [board_info $host ftp_fileid]; - unset board_info($host,ftp_fileid); + set spawn_id [board_info $host ftp_fileid] + unset board_info($host,ftp_fileid) send -i $spawn_id "quit\n" close -i $spawn_id - wait -i $spawn_id; - return ""; + wait -i $spawn_id + return "" } diff --git a/lib/kermit.exp b/lib/kermit.exp index cd4e9d9..0d46bb8 100644 --- a/lib/kermit.exp +++ b/lib/kermit.exp @@ -29,17 +29,17 @@ proc kermit_open { dest args } { global board_info if [board_info $dest exists name] { - set dest [board_info $dest name]; + set dest [board_info $dest name] } if [board_info ${dest} exists serial] { - set port [board_info ${dest} serial]; + set port [board_info ${dest} serial] set device "-l [board_info ${dest} serial]" if [board_info ${dest} exists baud] { append device " -b [board_info ${dest} baud]" } } else { - set port [board_info ${dest} netport]; - set device "-j [board_info ${dest} netport]"; + set port [board_info ${dest} netport] + set device "-j [board_info ${dest} netport]" } set tries 0 @@ -91,7 +91,7 @@ proc kermit_open { dest args } { if { $result < 0 } { perror "Couldn't connect after $tries tries." if [info exists board_info($dest,fileid)] { - unset board_info($dest,fileid); + unset board_info($dest,fileid) } return -1 } else { @@ -110,43 +110,43 @@ proc kermit_open { dest args } { # proc kermit_command { dest args } { if [board_info $dest exists name] { - set dest [board_info $dest name]; + set dest [board_info $dest name] } - set shell_id [board_info $dest fileid]; + set shell_id [board_info $dest fileid] # Sometimes we have to send multiple ^\c sequences. Don't know # why. - set timeout 2; + set timeout 2 for { set i 1; } {$i<=5} {incr i} { - send -i $shell_id "c"; + send -i $shell_id "c" expect { -i $shell_id -re ".*Back at.*ermit.*>.*$" { set i 10;} -i $shell_id timeout { if { $i > 2 } { - warning "Unable to get prompt from kermit."; + warning "Unable to get prompt from kermit." } } } } foreach command $args { set timeout 120 - send -i $shell_id "${command}\r"; + send -i $shell_id "${command}\r" expect { -i $shell_id -re ".*ermit.*>.*$" { } -i $shell_id timeout { - perror "Response failed from kermit."; - return -1; + perror "Response failed from kermit." + return -1 } } } - send -i $shell_id "c\r"; + send -i $shell_id "c\r" expect { -i $shell_id -re ".*other options.\[\r\n\]+" { } -i $shell_id timeout { - perror "Unable to resume kermit connection."; - return -1; + perror "Unable to resume kermit connection." + return -1 } } - return 0; + return 0 } @@ -155,14 +155,14 @@ proc kermit_command { dest args } { # proc kermit_send { dest string args } { if [board_info $dest exists transmit_pause] { - set f [open "/tmp/fff" "w"]; - puts -nonewline $f "$string"; - close $f; - set result [remote_transmit $dest /tmp/fff]; - remote_file build delete "/tmp/fff"; - return "$result"; + set f [open "/tmp/fff" "w"] + puts -nonewline $f "$string" + close $f + set result [remote_transmit $dest /tmp/fff] + remote_file build delete "/tmp/fff" + return "$result" } else { - return [standard_send $dest $string]; + return [standard_send $dest $string] } } @@ -172,9 +172,9 @@ proc kermit_send { dest string args } { # proc kermit_transmit { dest file args } { if [board_info $dest exists transmit_pause] { - kermit_command $dest "transmit $file"; - return ""; + kermit_command $dest "transmit $file" + return "" } else { - return [standard_transmit $dest $file]; + return [standard_transmit $dest $file] } } diff --git a/lib/libgloss.exp b/lib/libgloss.exp index ebb9ed4..b075638 100644 --- a/lib/libgloss.exp +++ b/lib/libgloss.exp @@ -120,7 +120,7 @@ proc newlib_link_flags { args } { return "" } - set ld_script_path [lookfor_file ${tool_root_dir} "ld/ldscripts"]; + set ld_script_path [lookfor_file ${tool_root_dir} "ld/ldscripts"] if { $ld_script_path != "" } { set result "-L[file dirname $ld_script_path]" } else { @@ -176,21 +176,21 @@ proc libio_include_flags { args } { set gccpath "[get_multilibs]" if { $gccpath == "" } { - set gccpath "$tool_root_dir"; + set gccpath "$tool_root_dir" } - set libio_bin_dir [lookfor_file ${gccpath} libio/_G_config.h]; + set libio_bin_dir [lookfor_file ${gccpath} libio/_G_config.h] # linux doesn't build _G_config.h and the test above fails, so # we search for iostream.list too. if { $libio_bin_dir == "" } { - set libio_bin_dir [lookfor_file ${gccpath} libio/iostream.list]; + set libio_bin_dir [lookfor_file ${gccpath} libio/iostream.list] } set libio_src_dir [lookfor_file ${srcdir} libio/Makefile.in] if { $libio_bin_dir != "" && $libio_src_dir != "" } { set libio_src_dir [file dirname ${libio_src_dir}] - set libio_bin_dir [file dirname ${libio_bin_dir}]; + set libio_bin_dir [file dirname ${libio_bin_dir}] return " -isystem ${libio_src_dir} -isystem ${libio_bin_dir}" } else { return "" @@ -252,7 +252,7 @@ proc g++_link_flags { args } { global srcdir global ld_library_path - set gccpath [get_multilibs]; + set gccpath [get_multilibs] set libio_dir "" set flags "" set ld_library_path "." @@ -280,25 +280,25 @@ proc g++_link_flags { args } { append flags "-L${gccpath}/librx " } } else { - global tool_root_dir; + global tool_root_dir - set libgpp [lookfor_file ${tool_root_dir} libg++]; + set libgpp [lookfor_file ${tool_root_dir} libg++] if { $libgpp != "" } { - append flags "-L${libgpp} "; + append flags "-L${libgpp} " append ld_library_path ":${libgpp}" } - set libstdcpp [lookfor_file ${tool_root_dir} libstdc++]; + set libstdcpp [lookfor_file ${tool_root_dir} libstdc++] if { $libstdcpp != "" } { - append flags "-L${libstdcpp} "; + append flags "-L${libstdcpp} " append ld_library_path ":${libstdcpp}" } - set libiberty [lookfor_file ${tool_root_dir} libiberty]; + set libiberty [lookfor_file ${tool_root_dir} libiberty] if { $libiberty != "" } { - append flags "-L${libiberty} "; + append flags "-L${libiberty} " } - set librx [lookfor_file ${tool_root_dir} librx]; + set librx [lookfor_file ${tool_root_dir} librx] if { $librx != "" } { - append flags "-L${librx} "; + append flags "-L${librx} " } } return "$flags" @@ -341,7 +341,7 @@ proc libstdc++_link_flags { args } { global srcdir global ld_library_path - set gccpath [get_multilibs]; + set gccpath [get_multilibs] set libio_dir "" set flags "" @@ -357,20 +357,20 @@ proc libstdc++_link_flags { args } { append flags "-L${gccpath}/librx " } } else { - global tool_root_dir; + global tool_root_dir - set libstdcpp [lookfor_file ${tool_root_dir} libstdc++]; + set libstdcpp [lookfor_file ${tool_root_dir} libstdc++] if { $libstdcpp != "" } { - append flags "-L${libstdcpp} "; + append flags "-L${libstdcpp} " append ld_library_path ":${libstdcpp}" } - set libiberty [lookfor_file ${tool_root_dir} libiberty]; + set libiberty [lookfor_file ${tool_root_dir} libiberty] if { $libiberty != "" } { - append flags "-L${libiberty} "; + append flags "-L${libiberty} " } - set librx [lookfor_file ${tool_root_dir} librx]; + set librx [lookfor_file ${tool_root_dir} librx] if { $librx != "" } { - append flags "-L${librx} "; + append flags "-L${librx} " } } return "$flags" @@ -394,34 +394,34 @@ proc get_multilibs { args } { } if [info exists board] { - set target_board $board; + set target_board $board } else { - set target_board [target_info name]; + set target_board [target_info name] } if { [llength $args] == 0 } { if [board_info $target_board exists multitop] { - return "[board_info $target_board multitop]"; + return "[board_info $target_board multitop]" } set board_info($target_board,multitop) "" } if { [board_info $target_board exists compiler] } { - set compiler [board_info $target_board compiler]; + set compiler [board_info $target_board compiler] } else { - set compiler [find_gcc]; + set compiler [find_gcc] } if { $compiler == "" } { - return ""; + return "" } foreach x "$compiler" { if [regexp "^-B" "$x"] { - regsub "^-B" "$x" "" comp_base_dir; - set comp_base_dir [file dirname $comp_base_dir]; - break; + regsub "^-B" "$x" "" comp_base_dir + set comp_base_dir [file dirname $comp_base_dir] + break } } @@ -430,21 +430,21 @@ proc get_multilibs { args } { verbose "compiler is $compiler" if { [which $compiler] == 0 } { - return ""; + return "" } if { [llength $args] > 0 } { - set mopts [lindex $args 0]; + set mopts [lindex $args 0] } else { if { [board_info $target_board exists multilib_flags] } { - set mopts [board_info $target_board multilib_flags]; + set mopts [board_info $target_board multilib_flags] } else { set mopts "" } } set default_multilib [exec $compiler --print-multi-lib] - set default_multilib [lindex $default_multilib 0]; + set default_multilib [lindex $default_multilib 0] set extra [string trimleft $default_multilib ".;@@"] # extract the options and their directory names as know by gcc @@ -485,7 +485,7 @@ proc get_multilibs { args } { } if ![info exists comp_base_dir] { - set comp_base_dir [file dirname [file dirname [file dirname [file dirname [file dirname [exec $compiler --print-prog-name=cc1]]]]]]; + set comp_base_dir [file dirname [file dirname [file dirname [file dirname [file dirname [exec $compiler --print-prog-name=cc1]]]]]] } # search for the top level multilib directory @@ -495,21 +495,21 @@ proc get_multilibs { args } { if { $multitop == "" } { set multitop "[lookfor_file ${comp_base_dir} gcc/xgcc]" if { $multitop != "" } { - set multitop [file dirname [file dirname $multitop]]; + set multitop [file dirname [file dirname $multitop]] } else { return "" } } } - set gccpath [eval exec "$compiler" --print-multi-directory $mopts]; - set gccpath [lindex $gccpath 0]; + set gccpath [eval exec "$compiler" --print-multi-directory $mopts] + set gccpath [lindex $gccpath 0] if { $gccpath != "" } { - verbose "GCC path is $gccpath"; + verbose "GCC path is $gccpath" if { [llength $args] == 0 } { set board_info($target_board,multitop) "$multitop/$gccpath" } - return "$multitop/$gccpath"; + return "$multitop/$gccpath" } # extract the MULTILIB_MATCHES from dumpspecs @@ -553,10 +553,10 @@ proc get_multilibs { args } { # compare the lists of gcc options with the list of support multilibs verbose "Supported multilibs are: $multilibs" 3 - set best 0; + set best 0 foreach i "$multilibs" { set hits 0 - set opts [lindex $i 1]; + set opts [lindex $i 1] if { [llength $opts] <= [llength $moptions] } { foreach j "$moptions" { # see if all the -m<foo> options match any of the multilibs @@ -569,12 +569,12 @@ proc get_multilibs { args } { if { $hits > $best } { verbose "[lindex $i 0] is better, using as gcc path" 2 set gccpath "[lindex $i 0]" - set best $hits; + set best $hits } } } if ![info exists multitop] { - return ""; + return "" } verbose "gccpath is $gccpath" 3 @@ -595,105 +595,105 @@ proc get_multilibs { args } { } proc find_binutils_prog { name } { - global tool_root_dir; + global tool_root_dir if ![is_remote host] { - set file [lookfor_file $tool_root_dir $name]; + set file [lookfor_file $tool_root_dir $name] if { $file == "" } { - set file [lookfor_file $tool_root_dir ${name}-new]; + set file [lookfor_file $tool_root_dir ${name}-new] } if { $file == "" } { - set file [lookfor_file $tool_root_dir binutils/$name]; + set file [lookfor_file $tool_root_dir binutils/$name] } if { $file == "" } { - set file [lookfor_file $tool_root_dir binutils/${name}-new]; + set file [lookfor_file $tool_root_dir binutils/${name}-new] } if { $file != "" } { - set NAME "$file"; + set NAME "$file" } else { - set NAME [transform $name]; + set NAME [transform $name] } } else { set NAME [transform $name] } - return $NAME; + return $NAME } proc find_gcc {} { global tool_root_dir if ![is_remote host] { - set file [lookfor_file $tool_root_dir xgcc]; + set file [lookfor_file $tool_root_dir xgcc] if { $file == "" } { - set file [lookfor_file $tool_root_dir gcc/xgcc]; + set file [lookfor_file $tool_root_dir gcc/xgcc] } if { $file != "" } { - set CC "$file -B[file dirname $file]/"; + set CC "$file -B[file dirname $file]/" } else { - set CC [transform gcc]; + set CC [transform gcc] } } else { set CC [transform gcc] } - return $CC; + return $CC } proc find_gcj {} { global tool_root_dir if ![is_remote host] { - set file [lookfor_file $tool_root_dir gcj]; + set file [lookfor_file $tool_root_dir gcj] if { $file == "" } { - set file [lookfor_file $tool_root_dir gcc/gcj]; + set file [lookfor_file $tool_root_dir gcc/gcj] } if { $file != "" } { - set CC "$file -B[file dirname $file]/"; + set CC "$file -B[file dirname $file]/" } else { - set CC [transform gcj]; + set CC [transform gcj] } } else { set CC [transform gcj] } - return $CC; + return $CC } proc find_g++ {} { global tool_root_dir if ![is_remote host] { - set file [lookfor_file $tool_root_dir g++]; + set file [lookfor_file $tool_root_dir g++] if { $file == "" } { - set file [lookfor_file $tool_root_dir gcc/g++]; + set file [lookfor_file $tool_root_dir gcc/g++] } if { $file != "" } { - set CC "$file -B[file dirname $file]/"; + set CC "$file -B[file dirname $file]/" } else { - set CC [transform g++]; + set CC [transform g++] } } else { set CC [transform g++] } - return $CC; + return $CC } proc find_g77 {} { global tool_root_dir if ![is_remote host] { - set file [lookfor_file $tool_root_dir g77]; + set file [lookfor_file $tool_root_dir g77] if { $file == "" } { - set file [lookfor_file $tool_root_dir gcc/g77]; + set file [lookfor_file $tool_root_dir gcc/g77] } if { $file != "" } { - set CC "$file -B[file dirname $file]/"; + set CC "$file -B[file dirname $file]/" } else { - set CC [transform g77]; + set CC [transform g77] } } else { set CC [transform g77] } - return $CC; + return $CC } proc find_nm {} { @@ -707,77 +707,77 @@ proc find_nm {} { } } if { $NM == ""} { - set NM [transform nm]; + set NM [transform nm] } - return $NM; + return $NM } proc process_multilib_options { args } { - global board; - global board_variant_list; - global is_gdb_remote; + global board + global board_variant_list + global is_gdb_remote - set is_gdb_remote 0; + set is_gdb_remote 0 if [board_info $board exists multilib_flags] { - return; + return } - eval add_multilib_option $args; + eval add_multilib_option $args - set multilib_flags ""; + set multilib_flags "" foreach x $board_variant_list { - regsub -all "^\[ \t\]*" "$x" "" x; - regsub -all "\[ \t\]*$" "$x" "" x; + regsub -all "^\[ \t\]*" "$x" "" x + regsub -all "\[ \t\]*$" "$x" "" x if { $x == "" } { - continue; + continue } case $x in { { aout } { - set_board_info obj_format "a.out"; + set_board_info obj_format "a.out" } { elf } { - set_board_info obj_format "elf"; + set_board_info obj_format "elf" } { pe } { - set_board_info obj_format "pe"; + set_board_info obj_format "pe" } { ecoff } { - set_board_info obj_format "ecoff"; + set_board_info obj_format "ecoff" } { stabs } { - set_board_info debug_flags "-gstabs"; + set_board_info debug_flags "-gstabs" } { dwarf2 } { - set_board_info debug_flags "-gdwarf2"; + set_board_info debug_flags "-gdwarf2" } { gdb:*=* } { - regsub "^gdb:\[^=\]*=(.*)$" "$x" "\\1" value; - regsub "^gdb:(\[^=\]*)=.*$" "$x" "\\1" variable; - set_board_info $variable "$value"; + regsub "^gdb:\[^=\]*=(.*)$" "$x" "\\1" value + regsub "^gdb:(\[^=\]*)=.*$" "$x" "\\1" variable + set_board_info $variable "$value" } { gdb*remote } { - set is_gdb_remote 1; + set is_gdb_remote 1 } { little*endian el EL } { - append multilib_flags " -EL"; + append multilib_flags " -EL" } { big*endian eb EB } { - append multilib_flags " -EB"; + append multilib_flags " -EB" } { "soft*float" } { append multilib_flags " -msoft-float" } { "-*" } { - append multilib_flags " $x"; + append multilib_flags " $x" } default { - append multilib_flags " -m$x"; + append multilib_flags " -m$x" } } } - set_board_info multilib_flags $multilib_flags; + set_board_info multilib_flags $multilib_flags } proc add_multilib_option { args } { @@ -786,7 +786,7 @@ proc add_multilib_option { args } { if ![info exists board_variant_list] { set board_variant_list "" } - set board_variant_list [concat $args $board_variant_list]; + set board_variant_list [concat $args $board_variant_list] } proc find_gas { } { @@ -795,15 +795,15 @@ proc find_gas { } { set AS "" if ![is_remote host] { - set AS [lookfor_file $tool_root_dir as-new]; + set AS [lookfor_file $tool_root_dir as-new] if { $AS == "" } { - set AS [lookfor_file $tool_root_dir gas/as-new]; + set AS [lookfor_file $tool_root_dir gas/as-new] } } if { $AS == "" } { - set AS [transform as]; + set AS [transform as] } - return $AS; + return $AS } proc find_ld { } { @@ -812,15 +812,15 @@ proc find_ld { } { set LD "" if ![is_remote host] { - set LD [lookfor_file $tool_root_dir ld-new]; + set LD [lookfor_file $tool_root_dir ld-new] if { $LD == "" } { - set LD [lookfor_file $tool_root_dir ld/ld-new]; + set LD [lookfor_file $tool_root_dir ld/ld-new] } } if { $LD == "" } { - set LD [transform ld]; + set LD [transform ld] } - return $LD; + return $LD } proc build_wrapper { gluefile } { @@ -828,28 +828,28 @@ proc build_wrapper { gluefile } { global tool if [target_info exists wrap_m68k_aout] { - set flags "additional_flags=-DWRAP_M68K_AOUT"; - set result ""; + set flags "additional_flags=-DWRAP_M68K_AOUT" + set result "" } elseif [target_info exists uses_underscores] { - set flags "additional_flags=-DUNDERSCORES"; - set result "-Wl,-wrap,_exit -Wl,-wrap,__exit -Wl,-wrap,_main -Wl,-wrap,_abort"; + set flags "additional_flags=-DUNDERSCORES" + set result "-Wl,-wrap,_exit -Wl,-wrap,__exit -Wl,-wrap,_main -Wl,-wrap,_abort" } else { - set flags ""; + set flags "" if [target_info exists is_vxworks] { - set flags "additional_flags=-DVXWORKS"; - set result "-Wl,-wrap,exit -Wl,-wrap,main -Wl,-wrap,abort"; - set result "-Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main -Wl,-wrap,abort"; + set flags "additional_flags=-DVXWORKS" + set result "-Wl,-wrap,exit -Wl,-wrap,main -Wl,-wrap,abort" + set result "-Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main -Wl,-wrap,abort" } else { - set result "-Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main -Wl,-wrap,abort"; + set result "-Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main -Wl,-wrap,abort" } } if [target_info exists wrap_compile_flags] { - lappend flags "additional_flags=[target_info wrap_compile_flags]"; + lappend flags "additional_flags=[target_info wrap_compile_flags]" } if { [target_compile ${libdir}/testglue.c ${gluefile} object $flags] == "" } { - set gluefile [remote_download host ${gluefile} ${tool}_tg.o]; - return [list $gluefile $result]; + set gluefile [remote_download host ${gluefile} ${tool}_tg.o] + return [list $gluefile $result] } else { return "" } diff --git a/lib/mondfe.exp b/lib/mondfe.exp index add4597..82486fe 100644 --- a/lib/mondfe.exp +++ b/lib/mondfe.exp @@ -35,24 +35,24 @@ proc mondfe_open { hostname } { set shell_prompt [board_info $hostname shell_prompt] if ![board_info $hostname exists mondfe,name] { perror "Must set board_info(${hostname},mondfe,name)" - return -1; + return -1 } if [board_info $hostname exists mondfe] { - set mondfe [board_info $hostname mondfe]; + set mondfe [board_info $hostname mondfe] } else { set mondfe "mondfe" } - set remote_host [board_info $hostname mondfe,name]; + set remote_host [board_info $hostname mondfe,name] if [board_info $hostname exists mondfe_host] { - set rh [board_info $hostname mondfe_host]; + set rh [board_info $hostname mondfe_host] } else { verbose "Attempting to connect to $hostname via mondfe." - set rh "host"; + set rh "host" } - set shell_id [remote_spawn $rh "$mondfe -D -TIP $remote_host"]; + set shell_id [remote_spawn $rh "$mondfe -D -TIP $remote_host"] remote_expect $rh 60 { "$shell_prompt" { @@ -63,16 +63,16 @@ proc mondfe_open { hostname } { warning "Socket file already exists." incr retries if { $retries <= 2 } { - exp_continue; + exp_continue } } -indices -re ".*(UDIERROR\[^\r\n\]*)\[\r\n\]" { warning "$expect_out(1,string)" - exp_continue; + exp_continue } -indices -re ".*(DFEERROR\[^\r\n\]*)\[\r\n\]" { warning "$expect_out(1,string)" - exp_continue; + exp_continue } timeout { warning "Timed out trying to connect." @@ -80,18 +80,18 @@ proc mondfe_open { hostname } { incr retries if { $retries <= 2 } { remote_send $rh "\n" - exp_continue; + exp_continue } } } if { $result < 0 } { perror "Couldn't connect after $retries retries." - remote_close $rh; + remote_close $rh return -1 } else { - set board_info($hostname,fileid) $shell_id; - return $shell_id; + set board_info($hostname,fileid) $shell_id + return $shell_id } } @@ -112,10 +112,10 @@ proc mondfe_ld { dest_machine file } { set shell_prompt [board_info $dest_machine shell_prompt] if [board_info $dest_machine exists mondfe_host] { - set remote_host [board_info $dest_machine mondfe_host]; + set remote_host [board_info $dest_machine mondfe_host] set file [remote_download $remote_host $file montest] } else { - set remote_host "host"; + set remote_host "host" } verbose "Downloading $file." 2 @@ -124,26 +124,26 @@ proc mondfe_ld { dest_machine file } { remote_send $remote_host "y $file\n" remote_expect $remote_host 60 { "y $file" { - exp_continue; + exp_continue } -re "loading $file\[\r\n\]+" { - exp_continue; + exp_continue } -re "Load(ing|ed) *TEXT section from\[^\r\n\]*\[\r\n\]+" { verbose -n "." 2 - exp_continue; + exp_continue } -re "Load(ing|ed) *LIT section from\[^\r\n\]*\[\r\n\]+" { verbose -n "." 2 - exp_continue; + exp_continue } -re "Load(ing|ed) *DATA section from\[^\r\n\]*\[\r\n\]+" { verbose -n "." 2 - exp_continue; + exp_continue } -re "Clear(ing|ed) *BSS section from\[^\r\n\]*\[\r\n\]+" { verbose -n "." 2 - exp_continue; + exp_continue } -re "(^|\[\r\n\]+)$shell_prompt$" { verbose "Downloaded $file successfully." 2 @@ -158,7 +158,7 @@ proc mondfe_ld { dest_machine file } { } -re "Ignoring COMMENT section \($decimal bytes\)\[^\r\n\]*\[\r\n\]+" { verbose "Ignoring COMMENT section" 2 - exp_continue; + exp_continue } timeout { perror "Timed out trying to download $file." @@ -184,13 +184,13 @@ proc mondfe_close { hostname } { global board_info if [board_info $hostname exists mondfe_host] { - set remote_host [board_info $hostname mondfe_host]; + set remote_host [board_info $hostname mondfe_host] } else { - set remote_host "host"; + set remote_host "host" } if ![board_info $hostname exists fileid] { - return 0; + return 0 } if [board_info $remote_host exists fileid] { @@ -204,10 +204,10 @@ proc mondfe_close { hostname } { } } - remote_close $remote_host; + remote_close $remote_host } - unset board_info($hostname,fileid); + unset board_info($hostname,fileid) - return 0; + return 0 } diff --git a/lib/remote.exp b/lib/remote.exp index 7a1db84..6c11554 100644 --- a/lib/remote.exp +++ b/lib/remote.exp @@ -50,14 +50,14 @@ proc remote_open { args } { # Shudder... if { $reboot && $type == "target" } { - reboot_target; + reboot_target } - return [call_remote "" open $type]; + return [call_remote "" open $type] } proc remote_raw_open { args } { - return [eval call_remote raw open $args]; + return [eval call_remote raw open $args] } # Run the specified COMMANDLINE on the local machine, redirecting input @@ -75,7 +75,7 @@ proc remote_raw_open { args } { # the kill command will be invoked. # proc local_exec { commandline inp outp timeout } { - # TCL's exec is a pile of crap. It does two very inappropriate things; + # TCL's exec is a pile of crap. It does two very inappropriate things # firstly, it has no business returning an error if the program being # executed happens to write to stderr. Secondly, it appends its own # error messages to the output of the command if the process exits with @@ -92,84 +92,84 @@ proc local_exec { commandline inp outp timeout } { # no way to timeout programs that hang. *sigh* # if { "$inp" == "" && "$outp" == "" } { - set id -1; - set result [catch "eval spawn \{${commandline}\}" pid]; + set id -1 + set result [catch "eval spawn \{${commandline}\}" pid] if { $result == 0 } { - set result2 0; + set result2 0 } else { - set pid 0; - set result2 5; + set pid 0 + set result2 5 } } else { # Can you say "uuuuuugly"? I knew you could! # All in the name of non-infinite hangs. if { $inp != "" } { - set inp "< $inp"; - set mode "r"; + set inp "< $inp" + set mode "r" } else { - set mode "w"; + set mode "w" } - set use_tee 0; + set use_tee 0 # We add |& cat so that TCL exec doesn't freak out if the # program writes to stderr. if { $outp == "" } { set outp "|& cat" } else { - set outpf "$outp"; + set outpf "$outp" set outp "> $outp" if { $inp != "" } { - set use_tee 1; + set use_tee 1 } } # Why do we use tee? Because open can't redirect both input and output. if { $use_tee } { - set result [catch {open "| ${commandline} $inp |& tee $outpf" RDONLY} id] ; + set result [catch {open "| ${commandline} $inp |& tee $outpf" RDONLY} id] } else { - set result [catch {open "| ${commandline} $inp $outp" $mode} id] ; + set result [catch {open "| ${commandline} $inp $outp" $mode} id] } if { $result != 0 } { global errorInfo - return [list -1 "open of $commandline $inp $outp failed: $errorInfo"]; + return [list -1 "open of $commandline $inp $outp failed: $errorInfo"] } - set pid [pid $id]; - set result [catch "spawn -leaveopen $id" result2]; + set pid [pid $id] + set result [catch "spawn -leaveopen $id" result2] } # Prepend "-" to each pid, to generate the "process group IDs" needed by # kill. - set pgid "-[join $pid { -}]"; - verbose "pid is $pid $pgid"; + set pgid "-[join $pid { -}]" + verbose "pid is $pid $pgid" if { $result != 0 || $result2 != 0 } { # This shouldn't happen. - global errorInfo; + global errorInfo if [info exists errorInfo] { - set foo $errorInfo; + set foo $errorInfo } else { - set foo ""; + set foo "" } - verbose "spawn -open $id failed, $result $result2, $foo"; - catch "close $id"; - return [list -1 "spawn failed"]; + verbose "spawn -open $id failed, $result $result2, $foo" + catch "close $id" + return [list -1 "spawn failed"] } - set got_eof 0; - set output ""; + set got_eof 0 + set output "" # Wait for either $timeout seconds to elapse, or for the program to # exit. expect { -i $spawn_id -timeout $timeout -re ".+" { - append output $expect_out(buffer); + append output $expect_out(buffer) if { [string length $output] < 512000 } { - exp_continue -continue_timer; + exp_continue -continue_timer } } timeout { - warning "program timed out."; + warning "program timed out." } eof { - set got_eof 1; + set got_eof 1 } } @@ -178,51 +178,51 @@ proc local_exec { commandline inp outp timeout } { # However, TCL has no kill primitive, so we have to execute an external # command in order to execute the execution. (English. Gotta love it.) if { ! $got_eof } { - verbose "killing $pid $pgid"; + verbose "killing $pid $pgid" # This is very, very nasty. SH, instead of EXPECT, is used to # run this in the background since, on older CYGWINs, a # strange file I/O error occures. - exec sh -c "exec > /dev/null 2>&1 && (kill -2 $pgid || kill -2 $pid) && sleep 5 && (kill -15 $pgid || kill $pid) && sleep 5 && (kill -9 $pgid || kill -9 $pid) &"; + exec sh -c "exec > /dev/null 2>&1 && (kill -2 $pgid || kill -2 $pid) && sleep 5 && (kill -15 $pgid || kill $pid) && sleep 5 && (kill -9 $pgid || kill -9 $pid) &" } # This will hang if the kill doesn't work. Nothin' to do, and it's not ok. - catch "close -i $spawn_id"; - set r2 [catch "wait -i $spawn_id" wres]; + catch "close -i $spawn_id" + set r2 [catch "wait -i $spawn_id" wres] if { $id > 0 } { - set r2 [catch "close $id" res]; + set r2 [catch "close $id" res] } else { - verbose "waitres is $wres" 2; + verbose "waitres is $wres" 2 if { $r2 == 0 } { - set r2 [lindex $wres 3]; + set r2 [lindex $wres 3] if { [llength $wres] > 4 } { if { [lindex $wres 4] == "CHILDKILLED" } { - set r2 1; + set r2 1 } } if { $r2 != 0 } { - set res "$wres"; + set res "$wres" } else { - set res ""; + set res "" } } else { - set res "wait failed"; + set res "wait failed" } } if { $r2 != 0 || $res != "" || ! $got_eof } { - verbose "close result is $res"; - set status 1; + verbose "close result is $res" + set status 1 } else { - set status 0; + set status 0 } - verbose "output is $output"; + verbose "output is $output" if { $outp == "" } { - return [list $status $output]; + return [list $status $output] } else { - return [list $status ""]; + return [list $status ""] } } # -# Execute the supplied program on HOSTNAME. There are four optional arguments; +# Execute the supplied program on HOSTNAME. There are four optional arguments # the first is a set of arguments to pass to PROGRAM, the second is an # input file to feed to stdin of PROGRAM, the third is the name of an # output file where the output from PROGRAM should be written, and @@ -236,42 +236,42 @@ proc local_exec { commandline inp outp timeout } { # proc remote_exec { hostname program args } { if { [llength $args] > 0 } { - set pargs [lindex $args 0]; + set pargs [lindex $args 0] } else { set pargs "" } if { [llength $args] > 1 } { - set inp "[lindex $args 1]"; + set inp "[lindex $args 1]" } else { set inp "" } if { [llength $args] > 2 } { - set outp "[lindex $args 2]"; + set outp "[lindex $args 2]" } else { set outp "" } # 300 is probably a lame default. if { [llength $args] > 3 } { - set timeout "[lindex $args 3]"; + set timeout "[lindex $args 3]" } else { set timeout 300 } - verbose -log "Executing on $hostname: $program $pargs $inp $outp (timeout = $timeout)" 2; + verbose -log "Executing on $hostname: $program $pargs $inp $outp (timeout = $timeout)" 2 # Run it locally if appropriate. if { ![is_remote $hostname] } { - return [local_exec "$program $pargs" $inp $outp $timeout]; + return [local_exec "$program $pargs" $inp $outp $timeout] } else { - return [call_remote "" exec $hostname $program $pargs $inp $outp]; + return [call_remote "" exec $hostname $program $pargs $inp $outp] } } proc standard_exec { hostname args } { - return [eval rsh_exec \"$hostname\" $args]; + return [eval rsh_exec \"$hostname\" $args] } # @@ -282,57 +282,57 @@ proc standard_exec { hostname args } { proc remote_close { host } { while { 1 } { - set result [call_remote "" close "$host"]; + set result [call_remote "" close "$host"] if { [remote_pop_conn $host] != "pass" } { - break; + break } } - return $result; + return $result } proc remote_raw_close { host } { - return [call_remote raw close "$host"]; + return [call_remote raw close "$host"] } proc standard_close { host } { global board_info if [board_info ${host} exists fileid] { - set shell_id [board_info ${host} fileid]; - set pid -1; + set shell_id [board_info ${host} fileid] + set pid -1 verbose "Closing the remote shell $shell_id" 2 if [board_info ${host} exists fileid_origid] { - set oid [board_info ${host} fileid_origid]; - set pid [pid $oid]; - unset board_info(${host},fileid_origid); + set oid [board_info ${host} fileid_origid] + set pid [pid $oid] + unset board_info(${host},fileid_origid) } else { - set result [catch "exp_pid -i $shell_id" pid]; + set result [catch "exp_pid -i $shell_id" pid] if { $result != 0 || $pid <= 0 } { - set result [catch "pid $shell_id" pid]; + set result [catch "pid $shell_id" pid] if { $result != 0 } { - set pid -1; + set pid -1 } } } if { $pid > 0 } { - verbose "doing kill, pid is $pid"; + verbose "doing kill, pid is $pid" # This is very, very nasty. SH, instead of EXPECT, is used # to run this in the background since, on older CYGWINs, a # strange file I/O error occures. - set pgid "-[join $pid { -}]"; - exec sh -c "exec > /dev/null 2>&1 && (kill -2 $pgid || kill -2 $pid) && sleep 5 && (kill $pgid || kill $pid) && sleep 5 && (kill -9 $pgid || kill -9 $pid) &"; + set pgid "-[join $pid { -}]" + exec sh -c "exec > /dev/null 2>&1 && (kill -2 $pgid || kill -2 $pid) && sleep 5 && (kill $pgid || kill $pid) && sleep 5 && (kill -9 $pgid || kill -9 $pid) &" } - verbose "pid is $pid"; - catch "close -i $shell_id"; + verbose "pid is $pid" + catch "close -i $shell_id" if [info exists oid] { - catch "close $oid"; + catch "close $oid" } - catch "wait -i $shell_id"; - unset board_info(${host},fileid); - verbose "Shell closed."; + catch "wait -i $shell_id" + unset board_info(${host},fileid) + verbose "Shell closed." } - return 0; + return 0 } # @@ -340,32 +340,32 @@ proc standard_close { host } { # characters. # proc remote_binary { host } { - return [call_remote "" binary "$host"]; + return [call_remote "" binary "$host"] } proc remote_raw_binary { host } { - return [call_remote raw binary "$host"]; + return [call_remote raw binary "$host"] } proc remote_reboot { host } { - clone_output "\nRebooting ${host}\n"; + clone_output "\nRebooting ${host}\n" # FIXME: don't close the host connection, or all the remote # procedures will fail. - # remote_close $host; - set status [call_remote "" reboot "$host"]; + # remote_close $host + set status [call_remote "" reboot "$host"] if [board_info $host exists name] { - set host [board_info $host name]; + set host [board_info $host name] } if { [info proc ${host}_init] != "" } { - ${host}_init $host; + ${host}_init $host } - return $status; + return $status } proc standard_reboot { host } { - return ""; + return "" } # # Download file FILE to DEST. If the optional DESTFILE is specified, @@ -376,16 +376,16 @@ proc standard_reboot { host } { proc remote_download { dest file args } { if { [llength $args] > 0 } { - set destfile [lindex $args 0]; + set destfile [lindex $args 0] } else { - set destfile [file tail $file]; + set destfile [file tail $file] } if { ![is_remote $dest] } { if { $destfile == "" || $destfile == $file } { - return $file; + return $file } else { - set result [catch "exec cp -p $file $destfile" output]; + set result [catch "exec cp -p $file $destfile" output] if [regexp "same file|are identical" $output] { set result 0 set output "" @@ -396,14 +396,14 @@ proc remote_download { dest file args } { } if { $result != 0 || $output != "" } { perror "remote_download to $dest of $file to $destfile: $output" - return ""; + return "" } else { - return $destfile; + return $destfile } } } - return [call_remote "" download $dest $file $destfile]; + return [call_remote "" download $dest $file $destfile] } # @@ -416,23 +416,23 @@ proc standard_download {dest file destfile} { if [board_info $dest exists nfsdir] { set destdir [board_info $dest nfsdir] if [board_info $dest exists nfsroot_server] { - set dest [board_info $dest nfsroot_server]; + set dest [board_info $dest nfsroot_server] } else { - set dest ""; + set dest "" } - set destfile "$destdir/$destfile"; + set destfile "$destdir/$destfile" } if { "$dest" != "" } { - set result [rsh_download $dest $file $destfile]; + set result [rsh_download $dest $file $destfile] if { $result == $destfile } { - return $orig_destfile; + return $orig_destfile } else { - return $result; + return $result } } - set result [catch "exec cp -p $file $destfile" output]; + set result [catch "exec cp -p $file $destfile" output] if [regexp "same file|are identical" $output] { set result 0 set output "" @@ -443,28 +443,28 @@ proc standard_download {dest file destfile} { } if { $result != 0 || $output != "" } { perror "remote_download to $dest of $file to $destfile: $output" - return ""; + return "" } else { - return $orig_destfile; + return $orig_destfile } } proc remote_upload {dest srcfile args} { if { [llength $args] > 0 } { - set destfile [lindex $args 0]; + set destfile [lindex $args 0] } else { - set destfile [file tail $srcfile]; + set destfile [file tail $srcfile] } if { ![is_remote $dest] } { if { $destfile == "" || $srcfile == $destfile } { - return $srcfile; + return $srcfile } - set result [catch "exec cp -p $srcfile $destfile" output]; - return $destfile; + set result [catch "exec cp -p $srcfile $destfile" output] + return $destfile } - return [call_remote "" upload $dest $srcfile $destfile]; + return [call_remote "" upload $dest $srcfile $destfile] } proc standard_upload { dest srcfile destfile } { @@ -473,18 +473,18 @@ proc standard_upload { dest srcfile destfile } { if [board_info $dest exists nfsdir] { set destdir [board_info $dest nfsdir] if [board_info $dest exists nfsroot_server] { - set dest [board_info $dest nfsroot_server]; + set dest [board_info $dest nfsroot_server] } else { - set dest ""; + set dest "" } - set srcfile "$destdir/$srcfile"; + set srcfile "$destdir/$srcfile" } if { "$dest" != "" } { - return [rsh_upload $dest $srcfile $destfile]; + return [rsh_upload $dest $srcfile $destfile] } - set result [catch "exec cp -p $srcfile $destfile" output]; + set result [catch "exec cp -p $srcfile $destfile" output] if [regexp "same file|are identical" $output] { set result 0 set output "" @@ -495,12 +495,12 @@ proc standard_upload { dest srcfile destfile } { } if { $result != 0 || $output != "" } { perror "remote_upload to $dest of $file to $destfile: $output" - return ""; + return "" } else { - return $destfile; + return $destfile } - return [rsh_upload $dest $srcfile $destfile]; + return [rsh_upload $dest $srcfile $destfile] } # @@ -511,26 +511,26 @@ proc standard_upload { dest srcfile destfile } { proc call_remote { type proc dest args } { if [board_info $dest exists name] { - set dest [board_info $dest name]; + set dest [board_info $dest name] } if { $dest != "host" && $dest != "build" && $dest != "target" } { if { ![board_info $dest exists name] } { - global board; + global board if [info exists board] { blooie } - load_board_description $dest; + load_board_description $dest } } set high_prot "" if { $type != "raw" } { if [board_info $dest exists protocol] { - set high_prot "${dest} [board_info $dest protocol]"; + set high_prot "${dest} [board_info $dest protocol]" } else { - set high_prot "${dest} [board_info $dest generic_name]"; + set high_prot "${dest} [board_info $dest generic_name]" } } @@ -541,31 +541,31 @@ proc call_remote { type proc dest args } { if { $try != "" } { if { [info proc "${try}_${proc}"] != "" } { verbose "call_remote calling ${try}_${proc}" 3 - set result [eval ${try}_${proc} \"$dest\" $args]; - break; + set result [eval ${try}_${proc} \"$dest\" $args] + break } } } set ft "[board_info $dest file_transfer]" if { [info proc "${ft}_${proc}"] != "" } { verbose "calling ${ft}_${proc} $dest $args" 3 - set result2 [eval ${ft}_${proc} \"$dest\" $args]; + set result2 [eval ${ft}_${proc} \"$dest\" $args] } if ![info exists result] { if [info exists result2] { - set result $result2; + set result $result2 } else { - set result ""; + set result "" } } - return $result; + return $result } foreach try "${high_prot} [board_info $dest file_transfer] [board_info $dest connect] telnet standard" { verbose "looking for ${try}_${proc}" 4 if { $try != "" } { if { [info proc "${try}_${proc}"] != "" } { verbose "call_remote calling ${try}_${proc}" 3 - return [eval ${try}_${proc} \"$dest\" $args]; + return [eval ${try}_${proc} \"$dest\" $args] } } } @@ -573,18 +573,18 @@ proc call_remote { type proc dest args } { return "" } error "No procedure for '$proc' in call_remote" - return -1; + return -1 } # # Send FILE through the existing session established to DEST. # proc remote_transmit { dest file } { - return [call_remote "" transmit "$dest" "$file"]; + return [call_remote "" transmit "$dest" "$file"] } proc remote_raw_transmit { dest file } { - return [call_remote raw transmit "$dest" "$file"]; + return [call_remote raw transmit "$dest" "$file"] } # @@ -593,17 +593,17 @@ proc remote_raw_transmit { dest file } { # proc standard_transmit {dest file} { if [board_info ${dest} exists name] { - set dest [board_info ${dest} name]; + set dest [board_info ${dest} name] } if [board_info ${dest} exists baud] { - set baud [board_info ${dest} baud]; + set baud [board_info ${dest} baud] } else { - set baud 9600; + set baud 9600 } - set shell_id [board_info ${dest} fileid]; + set shell_id [board_info ${dest} fileid] set lines 0 - set chars 0; + set chars 0 set fd [open $file r] while { [gets $fd cur_line] >= 0 } { set errmess "" @@ -615,7 +615,7 @@ proc standard_transmit {dest file} { } set chars [expr $chars + ([string length $cur_line] * 10)] if { $chars > $baud } { - sleep 1; + sleep 1 set chars 0 } verbose "." 3 @@ -628,43 +628,43 @@ proc standard_transmit {dest file} { } proc remote_send { dest string } { - return [call_remote "" send "$dest" "$string"]; + return [call_remote "" send "$dest" "$string"] } proc remote_raw_send { dest string } { - return [call_remote raw send "$dest" "$string"]; + return [call_remote raw send "$dest" "$string"] } proc standard_send { dest string } { if ![board_info $dest exists fileid] { perror "no fileid for $dest" - return "no fileid for $dest"; + return "no fileid for $dest" } else { set shell_id [board_info $dest fileid] verbose "shell_id in standard_send is $shell_id" 3 verbose "send -i [board_info $dest fileid] -- {$string}" 3 if [catch "send -i [board_info $dest fileid] -- {$string}" errorInfo] { - return "$errorInfo"; + return "$errorInfo" } else { - return ""; + return "" } } } proc file_on_host { op file args } { - return [eval remote_file host \"$op\" \"$file\" $args]; + return [eval remote_file host \"$op\" \"$file\" $args] } proc file_on_build { op file args } { - return [eval remote_file build \"$op\" \"$file\" $args]; + return [eval remote_file build \"$op\" \"$file\" $args] } proc remote_file { dest args } { - return [eval call_remote \"\" file \"$dest\" $args]; + return [eval call_remote \"\" file \"$dest\" $args] } proc remote_raw_file { dest args } { - return [eval call_remote raw file \"$dest\" $args]; + return [eval call_remote raw file \"$dest\" $args] } # @@ -672,68 +672,68 @@ proc remote_raw_file { dest args } { # proc standard_file { dest op args } { - set file [lindex $args 0]; - verbose "dest in proc standard_file is $dest" 3; + set file [lindex $args 0] + verbose "dest in proc standard_file is $dest" 3 if { ![is_remote $dest] } { switch $op { cmp { - set otherfile [lindex $args 1]; + set otherfile [lindex $args 1] if { [file exists $file] && [file exists $otherfile] && [file size $file] == [file size $otherfile] } { - set r [remote_exec build cmp "$file $otherfile"]; + set r [remote_exec build cmp "$file $otherfile"] if { [lindex $r 0] == 0 } { - return 0; + return 0 } } - return 1; + return 1 } tail { - return [file tail $file]; + return [file tail $file] } dirname { if { [file pathtype $file] == "relative" } { - set file [remote_file $dest absolute $file]; + set file [remote_file $dest absolute $file] } - set result [file dirname $file]; + set result [file dirname $file] if { $result == "" } { - return "/"; + return "/" } - return $result; + return $result } join { - return [file join [lindex $args 0] [lindex $args 1]]; + return [file join [lindex $args 0] [lindex $args 1]] } absolute { - return [unix_clean_filename $dest $file]; + return [unix_clean_filename $dest $file] } exists { - return [file exists $file]; + return [file exists $file] } delete { foreach x $args { if { [file exists $x] && [file isfile $x] } { - exec rm -f $x; + exec rm -f $x } } - return; + return } } } switch $op { exists { # mmmm, quotes. - set status [remote_exec $dest "sh -c 'exit `\[ -f $file \]`'"]; - return [lindex $status 0]; + set status [remote_exec $dest "sh -c 'exit `\[ -f $file \]`'"] + return [lindex $status 0] } delete { set file "" # Allow multiple files to be deleted at once. foreach x $args { - append file " $x"; + append file " $x" } verbose "remote_file deleting $file" - set status [remote_exec $dest "rm -f $file"]; - return [lindex $status 0]; + set status [remote_exec $dest "rm -f $file"] + return [lindex $status 0] } } } @@ -744,23 +744,23 @@ proc standard_file { dest op args } { # proc unix_clean_filename { dest file } { if { [file pathtype $file] == "relative" } { - set file [remote_file $dest join [pwd] $file]; + set file [remote_file $dest join [pwd] $file] } - set result ""; + set result "" foreach x [split $file "/"] { if { $x == "." || $x == "" } { - continue; + continue } if { $x == ".." } { - set rlen [expr [llength $result] - 2]; + set rlen [expr [llength $result] - 2] if { $rlen >= 0 } { - set result [lrange $result 0 $rlen]; + set result [lrange $result 0 $rlen] } else { set result "" } - continue; + continue } - lappend result $x; + lappend result $x } return "/[join $result /]" } @@ -782,68 +782,68 @@ proc remote_spawn { dest commandline args } { if ![is_remote $dest] { if [info exists board_info($dest,fileid)] { - unset board_info($dest,fileid); + unset board_info($dest,fileid) } - verbose "remote_spawn is local" 3; + verbose "remote_spawn is local" 3 if [board_info $dest exists name] { - set dest [board_info $dest name]; + set dest [board_info $dest name] } verbose "spawning command $commandline" if { [llength $args] > 0 } { if { [lindex $args 0] == "readonly" } { - set result [catch { open "| ${commandline} |& cat" "r" } id]; + set result [catch { open "| ${commandline} |& cat" "r" } id] if { $result != 0 } { - return -1; + return -1 } } else { - set result [catch {open "| ${commandline}" "w"} id] ; + set result [catch {open "| ${commandline}" "w"} id] if { $result != 0 } { - return -1; + return -1 } } - set result [catch "spawn -leaveopen $id" result2]; + set result [catch "spawn -leaveopen $id" result2] if { $result == 0 && $result2 == 0} { verbose "setting board_info($dest,fileid) to $spawn_id" 3 - set board_info($dest,fileid) $spawn_id; - set board_info($dest,fileid_origid) $id; - return $spawn_id; + set board_info($dest,fileid) $spawn_id + set board_info($dest,fileid_origid) $id + return $spawn_id } else { # This shouldn't happen. - global errorInfo; + global errorInfo if [info exists errorInfo] { - set foo $errorInfo; + set foo $errorInfo } else { - set foo ""; + set foo "" } - verbose "spawn -open $id failed, $result $result2, $foo"; - catch "close $id"; - return -1; + verbose "spawn -open $id failed, $result $result2, $foo" + catch "close $id" + return -1 } } else { - set result [catch "spawn $commandline" pid]; + set result [catch "spawn $commandline" pid] if { $result == 0 } { verbose "setting board_info($dest,fileid) to $spawn_id" 3 - set board_info($dest,fileid) $spawn_id; - return $spawn_id; + set board_info($dest,fileid) $spawn_id + return $spawn_id } else { - verbose -log "spawn of $commandline failed"; - return -1; + verbose -log "spawn of $commandline failed" + return -1 } } } # Seems to me there should be a cleaner way to do this. if { "$args" == "" } { - return [call_remote "" spawn "$dest" "$commandline"]; + return [call_remote "" spawn "$dest" "$commandline"] } else { - return [call_remote "" spawn "$dest" "$commandline" $args]; + return [call_remote "" spawn "$dest" "$commandline" $args] } } proc remote_raw_spawn { dest commandline } { - return [call_remote raw spawn "$dest" "$commandline"]; + return [call_remote raw spawn "$dest" "$commandline"] } # @@ -859,7 +859,7 @@ proc standard_spawn { dest commandline } { set RSH rsh } } else { - set RSH [board_info $dest rsh_prog]; + set RSH [board_info $dest rsh_prog] } if ![board_info $dest exists username] { @@ -869,14 +869,14 @@ proc standard_spawn { dest commandline } { } if [board_info $dest exists hostname] { - set remote [board_info $dest hostname]; + set remote [board_info $dest hostname] } else { - set remote $dest; + set remote $dest } - spawn $RSH $rsh_useropts $remote $commandline; - set board_info($dest,fileid) $spawn_id; - return $spawn_id; + spawn $RSH $rsh_useropts $remote $commandline + set board_info($dest,fileid) $spawn_id + return $spawn_id } # @@ -889,70 +889,70 @@ proc standard_spawn { dest commandline } { proc remote_load { dest prog args } { global tool - set dname [board_info $dest name]; - set cache "[getenv REMOTELOAD_CACHE]/$tool/$dname/[file tail $prog]"; - set empty [is_remote $dest]; + set dname [board_info $dest name] + set cache "[getenv REMOTELOAD_CACHE]/$tool/$dname/[file tail $prog]" + set empty [is_remote $dest] if { [board_info $dest exists is_simulator] || [getenv REMOTELOAD_CACHE] == "" } { - set empty 0; + set empty 0 } else { for { set x 0; } {$x < [llength $args] } {incr x} { if { [lindex $args $x] != "" } { - set empty 0; - break; + set empty 0 + break } } } if $empty { - global sum_program; + global sum_program if [info exists sum_program] { if ![target_info exists objcopy] { - set_currtarget_info objcopy [find_binutils_prog objcopy]; + set_currtarget_info objcopy [find_binutils_prog objcopy] } if [is_remote host] { - set dprog [remote_download host $prog "a.out"]; + set dprog [remote_download host $prog "a.out"] } else { - set dprog $prog; + set dprog $prog } - set status [remote_exec host "[target_info objcopy]" "-O srec $dprog ${dprog}.sum"]; + set status [remote_exec host "[target_info objcopy]" "-O srec $dprog ${dprog}.sum"] if [is_remote host] { - remote_file upload ${dprog}.sum ${prog}.sum; + remote_file upload ${dprog}.sum ${prog}.sum } if { [lindex $status 0] == 0 } { - set sumout [remote_exec build "$sum_program" "${prog}.sum"]; - set sum [lindex $sumout 1]; - regsub "\[\r\n \t\]+$" "$sum" "" sum; + set sumout [remote_exec build "$sum_program" "${prog}.sum"] + set sum [lindex $sumout 1] + regsub "\[\r\n \t\]+$" "$sum" "" sum } else { - set sumout [remote_exec build "$sum_program" "${prog}"]; - set sum [lindex $sumout 1]; - regsub "\[\r\n \t\]+$" "$sum" "" sum; + set sumout [remote_exec build "$sum_program" "${prog}"] + set sum [lindex $sumout 1] + regsub "\[\r\n \t\]+$" "$sum" "" sum } - remote_file build delete ${prog}.sum; + remote_file build delete ${prog}.sum } if [file exists $cache] { - set same 0; + set same 0 if [info exists sum_program] { - set id [open $cache "r"]; - set oldsum [read $id]; - close $id; + set id [open $cache "r"] + set oldsum [read $id] + close $id if { $oldsum == $sum } { - set same 1; + set same 1 } } else { if { [remote_file build cmp $prog $cache] == 0 } { - set same 1; + set same 1 } } if { $same } { - set fd [open "${cache}.res" "r"]; - gets $fd l1; - set result [list $l1 [read $fd]]; - close $fd; + set fd [open "${cache}.res" "r"] + gets $fd l1 + set result [list $l1 [read $fd]] + close $fd } } } if ![info exists result] { - set result [eval call_remote \"\" load \"$dname\" \"$prog\" $args]; + set result [eval call_remote \"\" load \"$dname\" \"$prog\" $args] # Not quite happy about the "pass" condition, but it makes sense if # you think about it for a while-- *why* did the test not pass? if { $empty && [lindex $result 0] == "pass" } { @@ -963,25 +963,25 @@ proc remote_load { dest prog args } { } if [file exists $dir] { if [info exists sum_program] { - set id [open $cache "w"]; - puts -nonewline $id "$sum"; - close $id; + set id [open $cache "w"] + puts -nonewline $id "$sum" + close $id } else { - remote_exec build cp "$prog $cache"; + remote_exec build cp "$prog $cache" } - set id [open "${cache}.res" "w"]; - puts $id [lindex $result 0]; - puts -nonewline $id [lindex $result 1]; - close $id; + set id [open "${cache}.res" "w"] + puts $id [lindex $result 0] + puts -nonewline $id [lindex $result 1] + close $id } } } } - return $result; + return $result } proc remote_raw_load { dest prog args } { - return [eval call_remote raw load \"$dest\" \"$prog\" $args ]; + return [eval call_remote raw load \"$dest\" \"$prog\" $args ] } # @@ -991,13 +991,13 @@ proc remote_raw_load { dest prog args } { proc standard_load { dest prog args } { if { [llength $args] > 0 } { - set pargs [lindex $args 0]; + set pargs [lindex $args 0] } else { set pargs "" } if { [llength $args] > 1 } { - set inp "[lindex $args 1]"; + set inp "[lindex $args 1]" } else { set inp "" } @@ -1011,7 +1011,7 @@ proc standard_load { dest prog args } { if [is_remote $dest] { set remotefile "/tmp/[file tail $prog].[pid]" - set remotefile [remote_download $dest $prog $remotefile]; + set remotefile [remote_download $dest $prog $remotefile] if { $remotefile == "" } { verbose -log "Download of $prog to [board_info $dest name] failed." 3 return "unresolved" @@ -1023,10 +1023,10 @@ proc standard_load { dest prog args } { return "unresolved" } } - set status [remote_exec $dest $remotefile $pargs $inp]; - remote_file $dest delete $remotefile; + set status [remote_exec $dest $remotefile $pargs $inp] + remote_file $dest delete $remotefile } else { - set status [remote_exec $dest $prog $pargs $inp]; + set status [remote_exec $dest $prog $pargs $inp] } if { [lindex $status 0] < 0 } { verbose -log "Couldn't execute $prog, [lindex $status 1]" 3 @@ -1040,9 +1040,9 @@ proc standard_load { dest prog args } { verbose -log -- "$output" 2 } if { $status == 0 } { - return [list "pass" $output]; + return [list "pass" $output] } else { - return [list "fail" $output]; + return [list "fail" $output] } } @@ -1050,11 +1050,11 @@ proc standard_load { dest prog args } { # Loads PROG into DEST. # proc remote_ld { dest prog } { - return [eval call_remote \"\" ld \"$dest\" \"$prog\"]; + return [eval call_remote \"\" ld \"$dest\" \"$prog\"] } proc remote_raw_ld { dest prog } { - return [eval call_remote raw ld \"$dest\" \"$prog\"]; + return [eval call_remote raw ld \"$dest\" \"$prog\"] } # Wait up to TIMEOUT seconds for the last spawned command on DEST to @@ -1063,62 +1063,62 @@ proc remote_raw_ld { dest prog } { # produced by the command. proc remote_wait { dest timeout } { - return [eval call_remote \"\" wait \"$dest\" $timeout]; + return [eval call_remote \"\" wait \"$dest\" $timeout] } proc remote_raw_wait { dest timeout } { - return [eval call_remote raw wait \"$dest\" $timeout]; + return [eval call_remote raw wait \"$dest\" $timeout] } # The standard wait procedure, used for commands spawned on the local # machine. proc standard_wait { dest timeout } { - set output ""; - set status -1; + set output "" + set status -1 if [info exists exp_close_result] { - unset exp_close_result; + unset exp_close_result } remote_expect $dest $timeout { -re ".+" { - append output $expect_out(buffer); + append output $expect_out(buffer) if { [string length $output] > 512000 } { - remote_close $dest; - set status 1; + remote_close $dest + set status 1 } else { - exp_continue -continue_timer; + exp_continue -continue_timer } } timeout { - warning "program timed out."; + warning "program timed out." } eof { if [board_info $dest exists fileid_origid] { - global board_info; + global board_info - set id [board_info $dest fileid]; - set oid [board_info $dest fileid_origid]; + set id [board_info $dest fileid] + set oid [board_info $dest fileid_origid] verbose "$id $oid" - unset board_info($dest,fileid); - unset board_info($dest,fileid_origid); - catch "close -i $id"; + unset board_info($dest,fileid) + unset board_info($dest,fileid_origid) + catch "close -i $id" # I don't believe this. You HAVE to do a wait, even tho # it won't work! stupid ()*$%*)(% expect... - catch "wait -i $id"; - set r2 [catch "close $oid" res]; + catch "wait -i $id" + set r2 [catch "close $oid" res] if { $r2 != 0 } { - verbose "close result is $res"; - set status 1; + verbose "close result is $res" + set status 1 } else { - set status 0; + set status 0 } } else { - set s [wait -i [board_info $dest fileid]]; + set s [wait -i [board_info $dest fileid]] if { [lindex $s 0] != 0 && [lindex $s 2] == 0 } { - set status [lindex $s 3]; + set status [lindex $s 3] if { [llength $s] > 4 } { if { [lindex $s 4] == "CHILDKILLED" } { - set status 1; + set status 1 } } } @@ -1126,8 +1126,8 @@ proc standard_wait { dest timeout } { } } - remote_close $dest; - return [list $status $output]; + remote_close $dest + return [list $status $output] } # This checks the value cotained in the variable named "variable" in @@ -1136,7 +1136,7 @@ proc standard_wait { dest timeout } { # output from the wrapper is removed from the variable. proc check_for_board_status { variable } { - upvar $variable output; + upvar $variable output # If all programs of this board have a wrapper that always outputs a # status message, then the absence of it means that the program @@ -1149,9 +1149,9 @@ proc check_for_board_status { variable } { } if [regexp "(^|\[\r\n\])\\*\\*\\* EXIT code" $output] { - regsub "^.*\\*\\*\\* EXIT code " $output "" result; - regsub "\[\r\n\].*$" $result "" result; - regsub -all "(^|\[\r\n\]|\r\n)\\*\\*\\* EXIT code \[^\r\n\]*(\[\r\n\]\[\r\n\]?|$)" $output "" output; + regsub "^.*\\*\\*\\* EXIT code " $output "" result + regsub "\[\r\n\].*$" $result "" result + regsub -all "(^|\[\r\n\]|\r\n)\\*\\*\\* EXIT code \[^\r\n\]*(\[\r\n\]\[\r\n\]?|$)" $output "" output regsub "^\[^0-9\]*" $result "" result regsub "\[^0-9\]*$" $result "" result verbose "got board status $result" 3 @@ -1162,7 +1162,7 @@ proc check_for_board_status { variable } { return [expr $result] } } else { - return $nomatch_return; + return $nomatch_return } } @@ -1174,96 +1174,96 @@ proc check_for_board_status { variable } { # proc remote_expect { board timeout args } { - global errorInfo errorCode; - global remote_suppress_flag; + global errorInfo errorCode + global remote_suppress_flag - set spawn_id [board_info $board fileid]; + set spawn_id [board_info $board fileid] if { [llength $args] == 1 } { - set args "[lindex $args 0]"; + set args "[lindex $args 0]" } set res {} - set got_re 0; - set need_append 1; + set got_re 0 + set need_append 1 - set orig "$args"; + set orig "$args" - set error_sect ""; - set save_next 0; + set error_sect "" + set save_next 0 if { $spawn_id == "" } { # This should be an invalid spawn id. - set spawn_id 1000; + set spawn_id 1000 } for { set i 0; } { $i < [llength $args] } { incr i ; } { if { $need_append } { - append res "\n-i $spawn_id "; - set need_append 0; + append res "\n-i $spawn_id " + set need_append 0 } - set x "[lrange $args $i $i]"; - regsub "^\n*\[ \]*" "$x" "" x; + set x "[lrange $args $i $i]" + regsub "^\n*\[ \]*" "$x" "" x if { $x == "-i" || $x == "-timeout" || $x == "-ex" } { - append res "$x "; - set next [expr ${i}+1]; - append res "[lrange $args $next $next]"; - incr i; - continue; + append res "$x " + set next [expr ${i}+1] + append res "[lrange $args $next $next]" + incr i + continue } if { $x == "-n" || $x == "-notransfer" || $x == "-nocase" || $x == "-indices" } { - append res "${x} "; - continue; + append res "${x} " + continue } if { $x == "-re" } { - append res "${x} "; - set next [expr ${i}+1]; - set y [lrange $args $next $next]; - append res "${y} "; - set got_re 1; - incr i; - continue; + append res "${x} " + set next [expr ${i}+1] + set y [lrange $args $next $next] + append res "${y} " + set got_re 1 + incr i + continue } if { $got_re } { - set need_append 0; - append res "$x "; - set got_re 0; + set need_append 0 + append res "$x " + set got_re 0 if { $save_next } { - set save_next 0; - set error_sect [lindex $args $i]; + set save_next 0 + set error_sect [lindex $args $i] } } else { if { ${x} == "eof" } { - set save_next 1; + set save_next 1 } elseif { ${x} == "default" || ${x} == "timeout" } { if { $error_sect == "" } { - set save_next 1; + set save_next 1 } } - append res "${x} "; - set got_re 1; + append res "${x} " + set got_re 1 } } if [info exists remote_suppress_flag] { if { $remote_suppress_flag } { - set code 1; + set code 1 } } if ![info exists code] { - set res "\n-timeout $timeout $res"; - set body "expect \{\n-i $spawn_id -timeout $timeout $orig\}"; - set code [catch {uplevel $body} string]; + set res "\n-timeout $timeout $res" + set body "expect \{\n-i $spawn_id -timeout $timeout $orig\}" + set code [catch {uplevel $body} string] } if {$code == 1} { if { $error_sect != "" } { - set code [catch {uplevel $error_sect} string]; + set code [catch {uplevel $error_sect} string] } else { - warning "remote_expect statement without a default case?!"; - return; + warning "remote_expect statement without a default case?!" + return } } @@ -1280,84 +1280,84 @@ proc remote_expect { board timeout args } { # Push the current connection to HOST onto a stack. proc remote_push_conn { host } { - global board_info; + global board_info - set name [board_info $host name]; + set name [board_info $host name] if { $name == "" } { - return "fail"; + return "fail" } if ![board_info $host exists fileid] { - return "fail"; + return "fail" } - set fileid [board_info $host fileid]; - set conninfo [board_info $host conninfo]; + set fileid [board_info $host fileid] + set conninfo [board_info $host conninfo] if ![info exists board_info($name,fileid_stack)] { set board_info($name,fileid_stack) {} } - set board_info($name,fileid_stack) [list $fileid $conninfo $board_info($name,fileid_stack)]; - unset board_info($name,fileid); + set board_info($name,fileid_stack) [list $fileid $conninfo $board_info($name,fileid_stack)] + unset board_info($name,fileid) if [info exists board_info($name,conninfo)] { - unset board_info($name,conninfo); + unset board_info($name,conninfo) } - return "pass"; + return "pass" } # Pop a previously-pushed connection from a stack. You should have closed the # current connection before doing this. proc remote_pop_conn { host } { - global board_info; + global board_info - set name [board_info $host name]; + set name [board_info $host name] if { $name == "" } { - return "fail"; + return "fail" } if ![info exists board_info($name,fileid_stack)] { - return "fail"; + return "fail" } - set stack $board_info($name,fileid_stack); + set stack $board_info($name,fileid_stack) if { [llength $stack] < 3 } { - return "fail"; + return "fail" } - set board_info($name,fileid) [lindex $stack 0]; - set board_info($name,conninfo) [lindex $stack 1]; - set board_info($name,fileid_stack) [lindex $stack 2]; - return "pass"; + set board_info($name,fileid) [lindex $stack 0] + set board_info($name,conninfo) [lindex $stack 1] + set board_info($name,fileid_stack) [lindex $stack 2] + return "pass" } # # Swap the current connection with the topmost one on the stack. # proc remote_swap_conn { host } { - global board_info; - set name [board_info $host name]; + global board_info + set name [board_info $host name] if ![info exists board_info($name,fileid)] { - return "fail"; + return "fail" } - set fileid $board_info($name,fileid); + set fileid $board_info($name,fileid) if [info exists board_info($name,conninfo)] { - set conninfo $board_info($name,conninfo); + set conninfo $board_info($name,conninfo) } else { set conninfo {} } if { [remote_pop_conn $host] != "pass" } { - set board_info($name,fileid) $fileid; - set board_info($name,conninfo) $conninfo; - return "fail"; - } - set newfileid $board_info($name,fileid); - set newconninfo $board_info($name,conninfo); - set board_info($name,fileid) $fileid; - set board_info($name,conninfo) $conninfo; - remote_push_conn $host; - set board_info($name,fileid) $newfileid; - set board_info($name,conninfo) $newconninfo; - return "pass"; + set board_info($name,fileid) $fileid + set board_info($name,conninfo) $conninfo + return "fail" + } + set newfileid $board_info($name,fileid) + set newconninfo $board_info($name,conninfo) + set board_info($name,fileid) $fileid + set board_info($name,conninfo) $conninfo + remote_push_conn $host + set board_info($name,fileid) $newfileid + set board_info($name,conninfo) $newconninfo + return "pass" } -set sum_program "testcsum"; +set sum_program "testcsum" diff --git a/lib/rlogin.exp b/lib/rlogin.exp index b49cd5d..8fe32a5 100644 --- a/lib/rlogin.exp +++ b/lib/rlogin.exp @@ -29,7 +29,7 @@ proc rlogin_open { arg } { set result -1 if [board_info $arg exists fileid] { - return [board_info $arg fileid]; + return [board_info $arg fileid] } # get the hostname and port number from the config array @@ -47,13 +47,13 @@ proc rlogin_open { arg } { } if [board_info $arg exists fileid] { - unset board_info($arg,fileid); + unset board_info($arg,fileid) } # get the right version of rlogin if ![board_info $arg exists rlogin_prog] { set RLOGIN rlogin } else { - set RLOGIN [board_info $arg rlogin_prog]; + set RLOGIN [board_info $arg rlogin_prog] } # start connection and store the spawn_id @@ -136,38 +136,38 @@ proc rlogin_open { arg } { # proc rlogin_spawn { dest cmdline } { if ![board_info $dest exists shell_prompt] { - set shell_prompt "(^|\[\r\n\])\[^\r\n\]*>"; + set shell_prompt "(^|\[\r\n\])\[^\r\n\]*>" } else { - set shell_prompt [board_info $dest shell_prompt]; + set shell_prompt [board_info $dest shell_prompt] } set prefix "" - set ok 0; + set ok 0 for {set i 0;} {$i <= 2 && ! $ok} {incr i;} { - set shell_id [remote_open $dest]; + set shell_id [remote_open $dest] if { $shell_id != "" && $shell_id > 0 } { - remote_send $dest "echo k\r"; + remote_send $dest "echo k\r" remote_expect $dest 20 { -re "\\(gdb\\)" { - set shell_prompt "\\(gdb\\)"; + set shell_prompt "\\(gdb\\)" # gdb uses 'shell command'. - set prefix "shell "; - set ok 1; + set prefix "shell " + set ok 1 } -re ".*$shell_prompt" { - set ok 1; + set ok 1 } default { } } } if { ! $ok } { - remote_close $dest; - remote_reboot $dest; + remote_close $dest + remote_reboot $dest } } if { ! $ok } { return "unable to start command" } else { - remote_send $dest "${prefix}${cmdline}\n"; - return [board_info $dest fileid]; + remote_send $dest "${prefix}${cmdline}\n" + return [board_info $dest fileid] } } diff --git a/lib/rsh.exp b/lib/rsh.exp index 95de794..ed71143 100644 --- a/lib/rsh.exp +++ b/lib/rsh.exp @@ -33,7 +33,7 @@ proc rsh_open { hostname } { set RSH rsh } } else { - set RSH [board_info $hostname rsh_prog]; + set RSH [board_info $hostname rsh_prog] } if [board_info $hostname exists username] { @@ -44,7 +44,7 @@ proc rsh_open { hostname } { # get the hostname and port number from the config array if [board_info $hostname exists name] { - set hostname [board_info $hostname name]; + set hostname [board_info $hostname name] } set hostname [lindex [split [board_info ${hostname} netport] ":"] 0] if [board_info ${hostname} exists shell_prompt] { @@ -54,7 +54,7 @@ proc rsh_open { hostname } { } if [board_info $hostname exists fileid] { - unset board_info($hostname,fileid); + unset board_info($hostname,fileid) } spawn $RSH $rsh_useropts $hostname @@ -152,13 +152,13 @@ proc rsh_open { hostname } { proc rsh_download {desthost srcfile destfile} { # must be done before desthost is rewritten if [board_info $desthost exists rcp_prog] { - set RCP [board_info $desthost rcp_prog]; + set RCP [board_info $desthost rcp_prog] } else { set RCP rcp } if [board_info $desthost exists rsh_prog] { - set RSH [board_info $desthost rsh_prog]; + set RSH [board_info $desthost rsh_prog] } else { if { [which remsh] != 0 } { set RSH remsh @@ -176,18 +176,18 @@ proc rsh_download {desthost srcfile destfile} { } if [board_info $desthost exists name] { - set desthost [board_info $desthost name]; + set desthost [board_info $desthost name] } if [board_info $desthost exists hostname] { - set desthost [board_info $desthost hostname]; + set desthost [board_info $desthost hostname] } set status [catch "exec $RSH $rsh_useropts $desthost rm -f $destfile |& cat" output] set status [catch "exec $RCP $srcfile $rcp_user$desthost:$destfile |& cat" output] if { $status == 0 } { verbose "Copied $srcfile to $desthost:$destfile" 2 - return $destfile; + return $destfile } else { verbose "Download to $desthost failed, $output." return "" @@ -196,7 +196,7 @@ proc rsh_download {desthost srcfile destfile} { proc rsh_upload {desthost srcfile destfile} { if [board_info $desthost exists rcp_prog] { - set RCP [board_info $desthost rcp_prog]; + set RCP [board_info $desthost rcp_prog] } else { set RCP rcp } @@ -208,17 +208,17 @@ proc rsh_upload {desthost srcfile destfile} { } if [board_info $desthost exists name] { - set desthost [board_info $desthost name]; + set desthost [board_info $desthost name] } if [board_info $desthost exists hostname] { - set desthost [board_info $desthost hostname]; + set desthost [board_info $desthost hostname] } - set status [catch "exec $RCP $rcp_user$desthost:$srcfile $destfile" output]; + set status [catch "exec $RCP $rcp_user$desthost:$srcfile $destfile" output] if { $status == 0 } { verbose "Copied $desthost:$srcfile to $destfile" 2 - return $destfile; + return $destfile } else { verbose "Upload from $desthost failed, $output." return "" @@ -230,11 +230,11 @@ proc rsh_upload {desthost srcfile destfile} { # proc rsh_exec { boardname cmd args } { if { [llength $args] > 0 } { - set pargs [lindex $args 0]; + set pargs [lindex $args 0] if { [llength $args] > 1 } { - set inp [lindex $args 1]; + set inp [lindex $args 1] } else { - set inp ""; + set inp "" } } else { set pargs "" @@ -250,7 +250,7 @@ proc rsh_exec { boardname cmd args } { set RSH rsh } } else { - set RSH [board_info $boardname rsh_prog]; + set RSH [board_info $boardname rsh_prog] } if [board_info $boardname exists username] { @@ -260,13 +260,13 @@ proc rsh_exec { boardname cmd args } { } if [board_info $boardname exists name] { - set boardname [board_info $boardname name]; + set boardname [board_info $boardname name] } if [board_info $boardname exists hostname] { - set hostname [board_info $boardname hostname]; + set hostname [board_info $boardname hostname] } else { - set hostname $boardname; + set hostname $boardname } diff --git a/lib/standard.exp b/lib/standard.exp index a197eaa..ecbd244 100644 --- a/lib/standard.exp +++ b/lib/standard.exp @@ -24,17 +24,17 @@ proc ${tool}_load { program args } { if { [llength $args] > 0 } { - set program_args [lindex $args 0]; + set program_args [lindex $args 0] } else { set program_args "" } if { [llength $args] > 1 } { - set input_file [lindex $args 1]; + set input_file [lindex $args 1] } else { - set input_file ""; + set input_file "" } - return [remote_load target $program $program_args $input_file]; + return [remote_load target $program $program_args $input_file] } proc ${tool}_compile { srcfile destfile compile_type options } { diff --git a/lib/target.exp b/lib/target.exp index a5d5f47..d5540e1 100644 --- a/lib/target.exp +++ b/lib/target.exp @@ -126,7 +126,7 @@ proc pop_host { } { # Remove extraneous warnings we don't care about # proc prune_warnings { text } { - global host_triplet; + global host_triplet # remove the \r part of "\r\n" so we don't break all the patterns # we want to match. @@ -290,11 +290,11 @@ proc prune_warnings { text } { # proc target_compile {source destfile type options} { - set target [target_info name]; + set target [target_info name] if { [info proc ${target}_compile] != "" } { - return [${target}_compile $source $destfile $type $options]; + return [${target}_compile $source $destfile $type $options] } else { - return [default_target_compile $source $destfile $type $options]; + return [default_target_compile $source $destfile $type $options] } } @@ -320,9 +320,9 @@ proc default_target_compile {source destfile type options} { } if [info exists target_info(host,name)] { - set host [host_info name]; + set host [host_info name] } else { - set host "unix"; + set host "unix" } foreach i $options { @@ -331,11 +331,11 @@ proc default_target_compile {source destfile type options} { if [board_info $dest exists cxxflags] { append add_flags " [target_info cxxflags]" } - append add_flags " [g++_include_flags]"; + append add_flags " [g++_include_flags]" if [board_info $dest exists c++compiler] { - set compiler [target_info c++compiler]; + set compiler [target_info c++compiler] } else { - set compiler [find_g++]; + set compiler [find_g++] } } @@ -355,9 +355,9 @@ proc default_target_compile {source destfile type options} { if [regexp "^dest=" $i] { regsub "^dest=" $i "" tmp if [board_info $tmp exists name] { - set dest [board_info $tmp name]; + set dest [board_info $tmp name] } else { - set dest $tmp; + set dest $tmp } } if [regexp "^compiler=" $i] { @@ -399,7 +399,7 @@ proc default_target_compile {source destfile type options} { } if [board_info $host exists cflags_for_target] { - append add_flags " [board_info $host cflags_for_target]"; + append add_flags " [board_info $host cflags_for_target]" } global CC_FOR_TARGET @@ -425,9 +425,9 @@ proc default_target_compile {source destfile type options} { } if { $compiler == "" } { - set compiler [board_info $dest compiler]; + set compiler [board_info $dest compiler] if { $compiler == "" } { - return "default_target_compile: No compiler to compile with"; + return "default_target_compile: No compiler to compile with" } } @@ -463,7 +463,7 @@ proc default_target_compile {source destfile type options} { append add_flags " [board_info $dest ldflags]" } if { $compiler_type == "c++" } { - append add_flags " [g++_link_flags]"; + append add_flags " [g++_link_flags]" } if [isnative] { # This is a lose. @@ -490,7 +490,7 @@ proc default_target_compile {source destfile type options} { foreach i $options { if { $i == "debug" } { if [board_info $dest exists debug_flags] { - append add_flags " [board_info $dest debug_flags]"; + append add_flags " [board_info $dest debug_flags]" } else { append add_flags " -g" } @@ -498,7 +498,7 @@ proc default_target_compile {source destfile type options} { } if [info exists optimize] { - append add_flags " $optimize"; + append add_flags " $optimize" } if { $type == "executable" } { @@ -507,7 +507,7 @@ proc default_target_compile {source destfile type options} { if [file exists $x] { append source " $x" } else { - append add_flags " $x"; + append add_flags " $x" } } @@ -527,19 +527,19 @@ proc default_target_compile {source destfile type options} { } # This must be added here. - append add_flags " $ldscript"; + append add_flags " $ldscript" if [board_info $dest exists remote_link] { # Relink option. append add_flags " -Wl,-r" } if [board_info $dest exists output_format] { - append add_flags " -Wl,-oformat,[board_info $dest output_format]"; + append add_flags " -Wl,-oformat,[board_info $dest output_format]" } } if [board_info $dest exists multilib_flags] { - append add_flags " [board_info $dest multilib_flags]"; + append add_flags " [board_info $dest multilib_flags]" } verbose "doing compile" @@ -547,12 +547,12 @@ proc default_target_compile {source destfile type options} { set sources "" if [is_remote host] { foreach x $source { - set file [remote_download host $x]; + set file [remote_download host $x] if { $file == "" } { warning "Unable to download $x to host." return "Unable to download $x to host." } else { - append sources " $file"; + append sources " $file" } } } else { @@ -561,10 +561,10 @@ proc default_target_compile {source destfile type options} { if [is_remote host] { append add_flags " -o a.out" - remote_file host delete a.out; + remote_file host delete a.out } else { if { $destfile != "" } { - append add_flags " -o $destfile"; + append add_flags " -o $destfile" } } @@ -579,9 +579,9 @@ proc default_target_compile {source destfile type options} { if [is_remote host] { if [host_info exists use_at] { - set fid [open "atfile" "w"]; - puts $fid "$opts"; - close $fid; + set fid [open "atfile" "w"] + puts $fid "$opts" + close $fid set opts "@[remote_download host atfile]" remote_file build delete atfile } @@ -591,39 +591,39 @@ proc default_target_compile {source destfile type options} { if [info exists redirect] { verbose "Redirecting output to $redirect" 2 - set status [remote_exec host "$compiler $opts" "" "" $redirect]; + set status [remote_exec host "$compiler $opts" "" "" $redirect] } else { if [info exists timeout] { verbose "Setting timeout to $timeout" 2 - set status [remote_exec host "$compiler $opts" "" "" "" $timeout]; + set status [remote_exec host "$compiler $opts" "" "" "" $timeout] } else { - set status [remote_exec host "$compiler $opts"]; + set status [remote_exec host "$compiler $opts"] } } set compiler_flags $opts if [is_remote host] { - remote_upload host a.out $destfile; - remote_file host delete a.out; + remote_upload host a.out $destfile + remote_file host delete a.out } - set comp_output [prune_warnings [lindex $status 1]]; - regsub "^\[\r\n\]+" $comp_output "" comp_output; + set comp_output [prune_warnings [lindex $status 1]] + regsub "^\[\r\n\]+" $comp_output "" comp_output if { [lindex $status 0] != 0 } { - verbose -log "compiler exited with status [lindex $status 0]"; + verbose -log "compiler exited with status [lindex $status 0]" } if { [lindex $status 1] != "" } { - verbose -log "output is:\n[lindex $status 1]" 2; + verbose -log "output is:\n[lindex $status 1]" 2 } if { [lindex $status 0] != 0 && "${comp_output}" == "" } { - set comp_output "exit status is [lindex $status 0]"; + set comp_output "exit status is [lindex $status 0]" } - return ${comp_output}; + return ${comp_output} } proc reboot_target { } { set result [remote_reboot target] puts "REBOOT_TARGET: \"$result\"" - return ${result}; + return ${result} } # @@ -632,7 +632,7 @@ proc reboot_target { } { # assembler. # proc target_assemble { source destfile flags } { - return [default_target_assemble $source $destfile $flags]; + return [default_target_assemble $source $destfile $flags] } proc default_target_assemble { source destfile flags } { @@ -640,21 +640,21 @@ proc default_target_assemble { source destfile flags } { global ASFLAGS_FOR_TARGET if [info exists AS_FOR_TARGET] { - set AS "$AS_FOR_TARGET"; + set AS "$AS_FOR_TARGET" } else { if ![board_info target exists assembler] { - set AS [find_gas]; + set AS [find_gas] } else { - set AS [board_info target assembler]; + set AS [board_info target assembler] } } if [info exists ASFLAGS_FOR_TARGET] { - append flags " $ASFLAGS_FOR_TARGET"; + append flags " $ASFLAGS_FOR_TARGET" } if [is_remote host] { - set source [remote_download host $source]; + set source [remote_download host $source] set dest "a.out" } else { set dest $destfile @@ -664,14 +664,14 @@ proc default_target_assemble { source destfile flags } { remote_upload host $dest $destfile } - set comp_output [prune_warnings [lindex $status 1]]; + set comp_output [prune_warnings [lindex $status 1]] if { [lindex $status 0] != 0 } { - verbose -log "assembler exited with status [lindex $status 0]"; + verbose -log "assembler exited with status [lindex $status 0]" } if { [lindex $status 1] != "" } { - verbose -log "assembler output is:\n[lindex $status 1]" 2; + verbose -log "assembler output is:\n[lindex $status 1]" 2 } - return ${comp_output}; + return ${comp_output} } # @@ -680,7 +680,7 @@ proc default_target_assemble { source destfile flags } { # linker. # proc target_link { objects destfile flags } { - return [default_link target "$objects" "$destfile" $flags]; + return [default_link target "$objects" "$destfile" $flags] } proc default_link { board objects destfile flags } { @@ -713,17 +713,17 @@ proc default_link { board objects destfile flags } { } if [info exists LD_FOR_TARGET] { - set LD "$LD_FOR_TARGET"; + set LD "$LD_FOR_TARGET" } else { if ![board_info target exists linker] { - set LD [find_ld]; + set LD [find_ld] } else { - set LD [board_info target linker]; + set LD [board_info target linker] } } if [info exists LDFLAGS_FOR_TARGET] { - append flags " $LDFLAGS_FOR_TARGET"; + append flags " $LDFLAGS_FOR_TARGET" } # `ldflags' consists of arguments to gcc (that are then @@ -744,24 +744,24 @@ proc default_link { board objects destfile flags } { if [is_remote host] { foreach x $objects { - set nobjects "$nobjects [remote_download host $x]"; + set nobjects "$nobjects [remote_download host $x]" } - set objects "$nobjects"; - set dest "a.out"; + set objects "$nobjects" + set dest "a.out" } else { - set dest $destfile; + set dest $destfile } set status [remote_exec host "$LD $objects $flags -o $dest"] if [is_remote host] { - remote_upload host $dest $destfile; + remote_upload host $dest $destfile } - set comp_output [prune_warnings [lindex $status 1]]; + set comp_output [prune_warnings [lindex $status 1]] if { [lindex $status 0] != 0 } { - verbose -log "linker exited with status [lindex $status 0]"; + verbose -log "linker exited with status [lindex $status 0]" } if { [lindex $status 1] != "" } { - verbose -log "linker output is:\n[lindex $status 1]" 2; + verbose -log "linker output is:\n[lindex $status 1]" 2 } - return ${comp_output}; + return ${comp_output} } diff --git a/lib/targetdb.exp b/lib/targetdb.exp index 99b3f58..7592653 100644 --- a/lib/targetdb.exp +++ b/lib/targetdb.exp @@ -28,50 +28,50 @@ proc board_info { machine op args } { verbose "board_info $machine $op $args" 3 if [info exists target_info($machine,name)] { - set machine $target_info($machine,name); + set machine $target_info($machine,name) } if { $op == "exists" } { if { [llength $args] == 0 } { if [info exists board_info($machine,name)] { - return 1; + return 1 } else { - return 0; + return 0 } } else { if [info exists "board_info($machine,[lindex $args 0])"] { - return 1; + return 1 } else { - return 0; + return 0 } } } if { [llength $args] == 0 } { verbose "getting $machine $op" 3 if [info exists board_info($machine,$op)] { - return $board_info($machine,$op); + return $board_info($machine,$op) } else { return "" } } - return ""; + return "" } proc target_info { op args } { - return [eval "board_info target \"$op\" $args"]; + return [eval "board_info target \"$op\" $args"] } proc host_info { op args } { - return [eval "board_info host \"$op\" $args"]; + return [eval "board_info host \"$op\" $args"] } # # Fill in ENTRY with VALUE for the current board being defined. # proc set_board_info { entry value } { - global board_info board; + global board_info board if ![info exists board_info($board,$entry)] { - set board_info($board,$entry) $value; + set board_info($board,$entry) $value } } @@ -79,12 +79,12 @@ proc set_board_info { entry value } { # Fill in ENTRY with VALUE for the current target. # proc set_currtarget_info { entry value } { - global board_info; + global board_info - set board [target_info name]; + set board [target_info name] if ![info exists board_info($board,$entry)] { - set board_info($board,$entry) $value; + set board_info($board,$entry) $value } } @@ -92,10 +92,10 @@ proc set_currtarget_info { entry value } { # Unset ENTRY for the current board being defined. # proc unset_board_info { entry } { - global board_info board; + global board_info board if [info exists board_info($board,$entry)] { - unset board_info($board,$entry); + unset board_info($board,$entry) } } @@ -103,11 +103,11 @@ proc unset_board_info { entry } { # Unset ENTRY for the current board being defined. # proc unset_currtarget_info { entry } { - global board_info; + global board_info - set board [target_info name]; + set board [target_info name] if [info exists board_info($board,$entry)] { - unset board_info($board,$entry); + unset board_info($board,$entry) } } diff --git a/lib/telnet.exp b/lib/telnet.exp index 061ea58..3c21752 100644 --- a/lib/telnet.exp +++ b/lib/telnet.exp @@ -30,11 +30,11 @@ proc telnet_open { hostname args } { global timeout global board_info - set raw 0; + set raw 0 if { [llength $args] > 0 } { if { [lindex $args 0] == "raw" } { - set raw 1; + set raw 1 } } @@ -46,19 +46,19 @@ proc telnet_open { hostname args } { } if [board_info $connhost exists hostname] { - set hostname [board_info $connhost hostname]; + set hostname [board_info $connhost hostname] } if [file exists /usr/kerberos/bin/telnet] { - set telnet /usr/kerberos/bin/telnet; + set telnet /usr/kerberos/bin/telnet } else { - set telnet telnet; + set telnet telnet } # Instead of unsetting it, let's return it. One connection at a # time, please. if [board_info $connhost exists fileid] { - return [board_info $connhost fileid]; + return [board_info $connhost fileid] } # get the hostname and port number from the config array if [board_info $connhost exists netport] { @@ -81,16 +81,16 @@ proc telnet_open { hostname args } { set tries 0 set result -1 - set need_respawn 1; + set need_respawn 1 verbose "Starting a telnet connection to $hostname:$port $shell_prompt" 2 while { $result < 0 && $tries <= 3 } { if { $need_respawn } { - set need_respawn 0; - spawn $telnet $hostname $port; + set need_respawn 0 + spawn $telnet $hostname $port } expect { "Trying " { - exp_continue; + exp_continue } -re "$shell_prompt.*$" { verbose "Got prompt\n" @@ -98,35 +98,35 @@ proc telnet_open { hostname args } { } -re "nt Name:|ogin:" { if [board_info $connhost exists telnet_username] { - exp_send "[board_info $connhost telnet_username]\n"; - exp_continue; + exp_send "[board_info $connhost telnet_username]\n" + exp_continue } if [board_info $connhost exists username] { - exp_send "[board_info $connhost username]\n"; - exp_continue; + exp_send "[board_info $connhost username]\n" + exp_continue } perror "telnet: need to login" break } "assword:" { if [board_info $connhost exists telnet_password] { - exp_send "[board_info $connhost telnet_password]\n"; - exp_continue; + exp_send "[board_info $connhost telnet_password]\n" + exp_continue } if [board_info $connhost exists password] { - exp_send "[board_info $connhost password]\n"; - exp_continue; + exp_send "[board_info $connhost password]\n" + exp_continue } perror "telnet: need a password" break } -re "advance.*y/n.*\\?" { - exp_send "n\n"; - exp_continue; + exp_send "n\n" + exp_continue } -re {([Aa]dvanced|[Ss]imple) or ([Ss]imple|[Aa]dvanced)} { - exp_send "simple\n"; - exp_continue; + exp_send "simple\n" + exp_continue } "Connected to" { exp_continue @@ -137,13 +137,13 @@ proc telnet_open { hostname args } { break } "VxWorks Boot" { - exp_send "@\n"; - sleep 20; - exp_continue; + exp_send "@\n" + sleep 20 + exp_continue } -re "Escape character is.*\\.\[\r\n\]" { if { $raw || [board_info $connhost exists dont_wait_for_prompt] } { - set result 0; + set result 0 } else { if [board_info $connhost exists send_initial_cr] { exp_send "\n" @@ -159,8 +159,8 @@ proc telnet_open { hostname args } { break } -re "Connection refused.*$" { - catch "exp_send \"\003\"" foo; - sleep 5; + catch "exp_send \"\003\"" foo + sleep 5 warning "telnet: connection refused." } -re "Sorry, this system is engaged.*" { @@ -179,10 +179,10 @@ proc telnet_open { hostname args } { } eof { warning "telnet: got unexpected EOF from telnet." - catch close; - catch wait; - set need_respawn 1; - sleep 5; + catch close + catch wait + set need_respawn 1 + sleep 5 } } incr tries @@ -211,7 +211,7 @@ proc telnet_open { hostname args } { # proc telnet_binary { hostname } { if [board_info $hostname exists fileid] { - remote_send $hostname ""; + remote_send $hostname "" remote_expect $hostname 5 { -re "telnet> *$" {} default {} @@ -219,16 +219,16 @@ proc telnet_binary { hostname } { remote_send $hostname "set binary\n" remote_expect $hostname 5 { -re "Format is .*telnet> *$" { - remote_send $hostname "toggle binary\n"; - exp_continue; + remote_send $hostname "toggle binary\n" + exp_continue } -re "Negotiating network ascii.*telnet> *$" { - remote_send $hostname "toggle binary\n"; - exp_continue; + remote_send $hostname "toggle binary\n" + exp_continue } -re "Negotiating binary.*\[\r\n\].*$" { } -re "binary.*unknown argument.*telnet> *$" { - remote_send $hostname "mode character\n"; + remote_send $hostname "mode character\n" } -re "Already operating in binary.*\[\r\n\].*$" { } timeout { @@ -239,5 +239,5 @@ proc telnet_binary { hostname } { } proc telnet_transmit { dest file args } { - return [standard_transmit $dest $file]; + return [standard_transmit $dest $file] } diff --git a/lib/tip.exp b/lib/tip.exp index e829595..0828cec 100644 --- a/lib/tip.exp +++ b/lib/tip.exp @@ -30,7 +30,7 @@ proc tip_open { hostname } { set result -1 if [board_info $hostname exists name] { - set hostname [board_info ${hostname} name]; + set hostname [board_info ${hostname} name] } set port [board_info ${hostname} tipname] if [board_info ${hostname} exists shell_prompt] { @@ -40,7 +40,7 @@ proc tip_open { hostname } { } if [board_info ${hostname} exists fileid] { - unset board_info(${hostname},fileid); + unset board_info(${hostname},fileid) } spawn tip -v $port if { $spawn_id < 0 } { @@ -130,7 +130,7 @@ proc tip_download { dest file args } { global expect_out if [board_info $dest exists shell_prompt] { - set shell_prompt [board_info $dest shell_prompt]; + set shell_prompt [board_info $dest shell_prompt] } else { set shell_prompt ".*>" } @@ -138,9 +138,9 @@ proc tip_download { dest file args } { set result "" if ![board_info $dest exists fileid] { perror "tip_download: no connection to $dest." - return $result; + return $result } - set shell_id [board_info $dest fileid]; + set shell_id [board_info $dest fileid] if ![file exists $file] { perror "$file doesn't exist." @@ -159,7 +159,7 @@ proc tip_download { dest file args } { } -i $shell_id -re ".*lines transferred in.*minute.*seconds.*$shell_prompt.*$" { verbose "Download $file successfully" 1 - set result $file; + set result $file } -i $shell_id -re ".*Invalid command.*$shell_prompt$" { warning "Got an invalid command to the remote shell." diff --git a/lib/xsh.exp b/lib/xsh.exp index 07d6911..4d3661d 100644 --- a/lib/xsh.exp +++ b/lib/xsh.exp @@ -29,28 +29,28 @@ proc xsh_open { hostname } { global board_info if [board_info $hostname exists fileid] { - unset board_info($hostname,fileid); + unset board_info($hostname,fileid) } if ![board_info $hostname exists spectra] { - perror "No spectra directory for $hostname"; - return -1; + perror "No spectra directory for $hostname" + return -1 } else { - set spectra [board_info $hostname spectra]; + set spectra [board_info $hostname spectra] } if ![board_info $hostname exists xsh_shell_prompt] { set xsh_shell_prompt ".*> " } else { - set xsh_shell_prompt [board_info $hostname shell_prompt]; + set xsh_shell_prompt [board_info $hostname shell_prompt] } set retries 0 set result 0 if ![board_info $hostname exists xsh_prog] { - set xsh xsh; + set xsh xsh } else { - set xsh [board_info $hostname xsh_prog]; + set xsh [board_info $hostname xsh_prog] } if {[which $xsh] != 0} { @@ -121,7 +121,7 @@ proc xsh_open { hostname } { } } - set board_info($hostname,fileid) $spawn_id; + set board_info($hostname,fileid) $spawn_id # load to operating system set timeout 20 set retries 0 @@ -164,7 +164,7 @@ proc xsh_open { hostname } { perror "Couldn't connect after $retries retries.\n" return -1 } else { - set board_info($hostname,fileid) $spawn_id; + set board_info($hostname,fileid) $spawn_id return $spawn_id } } @@ -187,7 +187,7 @@ proc xsh_download { dest file destfile args } { set result 1 set retries 0 - set shell_id [board_info $dest fileid]; + set shell_id [board_info $dest fileid] if { [llength $args] > 1 } { set opts [lindex $args 1] @@ -310,12 +310,12 @@ proc xsh_close { hostname } { global board_info if ![board_info $hostname exists fileid] { - return; + return } - set shell_id [board_info ${hostname} fileid]; + set shell_id [board_info ${hostname} fileid] send -i $shell_id "exit\n" - unset board_info(${hostname},fileid); + unset board_info(${hostname},fileid) verbose "Exiting shell." return 0 |