Running tclint on the test-cases in gdb.python shows a few problems.
Fix these.
Tested on x86_64-linux.
"gdb/testsuite/gdb.cp",
"gdb/testsuite/gdb.dwarf2",
"gdb/testsuite/gdb.mi",
-"gdb/testsuite/gdb.python",
"gdb/testsuite/gdb.threads",
"gdb/testsuite/gdb.trace",
# IGNORE (document reason in trailing comment):
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
} else {
set sign_result [lindex $sign_data 1]
}
- set fullsize [expr 8 * $size]
+ set fullsize [expr {8 * $size}]
gdb_test_no_output "python t = arch.integer_type($fullsize$sign)" \
"get integer type for $size$sign"
gdb_test "python print(t.sizeof)" "$size" \
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return 0
}
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
clean_restart $testfile
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
"check repr of disabled breakpoint location"
gdb_continue_to_breakpoint "" ".*25.*"
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
}
clean_restart "${testfile}"
-if ![runto_main] {
+if {![runto_main]} {
return
}
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return 0
}
i = <Enter 1 to explore this field of type 'int'>.*\
c = <Enter 2 to explore this field of type 'char'>.*"
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
proc pointer_description { value_name type_name } {
set type_description "'$value_name' is a pointer to a value of type '$type_name'\.\[\r\n\]+"
- set prompt "Continue exploring it as a pointer to a single value \[\[\]y/n\[\]\]: "
+ set prompt "Continue exploring it as a pointer to a single value \[\[\]y/n\[\]\]: "
return "$type_description$prompt"
}
set SS_fields [field_values {a = 10} {d = 100[.].*}]
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
}
}
}
- }
+ }
}
}
}
}
#
-# Test FinishBreakpoint with no debug symbol
+# Test FinishBreakpoint with no debug symbol
#
with_test_prefix "no debug symbol" {
}
#
-# Test FinishBreakpoint in function returned by longjmp
+# Test FinishBreakpoint in function returned by longjmp
#
with_test_prefix "function returned by longjump" {
}
#
-# Test FinishBreakpoint in BP condition evaluation
+# Test FinishBreakpoint in BP condition evaluation
# (finish in dummy frame)
#
}
#
-# Test FinishBreakpoint in BP condition evaluation
+# Test FinishBreakpoint in BP condition evaluation
# (finish in normal frame)
#
gdb_test "source $pyfile" ".*Python script imported.*" \
"import python scripts"
-
+
gdb_breakpoint "throw_exception_1"
#
clean_restart $testfile_foo
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
}
}
if { $next_addr == "UNKNOWN" || $next_addr == $main_addr } {
- set next_addr [format 0x%x [expr $main_addr + 1]]
+ set next_addr [format 0x%x [expr {$main_addr + 1}]]
}
verbose -log "main_addr: $main_addr"
return "\"${whole_big_string}\""
}
- set cut_string [string range $whole_big_string 0 [expr $max - 1]]
+ set cut_string [string range $whole_big_string 0 [expr {$max - 1}]]
return "\"${cut_string}\"..."
}
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
# For native targets, test a pattern straddling a chunk boundary.
-if [isnative] {
+if {[isnative]} {
with_test_prefix "straddling" {
gdb_test_no_output "set *(int32_t*) &search_buf\[${CHUNK_SIZE}-1\] = 0xfdb97531"
gdb_test_no_output "py pattern = pack('${python_pack_char}I', 0xfdb97531)"
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
return -1
}
-if ![runto_main ] {
+if {![runto_main ]} {
return -1
}
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
set opts {}
standard_testfile .S
-if [info exists COMPILE] {
+if {[info exists COMPILE]} {
# make check RUNTESTFLAGS="gdb.python/py-linetable.exp COMPILE=1"
standard_testfile
lappend opts debug optimize=-O2
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
{.*\^done} \
"set safe-path"
-if [is_remote host] {
+if {[is_remote host]} {
set filename ${testfile}
remote_download host ${binfile} ${filename}
} else {
{.*\^done} \
"set safe-path"
-if [is_remote host] {
+if {[is_remote host]} {
set filename ${testfile}
remote_download host ${binfile} ${filename}
} else {
# Verify gdb loaded the script.
gdb_test "info auto-load python-scripts" "Yes.*${testfile}-gdb.py.*"
-if ![runto_main] {
+if {![runto_main]} {
return
}
"None" "lookup_static_symbol can handle nonexistent symbol"
set binfile_build_id [get_build_id $binfile]
-if [string compare $binfile_build_id ""] {
+if {[string compare $binfile_build_id ""]} {
verbose -log "binfile_build_id = $binfile_build_id"
gdb_test "python print (objfile.build_id)" "$binfile_build_id" \
"Get objfile build id"
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return 0
}
# An objfile that was a symlink to a differently named file is still
# findable with its original name.
# On Windows we don't have proper symlinks, so skip this.
-if ![ishost *-*-mingw*] {
+if {![ishost *-*-mingw*]} {
set symlink_binary [standard_output_file "symlink-binary"]
remote_exec host "rm -f ${symlink_binary}"
remote_exec host "ln -sf ${testfile} ${symlink_binary}"
- if [remote_file host exists "${symlink_binary}"] {
+ if {[remote_file host exists "${symlink_binary}"]} {
clean_restart
gdb_load "${symlink_binary}"
gdb_test "python print (gdb.lookup_objfile (\"${symlink_binary}\").filename)" \
clean_restart
proc py_param_test_maybe_no_output { command pattern args } {
- if [string length $pattern] {
+ if {[string length $pattern]} {
gdb_test $command $pattern $args
} else {
gdb_test_no_output $command $args
return -1
}
-if ![runto break_function] {
+if {![runto break_function]} {
return -1
}
return -1
}
-if ![runto tick_tock] {
+if {![runto tick_tock]} {
return -1
}
"second enable of all pretty printers"
gdb_test "disable pretty-printer global lookup_function_lookup_test" \
- "1 printer disabled.*[expr $num_pp - 1] of $num_pp printers enabled"
+ "1 printer disabled.*[expr {$num_pp - 1}] of $num_pp printers enabled"
gdb_test "disable pretty-printer global pp-test;.*" \
"[expr {$num_pp - 1}] printers disabled.*0 of $num_pp printers enabled"
"0 printers enabled.*1 of $num_pp printers enabled"
gdb_test "enable pretty-printer global pp-test;.*ss.*" \
- "2 printers enabled.*[expr $num_pp - 3] of $num_pp printers enabled"
+ "2 printers enabled.*[expr {$num_pp - 3}] of $num_pp printers enabled"
gdb_test "enable pretty-printer global pp-test;.*s.*" \
- "2 printers enabled.*[expr $num_pp - 1] of $num_pp printers enabled"
+ "2 printers enabled.*[expr {$num_pp - 1}] of $num_pp printers enabled"
gdb_test "enable pretty-printer global pp-test;.*" \
"1 printer enabled.*$num_pp of $num_pp printers enabled"
return -1
}
-if ![runto tick_tock] {
+if {![runto tick_tock]} {
return -1
}
set remote_python_file [gdb_remote_download host \
${srcdir}/${subdir}/${testfile}.py]
-if ![runto_main ] {
+if {![runto_main ]} {
return -1
}
clean_restart ${testfile}
set run_to_here [gdb_get_line_number {break to inspect} ${testfile}.c ]
- if ![runto ${testfile}.c:$run_to_here] {
+ if {![runto ${testfile}.c:$run_to_here]} {
return 0
}
# Test registration with verbose off.
with_test_prefix "verbose off" {
- if ![prepare_test] {
+ if {![prepare_test]} {
return -1
}
# Test registration with verbose on.
with_test_prefix "verbose on" {
- if ![prepare_test] {
+ if {![prepare_test]} {
return -1
}
# Exercise the "replace" argument to register_pretty_printer.
with_test_prefix "replace" {
- if ![prepare_test] {
+ if {![prepare_test]} {
return -1
}
${srcdir}/${subdir}/${testfile}.py]
gdb_test_no_output "source ${remote_python_file}" "load python file"
-
+
gdb_test "print ss" " = a=< a=<1> b=<$hex>> b=< a=<2> b=<$hex>>"
gdb_test "print ssa\[1\]" " = a=< a=<5> b=<$hex>> b=< a=<6> b=<$hex>>"
gdb_test "print ssa" " = {a=< a=<3> b=<$hex>> b=< a=<4> b=<$hex>>, a=< a=<5> b=<$hex>> b=< a=<6> b=<$hex>>}"
-
+
gdb_test "print arraystruct" " = {$nl *y = 7, *$nl *x = { a=<23> b=<$hex>, a=<24> b=<$hex>} *$nl *}"
# Test that when a pretty-printer returns a gdb.Value in its to_string, we
"block end is after \$pc"
# Check what happens when we ask for a block of an invalid address.
-if ![is_address_zero_readable] {
+if {![is_address_zero_readable]} {
gdb_test "python print (gdb.current_progspace ().block_for_pc (0))" "None"
}
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] { return -1 }
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} { return -1 }
if {![runto_main]} {
return -1
standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] { return -1 }
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} { return -1 }
if {![runto_main]} {
return -1
# Get the name of the binfile on the host; on a remote host this means
# stripping off any directory prefix.
-if [is_remote host] {
+if {[is_remote host]} {
set remote_binfile [file tail ${binfile}]
} else {
set remote_binfile ${binfile}
}
-if [ishost *-*-mingw*] {
+if {[ishost *-*-mingw*]} {
set remote_pathsep ";"
} else {
set remote_pathsep ":"
gdb_test "info auto-load python-scripts no-script-matches-this" \
"No auto-load scripts matching no-script-matches-this."
-if ![runto_main] {
+if {![runto_main]} {
return
}
return
}
- if ![runto_main] {
+ if {![runto_main]} {
return
}
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return 0
}
gdb_test "test-events" "Event testers registered."
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
}
# Restart GDB.
-proc restart_gdb {exefile} {
+proc restart_gdb {exefile} {
clean_restart
gdb_load $exefile
# Test conversion to bool on scalar types
gdb_test "python print (not not st.type\['a'\].type)" "True"
-
+
# Test regression PR python/10805
gdb_py_test_silent_cmd "print (ar)" "print value(ar)" 1
gdb_py_test_silent_cmd "python ar = gdb.history (0)" "get value (ar) from history" 1
|| [test_compiler_info {gcc-4-[0-4]-*}]} {
set have_older_gcc 1
}
- if $have_older_gcc { setup_xfail *-*-* }
+ if {$have_older_gcc} { setup_xfail *-*-* }
gdb_test "python print (ttype.template_argument(1))" "23"
- if $have_older_gcc { setup_xfail *-*-* }
+ if {$have_older_gcc} { setup_xfail *-*-* }
gdb_test "python print (isinstance(ttype.template_argument(1), gdb.Value))" \
"True"
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
gdb_test "print argc" " = $argc_value" "sanity check argc"
gdb_test "python print (argc_lazy.is_lazy)" "\r\nTrue" \
"python print (argc_lazy.is_lazy) the second time"
- gdb_test_no_output "set argc=[expr $argc_value + 1]" "change argc"
+ gdb_test_no_output "set argc=[expr {$argc_value + 1}]" "change argc"
gdb_test "python print (argc_notlazy)" "\r\n$argc_value"
- gdb_test "python print (argc_lazy)" "\r\n[expr $argc_value + 1]"
+ gdb_test "python print (argc_lazy)" "\r\n[expr {$argc_value + 1}]"
gdb_test "python print (argc_lazy.is_lazy)" "False"
# Test string fetches, both partial and whole.
gdb_py_test_silent_cmd "python atpbig=tp.array(3)" "make bigger array type" 0
gdb_test "python vabig=gdb.Value(b,atpbig)" \
"ValueError.*: Size of type is larger than that of buffer object\..*" \
- "attempt to construct large value with small buffer"
+ "attempt to construct large value with small buffer"
gdb_test "python v=gdb.Value(2048,tp)" \
"TypeError.*: Object must support the python buffer protocol\..*" \
"attempt to construct value from buffer with non-buffer object"
proc test_unavailable {} {
set elem_size [get_valueof "/d" "sizeof(long_array\[0\])" "UNKNOWN" \
"get size of long_array element"]
- set max [expr $elem_size * 10]
+ set max [expr {$elem_size * 10}]
with_set "print elements" 5 {
with_max_value_size $max {
test_value_bytes
test_value_after_death
-# Test either C or C++ values.
+# Test either C or C++ values.
test_subscript_regression "${binfile}" "c"
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
}
gdb_test "q" "Quit.*" "verify pagination beforehand: q"
-gdb_test "python if gdb.execute('python print (\"\\\\n\" * $lines)', to_string=True) == \"\\n\" * [expr $lines + 1]: print (\"yes\")" "yes" "gdb.execute does not page"
+gdb_test "python if gdb.execute('python print (\"\\\\n\" * $lines)', to_string=True) == \"\\n\" * [expr {$lines + 1}]: print (\"yes\")" "yes" "gdb.execute does not page"
set test "verify pagination afterwards"
gdb_test_multiple "python print (\"\\n\" * $lines)" $test {
gdb_test "python gdb.write(\"Error stream\\n\", stream=gdb.STDERR)" "Error stream" "test stderr write"
gdb_test "python gdb.write(\"Normal stream\\n\", stream=gdb.STDOUT)" "Normal stream" "test stdout write"
-if ![gdb_debug_enabled] {
+if {![gdb_debug_enabled]} {
gdb_test "python gdb.write(\"Log stream\\n\", stream=gdb.STDLOG)" "Log stream" "test stdlog write"
}