]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite, Tcl 9.0] Namespace fixes
authorTom de Vries <tdevries@suse.de>
Fri, 20 Mar 2026 09:13:27 +0000 (10:13 +0100)
committerTom de Vries <tdevries@suse.de>
Fri, 20 Mar 2026 09:13:27 +0000 (10:13 +0100)
A few test-cases wrap code in namespaces.

Since Tcl 9.0, globals are no longer directly available inside namespaces.

Fix this by redeclaring using upvar.

Also, referring to variables in namespaces needs to be done using fully
qualified names.  Fix this by adding a :: prefix.

Approved-By: Tom Tromey <tom@tromey.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33948

gdb/testsuite/gdb.dap/bt-nodebug.exp
gdb/testsuite/gdb.dwarf2/implptr-64bit.exp
gdb/testsuite/gdb.linespec/cpexplicit.exp
gdb/testsuite/gdb.linespec/explicit.exp
gdb/testsuite/gdb.multi/multi-kill.exp
gdb/testsuite/gdb.tui/tuiterm-2.exp

index 4068eec222a14c2856307ee6a82a255273975279..8bfcfeaf62fd85f439db761cff2392639c91824a 100644 (file)
@@ -74,7 +74,7 @@ gdb_assert {[dict exists [lindex $breakpoints 0] instructionReference]} \
 # tclint-disable-next-line command-args
 set list_form [namespace eval ton::2list $last_ton]
 set ref [namespace eval ton::2list {
-    get $list_form body breakpoints 0 instructionReference
+    get $::list_form body breakpoints 0 instructionReference
 }]
 gdb_assert {[regexp "^$hex\$" $ref]} \
     "instructionReference is a hex string"
index ca7e1aa666747ffe63daf0def62eee372744d32c..59b91fad6faef9feee3519886e875520475fcc3f 100644 (file)
@@ -63,7 +63,7 @@ proc test_1 { name dwarf_version offset_size addr_size ref_addr_size two_cu } {
                }
 
                pointer_label: pointer_type {
-                    DW_AT_byte_size $Dwarf::_cu_addr_size sdata
+                    DW_AT_byte_size $::Dwarf::_cu_addr_size sdata
                     DW_AT_type  :$struct_label
                }
 
index 0aad2972a77c637484a321ba6955df51afbe3f39..b5dbc6dceece8259f50201b861dff895cbc3c70a 100644 (file)
@@ -27,6 +27,8 @@ if {[prepare_for_testing "failed to prepare" $exefile $srcfile \
 
 # Wrap this whole test in a namespace to avoid contaminating other tests.
 namespace eval $testfile {
+    upvar #0 ::srcfile srcfile
+
     # Test the given (explicit) LINESPEC which should cause gdb to break
     # at LOCATION.
     proc test_breakpoint {linespec location} {
index 9f72144f7a983d25a00a03ad8e430942425c243a..faee27bab4a5b7c56401bff5dfe758447862cd1d 100644 (file)
@@ -32,6 +32,9 @@ if {[prepare_for_testing "failed to prepare" $exefile \
 
 # Wrap the entire test in a namespace to avoid contaminating other tests.
 namespace eval $testfile {
+    upvar #0 ::srcfile srcfile
+    upvar #0 ::gdb_prompt gdb_prompt
+    upvar #0 ::exefile exefile
 
     # Test the given (explicit) LINESPEC which should cause gdb to break
     # at LOCATION.
@@ -232,7 +235,7 @@ namespace eval $testfile {
        }
 
        with_test_prefix "complete unique file name" {
-           foreach qc $completion::maybe_quoted_list {
+           foreach qc $::completion::maybe_quoted_list {
                set cmd "break -source ${qc}3explicit.c${qc}"
                test_gdb_complete_unique \
                    "break -source ${qc}3ex" \
@@ -342,7 +345,7 @@ namespace eval $testfile {
        }
 
        with_test_prefix "complete unique label name" {
-           foreach qc $completion::maybe_quoted_list {
+           foreach qc $::completion::maybe_quoted_list {
                test_gdb_complete_unique \
                    "break -function myfunction -label ${qc}to" \
                    "break -function myfunction -label ${qc}top${qc}"
index ffa77c00df84721c79918a2c737272ffe7560d24..20d39adaae2ce86aee60815be8989c1f81558513 100644 (file)
@@ -41,6 +41,8 @@ save_vars { GDBFLAGS } {
 
 # Wrap the entire test in a namespace to avoid contaminating other tests.
 namespace eval $testfile {
+    upvar #0 ::gdb_prompt gdb_prompt
+    upvar #0 ::decimal decimal
 
 # Start inferior NUM and record its PID in the TESTPID array.
 
index 7fd1739e28cd56e3be0ee801abbb5627d98edefe..cb1b6c8edac2045ab4651ff6cd3c2168bd6de70e 100644 (file)
@@ -117,7 +117,7 @@ with_override Term::accept_gdb_output test_accept_gdb_output {
                        Term::_move_cursor 0 0
 
                        Term::_insert "${::border}(gdb) "
-                       set pos $Term::_cur_col
+                       set pos $::Term::_cur_col
 
                        Term::_insert "foo"
 
@@ -130,7 +130,7 @@ with_override Term::accept_gdb_output test_accept_gdb_output {
                        Term::_move_cursor 0 1
 
                        Term::_insert "${::border}(gdb) "
-                       set pos $Term::_cur_col
+                       set pos $::Term::_cur_col
 
                        Term::_move_cursor 19 1
                        Term::_insert "$::border"