[binutils-gdb] [gdb/testsuite, Tcl 9.0] Namespace fixes

Tom de Vries via Gdb-cvs <[email protected]>
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=054cb87298a367d744946eeab34f434ca4602d2b

commit 054cb87298a367d744946eeab34f434ca4602d2b
Author: Tom de Vries <[email protected]>
Date:   Fri Mar 20 10:13:27 2026 +0100

    [gdb/testsuite, Tcl 9.0] Namespace fixes
    
    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 <[email protected]>
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33948

Diff:
---
 gdb/testsuite/gdb.dap/bt-nodebug.exp       | 2 +-
 gdb/testsuite/gdb.dwarf2/implptr-64bit.exp | 2 +-
 gdb/testsuite/gdb.linespec/cpexplicit.exp  | 2 ++
 gdb/testsuite/gdb.linespec/explicit.exp    | 7 +++++--
 gdb/testsuite/gdb.multi/multi-kill.exp     | 2 ++
 gdb/testsuite/gdb.tui/tuiterm-2.exp        | 4 ++--
 6 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/gdb/testsuite/gdb.dap/bt-nodebug.exp b/gdb/testsuite/gdb.dap/bt-nodebug.exp
index 4068eec222a..8bfcfeaf62f 100644
--- a/gdb/testsuite/gdb.dap/bt-nodebug.exp
+++ b/gdb/testsuite/gdb.dap/bt-nodebug.exp
@@ -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"
diff --git a/gdb/testsuite/gdb.dwarf2/implptr-64bit.exp b/gdb/testsuite/gdb.dwarf2/implptr-64bit.exp
index ca7e1aa6667..59b91fad6fa 100644
--- a/gdb/testsuite/gdb.dwarf2/implptr-64bit.exp
+++ b/gdb/testsuite/gdb.dwarf2/implptr-64bit.exp
@@ -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
 		}
 
diff --git a/gdb/testsuite/gdb.linespec/cpexplicit.exp b/gdb/testsuite/gdb.linespec/cpexplicit.exp
index 0aad2972a77..b5dbc6dceec 100644
--- a/gdb/testsuite/gdb.linespec/cpexplicit.exp
+++ b/gdb/testsuite/gdb.linespec/cpexplicit.exp
@@ -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} {
diff --git a/gdb/testsuite/gdb.linespec/explicit.exp b/gdb/testsuite/gdb.linespec/explicit.exp
index 9f72144f7a9..faee27bab4a 100644
--- a/gdb/testsuite/gdb.linespec/explicit.exp
+++ b/gdb/testsuite/gdb.linespec/explicit.exp
@@ -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}"
diff --git a/gdb/testsuite/gdb.multi/multi-kill.exp b/gdb/testsuite/gdb.multi/multi-kill.exp
index ffa77c00df8..20d39adaae2 100644
--- a/gdb/testsuite/gdb.multi/multi-kill.exp
+++ b/gdb/testsuite/gdb.multi/multi-kill.exp
@@ -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.
 
diff --git a/gdb/testsuite/gdb.tui/tuiterm-2.exp b/gdb/testsuite/gdb.tui/tuiterm-2.exp
index 7fd1739e28c..cb1b6c8edac 100644
--- a/gdb/testsuite/gdb.tui/tuiterm-2.exp
+++ b/gdb/testsuite/gdb.tui/tuiterm-2.exp
@@ -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"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.