# to a separate non-dbx testcase, we should be able to remove this.
proc gdb_load { arg } {
if { $arg != "" } {
- if [gdb_file_cmd $arg] then { return -1 }
+ if {[gdb_file_cmd $arg]} { return -1 }
}
return [extended_gdbserver_load_last_file]
global mi_gdb_prompt
set res [extended_gdbserver_mi_gdb_load $arg]
- if { $res } then { return -1 }
+ if {$res} { return -1 }
send_gdb "100-gdb-set remote exec-file $arg\n"
gdb_expect 10 {
{ *big-endian* *-EB* *-meb* } { set sidendian "-EB" }
{ *little-endian* *-EL* *-mel* } { set sidendian "-EL" }
default {
- if {[target_info exists sim,defaultendian]} then {
+ if {[target_info exists sim,defaultendian]} {
set sidendian [target_info sim,defaultendian]
} else {
# rely on endianness settings in sid configuration defaults
# test to see whether to use use sid in build or install tree
set use_build_tree [file exists ../../sid]
- if {$use_build_tree} then {
+ if {$use_build_tree} {
set pre_spawn {
global env
set env(SID_LIBRARY_PATH) [join [glob "../../sid/component/*"] ":"]
set env(SID) "../../sid/main/dynamic/sid"
- if {! [file exists $env(SID)]} then { error "Cannot find sid in build tree" }
+ if {![file exists $env(SID)]} { error "Cannot find sid in build tree" }
}
if { [board_info target sim,protocol] == "sid" } {
set spawncmd "[target_info sim] [target_info sim,options] $sidendian2 -e \"set cpu-gdb-socket sockaddr-local 0.0.0.0:$port\""
global retval
if { $arg != "" } {
- if [gdb_file_cmd $arg] then { return -1 }
+ if {[gdb_file_cmd $arg]} { return -1 }
}
gdb_target_sid
verbose "Timeout is now $timeout seconds" 2
gdb_expect {
-re ".*\[Ee\]rror.*$gdb_prompt $" {
- if $verbose>1 then {
+ if {$verbose > 1} {
perror "Error during download."
}
set retval -1
}
-re ".*$gdb_prompt $" {
- if $verbose>1 then {
+ if {$verbose > 1} {
send_user "Loaded $arg into $GDB\n"
}
set retval 0
}
-re "$gdb_prompt $" {
- if $verbose>1 then {
+ if {$verbose > 1} {
perror "GDB couldn't load."
}
set retval -1
}
timeout {
- if $verbose>1 then {
+ if {$verbose > 1} {
perror "Timed out trying to load $arg."
}
set retval -1
global gdb_prompt
if { $arg != "" } {
- if [gdb_file_cmd $arg] then { return -1 }
+ if {[gdb_file_cmd $arg]} { return -1 }
}
- if [gdb_target_sim] then { return -1 }
+ if {[gdb_target_sim]} { return -1 }
send_gdb "load\n"
gdb_expect 2400 {
-re ".*$gdb_prompt $" {
- if $verbose>1 then {
+ if {$verbose > 1} {
send_user "Loaded $arg into $GDB\n"
}
return 0
}
-re "$gdb_prompt $" {
- if $verbose>1 then {
+ if {$verbose > 1} {
perror "GDB couldn't load."
}
}
timeout {
- if $verbose>1 then {
+ if {$verbose > 1} {
perror "Timed out trying to load $arg."
}
}
}
-re "Remote target.*$gdb_prompt $" { }
-re ".*SPARClite appears to be alive.*$gdb_prompt $" {
- if $verbose>1 then {
+ if {$verbose > 1} {
send_user "Set target to $targetname\n"
}
}
verbose "Timeout is now $timeout seconds" 2
}
-re "$gdb_prompt $" {
- if $verbose>1 then {
+ if {$verbose > 1} {
perror "GDB couldn't load."
}
}
timeout {
- if $verbose>1 then {
+ if {$verbose > 1} {
perror "Timed out trying to load $arg."
}
}
}
}
- if [info exists expect_out(buffer)] then {
+ if {[info exists expect_out(buffer)]} {
send_log $expect_out(buffer)
}
return 0
# The test name defaults to the command, but without the
# arguments, for historical reasons.
- if { "$in_testname" == "" } then { set in_testname "ptype $in_exp" }
+ if {"$in_testname" == ""} { set in_testname "ptype $in_exp" }
set in_command "ptype${in_ptype_arg} $in_exp"
}
# Save class tables in a history array for reuse.
global cp_class_table_history
- if { $in_class_table == "ibid" } then {
- if { ! [info exists cp_class_table_history("$in_key,$in_tag") ] } then {
+ if {$in_class_table == "ibid"} {
+ if {![info exists cp_class_table_history("$in_key,$in_tag")]} {
fail "$in_testname // bad ibid"
return false
}
# Check the actual tag.
- if { "$actual_tag" != "$in_tag" } then {
+ if {"$actual_tag" != "$in_tag"} {
cp_check_errata "$in_tag" "$actual_tag" $in_errata_table
fail "$in_testname // wrong tag: $actual_tag"
return false
# First parse them into a list.
set list_actual_bases { }
- if { "$actual_base_string" != "" } then {
+ if {"$actual_base_string" != ""} {
regsub "^:${wsopt}" $actual_base_string "" actual_base_string
set list_actual_bases [split $actual_base_string ","]
}
# Check the base count.
- if { [llength $list_actual_bases] < [llength $list_bases] } then {
+ if {[llength $list_actual_bases] < [llength $list_bases]} {
fail "$in_testname // too few bases"
return false
}
- if { [llength $list_actual_bases] > [llength $list_bases] } then {
+ if {[llength $list_actual_bases] > [llength $list_bases]} {
fail "$in_testname // too many bases"
return false
}
foreach actual_base $list_actual_bases {
set actual_base [string trim $actual_base]
set base [lindex $list_bases 0]
- if { "$actual_base" != "$base" } then {
+ if {"$actual_base" != "$base"} {
cp_check_errata "$base" "$actual_base" $in_errata_table
fail "$in_testname // wrong base: $actual_base"
return false
# Get the next line.
set actual_line [cp_support_internal::next_line $line_queue]
- if { "$actual_line" == "" } then { continue }
+ if {"$actual_line" == ""} { continue }
# Access specifiers.
- if { [regexp "^(public|protected|private)${wsopt}:\$" "$actual_line" s0 s1] } then {
+ if {[regexp "^(public|protected|private)${wsopt}:\$" "$actual_line" s0 s1]} {
set access "$s1"
- if { $last_was_access } then {
+ if {$last_was_access} {
fail "$in_testname // redundant access specifier"
queue delete $line_queue
return false
# Optional virtual base pointer.
- if { [ llength $list_vbases ] > 0 } then {
+ if {[llength $list_vbases] > 0} {
set vbase [lindex $list_vbases 0]
- if { [ regexp "$vbase \\*(_vb.|_vb\\\$|__vb_)\[0-9\]*$vbase;" $actual_line ] } then {
- if { "$access" != "private" } then {
+ if {[regexp "$vbase \\*(_vb.|_vb\\\$|__vb_)\[0-9\]*$vbase;" $actual_line]} {
+ if {"$access" != "private"} {
cp_check_errata "private" "$access" $in_errata_table
fail "$in_testname // wrong access specifier for virtual base: $access"
queue delete $line_queue
# Data field.
- if { [llength $list_fields] > 0 } then {
+ if {[llength $list_fields] > 0} {
set field_access [lindex [lindex $list_fields 0] 0]
set field_decl [lindex [lindex $list_fields 0] 1]
if {$recursive_qid > 0} {
cp_ptype_class_verbose "\tfield_decl=$field_decl"
cp_ptype_class_verbose "\taccess=$access"
}
- if { "$actual_line" == "$field_decl" } then {
- if { "$access" != "$field_access" } then {
+ if {"$actual_line" == "$field_decl"} {
+ if {"$access" != "$field_access"} {
cp_check_errata "$field_access" "$access" $in_errata_table
fail "$in_testname // wrong access specifier for field: $access"
queue delete $line_queue
# Method function.
- if { [llength $list_methods] > 0 } then {
+ if {[llength $list_methods] > 0} {
set method_access [lindex [lindex $list_methods 0] 0]
set method_decl [lindex [lindex $list_methods 0] 1]
- if { "$actual_line" == "$method_decl" } then {
- if { "$access" != "$method_access" } then {
+ if {"$actual_line" == "$method_decl"} {
+ if {"$access" != "$method_access"} {
cp_check_errata "$method_access" "$access" $in_errata_table
fail "$in_testname // wrong access specifier for method: $access"
queue delete $line_queue
# gcc 2.95.3 shows "foo()" as "foo(void)".
regsub -all "\\(\\)" $method_decl "(void)" method_decl
- if { "$actual_line" == "$method_decl" } then {
- if { "$access" != "$method_access" } then {
+ if {"$actual_line" == "$method_decl"} {
+ if {"$access" != "$method_access"} {
cp_check_errata "$method_access" "$access" $in_errata_table
fail "$in_testname // wrong access specifier for method: $access"
queue delete $line_queue
set synth_access [lindex $synth 1]
set synth_re [lindex $synth 2]
- if { [ regexp "$synth_re" "$actual_line" ] } then {
+ if {[regexp "$synth_re" "$actual_line"]} {
- if { "$access" != "$synth_access" } then {
+ if {"$access" != "$synth_access"} {
cp_check_errata "$synth_access" "$access" $in_errata_table
fail "$in_testname // wrong access specifier for synthetic operator: $access"
queue delete $line_queue
return false
}
- if { $synth_count > 0 } then {
+ if {$synth_count > 0} {
cp_check_errata "$actual_line" "$actual_line" $in_errata_table
fail "$in_testname // duplicate synthetic operator: $actual_line"
}
break
}
}
- if { $synth_match } then { continue }
+ if {$synth_match} { continue }
# If checking a nested type/recursively and we see a closing curly
# brace, we're done.
# Unrecognized line.
- if { [llength $list_methods] > 0 } then {
+ if {[llength $list_methods] > 0} {
set method_decl [lindex [lindex $list_methods 0] 1]
cp_check_errata "$method_decl" "$actual_line" $in_errata_table
}
# Check for missing elements.
- if { $vbase_match } then {
- if { [llength $list_vbases] > 0 } then {
+ if {$vbase_match} {
+ if {[llength $list_vbases] > 0} {
fail "$in_testname // missing virtual base pointers"
return false
}
}
- if { [llength $list_fields] > 0 } then {
+ if {[llength $list_fields] > 0} {
fail "$in_testname // missing fields"
return false
}
- if { [llength $list_methods] > 0 } then {
+ if {[llength $list_methods] > 0} {
fail "$in_testname // missing methods"
return false
}
# Check the tail.
set actual_tail [string trim $actual_tail]
- if { "$actual_tail" != "$in_tail" } then {
+ if {"$actual_tail" != "$in_tail"} {
cp_check_errata "$in_tail" "$actual_tail" $in_errata_table
fail "$in_testname // wrong tail: $actual_tail"
return false
global subdir
global srcdir
- if { ! [regexp "^/" "$executable"] } then {
+ if {![regexp "^/" "$executable"]} {
set binfile [standard_output_file $executable]
} else {
set binfile $executable
set s [lindex $spec 0]
set local_options [lindex $spec 1]
- if { ! [regexp "^/" "$s"] } then {
+ if {![regexp "^/" "$s"]} {
set s "$srcdir/$subdir/$s"
}
proc base { addr } {
variable _debug_ranges_64_bit
- if { $_debug_ranges_64_bit } then {
+ if {$_debug_ranges_64_bit} {
_op .8byte 0xffffffffffffffff "Base Marker"
_op .8byte $addr "Base Address"
} else {
proc range { start end } {
variable _debug_ranges_64_bit
- if { $_debug_ranges_64_bit } then {
+ if {$_debug_ranges_64_bit} {
_op .8byte $start "Start Address"
_op .8byte $end "End Address"
} else {
uplevel $body
# End of the sequence.
- if { $_debug_ranges_64_bit } then {
+ if {$_debug_ranges_64_bit} {
_op .8byte 0x0 "End of Sequence Marker (Part 1)"
_op .8byte 0x0 "End of Sequence Marker (Part 2)"
} else {
# but it's not clear what removing one of them will break.
# See with_gdb_prompt for more details on prompt handling.
global gdb_prompt
-if ![info exists gdb_prompt] then {
+if {![info exists gdb_prompt]} {
set gdb_prompt "\\(gdb\\)"
}
regsub -all {\r} $patterns {\\r} patterns
regsub -all {\n} $patterns {\\n} patterns
- if $verbose>2 then {
+ if {$verbose > 2} {
send_user "Sending \"$command\" to gdb\n"
send_user "Looking to match \"$patterns\"\n"
send_user "Message is \"$message\"\n"
append code {
-re "Ending remote debugging.*$prompt_regexp" {
- if ![isnative] then {
+ if {![isnative]} {
warning "Can`t communicate to remote target."
}
gdb_exit
set result 1
}
-re "$inferior_exited_re with code \[0-9\]+.*$prompt_regexp" {
- if ![string match "" $message] then {
+ if {![string match "" $message]} {
set errmsg "$message (the program exited)"
} else {
set errmsg "$command (the program exited)"
set result -1
}
-re "$inferior_exited_re normally.*$prompt_regexp" {
- if ![string match "" $message] then {
+ if {![string match "" $message]} {
set errmsg "$message (the program exited)"
} else {
set errmsg "$command (the program exited)"
set result -1
}
-re "The program is not being run.*$prompt_regexp" {
- if ![string match "" $message] then {
+ if {![string match "" $message]} {
set errmsg "$message (the program is no longer running)"
} else {
set errmsg "$command (the program is no longer running)"
set result -1
}
-re "\r\n$prompt_regexp" {
- if ![string match "" $message] then {
+ if {![string match "" $message]} {
fail "$message"
}
set result 1
set result -1
}
timeout {
- if ![string match "" $message] then {
+ if {![string match "" $message]} {
fail "$message (timeout)"
}
set result 1
global gdb_prompt
global verbose
- if [llength $args]==2 then {
+ if {[llength $args] == 2} {
set expectthis [lindex $args 1]
} else {
set expectthis "should never match this bogus string"
}
set sendthis [lindex $args 0]
- if $verbose>2 then {
+ if {$verbose > 2} {
send_user "Sending \"$sendthis\" to gdb\n"
send_user "Looking to match \"$expectthis\"\n"
}
# case some users of gdb_test_exact already do the right thing.
regsub -all "\r\n" $pattern "\n" pattern
regsub -all "\n" $pattern "\r\n" pattern
- if [llength $args]==3 then {
+ if {[llength $args] == 3} {
set message [lindex $args 2]
return [gdb_test $command $pattern $message]
}
}
if ![is_remote host] {
- if { [which $GDB] == 0 } then {
+ if {[which $GDB] == 0} {
perror "$GDB does not exist."
exit 1
}
# such an option is specified.
set opt "additional_flags=-fdiagnostics-color=never"
set lines [target_compile $src $obj object [list "quiet" $opt]]
- if [string match "" $lines] then {
+ if {[string match "" $lines]} {
# Seems to have worked; use the option.
lappend options $opt
}
file delete $src
- if ![string match "" $lines] then {
+ if {![string match "" $lines]} {
verbose "$name: compilation failed, returning 0" 2
return 0
}
# We use exp_pid to get the inferior's pid, assuming that gives
# back the pid of the program. On remote boards, that would give
# us instead the PID of e.g., the ssh client, etc.
- if [is_remote target] then {
+ if {[is_remote target]} {
verbose -log "can't spawn for attach (target is remote)"
return 0
}
proc setup_xfail_format { format } {
set ret [test_debug_format $format]
- if {$ret} then {
+ if {$ret} {
setup_xfail "*-*-*"
}
return $ret
global subdir
global srcfile
- if { "$file" == "" } then {
+ if {"$file" == ""} {
set file "$srcfile"
}
- if { ! [regexp "^/" "$file"] } then {
+ if {![regexp "^/" "$file"]} {
set file "$srcdir/$subdir/$file"
}
- if { [ catch { set fd [open "$file"] } message ] } then {
+ if {[catch { set fd [open "$file"] } message]} {
error "$message"
}
set found -1
for { set line 1 } { 1 } { incr line } {
- if { [ catch { set nchar [gets "$fd" body] } message ] } then {
+ if {[catch { set nchar [gets "$fd" body] } message]} {
error "$message"
}
- if { $nchar < 0 } then {
+ if {$nchar < 0} {
break
}
- if { [string first "$text" "$body"] >= 0 } then {
+ if {[string first "$text" "$body"] >= 0} {
set found $line
break
}
}
- if { [ catch { close "$fd" } message ] } then {
+ if {[catch { close "$fd" } message]} {
error "$message"
}
set lines [gdb_compile $src $exe executable $compile_flags]
file delete $src
- if ![string match "" $lines] then {
+ if {![string match "" $lines]} {
verbose "testfile compilation failed, returning 1" 2
return 0
}
set data [read $fi]
close $fi
file delete $tmp
- if ![string compare $data ""] then {
+ if {![string compare $data ""]} {
return ""
}
# Convert it to hex.
if [string match gdb_compile_shlib* $func] {
set sources_path {}
foreach {s local_options} $args {
- if { [regexp "^/" "$s"] } then {
+ if {[regexp "^/" "$s"]} {
lappend sources_path "$s"
} else {
lappend sources_path "$srcdir/$subdir/$s"
} elseif {[lsearch -exact $options rust] != -1} {
set sources_path {}
foreach {s local_options} $args {
- if { [regexp "^/" "$s"] } then {
+ if {[regexp "^/" "$s"]} {
lappend sources_path "$s"
} else {
lappend sources_path "$srcdir/$subdir/$s"
set objects {}
set i 0
foreach {s local_options} $args {
- if { ! [regexp "^/" "$s"] } then {
+ if {![regexp "^/" "$s"]} {
set s "$srcdir/$subdir/$s"
}
if { [$func "${s}" "${binfile}${i}.o" object $local_options] != "" } {
set pattern "$prefix$argument"
set result [lsearch -exact $args $pattern]
- if {$result != -1} then {
+ if {$result != -1} {
set value 1
set args [lreplace $args $result $result]
} else {
set pattern "$prefix[lindex $arg 0]"
set result [lsearch -exact $args $pattern]
- if {$result != -1} then {
+ if {$result != -1} {
set value [lindex $args [expr $result+1]]
if { $eval } {
set value [uplevel [expr $level + 1] [list subst $value]]
set file_contents [read $fp]
close $fp
} error_message]
- if { $caught_error } then {
+ if {$caught_error} {
error "$error_message"
fail "$msg"
return
# The variable mi_gdb_prompt is a regexp which matches the gdb mi prompt.
# Set it if it is not already set.
global mi_gdb_prompt
-if ![info exists mi_gdb_prompt] then {
+if {![info exists mi_gdb_prompt]} {
set mi_gdb_prompt "\[(\]gdb\[)\] \r\n"
}
global inferior_exited_re async
upvar timeout timeout
- if { [llength $args] >= 1 } then {
+ if {[llength $args] >= 1} {
set command [lindex $args 0]
} else {
error "Not enough arguments in mi_gdb_test"
}
- if { [llength $args] >= 2 } then {
+ if {[llength $args] >= 2} {
set pattern [lindex $args 1]
} else {
set pattern ".*"
}
- if { [llength $args] >= 3 } then {
+ if {[llength $args] >= 3} {
set message [lindex $args 2]
} else {
set message $command
error "Too many arguments in mi_gdb_test"
}
- if $verbose>2 then {
+ if {$verbose > 2} {
send_user "Sending \"$command\" to gdb\n"
send_user "Looking to match \"$pattern\"\n"
send_user "Message is \"$message\"\n"
return -1
}
-re "Ending remote debugging.*$mi_gdb_prompt\[ \]*$" {
- if ![isnative] then {
+ if {![isnative]} {
warning "Can`t communicate to remote target."
}
gdb_exit
# match a single mi output command. If a second GDB/MI output
# response is sent, it will be in the buffer for the next
# time mi_gdb_test is called.
- if ![string match "" $message] then {
+ if {![string match "" $message]} {
pass "$message"
}
set result 0
set result 1
}
-re "$inferior_exited_re with code \[0-9\]+.*$mi_gdb_prompt\[ \]*$" {
- if ![string match "" $message] then {
+ if {![string match "" $message]} {
set errmsg "$message (the program exited)"
} else {
set errmsg "$command (the program exited)"
return -1
}
-re "The program is not being run.*$mi_gdb_prompt\[ \]*$" {
- if ![string match "" $message] then {
+ if {![string match "" $message]} {
set errmsg "$message (the program is no longer running)"
} else {
set errmsg "$command (the program is no longer running)"
return -1
}
-re ".*$mi_gdb_prompt\[ \]*$" {
- if ![string match "" $message] then {
+ if {![string match "" $message]} {
fail "$message (unexpected output)"
}
set result 1
fail "$message"
}
timeout {
- if ![string match "" $message] then {
+ if {![string match "" $message]} {
fail "$message (timeout)"
}
set result 1
set mi_autotest_source $filename
- if { ! [regexp "^/" "$filename"] } then {
+ if {![regexp "^/" "$filename"]} {
set filename "$srcdir/$subdir/$filename"
}
}
if ![is_remote host] {
- if { [which $GDB] == 0 } then {
+ if {[which $GDB] == 0} {
perror "$GDB does not exist."
exit 1
}
# If the arg directly specifies an existing executable file, then
# simply use it.
- if [file executable $arg] then {
+ if {[file executable $arg]} {
return $arg
}
set result [which $arg]
- if [string match "/" [ string range $result 0 0 ]] then {
+ if {[string match "/" [ string range $result 0 0 ]]} {
return $result
}
set result [gdb_load $executable]
- if { $result != 0 } then {
+ if {$result != 0} {
return -1
}
- if { $gdb_file_cmd_debug_info != "debug" } then {
+ if {$gdb_file_cmd_debug_info != "debug"} {
untested "no debug information, skipping testcase."
return -2
}
# duration of the test.
with_timeout_factor 10 {
set result [selftest_setup $file $function]
- if {$result == 0} then {
+ if {$result == 0} {
set result [uplevel $body]
}
}
gdb_exit
catch "remote_file host delete $file"
- if {$result == -1} then {
+ if {$result == -1} {
warning "Couldn't test self"
}
}
if { $testname != "" } {
$passfail $testname
}
- if { $passfail == "pass" } then {
+ if {$passfail == "pass"} {
return 0
} else {
return 1
-re "$gdb_prompt $" { }
}
$passfail "$testname"
- if { $passfail == "pass" } then {
+ if {$passfail == "pass"} {
return 0
} else {
return 1
clean_restart $binfile
- if ![runto_main] then {
+ if {![runto_main]} {
return 0
}
gdb_continue_to_end "" continue 1