]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Remove more uses of "eval"
authorTom de Vries <tdevries@suse.de>
Tue, 16 Sep 2025 20:03:43 +0000 (22:03 +0200)
committerTom de Vries <tdevries@suse.de>
Tue, 16 Sep 2025 20:03:43 +0000 (22:03 +0200)
Remove some more uses of the Tcl "eval" proc.

In most cases the {*} "splat" expansion is used instead.

The exceptions are:
- gdb.base/inferior-args.exp where we rewrite:
    set cmd [format "lappend item \{ '%c' '\\%c' \}" 34 34]
    eval $cmd
  into:
    lappend item [format { '%c' '\%c' } 34 34]
- reset_vars in lib/check-test-names.exp where we simply drop an unnecessary
  eval

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
gdb/testsuite/gdb.base/inferior-args.exp
gdb/testsuite/gdb.dwarf2/clztest.exp
gdb/testsuite/gdb.dwarf2/typeddwarf.exp
gdb/testsuite/lib/check-test-names.exp
gdb/testsuite/lib/debuginfod-support.exp
gdb/testsuite/lib/gdb.exp

index b2916701ba9a93e9d6729e02464340ac964fd414..6b92c08ab3d936bcb4a85a7beca42754e6dba3e1 100644 (file)
@@ -170,8 +170,7 @@ lappend test_desc_list [list "test one" \
 # the rest of this mess in order to avoid TCL escaping the quote for
 # me.  It's super important that what we send to GDB is '"' not '\"'.
 set item [list "test two" false]
-set cmd [format "lappend item \{ '%c' '\\%c' \}" 34 34]
-eval $cmd
+lappend item [format { '%c' '\%c' } 34 34]
 set bs "\\\\"
 lappend item [list "$hex \"$bs\"\"" "$hex \"$bs$bs$bs\"\""]
 lappend test_desc_list $item
index 7a74e02b83828067a025496f9a65375970b4081b..93c2cedd94086ec26c33b1f5e4963d636f80cf79 100644 (file)
@@ -61,7 +61,7 @@ proc scan_gdb_tests {} {
            continue
        }
 
-       eval $test_cmd
+       {*}$test_cmd
     }
     close $fd
 }
index 1135709c8c58a899150bb9cdbd90b1d913464817..b80ce973dd718eb70c8703b57cdea7b08e4bc191 100644 (file)
@@ -78,7 +78,7 @@ proc scan_gdb_tests {} {
            continue
        }
 
-       eval $test_cmd
+       {*}$test_cmd
     }
     close $fd
 }
index 049addd49a93744a832ec0fb5249cd59f3db74f1..d099ffcb0fc5c3ab9959d154451f3d996bf39cd7 100644 (file)
@@ -146,7 +146,7 @@ namespace eval ::CheckTestNames {
 
        # If ARGS is the empty list then we don't want to pass a single
        # empty string as a parameter here.
-       eval "CheckTestNames::log_summary $args"
+       CheckTestNames::log_summary {*}$args
 
        if { [llength $args] == 0 } {
            set which "count"
@@ -184,10 +184,10 @@ foreach nm {pass fail xfail kfail xpass kpass unresolved untested \
 
 # Create new global log_summary to replace Dejagnu's.
 proc log_summary { args } {
-    eval "CheckTestNames::do_log_summary $args"
+    CheckTestNames::do_log_summary {*}$args
 }
 
 # Create new global reset_vars to replace Dejagnu's.
 proc reset_vars {} {
-    eval "CheckTestNames::do_reset_vars"
+    CheckTestNames::do_reset_vars
 }
index 674888a564d946456ad4ed5044a5c30c9451a458..7a8baf427f92f0c8190bb69e23cbedf62cbc5776 100644 (file)
@@ -37,7 +37,7 @@ proc allow_debuginfod_tests {} {
     # (installed by ASan) exist on startup.  That makes TCL's exec throw an
     # error.  This is dealt with by the --quiet in INTERNAL_GDBFLAGS.
     if { [string first "with-debuginfod" \
-             [eval exec $::GDB $::INTERNAL_GDBFLAGS \
+             [exec $::GDB {*}$::INTERNAL_GDBFLAGS \
                   --configuration]] == -1 } {
        return false
     }
index 1780e3775360437884835c941886c00990f4c673..36bd3b48dbc8c277f5a5e0faed2a2407e50559c7 100644 (file)
@@ -5749,7 +5749,7 @@ gdb_caching_proc get_compiler_info_1 {language} {
        set ifile $tofile
        set cppout [ gdb_compile "${ifile}" "" preprocess [list "$language" quiet getting_compiler_info] ]
     }
-    eval log_file $saved_log
+    log_file {*}$saved_log
 
     # Eval the output.
     set unknown 0
@@ -7986,12 +7986,12 @@ proc default_gdb_init { test_file_name } {
 
 proc make_gdb_parallel_path { args } {
     global GDB_PARALLEL objdir
-    set joiner [list "file" "join" $objdir]
+    set joiner [list $objdir]
     if { [info exists GDB_PARALLEL] && $GDB_PARALLEL != "yes" } {
        lappend joiner $GDB_PARALLEL
     }
     set joiner [concat $joiner $args]
-    return [eval $joiner]
+    return [file join {*}$joiner]
 }
 
 # Turn BASENAME into a full file name in the standard output