Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/5] [gdb/testsuite] Use valnum_re more often (part 1)
Date: Wed, 28 Jan 2026 13:06:23 +0100	[thread overview]
Message-ID: <20260128120626.1032047-3-tdevries@suse.de> (raw)
In-Reply-To: <20260128120626.1032047-1-tdevries@suse.de>

Use valnum_re more often.  Do this by replacing "\\\$\[0-9\]+" and similar.

I ran these commands handling 6 variants of $decimal:
...
$ find gdb/testsuite/ -type f -name *.exp* \
    | xargs sed -i 's/\\\\\\$\\\[0-9\\\]+/${::valnum_re}/g
$ find gdb/testsuite/ -type f -name *.exp* \
    | xargs sed -i 's/\\\\\\$\\\[0-9\]+/${::valnum_re}/g'
$ find gdb/testsuite/ -type f -name *.exp* \
    | xargs sed -i 's/\\\\\\$$decimal/${::valnum_re}/g'
$ find gdb/testsuite/ -type f -name *.exp* \
    | xargs sed -i 's/\\\\\\$$::decimal/${::valnum_re}/g'
$ find gdb/testsuite/ -type f -name *.exp* \
    | xargs sed -i 's/\\\\\\$${decimal}/${::valnum_re}/g'
$ find gdb/testsuite/ -type f -name *.exp* \
    | xargs sed -i 's/\\\\\\$${::decimal}/${::valnum_re}/g'
...
and then once more matching '\\$' instead of '\\\$'.
---
 gdb/testsuite/gdb.ada/array_return.exp        |   6 +-
 gdb/testsuite/gdb.ada/formatted_ref.exp       |  14 +--
 gdb/testsuite/gdb.ada/operator_call.exp       |   2 +-
 gdb/testsuite/gdb.arch/aarch64-gcs-core.exp   |   2 +-
 gdb/testsuite/gdb.arch/aarch64-mte.exp        |   2 +-
 .../gdb.arch/amd64-shadow-stack-corefile.exp  |   2 +-
 gdb/testsuite/gdb.arch/iwmmxt-regs.exp        |  12 +-
 gdb/testsuite/gdb.arch/mips-fcr.exp           |   4 +-
 gdb/testsuite/gdb.arch/mips16-thunks.exp      |   2 +-
 gdb/testsuite/gdb.arch/powerpc-d128-regs.exp  |   2 +-
 gdb/testsuite/gdb.arch/s390-tdbregs.exp       |   6 +-
 gdb/testsuite/gdb.base/args.exp               |   4 +-
 gdb/testsuite/gdb.base/bitshift.exp           |   4 +-
 .../gdb.base/bp-cmds-sourced-script.exp       |   2 +-
 gdb/testsuite/gdb.base/charset.exp            |   2 +-
 gdb/testsuite/gdb.base/code_elim.exp          |   2 +-
 gdb/testsuite/gdb.base/coredump-filter.exp    |   2 +-
 gdb/testsuite/gdb.base/corefile.exp           |   8 +-
 gdb/testsuite/gdb.base/debug-expr.exp         |   4 +-
 gdb/testsuite/gdb.base/dump.exp               |   4 +-
 gdb/testsuite/gdb.base/finish.exp             |   2 +-
 gdb/testsuite/gdb.base/frameapply.exp         |  38 +++---
 gdb/testsuite/gdb.base/func-ptrs.exp          |   6 +-
 gdb/testsuite/gdb.base/gnu_vector.exp         | 116 +++++++++---------
 gdb/testsuite/gdb.base/infnan.exp             |   4 +-
 gdb/testsuite/gdb.base/interact.exp           |   2 +-
 .../gdb.base/multi-line-starts-subshell.exp   |   2 +-
 gdb/testsuite/gdb.base/new-ui.exp             |   2 +-
 .../gdb.base/non-lazy-array-index.exp         |   2 +-
 gdb/testsuite/gdb.base/overlays.exp           |   2 +-
 gdb/testsuite/gdb.base/prologue.exp           |   4 +-
 gdb/testsuite/gdb.base/ptr-typedef.exp        |   4 +-
 gdb/testsuite/gdb.base/randomize.exp          |   2 +-
 gdb/testsuite/gdb.base/range-stepping.exp     |   4 +-
 gdb/testsuite/gdb.base/relocate.exp           |   8 +-
 gdb/testsuite/gdb.base/scope.exp              | 112 ++++++++---------
 gdb/testsuite/gdb.base/set-cwd.exp            |  10 +-
 .../gdb.base/share-env-with-gdbserver.exp     |   6 +-
 gdb/testsuite/gdb.base/shell.exp              |   4 +-
 gdb/testsuite/gdb.base/signals.exp            |   2 +-
 gdb/testsuite/gdb.base/solib-disc.exp         |   8 +-
 gdb/testsuite/gdb.base/startup-with-shell.exp |   2 +-
 gdb/testsuite/gdb.base/structs3.exp           |   2 +-
 gdb/testsuite/gdb.base/style.exp              |   4 +-
 gdb/testsuite/gdb.cp/bs15503.exp              |   8 +-
 gdb/testsuite/gdb.cp/call-c.exp               |   6 +-
 gdb/testsuite/gdb.cp/classes.exp              |  26 ++--
 gdb/testsuite/gdb.cp/converts.exp             |   2 +-
 gdb/testsuite/gdb.cp/cp-relocate.exp          |   2 +-
 gdb/testsuite/gdb.cp/ctti.exp                 |  30 ++---
 gdb/testsuite/gdb.cp/derivation.exp           |  36 +++---
 gdb/testsuite/gdb.cp/formatted-ref.exp        |  18 +--
 gdb/testsuite/gdb.cp/inherit.exp              |   2 +-
 gdb/testsuite/gdb.cp/member-ptr.exp           |   2 +-
 gdb/testsuite/gdb.cp/method-ref-return.exp    |  12 +-
 gdb/testsuite/gdb.cp/namespace.exp            |   2 +-
 gdb/testsuite/gdb.cp/overload.exp             |  62 +++++-----
 gdb/testsuite/gdb.cp/static-print-quit.exp    |   2 +-
 gdb/testsuite/gdb.cp/virtfunc.exp             |  26 ++--
 gdb/testsuite/gdb.cp/virtfunc2.exp            |  10 +-
 gdb/testsuite/gdb.fortran/debug-expr.exp      |   6 +-
 gdb/testsuite/gdb.fortran/derived-type.exp    |  16 +--
 gdb/testsuite/gdb.fortran/namelist.exp        |   2 +-
 gdb/testsuite/gdb.fortran/subarray.exp        |  24 ++--
 .../gdb.mi/user-selected-context-sync.exp     |   2 +-
 gdb/testsuite/gdb.multi/tids.exp              |   2 +-
 .../gdb.opt/clobbered-registers-O2.exp        |   4 +-
 gdb/testsuite/gdb.opt/inline-cmds.exp         |   2 +-
 gdb/testsuite/gdb.opt/inline-locals.exp       |   4 +-
 .../gdb.opt/static-optimized-out.exp          |   2 +-
 gdb/testsuite/gdb.server/ext-wrapper.exp      |   4 +-
 gdb/testsuite/gdb.server/inferior-args.exp    |   4 +-
 gdb/testsuite/gdb.server/wrapper.exp          |   2 +-
 .../gdb.threads/infcall-thread-announce.exp   |   6 +-
 gdb/testsuite/gdb.threads/pthreads.exp        |  12 +-
 .../gdb.threads/reconnect-signal.exp          |   4 +-
 gdb/testsuite/gdb.threads/schedlock.exp       |   2 +-
 .../gdb.threads/thread-bp-deleted.exp         |   2 +-
 gdb/testsuite/gdb.threads/threadapply.exp     |   4 +-
 gdb/testsuite/gdb.threads/tls-core.exp        |   2 +-
 gdb/testsuite/gdb.trace/collection.exp        | 100 +++++++--------
 .../gdb.trace/disconnected-tracing.exp        |  14 +--
 gdb/testsuite/gdb.trace/report.exp            |   4 +-
 gdb/testsuite/gdb.trace/stap-trace.exp        |   2 +-
 .../gdb.trace/unavailable-dwarf-piece.exp     |  18 +--
 gdb/testsuite/gdb.trace/unavailable.exp       |   8 +-
 gdb/testsuite/lib/gdb.exp                     |   4 +-
 87 files changed, 468 insertions(+), 468 deletions(-)

diff --git a/gdb/testsuite/gdb.ada/array_return.exp b/gdb/testsuite/gdb.ada/array_return.exp
index 11cd1736c64..dab9bf8a3d4 100644
--- a/gdb/testsuite/gdb.ada/array_return.exp
+++ b/gdb/testsuite/gdb.ada/array_return.exp
@@ -60,7 +60,7 @@ gdb_test "cont" \
     "continuing to Create_Small"
 
 gdb_test "finish" \
-    "Value returned is \\\$\[0-9\]+ = \\(1, 1\\)" \
+    "Value returned is ${::valnum_re} = \\(1, 1\\)" \
     "value printed by finish of Create_Small"
 
 # Now continue until reaching the second breakpoint inside Create_Large,
@@ -79,7 +79,7 @@ if {![istarget "hppa*64*-*-*"]} {
 }
 
 gdb_test "finish" \
-    "Value returned is \\\$\[0-9\]+ = \\(2, 2, 2, 2\\)" \
+    "Value returned is ${::valnum_re} = \\(2, 2, 2, 2\\)" \
     "value printed by finish of Create_Large"
 
 # Now continue until reaching the third breakpoint, and then do another
@@ -90,5 +90,5 @@ gdb_test "cont" \
     "continuing to Create_Small_Float_Vector"
 
 gdb_test "finish" \
-    "Value returned is \\\$\[0-9\]+ = \\(4.25, 4.25\\)" \
+    "Value returned is ${::valnum_re} = \\(4.25, 4.25\\)" \
     "value printed by finish of Create_Small_Float_Vector"
diff --git a/gdb/testsuite/gdb.ada/formatted_ref.exp b/gdb/testsuite/gdb.ada/formatted_ref.exp
index 87efa78f5f1..0051ca95fec 100644
--- a/gdb/testsuite/gdb.ada/formatted_ref.exp
+++ b/gdb/testsuite/gdb.ada/formatted_ref.exp
@@ -40,7 +40,7 @@ proc get_address { var } {
     global gdb_prompt
 
     gdb_test_multiple "print $var'access" "address of $var" {
-	-re "\\$\[0-9\]+ = \\(.*\\) (0x\[0-9a-f\]+).*$gdb_prompt $" {
+	-re "${::valnum_re} = \\(.*\\) (0x\[0-9a-f\]+).*$gdb_prompt $" {
 	    return $expect_out(1,string)
 	}
     }
@@ -52,13 +52,13 @@ proc test_p_x { var val addr } {
 
     set test "print/x $var"
     gdb_test_multiple "$test" $test {
-	-re "\\$\[0-9\]+ = [string_to_regexp $val].*$gdb_prompt $" {
+	-re "${::valnum_re} = [string_to_regexp $val].*$gdb_prompt $" {
 	    pass $test
 	}
-	-re "\\$\[0-9\]+ = $addr.*$gdb_prompt $" {
+	-re "${::valnum_re} = $addr.*$gdb_prompt $" {
 	    fail "$test (prints just address)"
 	}
-	-re "\\$\[0-9\]+ = 0x\[a-f0-9\]+.*$gdb_prompt $" {
+	-re "${::valnum_re} = 0x\[a-f0-9\]+.*$gdb_prompt $" {
 	    fail "$test (prints unexpected address)"
 	}
     }
@@ -72,10 +72,10 @@ proc test_p_x_addr { var addr } {
 	foreach space {"" "  "} {
 	    set test "print/x $var'$space$attr"
 	    gdb_test_multiple $test $test {
-		-re "\\$\[0-9\]+ = $addr.*$gdb_prompt $" {
+		-re "${::valnum_re} = $addr.*$gdb_prompt $" {
 		    pass $test
 		}
-		-re "\\$\[0-9\]+ = 0x\[a-f0-9+\]+.*$gdb_prompt $" {
+		-re "${::valnum_re} = 0x\[a-f0-9+\]+.*$gdb_prompt $" {
 		    fail "$test (prints unexpected address)"
 		}
 	    }
@@ -91,7 +91,7 @@ proc test_p_x_addr { var addr } {
 
 proc test_p_op1_equals_op2 {op1 op2} {
     set test "print $op1 = $op2"
-    gdb_test $test "\\$\[0-9\]+ = true"
+    gdb_test $test "${::valnum_re} = true"
 }
 
 clean_restart ${testfile}
diff --git a/gdb/testsuite/gdb.ada/operator_call.exp b/gdb/testsuite/gdb.ada/operator_call.exp
index 24b3ab57240..5eb98f9f834 100644
--- a/gdb/testsuite/gdb.ada/operator_call.exp
+++ b/gdb/testsuite/gdb.ada/operator_call.exp
@@ -64,7 +64,7 @@ proc test_with_menu {command result} {
 	    # The number we just sent, ignore.
 	    exp_continue
 	}
-	-re "\\\$\[0-9\]+ = (\[^\r\n\]+)\r\n" {
+	-re "${::valnum_re} = (\[^\r\n\]+)\r\n" {
 	    if {[regexp $result $expect_out(1,string)]} {
 		pass $command
 	    } else {
diff --git a/gdb/testsuite/gdb.arch/aarch64-gcs-core.exp b/gdb/testsuite/gdb.arch/aarch64-gcs-core.exp
index d6aefbfb403..30a620ed06b 100644
--- a/gdb/testsuite/gdb.arch/aarch64-gcs-core.exp
+++ b/gdb/testsuite/gdb.arch/aarch64-gcs-core.exp
@@ -52,7 +52,7 @@ proc check_core_file {core_filename saved_gcspr} {
     }
 
     # Check the value of GCSPR in the core file.
-    gdb_test "print/x \$gcspr" "\\$\[0-9\]+ = $saved_gcspr" \
+    gdb_test "print/x \$gcspr" "${::valnum_re} = $saved_gcspr" \
 	"gcspr contents from core file"
 }
 
diff --git a/gdb/testsuite/gdb.arch/aarch64-mte.exp b/gdb/testsuite/gdb.arch/aarch64-mte.exp
index 99f1320da38..4da38109573 100644
--- a/gdb/testsuite/gdb.arch/aarch64-mte.exp
+++ b/gdb/testsuite/gdb.arch/aarch64-mte.exp
@@ -292,7 +292,7 @@ with_test_prefix "print command" {
     gdb_test "p/x ${tagged_ptr_symbol}" \
 	[multi_line \
 	    "Logical tag \\(${ltag}\\) does not match the allocation tag \\(0x${atag_hexnz}\\)\." \
-	    "\\\$\[0-9\]+ = ${untagged_ptr}"] \
+	    "${::valnum_re} = ${untagged_ptr}"] \
 	    "show tag mismatch"
 }
 
diff --git a/gdb/testsuite/gdb.arch/amd64-shadow-stack-corefile.exp b/gdb/testsuite/gdb.arch/amd64-shadow-stack-corefile.exp
index 0a8f3959049..754f59b3e04 100644
--- a/gdb/testsuite/gdb.arch/amd64-shadow-stack-corefile.exp
+++ b/gdb/testsuite/gdb.arch/amd64-shadow-stack-corefile.exp
@@ -37,7 +37,7 @@ proc check_core_file {core_filename saved_pl3_ssp} {
     }
 
     # Check the value of ssp in the core file.
-    gdb_test "print/x \$pl3_ssp" "\\$\[0-9\]+ = $saved_pl3_ssp" \
+    gdb_test "print/x \$pl3_ssp" "${::valnum_re} = $saved_pl3_ssp" \
 	"pl3_ssp contents from core file"
 }
 
diff --git a/gdb/testsuite/gdb.arch/iwmmxt-regs.exp b/gdb/testsuite/gdb.arch/iwmmxt-regs.exp
index 5e1af998bf5..6c1848593b2 100644
--- a/gdb/testsuite/gdb.arch/iwmmxt-regs.exp
+++ b/gdb/testsuite/gdb.arch/iwmmxt-regs.exp
@@ -55,20 +55,20 @@ for {set i 0} {$i < 4} {incr i 1} {
 gdb_test "next" ".*write_regs.*" "next over read_regs"
 
 for {set i 0} {$i < 16} {incr i 1} {
-    gdb_test "p \$wR$i.u64 == ((${i}LL << 32) | ${i})" "\\\$$decimal = 1" "test reg wR$i"
+    gdb_test "p \$wR$i.u64 == ((${i}LL << 32) | ${i})" "${::valnum_re} = 1" "test reg wR$i"
 }
 # Don't test wCSSF.
-gdb_test "p \$wCASF" "\\\$$decimal = 200" "test reg wCASF"
+gdb_test "p \$wCASF" "${::valnum_re} = 200" "test reg wCASF"
 for {set i 0} {$i < 4} {incr i 1} {
-    gdb_test "p \$wCGR$i == 100 + $i" "\\\$$decimal = 1" "test reg wCGR$i"
+    gdb_test "p \$wCGR$i == 100 + $i" "${::valnum_re} = 1" "test reg wCGR$i"
 }
 
 # Also verify the copies read by the target.
 for {set i 0} {$i < 16} {incr i 1} {
-    gdb_test "p regs\[$i\] == ((${i}LL << 32) | ${i})" "\\\$$decimal = 1" "test stored wR$i"
+    gdb_test "p regs\[$i\] == ((${i}LL << 32) | ${i})" "${::valnum_re} = 1" "test stored wR$i"
 }
 # Don't test wcssf.
-gdb_test "p control_regs\[1\]" "\\\$$decimal = 200" "test stored wCASF"
+gdb_test "p control_regs\[1\]" "${::valnum_re} = 200" "test stored wCASF"
 for {set i 0} {$i < 4} {incr i 1} {
-    gdb_test "p control_regs\[$i + 2\] == 100 + $i" "\\\$$decimal = 1" "test stored wCGR$i"
+    gdb_test "p control_regs\[$i + 2\] == 100 + $i" "${::valnum_re} = 1" "test stored wCGR$i"
 }
diff --git a/gdb/testsuite/gdb.arch/mips-fcr.exp b/gdb/testsuite/gdb.arch/mips-fcr.exp
index b24f7fe5243..2cb22004946 100644
--- a/gdb/testsuite/gdb.arch/mips-fcr.exp
+++ b/gdb/testsuite/gdb.arch/mips-fcr.exp
@@ -46,6 +46,6 @@ gdb_test_multiple "show mipsfpu" "check for MIPS floating-point coprocessor" {
 
 # Now check that FCRs are accessible and 32-bit wide.
 gdb_test "info registers \$fcsr" "fcsr: $hex"
-gdb_test "print sizeof \$fcsr" "\\\$$decimal = 4"
+gdb_test "print sizeof \$fcsr" "${::valnum_re} = 4"
 gdb_test "info registers \$fir" "fir: $hex"
-gdb_test "print sizeof \$fir" "\\\$$decimal = 4"
+gdb_test "print sizeof \$fir" "${::valnum_re} = 4"
diff --git a/gdb/testsuite/gdb.arch/mips16-thunks.exp b/gdb/testsuite/gdb.arch/mips16-thunks.exp
index 3ef044890c6..f8d485a08de 100644
--- a/gdb/testsuite/gdb.arch/mips16-thunks.exp
+++ b/gdb/testsuite/gdb.arch/mips16-thunks.exp
@@ -69,7 +69,7 @@ gdb_test_multiple "" "check for MIPS16 support in the processor" {
     -re "Breakpoint 1.*inmain .*$gdb_prompt $" {
 	gdb_test_multiple "finish" \
 	    "check for MIPS16 support in the processor" {
-	    -re "Value returned is \\\$\[0-9\]+ = 0\[^0-9\].*$gdb_prompt $" {
+	    -re "Value returned is ${::valnum_re} = 0\[^0-9\].*$gdb_prompt $" {
 		verbose "MIPS16 support check successful."
 	    }
 	    -re "$gdb_prompt $" {
diff --git a/gdb/testsuite/gdb.arch/powerpc-d128-regs.exp b/gdb/testsuite/gdb.arch/powerpc-d128-regs.exp
index 1140563d09f..05ae31877e1 100644
--- a/gdb/testsuite/gdb.arch/powerpc-d128-regs.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-d128-regs.exp
@@ -44,7 +44,7 @@ gdb_test "next" ""
 for {set i 0} {$i < 16} {incr i 1} {
 gdb_test "set \$dl$i=d128" "" "set dl$i register"
 
-gdb_test "print \$dl$i" "\\\$$decimal = 1\.2345678910" "print dl$i register as DFP"
+gdb_test "print \$dl$i" "${::valnum_re} = 1\.2345678910" "print dl$i register as DFP"
 
 gdb_test "info reg dl$i" \
 	 "dl$i\[ \]*1\.2345678910\[ \t\]*\\(raw 0x2205800000000000000000049c5de09c\\)" \
diff --git a/gdb/testsuite/gdb.arch/s390-tdbregs.exp b/gdb/testsuite/gdb.arch/s390-tdbregs.exp
index be217559a28..1225762a1ab 100644
--- a/gdb/testsuite/gdb.arch/s390-tdbregs.exp
+++ b/gdb/testsuite/gdb.arch/s390-tdbregs.exp
@@ -51,12 +51,12 @@ gdb_test_multiple "next" "check for TE support" {
 
 set crashline [gdb_get_line_number "FAULT"]
 
-gdb_test "print \$tdb0" "\\\$\[0-9\]+ = <unavailable>" "tdb0 unavailable"
-gdb_test "print \$tr0" "\\\$\[0-9\]+ = <unavailable>" "tr0 unavailable"
+gdb_test "print \$tdb0" "${::valnum_re} = <unavailable>" "tdb0 unavailable"
+gdb_test "print \$tr0" "${::valnum_re} = <unavailable>" "tr0 unavailable"
 gdb_test "next" \
     "Program received signal SIGSEGV, .*" \
     "crash in transaction"
-gdb_test "print/x \$tdb0" "\\\$\[0-9\]+ = 0x1.*" "tdb0 available"
+gdb_test "print/x \$tdb0" "${::valnum_re} = 0x1.*" "tdb0 available"
 gdb_test "set print symbol-filename" "" "set print symbol-filename"
 gdb_test "print/a \$atia" \
     "<crash_in_transaction.*:$crashline>" \
diff --git a/gdb/testsuite/gdb.base/args.exp b/gdb/testsuite/gdb.base/args.exp
index bc52701e38a..bd10c90b6cd 100644
--- a/gdb/testsuite/gdb.base/args.exp
+++ b/gdb/testsuite/gdb.base/args.exp
@@ -117,7 +117,7 @@ proc args_test { name arglist {re_esc_list {}} {re_no_esc_list {}} } {
 
 		set expected_len [expr {1 + [llength $re_list]}]
 		gdb_test "print argc" \
-		    "\\\$$::decimal = $expected_len" "argc for $name"
+		    "${::valnum_re} = $expected_len" "argc for $name"
 
 		set i 1
 		foreach arg $re_list {
@@ -142,7 +142,7 @@ proc args_test { name arglist {re_esc_list {}} {re_no_esc_list {}} } {
 		    }
 
 		    gdb_test "print argv\[$i\]" \
-			"\\\$$::decimal = $::hex \"$arg\"" \
+			"${::valnum_re} = $::hex \"$arg\"" \
 			"argv\[$i\] for $name"
 		    set i [expr {$i + 1}]
 		}
diff --git a/gdb/testsuite/gdb.base/bitshift.exp b/gdb/testsuite/gdb.base/bitshift.exp
index 3af6614b26f..4066cf5b2f8 100644
--- a/gdb/testsuite/gdb.base/bitshift.exp
+++ b/gdb/testsuite/gdb.base/bitshift.exp
@@ -34,7 +34,7 @@ proc test_shift {lang cmd result_re {warning_or_error ""}} {
 	    }
 	} else {
 	    gdb_test_multiple $cmd "" {
-		-re -wrap "^\\$$::decimal$result_re" {
+		-re -wrap "^${::valnum_re}$result_re" {
 		    pass $gdb_test_name
 		}
 	    }
@@ -47,7 +47,7 @@ proc test_shift {lang cmd result_re {warning_or_error ""}} {
 	}
 
 	gdb_test_multiple $cmd "" {
-	    -re -wrap "^$warning_re\\$$::decimal$result_re" {
+	    -re -wrap "^$warning_re${::valnum_re}$result_re" {
 		pass $gdb_test_name
 	    }
 	}
diff --git a/gdb/testsuite/gdb.base/bp-cmds-sourced-script.exp b/gdb/testsuite/gdb.base/bp-cmds-sourced-script.exp
index 62c3ac7ed85..e12016f2fc5 100644
--- a/gdb/testsuite/gdb.base/bp-cmds-sourced-script.exp
+++ b/gdb/testsuite/gdb.base/bp-cmds-sourced-script.exp
@@ -31,7 +31,7 @@ gdb_test "source $script_file" \
 gdb_run_cmd
 
 gdb_test_multiple "" "commands executed twice" {
-    -re "\\$${decimal} = 100123\r\n\\$${decimal} = 100123\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = 100123\r\n${::valnum_re} = 100123\r\n$gdb_prompt $" {
 	pass $gdb_test_name
     }
 }
diff --git a/gdb/testsuite/gdb.base/charset.exp b/gdb/testsuite/gdb.base/charset.exp
index e8c225bb438..9148fec57e8 100644
--- a/gdb/testsuite/gdb.base/charset.exp
+++ b/gdb/testsuite/gdb.base/charset.exp
@@ -368,7 +368,7 @@ foreach target_charset $charset_subset {
     # gdb_test that requires us to use gdb_expect here.
     send_gdb "print $L'\\0'\n"
     gdb_expect {
-	-re "\\\$${decimal} = 0 $L'\\\\000'\[\r\n\]+$gdb_prompt $" {
+	-re "${::valnum_re} = 0 $L'\\\\000'\[\r\n\]+$gdb_prompt $" {
 	    pass "print the null character in ${target_charset}"
 	}
 	-re "$gdb_prompt $" {
diff --git a/gdb/testsuite/gdb.base/code_elim.exp b/gdb/testsuite/gdb.base/code_elim.exp
index cac745ab8a3..86714346201 100644
--- a/gdb/testsuite/gdb.base/code_elim.exp
+++ b/gdb/testsuite/gdb.base/code_elim.exp
@@ -67,7 +67,7 @@ proc test_eliminated_var { var } {
 	-re "No symbol \"${var}\" in current context\\.\[\r\n\]+${gdb_prompt} $" {
 	    pass "test eliminated var ${var}"
 	}
-	-re "\\\$\[0-9\]+ = \\(.*\\) (0|$hex)( <${var}>)?\[\r\n\]+${gdb_prompt} $" {
+	-re "${::valnum_re} = \\(.*\\) (0|$hex)( <${var}>)?\[\r\n\]+${gdb_prompt} $" {
 	    fail "test eliminated var ${var}"
 	}
     }
diff --git a/gdb/testsuite/gdb.base/coredump-filter.exp b/gdb/testsuite/gdb.base/coredump-filter.exp
index c93c0c48162..c35a0334ff3 100644
--- a/gdb/testsuite/gdb.base/coredump-filter.exp
+++ b/gdb/testsuite/gdb.base/coredump-filter.exp
@@ -62,7 +62,7 @@ proc do_load_and_test_core { core var working_var working_value dump_excluded }
 
     # Access the memory the addresses point to.
     if { $dump_excluded == 0 } {
-	gdb_test "print/x *(char *) $coredump_var_addr($var)" "\(\\\$$decimal = <error: \)?Cannot access memory at address $hex\(>\)?" \
+	gdb_test "print/x *(char *) $coredump_var_addr($var)" "\(${::valnum_re} = <error: \)?Cannot access memory at address $hex\(>\)?" \
 	    "printing $var when core is loaded (should not work)"
 	gdb_test "print/x *(char *) $coredump_var_addr($working_var)" " = $working_value.*" \
 	    "print/x *$working_var ( = $working_value)"
diff --git a/gdb/testsuite/gdb.base/corefile.exp b/gdb/testsuite/gdb.base/corefile.exp
index fcc9b7b284a..957bccf43a4 100644
--- a/gdb/testsuite/gdb.base/corefile.exp
+++ b/gdb/testsuite/gdb.base/corefile.exp
@@ -130,11 +130,11 @@ gdb_test_multiple "core-file $corefile" "core-file command" {
 
 # Test correct mapping of corefile sections by printing some variables.
 
-gdb_test "print coremaker_data" "\\\$$decimal = 202"
-gdb_test "print coremaker_bss" "\\\$$decimal = 10"
-gdb_test "print coremaker_ro" "\\\$$decimal = 201"
+gdb_test "print coremaker_data" "${::valnum_re} = 202"
+gdb_test "print coremaker_bss" "${::valnum_re} = 10"
+gdb_test "print coremaker_ro" "${::valnum_re} = 201"
 
-gdb_test "print func2::coremaker_local" "\\\$$decimal = \\{0, 1, 2, 3, 4\\}"
+gdb_test "print func2::coremaker_local" "${::valnum_re} = \\{0, 1, 2, 3, 4\\}"
 
 # Test the presence and the correct values of $_exitsignal and
 # $_exitcode variables.  The corefile is generated with a SIGABRT,
diff --git a/gdb/testsuite/gdb.base/debug-expr.exp b/gdb/testsuite/gdb.base/debug-expr.exp
index 54389bc8683..80f6d5a968b 100644
--- a/gdb/testsuite/gdb.base/debug-expr.exp
+++ b/gdb/testsuite/gdb.base/debug-expr.exp
@@ -41,10 +41,10 @@ gdb_test_debug_expr "print /x {char\[4\]} array" \
 
 # This caused gdb to output garbage and possibly segfault
 gdb_test_debug_expr "print \"hello\"" \
-    ".*OP_STRING\[^\r\n\]*.*: ordinary string.*\[\r\n\]\\$$decimal = \"hello\"" \
+    ".*OP_STRING\[^\r\n\]*.*: ordinary string.*\[\r\n\]${::valnum_re} = \"hello\"" \
     "string evaluation with debug expr"
 
 # An expression using a function call.
 gdb_test_debug_expr "print call_me ( &val )" \
-    ".*OP_FUNCALL\[^\r\n\]*.*UNOP_ADDR.*\[\r\n\]\\$$decimal = 0.*" \
+    ".*OP_FUNCALL\[^\r\n\]*.*UNOP_ADDR.*\[\r\n\]${::valnum_re} = 0.*" \
     "function call expression"
diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp
index 341e6e55691..427161d4d91 100644
--- a/gdb/testsuite/gdb.base/dump.exp
+++ b/gdb/testsuite/gdb.base/dump.exp
@@ -159,7 +159,7 @@ proc capture_value { expression args } {
 	set test "capture $expression"
     }
     gdb_test_multiple "print ${expression}" "$test" {
-	-re "\\$\[0-9\]+ = (\[^\r\n\]+).*$gdb_prompt $" {
+	-re "${::valnum_re} = (\[^\r\n\]+).*$gdb_prompt $" {
 	    set output_string "$expect_out(1,string)"
 	    pass "$test"
 	}
@@ -184,7 +184,7 @@ proc capture_pointer_with_type { pointer } {
     set test "capture type of pointer $pointer"
     set output_string ""
     gdb_test_multiple "p ${pointer}" $test {
-	-re "\\$\[0-9\]+ = .*$gdb_prompt $" {
+	-re "${::valnum_re} = .*$gdb_prompt $" {
 	    # Expected output of "p ${pointer}" is like "$7 = (int (*)[32]) 0x804a0e0",
 	    # and we want to extract "(int (*)[32]) 0x804a0e0" from it via
 	    # following regexp.
diff --git a/gdb/testsuite/gdb.base/finish.exp b/gdb/testsuite/gdb.base/finish.exp
index 3c82305086f..43719cb9fc5 100644
--- a/gdb/testsuite/gdb.base/finish.exp
+++ b/gdb/testsuite/gdb.base/finish.exp
@@ -94,7 +94,7 @@ proc finish_no_print {} {
     }
     gdb_test_no_output "set print finish off"
     gdb_test "finish" \
-	"Value returned is \\\$$decimal = <not displayed>"
+	"Value returned is ${::valnum_re} = <not displayed>"
     gdb_test "print \$" " = 1" \
 	"Ensure return value was properly saved"
 }
diff --git a/gdb/testsuite/gdb.base/frameapply.exp b/gdb/testsuite/gdb.base/frameapply.exp
index 04459031c3d..73650052ad9 100644
--- a/gdb/testsuite/gdb.base/frameapply.exp
+++ b/gdb/testsuite/gdb.base/frameapply.exp
@@ -48,17 +48,17 @@ with_test_prefix "simple command" {
 	    gdb_test $cmd \
 		[multi_line \
 		     "#0${ws}setup_done ${any}" \
-		     "\\\$\[0-9]+ = 0x14${any}" \
+		     "${::valnum_re} = 0x14${any}" \
 		     "#1${ws}${any} f1 ${any}" \
-		     "\\\$\[0-9]+ = 0x14${any}" \
+		     "${::valnum_re} = 0x14${any}" \
 		     "#2${ws}${any} f2 ${any}" \
-		     "\\\$\[0-9]+ = 0x14${any}" \
+		     "${::valnum_re} = 0x14${any}" \
 		     "#3${ws}${any} f3 ${any}" \
-		     "\\\$\[0-9]+ = 0x14${any}" \
+		     "${::valnum_re} = 0x14${any}" \
 		     "#4${ws}${any} f4 ${any}" \
-		     "\\\$\[0-9]+ = 0x14${any}" \
+		     "${::valnum_re} = 0x14${any}" \
 		     "#5${ws}${any} main ${any}" \
-		     "\\\$\[0-9]+ = 0x14${any}" \
+		     "${::valnum_re} = 0x14${any}" \
 		    ] \
 		"run a simple command on all frames"
 	}
@@ -73,11 +73,11 @@ with_test_prefix "innermost 3" {
 	    gdb_test $cmd \
 		[multi_line \
 		     "#0${ws}setup_done ${any}" \
-		     "\\\$\[0-9]+ = 0x14${any}" \
+		     "${::valnum_re} = 0x14${any}" \
 		     "#1${ws}${any} f1 ${any}" \
-		     "\\\$\[0-9]+ = 0x14${any}" \
+		     "${::valnum_re} = 0x14${any}" \
 		     "#2${ws}${any} f2 ${any}" \
-		     "\\\$\[0-9]+ = 0x14${any}" \
+		     "${::valnum_re} = 0x14${any}" \
 		    ] \
 		"run a simple command on the 3 innermost frames"
 	}
@@ -91,11 +91,11 @@ with_test_prefix "outermost 3" {
 	    gdb_test $cmd \
 		[multi_line \
 		     "#3${ws}${any} f3 ${any}" \
-		     "\\\$\[0-9]+ = 0x14${any}" \
+		     "${::valnum_re} = 0x14${any}" \
 		     "#4${ws}${any} f4 ${any}" \
-		     "\\\$\[0-9]+ = 0x14${any}" \
+		     "${::valnum_re} = 0x14${any}" \
 		     "#5${ws}${any} main ${any}" \
-		     "\\\$\[0-9]+ = 0x14${any}" \
+		     "${::valnum_re} = 0x14${any}" \
 		    ] \
 		"run a simple command on the 3 outermost frames"
 	}
@@ -131,7 +131,7 @@ with_test_prefix "cont !silent flags" {
 		     "#2${ws}${any} f2 ${any}" \
 		     "No symbol \\\"f3arg\\\" in current context." \
 		     "#3${ws}${any} f3 ${any}" \
-		     "\\\$\[0-9]+ = 3${any}" \
+		     "${::valnum_re} = 3${any}" \
 		     "#4${ws}${any} f4 ${any}" \
 		     "No symbol \\\"f3arg\\\" in current context." \
 		     "#5${ws}${any} main ${any}" \
@@ -150,7 +150,7 @@ with_test_prefix "!cont silent flags" {
 	    gdb_test $cmd \
 		[multi_line \
 		     "#3${ws}${any} f3 ${any}" \
-		     "\\\$\[0-9]+ = 3${any}" \
+		     "${::valnum_re} = 3${any}" \
 		    ] \
 		"run a command failing in all frames except #3, -s to silently continue"
 	}
@@ -165,9 +165,9 @@ with_test_prefix "!quiet flag" {
 	    gdb_test $cmd \
 		[multi_line \
 		     "#0${ws}setup_done ${any}" \
-		     "\\\$\[0-9]+ = 0x14${any}" \
+		     "${::valnum_re} = 0x14${any}" \
 		     "#1${ws}${any} f1 ${any}" \
-		     "\\\$\[0-9]+ = 0x14${any}" \
+		     "${::valnum_re} = 0x14${any}" \
 		    ] \
 		"run a command, printing location"
 	}
@@ -180,8 +180,8 @@ with_test_prefix "quiet flag" {
 	    set cmd "frame apply $frame_apply_args p /x 20"
 	    gdb_test $cmd \
 		[multi_line \
-		     "\\\$\[0-9]+ = 0x14${any}" \
-		     "\\\$\[0-9]+ = 0x14${any}" \
+		     "${::valnum_re} = 0x14${any}" \
+		     "${::valnum_re} = 0x14${any}" \
 		    ] \
 		"run a command with -q quiet flag, printing only command results"
 	}
@@ -194,7 +194,7 @@ with_test_prefix "quiet silent flags" {
 	"level 0-5 -q -s -q"} {
 	    set cmd "frame apply $frame_apply_args p f3arg"
 	    gdb_test $cmd \
-		"\\\$\[0-9]+ = 3${any}" \
+		"${::valnum_re} = 3${any}" \
 		"run a command failing in all frames except #3, -s to silently continue, quiet"
 	}
 }
diff --git a/gdb/testsuite/gdb.base/func-ptrs.exp b/gdb/testsuite/gdb.base/func-ptrs.exp
index fc411b8e958..66c3daac7a9 100644
--- a/gdb/testsuite/gdb.base/func-ptrs.exp
+++ b/gdb/testsuite/gdb.base/func-ptrs.exp
@@ -49,7 +49,7 @@ gdb_test "continue" \
 # Go back up, make sure the return value is 0.
 
 gdb_test "finish" \
-    "Run till exit from #0 +incr \\(i=-1\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+($hex in )?main \\(\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+.*Value returned is \\$$decimal = 0" \
+    "Run till exit from #0 +incr \\(i=-1\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+($hex in )?main \\(\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+.*Value returned is ${::valnum_re} = 0" \
     "go back to main from incr, first time"
 
 
@@ -72,7 +72,7 @@ gdb_test "finish" \
 
 gdb_test_no_output "up-silently" "move up to decr"
 gdb_test "finish" \
-    "Run till exit from #1 +($hex in )?decr \\(i=0\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+($hex in )?main \\(\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+.*Value returned is \\$$decimal = -1" \
+    "Run till exit from #1 +($hex in )?decr \\(i=0\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+($hex in )?main \\(\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+.*Value returned is ${::valnum_re} = -1" \
     "go back to main from decr"
 
 
@@ -87,7 +87,7 @@ gdb_test "continue" \
 # Go back up again, make sure the return value is 0.
 
 gdb_test "finish" \
-    "Run till exit from #0 +incr \\(i=-1\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+($hex in )?main \\(\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+.*Value returned is \\$$decimal = 0" \
+    "Run till exit from #0 +incr \\(i=-1\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+($hex in )?main \\(\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+.*Value returned is ${::valnum_re} = 0" \
     "go back to main from incr, second time"
 
 
diff --git a/gdb/testsuite/gdb.base/gnu_vector.exp b/gdb/testsuite/gdb.base/gnu_vector.exp
index a8be3072555..c1616fd3275 100644
--- a/gdb/testsuite/gdb.base/gnu_vector.exp
+++ b/gdb/testsuite/gdb.base/gnu_vector.exp
@@ -50,49 +50,49 @@ if { ![runto_main] } {
 set endian [get_endianness]
 
 # Test printing of character vector types
-gdb_test "print c4" "\\\$$decimal = \\{1, 2, 3, 4\\}"
-gdb_test "print c4\[2\]" "\\\$$decimal = 3"
+gdb_test "print c4" "${::valnum_re} = \\{1, 2, 3, 4\\}"
+gdb_test "print c4\[2\]" "${::valnum_re} = 3"
 
 # Test operators on integer vector types
-gdb_test "print i4a" "\\\$$decimal = \\{2, 4, 8, 16\\}"
-gdb_test "print i4b" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+gdb_test "print i4a" "${::valnum_re} = \\{2, 4, 8, 16\\}"
+gdb_test "print i4b" "${::valnum_re} = \\{1, 2, 8, 4\\}"
 # Arithmetic operators
-gdb_test "print i4a + i4b" "\\\$$decimal = \\{3, 6, 16, 20\\}"
-gdb_test "print i4a - i4b" "\\\$$decimal = \\{1, 2, 0, 12\\}"
-gdb_test "print i4a * i4b" "\\\$$decimal = \\{2, 8, 64, 64\\}"
-gdb_test "print i4a / i4b" "\\\$$decimal = \\{2, 2, 1, 4\\}"
-gdb_test "print i4a % i4b" "\\\$$decimal = \\{0, 0, 0, 0\\}"
-gdb_test "print i4a++" "\\\$$decimal = \\{2, 4, 8, 16\\}"
-gdb_test "print ++i4a" "\\\$$decimal = \\{4, 6, 10, 18\\}"
-gdb_test "print i4a--" "\\\$$decimal = \\{4, 6, 10, 18\\}"
-gdb_test "print --i4a" "\\\$$decimal = \\{2, 4, 8, 16\\}"
-gdb_test "print +i4a" "\\\$$decimal = \\{2, 4, 8, 16\\}"
-gdb_test "print -i4a" "\\\$$decimal = \\{-2, -4, -8, -16\\}"
+gdb_test "print i4a + i4b" "${::valnum_re} = \\{3, 6, 16, 20\\}"
+gdb_test "print i4a - i4b" "${::valnum_re} = \\{1, 2, 0, 12\\}"
+gdb_test "print i4a * i4b" "${::valnum_re} = \\{2, 8, 64, 64\\}"
+gdb_test "print i4a / i4b" "${::valnum_re} = \\{2, 2, 1, 4\\}"
+gdb_test "print i4a % i4b" "${::valnum_re} = \\{0, 0, 0, 0\\}"
+gdb_test "print i4a++" "${::valnum_re} = \\{2, 4, 8, 16\\}"
+gdb_test "print ++i4a" "${::valnum_re} = \\{4, 6, 10, 18\\}"
+gdb_test "print i4a--" "${::valnum_re} = \\{4, 6, 10, 18\\}"
+gdb_test "print --i4a" "${::valnum_re} = \\{2, 4, 8, 16\\}"
+gdb_test "print +i4a" "${::valnum_re} = \\{2, 4, 8, 16\\}"
+gdb_test "print -i4a" "${::valnum_re} = \\{-2, -4, -8, -16\\}"
 
 # Bitwise operators
-gdb_test "print i4a & i4b" "\\\$$decimal = \\{0, 0, 8, 0\\}"
-gdb_test "print i4a | i4b" "\\\$$decimal = \\{3, 6, 8, 20\\}"
-gdb_test "print i4a ^ i4b" "\\\$$decimal = \\{3, 6, 0, 20\\}"
-gdb_test "print ~i4a" "\\\$$decimal = \\{-3, -5, -9, -17\\}"
+gdb_test "print i4a & i4b" "${::valnum_re} = \\{0, 0, 8, 0\\}"
+gdb_test "print i4a | i4b" "${::valnum_re} = \\{3, 6, 8, 20\\}"
+gdb_test "print i4a ^ i4b" "${::valnum_re} = \\{3, 6, 0, 20\\}"
+gdb_test "print ~i4a" "${::valnum_re} = \\{-3, -5, -9, -17\\}"
 # Shift operators
-gdb_test "print i4a << i4b" "\\\$$decimal = \\{4, 16, 2048, 256\\}"
-gdb_test "print i4a >> i4b" "\\\$$decimal = \\{1, 1, 0, 1\\}"
+gdb_test "print i4a << i4b" "${::valnum_re} = \\{4, 16, 2048, 256\\}"
+gdb_test "print i4a >> i4b" "${::valnum_re} = \\{1, 1, 0, 1\\}"
 
 # Test operators on floating point vector types
-gdb_test "print f4a" "\\\$$decimal = \\{2, 4, 8, 16\\}"
-gdb_test "print f4b" "\\\$$decimal = \\{1, 2, 8, 4\\}"
+gdb_test "print f4a" "${::valnum_re} = \\{2, 4, 8, 16\\}"
+gdb_test "print f4b" "${::valnum_re} = \\{1, 2, 8, 4\\}"
 # Arithmetic operators
-gdb_test "print f4a + f4b" "\\\$$decimal = \\{3, 6, 16, 20\\}"
-gdb_test "print f4a - f4b" "\\\$$decimal = \\{1, 2, 0, 12\\}"
-gdb_test "print f4a * f4b" "\\\$$decimal = \\{2, 8, 64, 64\\}"
-gdb_test "print f4a / f4b" "\\\$$decimal = \\{2, 2, 1, 4\\}"
-gdb_test "print +f4a" "\\\$$decimal = \\{2, 4, 8, 16\\}"
-gdb_test "print -f4a" "\\\$$decimal = \\{-2, -4, -8, -16\\}"
+gdb_test "print f4a + f4b" "${::valnum_re} = \\{3, 6, 16, 20\\}"
+gdb_test "print f4a - f4b" "${::valnum_re} = \\{1, 2, 0, 12\\}"
+gdb_test "print f4a * f4b" "${::valnum_re} = \\{2, 8, 64, 64\\}"
+gdb_test "print f4a / f4b" "${::valnum_re} = \\{2, 2, 1, 4\\}"
+gdb_test "print +f4a" "${::valnum_re} = \\{2, 4, 8, 16\\}"
+gdb_test "print -f4a" "${::valnum_re} = \\{-2, -4, -8, -16\\}"
 
 # When casting to vector the input type must have the same length as
 # the total length of the vector.
-gdb_test "print (char4) 0x01010101" "\\\$$decimal = \\{1, 1, 1, 1\\}"
-gdb_test "print (int2) lla" "\\\$$decimal = \\{1, 1\\}"
+gdb_test "print (char4) 0x01010101" "${::valnum_re} = \\{1, 1, 1, 1\\}"
+gdb_test "print (int2) lla" "${::valnum_re} = \\{1, 1\\}"
 
 # Check that "whatis" doesn't peel off the destination type's typedef
 # by mistake, in expressions that involve a cast to typedef type.
@@ -106,9 +106,9 @@ gdb_test "ptype (int2) lla" \
     "type = int __attribute__ \\(\\(vector_size\\(2\\)\\)\\)"
 
 if {![string compare $endian big]} {
-    gdb_test "print (char4) ia" "\\\$$decimal = \\{0, 0, 0, 2\\}"
+    gdb_test "print (char4) ia" "${::valnum_re} = \\{0, 0, 0, 2\\}"
 } else {
-    gdb_test "print (char4) ia" "\\\$$decimal = \\{2, 0, 0, 0\\}"
+    gdb_test "print (char4) ia" "${::valnum_re} = \\{2, 0, 0, 0\\}"
 }
 
 gdb_test "print (int2) 1" "can only cast scalar to vector of same size"
@@ -129,31 +129,31 @@ gdb_test "print i4a + lla" "conversion of scalar to vector involves truncation"
 gdb_test "print lla + c4" "conversion of scalar to vector involves truncation"
 gdb_test "print lla + i4a" "conversion of scalar to vector involves truncation"
 
-gdb_test "print c4 + ib" "\\\$$decimal = \\{2, 3, 4, 5\\}"
-gdb_test "print i4a + ib" "\\\$$decimal = \\{3, 5, 9, 17\\}"
-gdb_test "print i4a + 1" "\\\$$decimal = \\{3, 5, 9, 17\\}"
-gdb_test "print 1 + i4a" "\\\$$decimal = \\{3, 5, 9, 17\\}"
-gdb_test "print fa - f4b" "\\\$$decimal = \\{1, 0, -6, -2\\}"
-gdb_test "print 2 - f4b" "\\\$$decimal = \\{1, 0, -6, -2\\}"
-gdb_test "print f4a * fb" "\\\$$decimal = \\{2, 4, 8, 16\\}"
-gdb_test "print f4a * 1" "\\\$$decimal = \\{2, 4, 8, 16\\}"
-gdb_test "print ia / i4b" "\\\$$decimal = \\{2, 1, 0, 0\\}"
-gdb_test "print 2 / i4b" "\\\$$decimal = \\{2, 1, 0, 0\\}"
-gdb_test "print i4a % ib" "\\\$$decimal = \\{0, 0, 0, 0\\}"
-gdb_test "print i4a % 1" "\\\$$decimal = \\{0, 0, 0, 0\\}"
-gdb_test "print ia & i4b" "\\\$$decimal = \\{0, 2, 0, 0\\}"
-gdb_test "print 2 & i4b" "\\\$$decimal = \\{0, 2, 0, 0\\}"
-gdb_test "print i4a | ib" "\\\$$decimal = \\{3, 5, 9, 17\\}"
-gdb_test "print i4a | 1" "\\\$$decimal = \\{3, 5, 9, 17\\}"
-gdb_test "print ia ^ i4b" "\\\$$decimal = \\{3, 0, 10, 6\\}"
-gdb_test "print 2 ^ i4b" "\\\$$decimal = \\{3, 0, 10, 6\\}"
-gdb_test "print i4a << ib" "\\\$$decimal = \\{4, 8, 16, 32\\}"
-gdb_test "print i4a << 1" "\\\$$decimal = \\{4, 8, 16, 32\\}"
-gdb_test "print i4a >> ib" "\\\$$decimal = \\{1, 2, 4, 8\\}"
-gdb_test "print i4a >> 1" "\\\$$decimal = \\{1, 2, 4, 8\\}"
-
-gdb_test "print i4a = \{2, 4, 8, 16\}" "\\\$$decimal = \\{2, 4, 8, 16\\}"
-gdb_test "print i4a <<= ib" "\\\$$decimal = \\{4, 8, 16, 32\\}"
+gdb_test "print c4 + ib" "${::valnum_re} = \\{2, 3, 4, 5\\}"
+gdb_test "print i4a + ib" "${::valnum_re} = \\{3, 5, 9, 17\\}"
+gdb_test "print i4a + 1" "${::valnum_re} = \\{3, 5, 9, 17\\}"
+gdb_test "print 1 + i4a" "${::valnum_re} = \\{3, 5, 9, 17\\}"
+gdb_test "print fa - f4b" "${::valnum_re} = \\{1, 0, -6, -2\\}"
+gdb_test "print 2 - f4b" "${::valnum_re} = \\{1, 0, -6, -2\\}"
+gdb_test "print f4a * fb" "${::valnum_re} = \\{2, 4, 8, 16\\}"
+gdb_test "print f4a * 1" "${::valnum_re} = \\{2, 4, 8, 16\\}"
+gdb_test "print ia / i4b" "${::valnum_re} = \\{2, 1, 0, 0\\}"
+gdb_test "print 2 / i4b" "${::valnum_re} = \\{2, 1, 0, 0\\}"
+gdb_test "print i4a % ib" "${::valnum_re} = \\{0, 0, 0, 0\\}"
+gdb_test "print i4a % 1" "${::valnum_re} = \\{0, 0, 0, 0\\}"
+gdb_test "print ia & i4b" "${::valnum_re} = \\{0, 2, 0, 0\\}"
+gdb_test "print 2 & i4b" "${::valnum_re} = \\{0, 2, 0, 0\\}"
+gdb_test "print i4a | ib" "${::valnum_re} = \\{3, 5, 9, 17\\}"
+gdb_test "print i4a | 1" "${::valnum_re} = \\{3, 5, 9, 17\\}"
+gdb_test "print ia ^ i4b" "${::valnum_re} = \\{3, 0, 10, 6\\}"
+gdb_test "print 2 ^ i4b" "${::valnum_re} = \\{3, 0, 10, 6\\}"
+gdb_test "print i4a << ib" "${::valnum_re} = \\{4, 8, 16, 32\\}"
+gdb_test "print i4a << 1" "${::valnum_re} = \\{4, 8, 16, 32\\}"
+gdb_test "print i4a >> ib" "${::valnum_re} = \\{1, 2, 4, 8\\}"
+gdb_test "print i4a >> 1" "${::valnum_re} = \\{1, 2, 4, 8\\}"
+
+gdb_test "print i4a = \{2, 4, 8, 16\}" "${::valnum_re} = \\{2, 4, 8, 16\\}"
+gdb_test "print i4a <<= ib" "${::valnum_re} = \\{4, 8, 16, 32\\}"
 
 # Test some error scenarios
 gdb_test "print i4a + d2" "Cannot perform operation on vectors with different types"
diff --git a/gdb/testsuite/gdb.base/infnan.exp b/gdb/testsuite/gdb.base/infnan.exp
index cc9000d176f..18a0d235525 100644
--- a/gdb/testsuite/gdb.base/infnan.exp
+++ b/gdb/testsuite/gdb.base/infnan.exp
@@ -23,5 +23,5 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
 
 runto_main
 
-gdb_test "print a" "\\\$$decimal = inf"
-gdb_test "print b" "\\\$$decimal = nan\\(0x.*\\)"
+gdb_test "print a" "${::valnum_re} = inf"
+gdb_test "print b" "${::valnum_re} = nan\\(0x.*\\)"
diff --git a/gdb/testsuite/gdb.base/interact.exp b/gdb/testsuite/gdb.base/interact.exp
index 4b538131647..70a9825cb58 100644
--- a/gdb/testsuite/gdb.base/interact.exp
+++ b/gdb/testsuite/gdb.base/interact.exp
@@ -22,7 +22,7 @@ puts $fd "print 2"
 close $fd
 
 # The expected output from the script...
-set script_output "\\$\[0-9\]+ = 1\[\r\n\]+\\$\[0-9\]+ = 2.*"
+set script_output "${::valnum_re} = 1\[\r\n\]+${::valnum_re} = 2.*"
 
 # Start a fresh GDB.  We don't need an executable for this test, so
 # nothing else to do in terms of testcase setup.
diff --git a/gdb/testsuite/gdb.base/multi-line-starts-subshell.exp b/gdb/testsuite/gdb.base/multi-line-starts-subshell.exp
index 6bf315b7881..be548281869 100644
--- a/gdb/testsuite/gdb.base/multi-line-starts-subshell.exp
+++ b/gdb/testsuite/gdb.base/multi-line-starts-subshell.exp
@@ -52,4 +52,4 @@ gdb_test_multiple "if 1\nshell ${shell_cmd}\nend\nPS1=\"$shell_prompt\"" $test {
 }
 
 # Check that we restore input in GDB correctly.
-gdb_test "print 1" "^\\\$$decimal = 1" "gdb input still works"
+gdb_test "print 1" "^${::valnum_re} = 1" "gdb input still works"
diff --git a/gdb/testsuite/gdb.base/new-ui.exp b/gdb/testsuite/gdb.base/new-ui.exp
index 6380f173966..6bc45392733 100644
--- a/gdb/testsuite/gdb.base/new-ui.exp
+++ b/gdb/testsuite/gdb.base/new-ui.exp
@@ -28,7 +28,7 @@ proc ensure_no_output {message} {
 
     # Run a command and use an anchor to make sure no output appears
     # before the command's expected output.
-    gdb_test "print 999" "^\\\$$decimal = 999" $message
+    gdb_test "print 999" "^${::valnum_re} = 999" $message
 }
 
 # Run a few execution-related commands on CON1, and ensure the proper
diff --git a/gdb/testsuite/gdb.base/non-lazy-array-index.exp b/gdb/testsuite/gdb.base/non-lazy-array-index.exp
index d21b80b6d6d..48eb7db77c1 100644
--- a/gdb/testsuite/gdb.base/non-lazy-array-index.exp
+++ b/gdb/testsuite/gdb.base/non-lazy-array-index.exp
@@ -62,7 +62,7 @@ gdb_test_multiple "p \$.array\[1\]" "" {
     -re "^\[^\$\]\[^\r\n\]+\r\n" {
 	exp_continue
     }
-    -re "^\\\$${decimal} = 2\r\n$gdb_prompt " {
+    -re "^${::valnum_re} = 2\r\n$gdb_prompt " {
 	if { $saw_memory_access } {
 	    if { $saw_auxv_parse } {
 		# The expression parser may look up global symbols, which
diff --git a/gdb/testsuite/gdb.base/overlays.exp b/gdb/testsuite/gdb.base/overlays.exp
index d45412ba696..3f584ee83c3 100644
--- a/gdb/testsuite/gdb.base/overlays.exp
+++ b/gdb/testsuite/gdb.base/overlays.exp
@@ -66,7 +66,7 @@ proc get_func_address { func func_sym msg } {
     set func_addr 0
     send_gdb "print $func\n"
     gdb_expect {
-	-re "\\$\[0-9\]+ = $fptrcast (${hexx}) <$func_sym>.*$gdb_prompt $" {
+	-re "${::valnum_re} = $fptrcast (${hexx}) <$func_sym>.*$gdb_prompt $" {
 	    set func_addr $expect_out(1,string)
 	    pass "get $msg"
 	}
diff --git a/gdb/testsuite/gdb.base/prologue.exp b/gdb/testsuite/gdb.base/prologue.exp
index b8fd232a549..cd7c1bf8e4a 100644
--- a/gdb/testsuite/gdb.base/prologue.exp
+++ b/gdb/testsuite/gdb.base/prologue.exp
@@ -38,7 +38,7 @@ proc find_breakpoint_pc { sym } {
     set pc 0
     set msg "reading \$pc: $sym"
     gdb_test_multiple "print/x \$pc" $msg {
-	-re "\\\$$decimal = ($hex)\r\n$gdb_prompt $" {
+	-re "${::valnum_re} = ($hex)\r\n$gdb_prompt $" {
 	    set pc $expect_out(1,string)
 	    pass $msg
 	}
@@ -55,4 +55,4 @@ set pc1 [find_breakpoint_pc "marker"]
 
 set pc2 [find_breakpoint_pc "other"]
 
-gdb_test "print /d $pc1 == $pc2" "\\\$$decimal = 1" "same pc from minimal symbol"
+gdb_test "print /d $pc1 == $pc2" "${::valnum_re} = 1" "same pc from minimal symbol"
diff --git a/gdb/testsuite/gdb.base/ptr-typedef.exp b/gdb/testsuite/gdb.base/ptr-typedef.exp
index fbb4b48dde7..5dfd96d12ea 100644
--- a/gdb/testsuite/gdb.base/ptr-typedef.exp
+++ b/gdb/testsuite/gdb.base/ptr-typedef.exp
@@ -23,5 +23,5 @@ if {![runto marker1]} {
     untested "couldn't run to marker1"
 }
 
-gdb_test "print foo_ptr" "\\\$$decimal = \\\(struct foo \\\*\\\) $hex"
-gdb_test "print foz_ptr" "\\\$$decimal = \\\(foz\\\) $hex"
+gdb_test "print foo_ptr" "${::valnum_re} = \\\(struct foo \\\*\\\) $hex"
+gdb_test "print foz_ptr" "${::valnum_re} = \\\(foz\\\) $hex"
diff --git a/gdb/testsuite/gdb.base/randomize.exp b/gdb/testsuite/gdb.base/randomize.exp
index d9198e1272b..52c2ff71ab1 100644
--- a/gdb/testsuite/gdb.base/randomize.exp
+++ b/gdb/testsuite/gdb.base/randomize.exp
@@ -32,7 +32,7 @@ proc address_get { testname } {
     gdb_continue_to_breakpoint "$testname - address set"
 
     gdb_test_multiple "print/x p" $testname {
-	-re "\\$\[0-9\]+ = (0x\[0-9a-f\]*)\r?\n$gdb_prompt $" {
+	-re "${::valnum_re} = (0x\[0-9a-f\]*)\r?\n$gdb_prompt $" {
 	    pass $testname
 	    return $expect_out(1,string)
 	}
diff --git a/gdb/testsuite/gdb.base/range-stepping.exp b/gdb/testsuite/gdb.base/range-stepping.exp
index 531687df966..53083f066c3 100644
--- a/gdb/testsuite/gdb.base/range-stepping.exp
+++ b/gdb/testsuite/gdb.base/range-stepping.exp
@@ -41,7 +41,7 @@ with_test_prefix "multi insns" {
     set pc_before_stepping ""
     set test "pc before stepping"
     gdb_test_multiple "print/x \$pc" $test {
-	-re "\\\$$decimal = (\[^\r\n\]*)\r\n$gdb_prompt $" {
+	-re "${::valnum_re} = (\[^\r\n\]*)\r\n$gdb_prompt $" {
 	    set pc_before_stepping $expect_out(1,string)
 	    pass $test
 	}
@@ -67,7 +67,7 @@ with_test_prefix "multi insns" {
     set pc_after_stepping ""
     set msg "pc after stepping"
     gdb_test_multiple "print/x \$pc" $msg {
-	-re "\\\$$decimal = (\[^\r\n\]*)\r\n$gdb_prompt $" {
+	-re "${::valnum_re} = (\[^\r\n\]*)\r\n$gdb_prompt $" {
 	    set pc_after_stepping $expect_out(1,string)
 	    pass $msg
 	}
diff --git a/gdb/testsuite/gdb.base/relocate.exp b/gdb/testsuite/gdb.base/relocate.exp
index 99e8cb67448..8c1ffc52e50 100644
--- a/gdb/testsuite/gdb.base/relocate.exp
+++ b/gdb/testsuite/gdb.base/relocate.exp
@@ -317,7 +317,7 @@ clean_restart
 gdb_file_cmd ${binfile}
 
 # Check the values of the variables.
-gdb_test "print static_foo" "\\\$$decimal = 1"
-gdb_test "print static_bar" "\\\$$decimal = 2"
-gdb_test "print global_foo" "\\\$$decimal = 3"
-gdb_test "print global_bar" "\\\$$decimal = 4"
+gdb_test "print static_foo" "${::valnum_re} = 1"
+gdb_test "print static_bar" "${::valnum_re} = 2"
+gdb_test "print global_foo" "${::valnum_re} = 3"
+gdb_test "print global_bar" "${::valnum_re} = 4"
diff --git a/gdb/testsuite/gdb.base/scope.exp b/gdb/testsuite/gdb.base/scope.exp
index 9430c4bf59c..b82465a1184 100644
--- a/gdb/testsuite/gdb.base/scope.exp
+++ b/gdb/testsuite/gdb.base/scope.exp
@@ -42,51 +42,51 @@ proc_with_prefix test_at_main {} {
     gdb_test "next" "$decimal.*foo \\(\\);" "next over init0() in main"
 
     # Print scope0.c::filelocal, which is 1
-    gdb_test "print filelocal" "\\\$$decimal = 1"
-    gdb_test "print 'scope0.c'::filelocal" "\\\$$decimal = 1" "print 'scope0.c'::filelocal at main"
+    gdb_test "print filelocal" "${::valnum_re} = 1"
+    gdb_test "print 'scope0.c'::filelocal" "${::valnum_re} = 1" "print 'scope0.c'::filelocal at main"
 
     # Print scope0.c::filelocal_bss, which is 101
-    gdb_test "print filelocal_bss" "\\\$$decimal = 101"
-    gdb_test "print 'scope0.c'::filelocal_bss" "\\\$$decimal = 101" "print 'scope0.c'::filelocal_bss in test_at_main"
+    gdb_test "print filelocal_bss" "${::valnum_re} = 101"
+    gdb_test "print 'scope0.c'::filelocal_bss" "${::valnum_re} = 101" "print 'scope0.c'::filelocal_bss in test_at_main"
 
     # Print scope0.c::filelocal_ro, which is 201
 
     # No clue why the rs6000 fails this test.
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print filelocal_ro" "\\\$$decimal = 201" "print filelocal_ro in test_at_main"
+    gdb_test "print filelocal_ro" "${::valnum_re} = 201" "print filelocal_ro in test_at_main"
 
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope0.c'::filelocal_ro" "\\\$$decimal = 201" "print 'scope0.c'::filelocal_ro"
+    gdb_test "print 'scope0.c'::filelocal_ro" "${::valnum_re} = 201" "print 'scope0.c'::filelocal_ro"
 
     # Print scope1.c::filelocal, which is 2
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope1.c'::filelocal" "\\\$$decimal = 2" "print 'scope1.c'::filelocal"
+    gdb_test "print 'scope1.c'::filelocal" "${::valnum_re} = 2" "print 'scope1.c'::filelocal"
 
     # Print scope1.c::filelocal_bss, which is 102
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope1.c'::filelocal_bss" "\\\$$decimal = 102" "print 'scope1.c'::filelocal_bss"
+    gdb_test "print 'scope1.c'::filelocal_bss" "${::valnum_re} = 102" "print 'scope1.c'::filelocal_bss"
 
     # Print scope1.c::filelocal_ro, which is 202
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope1.c'::filelocal_ro" "\\\$$decimal = 202" "print 'scope1.c'::filelocal_ro"
+    gdb_test "print 'scope1.c'::filelocal_ro" "${::valnum_re} = 202" "print 'scope1.c'::filelocal_ro"
 
     # Print scope1.c::foo::funclocal, which is 3
-    gdb_test "print foo::funclocal" "\\\$$decimal = 3"
+    gdb_test "print foo::funclocal" "${::valnum_re} = 3"
 
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope1.c'::foo::funclocal" "\\\$$decimal = 3" "print 'scope1.c'::foo::funclocal"
+    gdb_test "print 'scope1.c'::foo::funclocal" "${::valnum_re} = 3" "print 'scope1.c'::foo::funclocal"
 
     # Print scope1.c::foo::funclocal_ro, which is 203
-    gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203"
+    gdb_test "print foo::funclocal_ro" "${::valnum_re} = 203"
 
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope1.c'::foo::funclocal_ro" "\\\$$decimal = 203" "print 'scope1.c'::foo::funclocal_ro"
+    gdb_test "print 'scope1.c'::foo::funclocal_ro" "${::valnum_re} = 203" "print 'scope1.c'::foo::funclocal_ro"
 
     # Print scope1.c::bar::funclocal, which is 4
-    gdb_test "print bar::funclocal" "\\\$$decimal = 4"
+    gdb_test "print bar::funclocal" "${::valnum_re} = 4"
 
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope1.c'::bar::funclocal" "\\\$$decimal = 4" "print 'scope1.c'::bar::funclocal"
+    gdb_test "print 'scope1.c'::bar::funclocal" "${::valnum_re} = 4" "print 'scope1.c'::bar::funclocal"
 }
 
 proc_with_prefix test_at_foo {} {
@@ -99,78 +99,78 @@ proc_with_prefix test_at_foo {} {
     gdb_test "next" ".*bar \\(\\);"
 
     # Print scope0.c::filelocal, which is 1
-    gdb_test "print 'scope0.c'::filelocal" "\\\$$decimal = 1" "print 'scope0.c'::filelocal at foo"
+    gdb_test "print 'scope0.c'::filelocal" "${::valnum_re} = 1" "print 'scope0.c'::filelocal at foo"
 
     # Print scope0.c::filelocal_bss, which is 101
-    gdb_test "print 'scope0.c'::filelocal_bss" "\\\$$decimal = 101" "print 'scope0.c'::filelocal_bss in test_at_foo"
+    gdb_test "print 'scope0.c'::filelocal_bss" "${::valnum_re} = 101" "print 'scope0.c'::filelocal_bss in test_at_foo"
 
     # Print scope0.c::filelocal_ro, which is 201
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope0.c'::filelocal_ro" "\\\$$decimal = 201" "print 'scope0.c'::filelocal_ro"
+    gdb_test "print 'scope0.c'::filelocal_ro" "${::valnum_re} = 201" "print 'scope0.c'::filelocal_ro"
 
 
     # Print scope1.c::filelocal, which is 2
-    gdb_test "print filelocal" "\\\$$decimal = 2" "print filelocal at foo"
+    gdb_test "print filelocal" "${::valnum_re} = 2" "print filelocal at foo"
 
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope1.c'::filelocal" "\\\$$decimal = 2" "print 'scope1.c'::filelocal at foo"
+    gdb_test "print 'scope1.c'::filelocal" "${::valnum_re} = 2" "print 'scope1.c'::filelocal at foo"
 
-    gdb_test "print filelocal_bss" "\\\$$decimal = 102" \
+    gdb_test "print filelocal_bss" "${::valnum_re} = 102" \
 	"print filelocal_bss at foo"
 
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope1.c'::filelocal_bss" "\\\$$decimal = 102" "print 'scope1.c'::filelocal_bss at foo"
+    gdb_test "print 'scope1.c'::filelocal_bss" "${::valnum_re} = 102" "print 'scope1.c'::filelocal_bss at foo"
 
 
-    gdb_test "print filelocal_ro" "\\\$$decimal = 202" \
+    gdb_test "print filelocal_ro" "${::valnum_re} = 202" \
 	"print filelocal_ro at foo"
 
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope1.c'::filelocal_ro" "\\\$$decimal = 202" "print 'scope1.c'::filelocal_ro at foo"
+    gdb_test "print 'scope1.c'::filelocal_ro" "${::valnum_re} = 202" "print 'scope1.c'::filelocal_ro at foo"
 
 
     # Print scope1.c::foo::funclocal, which is 3
 
-    gdb_test "print funclocal" "\\\$$decimal = 3" "print funclocal at foo"
+    gdb_test "print funclocal" "${::valnum_re} = 3" "print funclocal at foo"
 
-    gdb_test "print foo::funclocal" "\\\$$decimal = 3" \
+    gdb_test "print foo::funclocal" "${::valnum_re} = 3" \
 	"print foo::funclocal at foo"
 
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope1.c'::foo::funclocal" "\\\$$decimal = 3" "print 'scope1.c'::foo::funclocal at foo"
+    gdb_test "print 'scope1.c'::foo::funclocal" "${::valnum_re} = 3" "print 'scope1.c'::foo::funclocal at foo"
 
 
     # Print scope1.c::foo::funclocal_bss, which is 103
 
-    gdb_test "print funclocal_bss" "\\\$$decimal = 103" \
+    gdb_test "print funclocal_bss" "${::valnum_re} = 103" \
 	"print funclocal_bss at foo"
 
-    gdb_test "print foo::funclocal_bss" "\\\$$decimal = 103" \
+    gdb_test "print foo::funclocal_bss" "${::valnum_re} = 103" \
 	"print foo::funclocal_bss at foo"
 
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope1.c'::foo::funclocal_bss" "\\\$$decimal = 103" "print 'scope1.c'::foo::funclocal_bss at foo"
+    gdb_test "print 'scope1.c'::foo::funclocal_bss" "${::valnum_re} = 103" "print 'scope1.c'::foo::funclocal_bss at foo"
 
 
     # Print scope1.c::foo::funclocal_ro, which is 203
 
-    gdb_test "print funclocal_ro" "\\\$$decimal = 203" \
+    gdb_test "print funclocal_ro" "${::valnum_re} = 203" \
 	"print funclocal_ro at foo"
 
-    gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" \
+    gdb_test "print foo::funclocal_ro" "${::valnum_re} = 203" \
 	"print foo::funclocal_ro at foo"
 
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope1.c'::foo::funclocal_ro" "\\\$$decimal = 203" "print 'scope1.c'::foo::funclocal_ro at foo"
+    gdb_test "print 'scope1.c'::foo::funclocal_ro" "${::valnum_re} = 203" "print 'scope1.c'::foo::funclocal_ro at foo"
 
 
     # Print scope1.c::bar::funclocal, which is 4
 
-    gdb_test "print bar::funclocal" "\\\$$decimal = 4" \
+    gdb_test "print bar::funclocal" "${::valnum_re} = 4" \
 	"print bar::funclocal at foo"
 
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope1.c'::bar::funclocal" "\\\$$decimal = 4" "print 'scope1.c'::bar::funclocal at foo"
+    gdb_test "print 'scope1.c'::bar::funclocal" "${::valnum_re} = 4" "print 'scope1.c'::bar::funclocal at foo"
 
 }
 
@@ -184,64 +184,64 @@ proc_with_prefix test_at_bar {} {
     gdb_test "next"
 
     # Print scope0.c::filelocal, which is 1
-    gdb_test "print 'scope0.c'::filelocal" "\\\$$decimal = 1" "print 'scope0.c'::filelocal at bar"
+    gdb_test "print 'scope0.c'::filelocal" "${::valnum_re} = 1" "print 'scope0.c'::filelocal at bar"
 
     # Print scope0.c::filelocal_bss, which is 101
-    gdb_test "print 'scope0.c'::filelocal_bss" "\\\$$decimal = 101" "print 'scope0.c'::filelocal_bss in test_at_bar"
+    gdb_test "print 'scope0.c'::filelocal_bss" "${::valnum_re} = 101" "print 'scope0.c'::filelocal_bss in test_at_bar"
 
     # Print scope0.c::filelocal_ro, which is 201
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope0.c'::filelocal_ro" "\\\$$decimal = 201" "print 'scope0.c'::filelocal_ro at bar"
+    gdb_test "print 'scope0.c'::filelocal_ro" "${::valnum_re} = 201" "print 'scope0.c'::filelocal_ro at bar"
 
     # Print scope1.c::filelocal, which is 2
-    gdb_test "print filelocal" "\\\$$decimal = 2" "print filelocal at bar"
+    gdb_test "print filelocal" "${::valnum_re} = 2" "print filelocal at bar"
 
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope1.c'::filelocal" "\\\$$decimal = 2" "print 'scope1.c'::filelocal at bar"
+    gdb_test "print 'scope1.c'::filelocal" "${::valnum_re} = 2" "print 'scope1.c'::filelocal at bar"
 
     # Print scope1.c::filelocal_bss, which is 102
-    gdb_test "print filelocal_bss" "\\\$$decimal = 102" "print filelocal_bss at bar"
+    gdb_test "print filelocal_bss" "${::valnum_re} = 102" "print filelocal_bss at bar"
 
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope1.c'::filelocal_bss" "\\\$$decimal = 102" "print 'scope1.c'::filelocal_bss at bar"
+    gdb_test "print 'scope1.c'::filelocal_bss" "${::valnum_re} = 102" "print 'scope1.c'::filelocal_bss at bar"
 
     # Print scope1.c::filelocal_ro, which is 202
-    gdb_test "print filelocal_ro" "\\\$$decimal = 202" "print filelocal_ro in test_at_bar"
+    gdb_test "print filelocal_ro" "${::valnum_re} = 202" "print filelocal_ro in test_at_bar"
 
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope1.c'::filelocal_ro" "\\\$$decimal = 202" "print 'scope1.c'::filelocal_ro at bar"
+    gdb_test "print 'scope1.c'::filelocal_ro" "${::valnum_re} = 202" "print 'scope1.c'::filelocal_ro at bar"
 
     # Print scope1.c::foo::funclocal, which is 3
-    gdb_test "print foo::funclocal" "\\\$$decimal = 3" "print foo::funclocal at bar"
+    gdb_test "print foo::funclocal" "${::valnum_re} = 3" "print foo::funclocal at bar"
 
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope1.c'::foo::funclocal" "\\\$$decimal = 3" "print 'scope1.c'::foo::funclocal at bar"
+    gdb_test "print 'scope1.c'::foo::funclocal" "${::valnum_re} = 3" "print 'scope1.c'::foo::funclocal at bar"
 
     # Print scope1.c::foo::funclocal_bss, which is 103
-    gdb_test "print foo::funclocal_bss" "\\\$$decimal = 103" "print foo::funclocal_bss at bar"
+    gdb_test "print foo::funclocal_bss" "${::valnum_re} = 103" "print foo::funclocal_bss at bar"
 
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope1.c'::foo::funclocal_bss" "\\\$$decimal = 103" "print 'scope1.c'::foo::funclocal_bss at bar"
+    gdb_test "print 'scope1.c'::foo::funclocal_bss" "${::valnum_re} = 103" "print 'scope1.c'::foo::funclocal_bss at bar"
 
     # Print scope1.c::foo::funclocal_ro, which is 203
-    gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" "print foo::funclocal_ro at bar"
+    gdb_test "print foo::funclocal_ro" "${::valnum_re} = 203" "print foo::funclocal_ro at bar"
 
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope1.c'::foo::funclocal_ro" "\\\$$decimal = 203" "print 'scope1.c'::foo::funclocal_ro at bar"
+    gdb_test "print 'scope1.c'::foo::funclocal_ro" "${::valnum_re} = 203" "print 'scope1.c'::foo::funclocal_ro at bar"
 
     # Print scope1.c::bar::funclocal, which is 4
-    gdb_test "print funclocal" "\\\$$decimal = 4" "print funclocal at bar"
-    gdb_test "print bar::funclocal" "\\\$$decimal = 4" "print bar::funclocal at bar"
+    gdb_test "print funclocal" "${::valnum_re} = 4" "print funclocal at bar"
+    gdb_test "print bar::funclocal" "${::valnum_re} = 4" "print bar::funclocal at bar"
 
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope1.c'::bar::funclocal" "\\\$$decimal = 4" "print 'scope1.c'::bar::funclocal at bar"
+    gdb_test "print 'scope1.c'::bar::funclocal" "${::valnum_re} = 4" "print 'scope1.c'::bar::funclocal at bar"
 
     # Print scope1.c::bar::funclocal_bss, which is 104
-    gdb_test "print funclocal_bss" "\\\$$decimal = 104" "print funclocal_bss at bar"
-    gdb_test "print bar::funclocal_bss" "\\\$$decimal = 104" "print bar::funclocal_bss at bar"
+    gdb_test "print funclocal_bss" "${::valnum_re} = 104" "print funclocal_bss at bar"
+    gdb_test "print bar::funclocal_bss" "${::valnum_re} = 104" "print bar::funclocal_bss at bar"
 
     if {[test_compiler_info gcc-*-*]} { setup_xfail "rs6000-*-*" }
-    gdb_test "print 'scope1.c'::bar::funclocal_bss" "\\\$$decimal = 104" "print 'scope1.c'::bar::funclocal_bss at bar"
+    gdb_test "print 'scope1.c'::bar::funclocal_bss" "${::valnum_re} = 104" "print 'scope1.c'::bar::funclocal_bss at bar"
 }
 
 # This test has little to do with local scopes, but it is in scope.exp anyway.
diff --git a/gdb/testsuite/gdb.base/set-cwd.exp b/gdb/testsuite/gdb.base/set-cwd.exp
index a45ffd4a743..3fbffdc6136 100644
--- a/gdb/testsuite/gdb.base/set-cwd.exp
+++ b/gdb/testsuite/gdb.base/set-cwd.exp
@@ -40,7 +40,7 @@ proc_with_prefix test_tilde_expansion { } {
     set home ""
     set test "print home var"
     gdb_test_multiple "print home" $test {
-	-re "\\\$$decimal = $hex \"\(.+\)\"\r\n$gdb_prompt $" {
+	-re "${::valnum_re} = $hex \"\(.+\)\"\r\n$gdb_prompt $" {
 	    set home $expect_out(1,string)
 	    pass $test
 	}
@@ -54,7 +54,7 @@ proc_with_prefix test_tilde_expansion { } {
     set curdir ""
     set test "print dir var"
     gdb_test_multiple "print dir" $test {
-	-re "\\\$$decimal = \"\(.+\)\"\(, .*repeats.*\)?\r\n$gdb_prompt $" {
+	-re "${::valnum_re} = \"\(.+\)\"\(, .*repeats.*\)?\r\n$gdb_prompt $" {
 	    set curdir $expect_out(1,string)
 	    pass $test
 	}
@@ -107,7 +107,7 @@ proc_with_prefix test_cd_into_dir { } {
     gdb_breakpoint [gdb_get_line_number "break-here"]
     gdb_continue_to_breakpoint "break-here" ".* break-here .*"
 
-    gdb_test "print dir" "\\\$$decimal = \"$tmpdir\", .*" \
+    gdb_test "print dir" "${::valnum_re} = \"$tmpdir\", .*" \
 	"inferior cwd is correctly set"
 
     set gdb_cwd_after_run ""
@@ -164,7 +164,7 @@ proc_with_prefix test_cwd_reset { } {
     gdb_breakpoint [gdb_get_line_number "break-here"]
     gdb_continue_to_breakpoint "break-here" ".* break-here .*"
 
-    gdb_test "print dir" "\\\$$decimal = \"$tmpdir\", .*" \
+    gdb_test "print dir" "${::valnum_re} = \"$tmpdir\", .*" \
 	"inferior cwd is correctly set"
 
     # Reset the inferior's cwd.
@@ -178,7 +178,7 @@ proc_with_prefix test_cwd_reset { } {
 	gdb_breakpoint [gdb_get_line_number "break-here"]
 	gdb_continue_to_breakpoint "break-here" ".* break-here .*"
 
-	gdb_test "print dir" "\\\$$decimal = \"$gdb_cwd\", .*" \
+	gdb_test "print dir" "${::valnum_re} = \"$gdb_cwd\", .*" \
 	    "inferior cwd got reset correctly"
     }
 }
diff --git a/gdb/testsuite/gdb.base/share-env-with-gdbserver.exp b/gdb/testsuite/gdb.base/share-env-with-gdbserver.exp
index 238f113119e..e1b3540d5d7 100644
--- a/gdb/testsuite/gdb.base/share-env-with-gdbserver.exp
+++ b/gdb/testsuite/gdb.base/share-env-with-gdbserver.exp
@@ -51,7 +51,7 @@ proc check_getenv { var_name var_value { test_msg "" } { empty_var_p 0 } } {
 	set var_value_match "$hex \"$var_value\""
     }
 
-    gdb_test "print my_getenv (\"$var_name\")" "\\\$$decimal = $var_value_match" \
+    gdb_test "print my_getenv (\"$var_name\")" "${::valnum_re} = $var_value_match" \
 	$test_msg
 }
 
@@ -210,11 +210,11 @@ proc test_unset { } {
     set test_msg "check if unset works"
     set found_home 0
     gdb_test_multiple "print my_getenv (\"HOME\")" $test_msg {
-	-re "\\\$$decimal = $hex \".*\"\r\n$gdb_prompt $" {
+	-re "${::valnum_re} = $hex \".*\"\r\n$gdb_prompt $" {
 	    pass $test_msg
 	    set found_home 1
 	}
-	-re "\\\$$decimal = 0x0\r\n$gdb_prompt $" {
+	-re "${::valnum_re} = 0x0\r\n$gdb_prompt $" {
 	    untested $test_msg
 	}
     }
diff --git a/gdb/testsuite/gdb.base/shell.exp b/gdb/testsuite/gdb.base/shell.exp
index 71d95d42122..f6b36dc3a7c 100644
--- a/gdb/testsuite/gdb.base/shell.exp
+++ b/gdb/testsuite/gdb.base/shell.exp
@@ -49,14 +49,14 @@ with_test_prefix "\$_shell convenience function" {
     gdb_test "p \$_shell(\"false\")" " = 1"
 
     # Test command with arguments.
-    gdb_test "p \$_shell(\"echo foo\")" "foo\r\n\\$${decimal} = 0"
+    gdb_test "p \$_shell(\"echo foo\")" "foo\r\n${::valnum_re} = 0"
 
     # Check the type of the result.
     gdb_test "ptype \$_shell(\"true\")" "type = int"
 
     # Test passing a non-literal string as command name.
     gdb_test "p \$cmd = \"echo bar\"" " = \"echo bar\""
-    gdb_test "p \$_shell(\$cmd)" "bar\r\n\\$${decimal} = 0"
+    gdb_test "p \$_shell(\$cmd)" "bar\r\n${::valnum_re} = 0"
 
     # Test executing a non-existing command.  The result is
     # shell-dependent, but most (all?) POSIX-like shells return 127 in
diff --git a/gdb/testsuite/gdb.base/signals.exp b/gdb/testsuite/gdb.base/signals.exp
index 51adb19e613..5ce3ff12d57 100644
--- a/gdb/testsuite/gdb.base/signals.exp
+++ b/gdb/testsuite/gdb.base/signals.exp
@@ -88,7 +88,7 @@ if {[runto_main]} {
 
     # ...call the function
 
-    gdb_test "p func1 ()" "^\\\$$decimal = void" \
+    gdb_test "p func1 ()" "^${::valnum_re} = void" \
 	"p func1 () #1"
 
     # ...veryfiy that the cout was updated
diff --git a/gdb/testsuite/gdb.base/solib-disc.exp b/gdb/testsuite/gdb.base/solib-disc.exp
index e2898699877..a9b2bd471ee 100644
--- a/gdb/testsuite/gdb.base/solib-disc.exp
+++ b/gdb/testsuite/gdb.base/solib-disc.exp
@@ -60,7 +60,7 @@ gdb_test "continue" "Stopped due to shared library event.*" "continue to load"
 set msg "save \$pc after load"
 set saved_pc ""
 gdb_test_multiple "print/x \$pc" $msg {
-    -re "\\\$$decimal = (\[^\r\n\]*)\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = (\[^\r\n\]*)\r\n$gdb_prompt $" {
 	set saved_pc $expect_out(1,string)
 	pass $msg
     }
@@ -74,7 +74,7 @@ if { [gdb_reconnect] == 0 } {
     return 0
 }
 
-gdb_test "print/x \$pc" "\\\$$decimal = $saved_pc" "check \$pc after load"
+gdb_test "print/x \$pc" "${::valnum_re} = $saved_pc" "check \$pc after load"
 
 
 gdb_test "continue" "Stopped due to shared library event.*" "continue to unload"
@@ -82,7 +82,7 @@ gdb_test "continue" "Stopped due to shared library event.*" "continue to unload"
 set msg "save \$pc after unload"
 set saved_pc ""
 gdb_test_multiple "print/x \$pc" $msg {
-    -re "\\\$$decimal = (\[^\r\n\]*)\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = (\[^\r\n\]*)\r\n$gdb_prompt $" {
 	set saved_pc $expect_out(1,string)
 	pass $msg
     }
@@ -96,4 +96,4 @@ if { [gdb_reconnect] == 0 } {
     return 0
 }
 
-gdb_test "print/x \$pc" "\\\$$decimal = $saved_pc" "check \$pc after unload"
+gdb_test "print/x \$pc" "${::valnum_re} = $saved_pc" "check \$pc after unload"
diff --git a/gdb/testsuite/gdb.base/startup-with-shell.exp b/gdb/testsuite/gdb.base/startup-with-shell.exp
index 5a9b69e9b9e..b27cdce63d7 100644
--- a/gdb/testsuite/gdb.base/startup-with-shell.exp
+++ b/gdb/testsuite/gdb.base/startup-with-shell.exp
@@ -81,7 +81,7 @@ proc run_test { args on_re off_re testname { problematic_on false } } {
 		setup_xfail "*-*-*" gdb/28392
 	    }
 
-	    gdb_test "print argv\[1\]" "\\\$$::decimal = $::hex $re" $testname
+	    gdb_test "print argv\[1\]" "${::valnum_re} = $::hex $re" $testname
 	}
     }
 }
diff --git a/gdb/testsuite/gdb.base/structs3.exp b/gdb/testsuite/gdb.base/structs3.exp
index 4eea63b4305..bdcf19a9932 100644
--- a/gdb/testsuite/gdb.base/structs3.exp
+++ b/gdb/testsuite/gdb.base/structs3.exp
@@ -25,7 +25,7 @@ if {![runto_main]} {
     return -1
 }
 
-set vhn "\\$\[0-9\]+"
+set vhn "${::valnum_re}"
 
 # Check the real contents.
 gdb_test "print two" "$vhn = {one = {x = 1}, x = 2, y = 3}"
diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp
index 23d50f4cfad..2bffe8cf437 100644
--- a/gdb/testsuite/gdb.base/style.exp
+++ b/gdb/testsuite/gdb.base/style.exp
@@ -213,7 +213,7 @@ proc run_style_tests { } {
 	set sfield [limited_style string_field variable]
 	set efield [limited_style e_field variable]
 	set evalue [limited_style VALUE_TWO variable]
-	set lhs [limited_style "\\\$$decimal" variable]
+	set lhs [limited_style "${::valnum_re}" variable]
 	gdb_test "print struct_value" \
 	    "$lhs = \{$ifield = 23,.*$sfield = .*,.*$efield = $evalue.*"
 
@@ -1044,7 +1044,7 @@ proc test_finish_styling {} {
 	return
     }
 
-    gdb_test "finish" "Value returned is [style \\\$$::decimal variable] = 0"
+    gdb_test "finish" "Value returned is [style ${::valnum_re} variable] = 0"
 }
 
 # Check to see if the Python styling of disassembler output is
diff --git a/gdb/testsuite/gdb.cp/bs15503.exp b/gdb/testsuite/gdb.cp/bs15503.exp
index f48d692ca25..3a1ec22b5a4 100644
--- a/gdb/testsuite/gdb.cp/bs15503.exp
+++ b/gdb/testsuite/gdb.cp/bs15503.exp
@@ -45,8 +45,8 @@ gdb_continue_to_breakpoint "find position where blank needs to be inserted"
 
 # Call some string methods.
 
-gdb_test "print s.length()"		"\\$\[0-9\]+ = 42"
-gdb_test "print s\[0\]"			"\\$\[0-9\]+ =.* 'I'"
-gdb_test "print s\[s.length()-1\]"	"\\$\[0-9\]+ =.* 'g'"
+gdb_test "print s.length()"		"${::valnum_re} = 42"
+gdb_test "print s\[0\]"			"${::valnum_re} =.* 'I'"
+gdb_test "print s\[s.length()-1\]"	"${::valnum_re} =.* 'g'"
 gdb_test "print (const char *) s" \
-    "\\$\[0-9\]+ = $hex \"I am a short stringand now a longer string\""
+    "${::valnum_re} = $hex \"I am a short stringand now a longer string\""
diff --git a/gdb/testsuite/gdb.cp/call-c.exp b/gdb/testsuite/gdb.cp/call-c.exp
index 8cb487a6092..bdbe4277239 100644
--- a/gdb/testsuite/gdb.cp/call-c.exp
+++ b/gdb/testsuite/gdb.cp/call-c.exp
@@ -34,9 +34,9 @@ runto_main
 gdb_test "b [gdb_get_line_number {breakpoint here} ${testfile}.cc ]" \
 	 ".*Breakpoint .*call-c.*"
 
-gdb_test "print foo(1)" "\\\$$decimal = 1"
+gdb_test "print foo(1)" "${::valnum_re} = 1"
 gdb_test "continue" ".*breakpoint here.*" "continue to bp"
-gdb_test "print rf->func()" "\\\$$decimal = 1"
+gdb_test "print rf->func()" "${::valnum_re} = 1"
 
 gdb_test "print sum_vararg_int(0)" "0"
 gdb_test "print sum_vararg_int(1, 10)" "10"
@@ -52,4 +52,4 @@ gdb_test "print vararg_func(11, 12, 13.5)" "2"
 gdb_test "print vararg_func(14, 15, \"16\")" "2"
 
 # Regression test for method call via a typedef.
-gdb_test "print handle->func()" "\\\$$decimal = 1"
+gdb_test "print handle->func()" "${::valnum_re} = 1"
diff --git a/gdb/testsuite/gdb.cp/classes.exp b/gdb/testsuite/gdb.cp/classes.exp
index 231c6c7cff2..ea4b2033b83 100644
--- a/gdb/testsuite/gdb.cp/classes.exp
+++ b/gdb/testsuite/gdb.cp/classes.exp
@@ -491,7 +491,7 @@ proc test_enums {} {
     # 2008-08-21 we can output the qualifiers for DWARF-2.
 
     gdb_test "print obj_with_enum" \
-	"\\$\[0-9\]+ = \{priv_enum = (ClassWithEnum::)?red, x = 0\}" \
+	"${::valnum_re} = \{priv_enum = (ClassWithEnum::)?red, x = 0\}" \
 	"print obj_with_enum (1)"
 
     # advance one line
@@ -501,12 +501,12 @@ proc test_enums {} {
     # print the object again
 
     gdb_test "print obj_with_enum" \
-	"\\$\[0-9\]+ = \{priv_enum = (ClassWithEnum::)?green, x = 0\}" \
+	"${::valnum_re} = \{priv_enum = (ClassWithEnum::)?green, x = 0\}" \
 	"print obj_with_enum, 2"
 
     # print the enum member
 
-    gdb_test "print obj_with_enum.priv_enum" "\\$\[0-9\]+ = (ClassWithEnum::)?green"
+    gdb_test "print obj_with_enum.priv_enum" "${::valnum_re} = (ClassWithEnum::)?green"
 
     # ptype on the enum member
 
@@ -585,7 +585,7 @@ proc test_enums {} {
     # See PR gdb/1588.
 
     gdb_test_multiple "print (ClassWithEnum::PrivEnum) 42" "print (ClassWithEnum::PrivEnum) 42" {
-	-re "\\$\[0-9\]+ = (ClassWithEnum::)?yellow$nl$gdb_prompt $" {
+	-re "${::valnum_re} = (ClassWithEnum::)?yellow$nl$gdb_prompt $" {
 	    pass "print (ClassWithEnum::PrivEnum) 42"
 	}
 	-re "A (parse|syntax) error in expression, near `42'.$nl$gdb_prompt $" {
@@ -596,7 +596,7 @@ proc test_enums {} {
     }
 
     gdb_test_multiple "print ('ClassWithEnum::PrivEnum') 42" "print ('ClassWithEnum::PrivEnum') 42" {
-	-re "\\$\[0-9\]+ = (ClassWithEnum::)?yellow$nl$gdb_prompt $" {
+	-re "${::valnum_re} = (ClassWithEnum::)?yellow$nl$gdb_prompt $" {
 	    # gcc 3.3.2 -gstabs+
 	    # gcc HEAD 2003-12-28 21:08:30 UTC -gstabs+
 	    pass "print ('ClassWithEnum::PrivEnum') 42"
@@ -615,9 +615,9 @@ proc test_enums {} {
 
 proc test_pointers_to_class_members {} {
     gdb_test "print Bar::z" "Cannot reference non-static field \"z\""
-    gdb_test "print &Foo::x" "\\$\[0-9\]+ = &Foo::x"
-    gdb_test "print (int)&Foo::x" "\\$\[0-9\]+ = 0"
-    gdb_test "print (int)&Bar::y == 2*sizeof(int)" "\\$\[0-9\]+ = true"
+    gdb_test "print &Foo::x" "${::valnum_re} = &Foo::x"
+    gdb_test "print (int)&Foo::x" "${::valnum_re} = 0"
+    gdb_test "print (int)&Bar::y == 2*sizeof(int)" "${::valnum_re} = true"
 
     gdb_test "ptype Bar::z" "type = int"
     gdb_test "ptype &Bar::z" "type = int Bar::\\*"
@@ -630,12 +630,12 @@ proc test_pointers_to_class_members {} {
 proc test_static_members {} {
     global hex
 
-    gdb_test "print Foo::st" "\\$\[0-9\]+ = 100"
+    gdb_test "print Foo::st" "${::valnum_re} = 100"
     gdb_test_no_output "set foo.st = 200" ""
-    gdb_test "print bar.st" "\\$\[0-9\]+ = 200"
-    gdb_test "print &foo.st" "\\$\[0-9\]+ = \\(int ?\\*\\) $hex <Foo::st>"
-    gdb_test "print &Bar::st" "\\$\[0-9\]+ = \\(int ?\\*\\) $hex <Foo::st>"
-    gdb_test "print *\$" "\\$\[0-9\]+ = 200"
+    gdb_test "print bar.st" "${::valnum_re} = 200"
+    gdb_test "print &foo.st" "${::valnum_re} = \\(int ?\\*\\) $hex <Foo::st>"
+    gdb_test "print &Bar::st" "${::valnum_re} = \\(int ?\\*\\) $hex <Foo::st>"
+    gdb_test "print *\$" "${::valnum_re} = 200"
 
     gdb_test_no_output "set print static-members off"
     gdb_test "print csi" \
diff --git a/gdb/testsuite/gdb.cp/converts.exp b/gdb/testsuite/gdb.cp/converts.exp
index abc583c5299..7d26db9f302 100644
--- a/gdb/testsuite/gdb.cp/converts.exp
+++ b/gdb/testsuite/gdb.cp/converts.exp
@@ -68,7 +68,7 @@ gdb_test_multiple "p foo3_1 (0, 0)" $t {
     fail "$t (conversion failed)"
   }
 
-  -re "\\$\[0-9\]+ = 31$nl$gdb_prompt $" {
+  -re "${::valnum_re} = 31$nl$gdb_prompt $" {
     pass $t
   }
 }
diff --git a/gdb/testsuite/gdb.cp/cp-relocate.exp b/gdb/testsuite/gdb.cp/cp-relocate.exp
index 8866324148f..fb45313466b 100644
--- a/gdb/testsuite/gdb.cp/cp-relocate.exp
+++ b/gdb/testsuite/gdb.cp/cp-relocate.exp
@@ -30,7 +30,7 @@ proc get_func_address { func } {
 
     set rfunc [string_to_regexp $func]
     gdb_test_multiple "print ${func}" "get address of ${func}" {
-	-re "\\\$\[0-9\]+ = \\{.*\\} (($hex) <${rfunc}.*>)\[\r\n\]+${gdb_prompt} $" {
+	-re "${::valnum_re} = \\{.*\\} (($hex) <${rfunc}.*>)\[\r\n\]+${gdb_prompt} $" {
 	    # $1 = {int ()} 0x24 <function_bar>
 	    # But if the function is at zero, the name may be omitted.
 	    pass "get address of ${func}"
diff --git a/gdb/testsuite/gdb.cp/ctti.exp b/gdb/testsuite/gdb.cp/ctti.exp
index 941143c81b7..e328b7c59c4 100644
--- a/gdb/testsuite/gdb.cp/ctti.exp
+++ b/gdb/testsuite/gdb.cp/ctti.exp
@@ -37,12 +37,12 @@ if {![runto_main]} {
 gdb_breakpoint [gdb_get_line_number "marker add1"]
 gdb_continue_to_breakpoint "marker add1"
 
-gdb_test "print c" "\\$\[0-9\]+ = 194 .*"
-gdb_test "print f" "\\$\[0-9\]+ = 9"
-gdb_test "print i" "\\$\[0-9\]+ = 4"
+gdb_test "print c" "${::valnum_re} = 194 .*"
+gdb_test "print f" "${::valnum_re} = 9"
+gdb_test "print i" "${::valnum_re} = 4"
 
 gdb_test_multiple "print add<int>(2,2)" "print add<int>(2,2)" {
-    -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = 4\r\n$gdb_prompt $" {
 	pass "print add<int>(2,2)"
     }
     -re "No symbol \"add<int>\" in current context.\r\n$gdb_prompt $" {
@@ -52,7 +52,7 @@ gdb_test_multiple "print add<int>(2,2)" "print add<int>(2,2)" {
 
 # Note: 2.25 and 4.5 are exactly representable in IEEE-ish formats
 gdb_test_multiple "print add<float>(2.25,2.25)" "print add<float>(2.25,2.25)" {
-    -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = 4\\.5\r\n$gdb_prompt $" {
 	pass "print add<float>(2.25,2.25)"
     }
     -re "No symbol \"add<float>\" in current context.\r\n$gdb_prompt $" {
@@ -61,7 +61,7 @@ gdb_test_multiple "print add<float>(2.25,2.25)" "print add<float>(2.25,2.25)" {
 }
 
 gdb_test_multiple "print add<unsigned char>('A','A')" "print add<unsigned char>('A','A')" {
-    -re "\\$\[0-9\]+ = 130 .*\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = 130 .*\r\n$gdb_prompt $" {
 	pass "print add<unsigned char>('A','A')"
     }
     -re "No symbol \"add<unsigned char>\" in current context.\r\n$gdb_prompt $" {
@@ -70,7 +70,7 @@ gdb_test_multiple "print add<unsigned char>('A','A')" "print add<unsigned char>(
 }
 
 gdb_test_multiple "print add2<int>(2,2)" "print add2<int>(2,2)" {
-    -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = 4\r\n$gdb_prompt $" {
 	pass "print add2<int>(2,2)"
     }
     -re "No symbol \"add2<int>\" in current context.\r\n$gdb_prompt $" {
@@ -79,7 +79,7 @@ gdb_test_multiple "print add2<int>(2,2)" "print add2<int>(2,2)" {
 }
 
 gdb_test_multiple "print add2<float>(2.25,2.25)" "print add2<float>(2.25,2.25)" {
-    -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = 4\\.5\r\n$gdb_prompt $" {
 	pass "print add2<float>(2.25,2.25)"
     }
     -re "No symbol \"add2<float>\" in current context.\r\n$gdb_prompt $" {
@@ -88,7 +88,7 @@ gdb_test_multiple "print add2<float>(2.25,2.25)" "print add2<float>(2.25,2.25)"
 }
 
 gdb_test_multiple "print add2<unsigned char>('A','A')" "print add2<unsigned char>('A','A')" {
-    -re "\\$\[0-9]+ = 130 .*$gdb_prompt $" {
+    -re "${::valnum_re} = 130 .*$gdb_prompt $" {
 	pass "print add2<unsigned char>('A','A')"
     }
     -re "No symbol \"add2<unsigned char>\" in current context.\r\n$gdb_prompt $" {
@@ -97,7 +97,7 @@ gdb_test_multiple "print add2<unsigned char>('A','A')" "print add2<unsigned char
 }
 
 gdb_test_multiple "print add3<int>(2,2)" "print add3<int>(2,2)" {
-    -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = 4\r\n$gdb_prompt $" {
 	pass "print add3<int>(2,2)"
     }
     -re "No symbol \"add3<int>\" in current context.\r\n$gdb_prompt $" {
@@ -106,7 +106,7 @@ gdb_test_multiple "print add3<int>(2,2)" "print add3<int>(2,2)" {
 }
 
 gdb_test_multiple "print add3<float>(2.25,2.25)" "print add3<float>(2.25,2.25)" {
-    -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = 4\\.5\r\n$gdb_prompt $" {
 	pass "print add3<float>(2.25,2.25)"
     }
     -re "No symbol \"add3<float>\" in current context.\r\n$gdb_prompt $" {
@@ -115,7 +115,7 @@ gdb_test_multiple "print add3<float>(2.25,2.25)" "print add3<float>(2.25,2.25)"
 }
 
 gdb_test_multiple "print add3<unsigned char>('A','A')" "print add3<unsigned char>('A','A')" {
-    -re "\\$\[0-9]+ = 130 .*$gdb_prompt $" {
+    -re "${::valnum_re} = 130 .*$gdb_prompt $" {
 	pass "print add3<unsigned char>('A','A')"
     }
     -re "No symbol \"add3<unsigned char>\" in current context.\r\n$gdb_prompt $" {
@@ -124,7 +124,7 @@ gdb_test_multiple "print add3<unsigned char>('A','A')" "print add3<unsigned char
 }
 
 gdb_test_multiple "print add4<int>(2,2)" "print add4<int>(2,2)" {
-    -re "\\$\[0-9\]+ = 4\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = 4\r\n$gdb_prompt $" {
 	pass "print add4<int>(2,2)"
     }
     -re "No symbol \"add4<int>\" in current context.\r\n$gdb_prompt $" {
@@ -133,7 +133,7 @@ gdb_test_multiple "print add4<int>(2,2)" "print add4<int>(2,2)" {
 }
 
 gdb_test_multiple "print add4<float>(2.25,2.25)" "print add4<float>(2.25,2.25)" {
-    -re "\\$\[0-9\]+ = 4\\.5\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = 4\\.5\r\n$gdb_prompt $" {
 	pass "print add4<float>(2.25,2.25)"
     }
     -re "No symbol \"add4<float>\" in current context.\r\n$gdb_prompt $" {
@@ -142,7 +142,7 @@ gdb_test_multiple "print add4<float>(2.25,2.25)" "print add4<float>(2.25,2.25)"
 }
 
 gdb_test_multiple "print add4<unsigned char>('A','A')" "print add4<unsigned char>('A','A')" {
-    -re "\\$\[0-9]+ = 130 .*$gdb_prompt $" {
+    -re "${::valnum_re} = 130 .*$gdb_prompt $" {
 	pass "print add4<unsigned char>('A','A')"
     }
     -re "No symbol \"add4<unsigned char>\" in current context.\r\n$gdb_prompt $" {
diff --git a/gdb/testsuite/gdb.cp/derivation.exp b/gdb/testsuite/gdb.cp/derivation.exp
index 1e727a7cc82..34fbf3c250e 100644
--- a/gdb/testsuite/gdb.cp/derivation.exp
+++ b/gdb/testsuite/gdb.cp/derivation.exp
@@ -74,7 +74,7 @@ gdb_test "up" ".*main.*" "up from marker1"
 
 # class A
 
-gdb_test "print a_instance" "\\$\[0-9\]+ = \{a = 1, aa = 2\}" "print value of a_instance"
+gdb_test "print a_instance" "${::valnum_re} = \{a = 1, aa = 2\}" "print value of a_instance"
 
 # Clang does not add accessibility information for typedefs inside classes.
 if {[test_compiler_info {clang*} c++]} {
@@ -94,7 +94,7 @@ cp_test_ptype_class \
 # class D
 
 gdb_test_multiple "print d_instance" "print value of d_instance" {
-    -re "\\$\[0-9\]+ = \{<(class A|A)> = \{a = 1, aa = 2\}, <(class B|B)> = \{b = 3, bb = 4\}, <(class C|C)> = \{c = 5, cc = 6\}, d = 7, dd = 8\}$nl$gdb_prompt $" {
+    -re "${::valnum_re} = \{<(class A|A)> = \{a = 1, aa = 2\}, <(class B|B)> = \{b = 3, bb = 4\}, <(class C|C)> = \{c = 5, cc = 6\}, d = 7, dd = 8\}$nl$gdb_prompt $" {
 	pass "print value of d_instance"
     }
 }
@@ -119,7 +119,7 @@ cp_test_ptype_class \
 # class E
 
 gdb_test_multiple "print e_instance" "print value of e_instance" {
-    -re "\\$\[0-9\]+ = \{<(class A|A)> = \{a = 1, aa = 2\}, <(class B|B)> = \{b = 3, bb = 4\}, <(class C|C)> = \{c = 5, cc = 6\}, e = 9, ee = 10\}$nl$gdb_prompt $" {
+    -re "${::valnum_re} = \{<(class A|A)> = \{a = 1, aa = 2\}, <(class B|B)> = \{b = 3, bb = 4\}, <(class C|C)> = \{c = 5, cc = 6\}, e = 9, ee = 10\}$nl$gdb_prompt $" {
 	pass "print value of e_instance"
     }
 }
@@ -144,7 +144,7 @@ cp_test_ptype_class \
 # class F
 
 gdb_test_multiple "print f_instance" "print value of f_instance" {
-    -re "\\$\[0-9\]+ = \{<(class A|A)> = \{a = 1, aa = 2\}, <(class B|B)> = \{b = 3, bb = 4\}, <(class C|C)> = \{c = 5, cc = 6\}, f = 11, ff = 12\}$nl$gdb_prompt $" {
+    -re "${::valnum_re} = \{<(class A|A)> = \{a = 1, aa = 2\}, <(class B|B)> = \{b = 3, bb = 4\}, <(class C|C)> = \{c = 5, cc = 6\}, f = 11, ff = 12\}$nl$gdb_prompt $" {
 	pass "print value of f_instance"
     }
 }
@@ -180,25 +180,25 @@ cp_test_ptype_class \
 
 # Print individual fields.
 
-gdb_test "print d_instance.a"  "\\$\[0-9\]+ = 1" "print value of d_instance.a"
-gdb_test "print d_instance.aa" "\\$\[0-9\]+ = 2" "print value of d_instance.aa"
-gdb_test "print d_instance.b"  "\\$\[0-9\]+ = 3" "print value of d_instance.b"
-gdb_test "print d_instance.bb" "\\$\[0-9\]+ = 4" "print value of d_instance.bb"
-gdb_test "print d_instance.c"  "\\$\[0-9\]+ = 5" "print value of d_instance.c"
-gdb_test "print d_instance.cc" "\\$\[0-9\]+ = 6" "print value of d_instance.cc"
-gdb_test "print d_instance.d"  "\\$\[0-9\]+ = 7" "print value of d_instance.d"
-gdb_test "print d_instance.dd" "\\$\[0-9\]+ = 8" "print value of d_instance.dd"
+gdb_test "print d_instance.a"  "${::valnum_re} = 1" "print value of d_instance.a"
+gdb_test "print d_instance.aa" "${::valnum_re} = 2" "print value of d_instance.aa"
+gdb_test "print d_instance.b"  "${::valnum_re} = 3" "print value of d_instance.b"
+gdb_test "print d_instance.bb" "${::valnum_re} = 4" "print value of d_instance.bb"
+gdb_test "print d_instance.c"  "${::valnum_re} = 5" "print value of d_instance.c"
+gdb_test "print d_instance.cc" "${::valnum_re} = 6" "print value of d_instance.cc"
+gdb_test "print d_instance.d"  "${::valnum_re} = 7" "print value of d_instance.d"
+gdb_test "print d_instance.dd" "${::valnum_re} = 8" "print value of d_instance.dd"
 
 # Print some fields which are defined in the top of class G
 # and in its base classes.  This is not be ambiguous.
 
-gdb_test "print g_instance.a"  "\\$\[0-9\]+ = 15" "print value of g_instance.a"
-gdb_test "print g_instance.b"  "\\$\[0-9\]+ = 16" "print value of g_instance.b"
-gdb_test "print g_instance.c"  "\\$\[0-9\]+ = 17" "print value of g_instance.c"
+gdb_test "print g_instance.a"  "${::valnum_re} = 15" "print value of g_instance.a"
+gdb_test "print g_instance.b"  "${::valnum_re} = 16" "print value of g_instance.b"
+gdb_test "print g_instance.c"  "${::valnum_re} = 17" "print value of g_instance.c"
 
 # Print a function call.
 
-gdb_test "print g_instance.afoo()" "\\$\[0-9\]+ = 1" "print value of g_instance.afoo()"
+gdb_test "print g_instance.afoo()" "${::valnum_re} = 1" "print value of g_instance.afoo()"
 
 # If GDB fails to restore the selected frame properly after the
 # inferior function call above (see GDB PR 1155 for an explanation of
@@ -218,8 +218,8 @@ gdb_test_multiple "frame" "re-selected 'main' frame after inferior call" {
     }
 }
 
-gdb_test "print g_instance.bfoo()" "\\$\[0-9\]+ = 2" "print value of g_instance.bfoo()"
-gdb_test "print g_instance.cfoo()" "\\$\[0-9\]+ = 3" "print value of g_instance.cfoo()"
+gdb_test "print g_instance.bfoo()" "${::valnum_re} = 2" "print value of g_instance.bfoo()"
+gdb_test "print g_instance.cfoo()" "${::valnum_re} = 3" "print value of g_instance.cfoo()"
 
 # Check typedefs of fields
 foreach Klass {"C" "G"} {
diff --git a/gdb/testsuite/gdb.cp/formatted-ref.exp b/gdb/testsuite/gdb.cp/formatted-ref.exp
index 3e4a76c1a8a..cecc3876b5a 100644
--- a/gdb/testsuite/gdb.cp/formatted-ref.exp
+++ b/gdb/testsuite/gdb.cp/formatted-ref.exp
@@ -41,7 +41,7 @@ proc get_address { var } {
     global gdb_prompt
 
     gdb_test_multiple "print &$var" "find address of $var" {
-	-re "\\$\[0-9\]+ = \\(.*\\) (0x\[0-9a-f\]+).*$gdb_prompt $" {
+	-re "${::valnum_re} = \\(.*\\) (0x\[0-9a-f\]+).*$gdb_prompt $" {
 	    return $expect_out(1,string)
 	}
 	timeout {
@@ -57,13 +57,13 @@ proc test_p_x { var type val addr } {
 
     set test "print/x $var"
     gdb_test_multiple $test $test {
-	-re "\\$\[0-9\]+ = \\([string_to_regexp $type]\\) @0x\[a-f0-9\]+: [string_to_regexp $val].*$gdb_prompt $" {
+	-re "${::valnum_re} = \\([string_to_regexp $type]\\) @0x\[a-f0-9\]+: [string_to_regexp $val].*$gdb_prompt $" {
 	    pass $test
 	}
-	-re "\\$\[0-9\]+ = $addr.*$gdb_prompt $" {
+	-re "${::valnum_re} = $addr.*$gdb_prompt $" {
 	    fail "$test (prints just address)"
 	}
-	-re "\\$\[0-9\]+ = 0x\[a-f0-9\]+.*$gdb_prompt $" {
+	-re "${::valnum_re} = 0x\[a-f0-9\]+.*$gdb_prompt $" {
 	    fail "$test (prints unexpected address)"
 	}
     }
@@ -75,10 +75,10 @@ proc test_p_x_addr { var addr } {
 
     set test "print/x &$var"
     gdb_test_multiple $test $test {
-	-re "\\$\[0-9\]+ = $addr.*$gdb_prompt $" {
+	-re "${::valnum_re} = $addr.*$gdb_prompt $" {
 	    pass $test
 	}
-	-re "\\$\[0-9\]+ = 0x\[a-f0-9+\]+.*$gdb_prompt $" {
+	-re "${::valnum_re} = 0x\[a-f0-9+\]+.*$gdb_prompt $" {
 	    fail "$test (prints unexpected address)"
 	}
     }
@@ -90,7 +90,7 @@ proc test_p_x_ref_addr { var addr } {
 
     set test "print/x *(&(&$var))"
     gdb_test_multiple $test $test {
-	-re "\\$\[0-9\]+ = $addr.*$gdb_prompt $" {
+	-re "${::valnum_re} = $addr.*$gdb_prompt $" {
 	    pass $test
 	}
 	-re "Attempt to take address of value not located in memory.*$gdb_prompt $" {
@@ -98,7 +98,7 @@ proc test_p_x_ref_addr { var addr } {
 	    # correctly...
 	    pass $test
 	}
-	-re "\\$\[0-9\]+ = 0x\[a-f0-9+\]+.*$gdb_prompt $" {
+	-re "${::valnum_re} = 0x\[a-f0-9+\]+.*$gdb_prompt $" {
 	    fail "$test (prints unexpected address)"
 	}
     }
@@ -107,7 +107,7 @@ proc test_p_x_ref_addr { var addr } {
 
 proc test_p_op1_equals_op2 {op1 op2} {
     set test "print $op1 == $op2"
-    gdb_test $test "\\$\[0-9\]+ = true"
+    gdb_test $test "${::valnum_re} = true"
 }
 
 runto ${srcfile}:[gdb_get_line_number "marker here"]
diff --git a/gdb/testsuite/gdb.cp/inherit.exp b/gdb/testsuite/gdb.cp/inherit.exp
index f3c7a23f4e2..eafec26828f 100644
--- a/gdb/testsuite/gdb.cp/inherit.exp
+++ b/gdb/testsuite/gdb.cp/inherit.exp
@@ -18,7 +18,7 @@
 
 set ws  "\[\r\n\t \]+"
 set nl  "\[\r\n\]+"
-set vhn "\\$\[0-9\]+"
+set vhn "${::valnum_re}"
 
 require allow_cplus_tests
 
diff --git a/gdb/testsuite/gdb.cp/member-ptr.exp b/gdb/testsuite/gdb.cp/member-ptr.exp
index bce11019fd2..f7aa475d4f8 100644
--- a/gdb/testsuite/gdb.cp/member-ptr.exp
+++ b/gdb/testsuite/gdb.cp/member-ptr.exp
@@ -19,7 +19,7 @@
 # Written by Satish Pai <pai@apollo.hp.com> 1997-08-19
 # Rewritten by Michael Chastain <mec.gnu@mindspring.com> 2004-01-11
 
-set vhn "\\$\[0-9\]+"
+set vhn "${::valnum_re}"
 
 require allow_cplus_tests
 
diff --git a/gdb/testsuite/gdb.cp/method-ref-return.exp b/gdb/testsuite/gdb.cp/method-ref-return.exp
index 2e75d5b6636..8f3638172c3 100644
--- a/gdb/testsuite/gdb.cp/method-ref-return.exp
+++ b/gdb/testsuite/gdb.cp/method-ref-return.exp
@@ -33,7 +33,7 @@ gdb_continue_to_breakpoint "after reference assignment"
 
 # Test that we can call the method through reference and get the expected result.
 gdb_test_multiple "print b.get_foo()" "print method call returning reference" {
-    -re "\\$\[0-9\]+ = \\(const foo &\\) @$hex: \\{m_a = 42\\}\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = \\(const foo &\\) @$hex: \\{m_a = 42\\}\r\n$gdb_prompt $" {
 	pass $gdb_test_name
     }
     -re "Could not validate memory tag: Value can't be converted to integer\\." {
@@ -43,17 +43,17 @@ gdb_test_multiple "print b.get_foo()" "print method call returning reference" {
 
 # Test accessing the member through the reference.
 gdb_test "print b.get_foo ().m_a" \
-    "\\$\[0-9\]+ = 42" \
+    "${::valnum_re} = 42" \
     "print member access through reference"
 
 # Test calling method on the referenced object.
 gdb_test "print b.get_foo ().get_a()" \
-    "\\$\[0-9\]+ = 42" \
+    "${::valnum_re} = 42" \
     "print method call on referenced object"
 
 # Test that the stored reference works correctly.
 gdb_test_multiple "print ref" "print stored reference" {
-    -re "\\$\[0-9\]+ = \\(const foo &\\) @$hex: \\{m_a = 42\\}\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = \\(const foo &\\) @$hex: \\{m_a = 42\\}\r\n$gdb_prompt $" {
 	pass $gdb_test_name
     }
     -re "Could not validate memory tag: Value can't be converted to integer\\." {
@@ -62,9 +62,9 @@ gdb_test_multiple "print ref" "print stored reference" {
 }
 
 gdb_test "print ref.m_a" \
-    "\\$\[0-9\]+ = 42" \
+    "${::valnum_re} = 42" \
     "print member through stored reference"
 
 gdb_test "print ref.get_a()" \
-    "\\$\[0-9\]+ = 42" \
+    "${::valnum_re} = 42" \
     "print method call through stored reference"
\ No newline at end of file
diff --git a/gdb/testsuite/gdb.cp/namespace.exp b/gdb/testsuite/gdb.cp/namespace.exp
index 7ba3efb9ba4..5e9bee31239 100644
--- a/gdb/testsuite/gdb.cp/namespace.exp
+++ b/gdb/testsuite/gdb.cp/namespace.exp
@@ -72,7 +72,7 @@ gdb_test "print AAA::c" \
 
 # An object declared using "using".
 
-gdb_test "print ina" "\\$\[0-9\]+ = {xx = 33}"
+gdb_test "print ina" "${::valnum_re} = {xx = 33}"
 
 gdb_test_multiple "ptype ina" "ptype ina" {
     -re "type = class (AAA::|)inA \{\r\n\[ \]*public:\r\n\[ \]*int xx;\r\n\[ \]*\r\n\[ \]*.*int fum\\(int\\);\r\n\}\r\n$gdb_prompt $" {
diff --git a/gdb/testsuite/gdb.cp/overload.exp b/gdb/testsuite/gdb.cp/overload.exp
index c017ae1a55e..5d586b19e24 100644
--- a/gdb/testsuite/gdb.cp/overload.exp
+++ b/gdb/testsuite/gdb.cp/overload.exp
@@ -87,7 +87,7 @@ set re_methods	"${re_methods}${ws}int overloadargs\\(int, int, int, int, int, in
 set re_methods	"${re_methods}${ws}int overloadargs\\(int, int, int, int, int, int, int, int, int, int, int\\);"
 set re_synth	"foo & operator=\\(foo const ?&\\);"
 
-gdb_test "print foo_instance1" "\\$\[0-9\]+ = \{ifoo = 111, ccpfoo = 0x0\}"
+gdb_test "print foo_instance1" "${::valnum_re} = \{ifoo = 111, ccpfoo = 0x0\}"
 
 set lines [gdb_get_lines "ptype foo_instance1"]
 set test "ptype foo_instance1 output"
@@ -127,10 +127,10 @@ if { [regexp "^type = $re_class${ws}$XX_fields${ws}$re_synth${ws}$re_dtor${ws}$r
 # Print variables and method calls.
 # This is a walk in the park.
 
-gdb_test "print foo_instance2" "\\$\[0-9\]+ = \{ifoo = 222, ccpfoo = $hex \"A\"\}"
-gdb_test "print foo_instance3" "\\$\[0-9\]+ = \{ifoo = 222, ccpfoo = $hex \"A\"\}"
+gdb_test "print foo_instance2" "${::valnum_re} = \{ifoo = 222, ccpfoo = $hex \"A\"\}"
+gdb_test "print foo_instance3" "${::valnum_re} = \{ifoo = 222, ccpfoo = $hex \"A\"\}"
 
-gdb_test "print foo_instance1.overloadargs(1)" "\\$\[0-9\]+ = 1" \
+gdb_test "print foo_instance1.overloadargs(1)" "${::valnum_re} = 1" \
     "print call overloaded func 1 arg"
 
 # Regression test for overloading with function pointer type.
@@ -155,99 +155,99 @@ gdb_test_multiple "frame" "re-selected 'main' frame after inferior call" {
 }
 
 gdb_test "print foo_instance1.overloadargs(1, 2)" \
-    "\\$\[0-9\]+ = 2" \
+    "${::valnum_re} = 2" \
     "print call overloaded func 2 args"
 
 gdb_test "print foo_instance1.overloadargs(1, 2, 3)" \
-    "\\$\[0-9\]+ = 3" \
+    "${::valnum_re} = 3" \
     "print call overloaded func 3 args"
 
 gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4)" \
-    "\\$\[0-9\]+ = 4" \
+    "${::valnum_re} = 4" \
     "print call overloaded func 4 args"
 
 gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5)" \
-    "\\$\[0-9\]+ = 5" \
+    "${::valnum_re} = 5" \
     "print call overloaded func 5 args"
 
 gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6)" \
-    "\\$\[0-9\]+ = 6" \
+    "${::valnum_re} = 6" \
     "print call overloaded func 6 args"
 
 gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7)" \
-    "\\$\[0-9\]+ = 7" \
+    "${::valnum_re} = 7" \
     "print call overloaded func 7 args"
 
 gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8)" \
-    "\\$\[0-9\]+ = 8" \
+    "${::valnum_re} = 8" \
     "print call overloaded func 8 args"
 
 gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9)" \
-    "\\$\[0-9\]+ = 9" \
+    "${::valnum_re} = 9" \
     "print call overloaded func 9 args"
 
 gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)" \
-    "\\$\[0-9\]+ = 10" \
+    "${::valnum_re} = 10" \
     "print call overloaded func 10 args"
 
 gdb_test "print foo_instance1.overloadargs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)" \
-    "\\$\[0-9\]+ = 11" \
+    "${::valnum_re} = 11" \
     "print call overloaded func 11 args"
 
 gdb_test "print foo_instance1.overload1arg()" \
-    "\\$\[0-9\]+ = 1" \
+    "${::valnum_re} = 1" \
     "print call overloaded func void arg"
 
 gdb_test "print foo_instance1.overload1arg((char)arg2)" \
-    "\\$\[0-9\]+ = 2" \
+    "${::valnum_re} = 2" \
     "print call overloaded func char arg"
 
 gdb_test "print foo_instance1.overload1arg((signed char)arg3)" \
-    "\\$\[0-9\]+ = 3" \
+    "${::valnum_re} = 3" \
     "print call overloaded func signed char arg"
 
 gdb_test "print foo_instance1.overload1arg((unsigned char)arg4)" \
-    "\\$\[0-9\]+ = 4" \
+    "${::valnum_re} = 4" \
     "print call overloaded func unsigned char arg"
 
 gdb_test "print foo_instance1.overload1arg((short)arg5)" \
-    "\\$\[0-9\]+ = 5" \
+    "${::valnum_re} = 5" \
     "print call overloaded func short arg"
 
 gdb_test "print foo_instance1.overload1arg((unsigned short)arg6)" \
-    "\\$\[0-9\]+ = 6" \
+    "${::valnum_re} = 6" \
     "print call overloaded func unsigned short arg"
 
 gdb_test "print foo_instance1.overload1arg((int)arg7)" \
-    "\\$\[0-9\]+ = 7" \
+    "${::valnum_re} = 7" \
     "print call overloaded func int arg"
 
 gdb_test "print foo_instance1.overload1arg((unsigned int)arg8)" \
-    "\\$\[0-9\]+ = 8" \
+    "${::valnum_re} = 8" \
     "print call overloaded func unsigned int arg"
 
 gdb_test "print foo_instance1.overload1arg((long)arg9)" \
-    "\\$\[0-9\]+ = 9" \
+    "${::valnum_re} = 9" \
     "print call overloaded func long arg"
 
 gdb_test "print foo_instance1.overload1arg((unsigned long)arg10)" \
-    "\\$\[0-9\]+ = 10" \
+    "${::valnum_re} = 10" \
     "print call overloaded func unsigned long arg"
 
 gdb_test "print foo_instance1.overload1arg((float)arg11)" \
-    "\\$\[0-9\]+ = 11" \
+    "${::valnum_re} = 11" \
     "print call overloaded func float arg"
 
 gdb_test "print foo_instance1.overload1arg((double)arg12)" \
-    "\\$\[0-9\]+ = 12" \
+    "${::valnum_re} = 12" \
     "print call overloaded func double arg"
 
 gdb_test "print foo_instance1.overload1arg(&arg13)" \
-    "\\$\[0-9\]+ = 13" \
+    "${::valnum_re} = 13" \
     "print call overloaded func int\\* arg"
 
 gdb_test "print foo_instance1.overload1arg(&arg14)" \
-    "\\$\[0-9\]+ = 14" \
+    "${::valnum_re} = 14" \
     "print call overloaded func char\\* arg"
 
 gdb_test "print bar(a)" "= 11"
@@ -366,7 +366,7 @@ gdb_test "print overloadNamespace(dummyInstance)" ".\[0-9\]* = 2" "print overloa
 # One last mysterious test.
 # I wonder what this is for?
 
-gdb_test "print intToChar(1)" "\\$\[0-9\]+ = 297"
+gdb_test "print intToChar(1)" "${::valnum_re} = 297"
 
 # Test expression evaluation with overloaded methods
 gdb_test "print foo::overload1arg" \
@@ -376,11 +376,11 @@ gdb_test "print foo::overload1arg(char***)" \
     "no member function matches that type instantiation"
 
 gdb_test "print foo::overload1arg(void)" \
-    "\\$$decimal = {int \\(foo \\*( const|)\\)} $hex <foo::overload1arg\\(\\)>"
+    "${::valnum_re} = {int \\(foo \\*( const|)\\)} $hex <foo::overload1arg\\(\\)>"
 
 foreach t [list char "signed char" "unsigned char" "short" \
 	       "unsigned short" int "unsigned int" long "unsigned long" \
 	       float double] {
     gdb_test "print foo::overload1arg($t)" \
-	"\\$$decimal = {int \\(foo \\*( const|), $t\\)} $hex <foo::overload1arg\\($t\\)>"
+	"${::valnum_re} = {int \\(foo \\*( const|), $t\\)} $hex <foo::overload1arg\\($t\\)>"
 }
diff --git a/gdb/testsuite/gdb.cp/static-print-quit.exp b/gdb/testsuite/gdb.cp/static-print-quit.exp
index 7a26f4b9cd8..088abb9b9f8 100644
--- a/gdb/testsuite/gdb.cp/static-print-quit.exp
+++ b/gdb/testsuite/gdb.cp/static-print-quit.exp
@@ -28,7 +28,7 @@ gdb_test_no_output "set width 80"
 gdb_test_no_output "set height 2"
 
 gdb_test_multiple "print c" "" {
-    -re "\\$\[0-9\]+ = \{loooooooooooooooooooooooooooooooooooooooooooooong = 0, static field = \{\r\n$pagination_prompt$" {
+    -re "${::valnum_re} = \{loooooooooooooooooooooooooooooooooooooooooooooong = 0, static field = \{\r\n$pagination_prompt$" {
 	pass $gdb_test_name
     }
     -re "\r\n$pagination_prompt$" {
diff --git a/gdb/testsuite/gdb.cp/virtfunc.exp b/gdb/testsuite/gdb.cp/virtfunc.exp
index ffacc77e6f4..21e300e4ffc 100644
--- a/gdb/testsuite/gdb.cp/virtfunc.exp
+++ b/gdb/testsuite/gdb.cp/virtfunc.exp
@@ -181,17 +181,17 @@ proc test_virtual_calls {} {
 	return 0
     }
 
-    gdb_test "print pAe->f()"   "\\$\[0-9\]+ = 20"
-    gdb_test "print pAa->f()"   "\\$\[0-9\]+ = 1"
-    gdb_test "print pDe->vg()"  "\\$\[0-9\]+ = 202"
-    gdb_test "print pADe->vg()" "\\$\[0-9\]+ = 202"
-    gdb_test "print pDd->vg()"  "\\$\[0-9\]+ = 101"
-    gdb_test "print pEe->vvb()" "\\$\[0-9\]+ = 411"
-    gdb_test "print pVB->vvb()" "\\$\[0-9\]+ = 407"
-    gdb_test "print pBe->vvb()" "\\$\[0-9\]+ = 411"
-    gdb_test "print pDe->vvb()" "\\$\[0-9\]+ = 411"
-    gdb_test "print pEe->vd()"  "\\$\[0-9\]+ = 282"
-    gdb_test "print pEe->fvb()" "\\$\[0-9\]+ = 311"
+    gdb_test "print pAe->f()"   "${::valnum_re} = 20"
+    gdb_test "print pAa->f()"   "${::valnum_re} = 1"
+    gdb_test "print pDe->vg()"  "${::valnum_re} = 202"
+    gdb_test "print pADe->vg()" "${::valnum_re} = 202"
+    gdb_test "print pDd->vg()"  "${::valnum_re} = 101"
+    gdb_test "print pEe->vvb()" "${::valnum_re} = 411"
+    gdb_test "print pVB->vvb()" "${::valnum_re} = 407"
+    gdb_test "print pBe->vvb()" "${::valnum_re} = 411"
+    gdb_test "print pDe->vvb()" "${::valnum_re} = 411"
+    gdb_test "print pEe->vd()"  "${::valnum_re} = 282"
+    gdb_test "print pEe->fvb()" "${::valnum_re} = 311"
 
     # more recent results:
     # wrong value "202"
@@ -204,10 +204,10 @@ proc test_virtual_calls {} {
     # -- chastain 2003-12-31
 
     gdb_test_multiple "print pEe->D::vg()" "print pEe->D::vg()" {
-	-re "\\$\[0-9]+ = 102$nl$gdb_prompt $" {
+	-re "${::valnum_re} = 102$nl$gdb_prompt $" {
 	    pass "print pEe->D::vg()"
 	}
-	-re "\\$\[0-9]+ = 202$nl$gdb_prompt $" {
+	-re "${::valnum_re} = 202$nl$gdb_prompt $" {
 	    # To get this result, we have called pEe->*(&D::vg) ().
 	    # That's how GDB interprets this, but it's wrong; in fact
 	    # the explicit D:: means to bypass virtual function lookup,
diff --git a/gdb/testsuite/gdb.cp/virtfunc2.exp b/gdb/testsuite/gdb.cp/virtfunc2.exp
index 598fe4304b3..761453f6227 100644
--- a/gdb/testsuite/gdb.cp/virtfunc2.exp
+++ b/gdb/testsuite/gdb.cp/virtfunc2.exp
@@ -37,12 +37,12 @@ if {![runto_main]} {
 gdb_breakpoint [gdb_get_line_number "marker 1"]
 gdb_continue_to_breakpoint "marker 1"
 
-gdb_test "print o.do_print()"  "\\$\[0-9\]+ = 123456"
-gdb_test "print o.do_print3()"  "\\$\[0-9\]+ = 111111"
+gdb_test "print o.do_print()"  "${::valnum_re} = 123456"
+gdb_test "print o.do_print3()"  "${::valnum_re} = 111111"
 
-gdb_test "print o2.do_print()"  "\\$\[0-9\]+ = 123456"
-gdb_test "print o2.do_print2()"  "\\$\[0-9\]+ = 654321"
-gdb_test "print o2.do_print3()"  "\\$\[0-9\]+ = 111111"
+gdb_test "print o2.do_print()"  "${::valnum_re} = 123456"
+gdb_test "print o2.do_print2()"  "${::valnum_re} = 654321"
+gdb_test "print o2.do_print3()"  "${::valnum_re} = 111111"
 
 gdb_test "print o" " = {<interface> = {.*_vptr.interface = $hex <vtable for Obj.*>}, <No data fields>}"
 
diff --git a/gdb/testsuite/gdb.fortran/debug-expr.exp b/gdb/testsuite/gdb.fortran/debug-expr.exp
index 638624b3438..4cd78c7d478 100644
--- a/gdb/testsuite/gdb.fortran/debug-expr.exp
+++ b/gdb/testsuite/gdb.fortran/debug-expr.exp
@@ -36,12 +36,12 @@ gdb_breakpoint [gdb_get_line_number "Break Here"]
 gdb_continue_to_breakpoint "Break Here"
 
 gdb_test_no_output "set debug expression 1"
-gdb_test_debug_expr "print obj%three(1)%two(1)%one(1)%i" "\\\$$decimal = 1"
+gdb_test_debug_expr "print obj%three(1)%two(1)%one(1)%i" "${::valnum_re} = 1"
 gdb_test_debug_expr "print .TRUE."  [multi_line \
 					 "Operation: OP_BOOL" \
 					 " Constant: .*1" \
-					 "\\\$$decimal = \.TRUE\."]
+					 "${::valnum_re} = \.TRUE\."]
 gdb_test_debug_expr "print .FALSE."  [multi_line \
 					 "Operation: OP_BOOL" \
 					 " Constant: .*0" \
-					  "\\\$$decimal = \.FALSE\."]
+					  "${::valnum_re} = \.FALSE\."]
diff --git a/gdb/testsuite/gdb.fortran/derived-type.exp b/gdb/testsuite/gdb.fortran/derived-type.exp
index 6e05b3229f4..c55ebb338e2 100644
--- a/gdb/testsuite/gdb.fortran/derived-type.exp
+++ b/gdb/testsuite/gdb.fortran/derived-type.exp
@@ -52,25 +52,25 @@ gdb_test_multiple "ptype q" $test {
 gdb_breakpoint [gdb_get_line_number "print"]
 gdb_continue_to_breakpoint "print"
 
-gdb_test "print p" "\\$\[0-9\]+ = \\( c = 1, d = 2\\.375 \\)"
-gdb_test "print p%c" "\\$\[0-9\]+ = 1"
-gdb_test "print p%d" "\\$\[0-9\]+ = 2\\.375"
-gdb_test "print q%a" "\\$\[0-9\]+ = 3\\.125"
+gdb_test "print p" "${::valnum_re} = \\( c = 1, d = 2\\.375 \\)"
+gdb_test "print p%c" "${::valnum_re} = 1"
+gdb_test "print p%d" "${::valnum_re} = 2\\.375"
+gdb_test "print q%a" "${::valnum_re} = 3\\.125"
 
 set test "print q%b"
 gdb_test_multiple $test $test {
-    -re "\\$\[0-9\]+ = 'abcdefg'\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = 'abcdefg'\r\n$gdb_prompt $" {
 	pass $test
     }
-    -re "\\$\[0-9\]+ = \\(97 'a', 98 'b', 99 'c', 100 'd', 101 'e', 102 'f', 103 'g'\\)\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = \\(97 'a', 98 'b', 99 'c', 100 'd', 101 'e', 102 'f', 103 'g'\\)\r\n$gdb_prompt $" {
 	# Compiler should produce string, not an array of characters.
 	setup_xfail "*-*-*"
 	fail $test
     }
 }
 
-gdb_test "print q%x%c" "\\$\[0-9\]+ = 1"
-gdb_test "print q%x%d" "\\$\[0-9\]+ = 2\\.375"
+gdb_test "print q%x%c" "${::valnum_re} = 1"
+gdb_test "print q%x%d" "${::valnum_re} = 2\\.375"
 
 set result_line "= \\( a = 3.125, x = \\( c = 1, d = 2\\.375 \\),\
 b = 'abcdefg' \\)\r\n$gdb_prompt $"
diff --git a/gdb/testsuite/gdb.fortran/namelist.exp b/gdb/testsuite/gdb.fortran/namelist.exp
index 3f60fb1475d..25c9ae920a6 100644
--- a/gdb/testsuite/gdb.fortran/namelist.exp
+++ b/gdb/testsuite/gdb.fortran/namelist.exp
@@ -44,7 +44,7 @@ if { $supported } {
     gdb_test "ptype nml" \
 	"type = Type nml\r\n *$int :: a\r\n *$int :: b\r\n *End Type nml"
     gdb_test "print nml" \
-	"\\$\[0-9\]+ = \\( a = 10, b = 20 \\)"
+	"${::valnum_re} = \\( a = 10, b = 20 \\)"
 } else {
     gdb_test "ptype nml" \
 	"No symbol \"nml\" in current context\\."
diff --git a/gdb/testsuite/gdb.fortran/subarray.exp b/gdb/testsuite/gdb.fortran/subarray.exp
index 9bd4698050c..f8677168b33 100644
--- a/gdb/testsuite/gdb.fortran/subarray.exp
+++ b/gdb/testsuite/gdb.fortran/subarray.exp
@@ -48,10 +48,10 @@ gdb_test "continue" \
 
 set test "print str(2:4)"
 gdb_test_multiple $test $test {
-    -re "\\$\[0-9\]+ = 'bcd'\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = 'bcd'\r\n$gdb_prompt $" {
 	pass $test
     }
-    -re "\\$\[0-9\]+ = \\(98 'b', 99 'c', 100 'd'\\)\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = \\(98 'b', 99 'c', 100 'd'\\)\r\n$gdb_prompt $" {
 	# Compiler should produce string, not an array of characters.
 	setup_xfail "*-*-*"
 	fail $test
@@ -60,10 +60,10 @@ gdb_test_multiple $test $test {
 
 set test "print str(:3)"
 gdb_test_multiple $test $test {
-    -re "\\$\[0-9\]+ = 'abc'\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = 'abc'\r\n$gdb_prompt $" {
 	pass $test
     }
-    -re "\\$\[0-9\]+ = \\(97 'a', 98 'b', 99 'c'\\)\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = \\(97 'a', 98 'b', 99 'c'\\)\r\n$gdb_prompt $" {
 	# Compiler should produce string, not an array of characters.
 	setup_xfail "*-*-*"
 	fail $test
@@ -72,10 +72,10 @@ gdb_test_multiple $test $test {
 
 set test "print str(5:)"
 gdb_test_multiple $test $test {
-    -re "\\$\[0-9\]+ = 'efg'\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = 'efg'\r\n$gdb_prompt $" {
 	pass $test
     }
-    -re "\\$\[0-9\]+ = \\(101 'e', 102 'f', 103 'g'\\)\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = \\(101 'e', 102 'f', 103 'g'\\)\r\n$gdb_prompt $" {
 	# Compiler should produce string, not an array of characters.
 	setup_xfail "*-*-*"
 	fail $test
@@ -84,17 +84,17 @@ gdb_test_multiple $test $test {
 
 set test "print str(:)"
 gdb_test_multiple $test $test {
-    -re "\\$\[0-9\]+ = 'abcdefg'\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = 'abcdefg'\r\n$gdb_prompt $" {
 	pass $test
     }
-    -re "\\$\[0-9\]+ = \\(97 'a', 98 'b', 99 'c', 100 'd', 101 'e', 102 'f', 103 'g'\\)\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = \\(97 'a', 98 'b', 99 'c', 100 'd', 101 'e', 102 'f', 103 'g'\\)\r\n$gdb_prompt $" {
 	# Compiler should produce string, not an array of characters.
 	setup_xfail "*-*-*"
 	fail $test
     }
 }
 
-gdb_test "print array(2:4)" "\\$\[0-9\]+ = \\(2, 3, 4\\)"
-gdb_test "print array(:3)" "\\$\[0-9\]+ = \\(1, 2, 3\\)"
-gdb_test "print array(5:)" "\\$\[0-9\]+ = \\(5, 6, 7\\)"
-gdb_test "print array(:)" "\\$\[0-9\]+ = \\(1, 2, 3, 4, 5, 6, 7\\)"
+gdb_test "print array(2:4)" "${::valnum_re} = \\(2, 3, 4\\)"
+gdb_test "print array(:3)" "${::valnum_re} = \\(1, 2, 3\\)"
+gdb_test "print array(5:)" "${::valnum_re} = \\(5, 6, 7\\)"
+gdb_test "print array(:)" "${::valnum_re} = \\(1, 2, 3, 4, 5, 6, 7\\)"
diff --git a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp
index 3434ffa2a46..844206f7511 100644
--- a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp
+++ b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp
@@ -485,7 +485,7 @@ proc ensure_no_output { test } {
     if { $gdb_spawn_id == $gdb_main_spawn_id } {
 	# CLI
 	gdb_test "print 666" \
-		 "^\\\$$decimal = 666" \
+		 "^${::valnum_re} = 666" \
 		 "$test, ensure no output CLI"
     } elseif { $gdb_spawn_id == $mi_spawn_id } {
 	# MI
diff --git a/gdb/testsuite/gdb.multi/tids.exp b/gdb/testsuite/gdb.multi/tids.exp
index 2d843a05f5d..be42fcbffd0 100644
--- a/gdb/testsuite/gdb.multi/tids.exp
+++ b/gdb/testsuite/gdb.multi/tids.exp
@@ -43,7 +43,7 @@ proc thread_apply {tid_list exp_tid_list {message ""}} {
     foreach tid $expected {
 	append r "\[\r\n\]+"
 	append r "Thread $tid $any:\r\n"
-	append r "\\$$decimal = 1234"
+	append r "${::valnum_re} = 1234"
     }
 
     set cmd "thread apply $tid_list"
diff --git a/gdb/testsuite/gdb.opt/clobbered-registers-O2.exp b/gdb/testsuite/gdb.opt/clobbered-registers-O2.exp
index 72eceb8b91d..f36bb62a78a 100644
--- a/gdb/testsuite/gdb.opt/clobbered-registers-O2.exp
+++ b/gdb/testsuite/gdb.opt/clobbered-registers-O2.exp
@@ -33,11 +33,11 @@ if {![runto start_sequence]} {
 gdb_test "frame 1" "#1.*in gen_movsd.*" "backtracing"
 
 gdb_test_multiple "print operand0" "print operand0" {
-    -re "\\\$$decimal = <optimized out>\r\n$gdb_prompt $" { pass "print operand0"}
+    -re "${::valnum_re} = <optimized out>\r\n$gdb_prompt $" { pass "print operand0"}
     -re "$hex\r\n$gdb_prompt $" { gdb_test "print *operand0" "13" "print operand0" }
 }
 
 gdb_test_multiple "print operand1" "print operand1" {
-    -re "\\\$$decimal = <optimized out>\r\n$gdb_prompt $" { pass "print operand1"}
+    -re "${::valnum_re} = <optimized out>\r\n$gdb_prompt $" { pass "print operand1"}
     -re "$hex\r\n$gdb_prompt $" { gdb_test "print *operand1" "14" "print operand1" }
 }
diff --git a/gdb/testsuite/gdb.opt/inline-cmds.exp b/gdb/testsuite/gdb.opt/inline-cmds.exp
index 8f1005adf36..12db0709fe6 100644
--- a/gdb/testsuite/gdb.opt/inline-cmds.exp
+++ b/gdb/testsuite/gdb.opt/inline-cmds.exp
@@ -107,7 +107,7 @@ gdb_test_multiple "list" $msg {
 	# func1_step above).
 	set x_val -1
 	gdb_test_multiple "print x" "" {
-	    -re "\\\$$decimal = (\[0-9\]*)\r\n$gdb_prompt $" {
+	    -re "${::valnum_re} = (\[0-9\]*)\r\n$gdb_prompt $" {
 		set x_val $expect_out(1,string)
 	    }
 	    -re "$gdb_prompt $" { }
diff --git a/gdb/testsuite/gdb.opt/inline-locals.exp b/gdb/testsuite/gdb.opt/inline-locals.exp
index a2671648b3b..2c3a9f71c2f 100644
--- a/gdb/testsuite/gdb.opt/inline-locals.exp
+++ b/gdb/testsuite/gdb.opt/inline-locals.exp
@@ -74,7 +74,7 @@ if { ! $no_frames } {
 
 # Make sure that locals on the stack are found.  This is an array to
 # prevent it from living in a register.
-gdb_test "print array\[0\]" "\\\$$decimal = 0" "print local 2"
+gdb_test "print array\[0\]" "${::valnum_re} = 0" "print local 2"
 
 if { ! $no_frames } {
     # Verify that we do not print out variables from the inlined
@@ -122,7 +122,7 @@ if { ! $no_frames } {
     gdb_test "info locals" ".*arg2 = 184.*" "info locals above bar (3b)"
 }
 
-gdb_test "print array\[0\]" "\\\$$decimal = 184" "print local 3"
+gdb_test "print array\[0\]" "${::valnum_re} = 184" "print local 3"
 
 # Test printing scoped local variables.
 
diff --git a/gdb/testsuite/gdb.opt/static-optimized-out.exp b/gdb/testsuite/gdb.opt/static-optimized-out.exp
index 6b2a94e6760..92a5d2836d6 100644
--- a/gdb/testsuite/gdb.opt/static-optimized-out.exp
+++ b/gdb/testsuite/gdb.opt/static-optimized-out.exp
@@ -29,7 +29,7 @@ if { [prepare_for_testing "failed to prepare" $testfile \
 
 set val ""
 gdb_test_multiple "print aaa" "" {
-    -re -wrap "^(?:\\$$decimal = )?(.*)" {
+    -re -wrap "^(?:${::valnum_re} = )?(.*)" {
 	set val $expect_out(1,string)
     }
 }
diff --git a/gdb/testsuite/gdb.server/ext-wrapper.exp b/gdb/testsuite/gdb.server/ext-wrapper.exp
index ad4dd660228..836c32a7574 100644
--- a/gdb/testsuite/gdb.server/ext-wrapper.exp
+++ b/gdb/testsuite/gdb.server/ext-wrapper.exp
@@ -49,7 +49,7 @@ gdb_test_no_output "set remote exec-file $target_exec" "set remote exec-file"
 gdb_breakpoint marker
 gdb_test "run" "Breakpoint.* marker .*" "run to marker"
 
-gdb_test "print d" "\\$${decimal} = ${hex} \"1\".*"
+gdb_test "print d" "${::valnum_re} = ${hex} \"1\".*"
 
 # Restart the process.
 with_test_prefix "restart" {
@@ -71,7 +71,7 @@ with_test_prefix "restart" {
 	}
     }
 
-    gdb_test "print d" "\\$${decimal} = ${hex} \"1\".*"
+    gdb_test "print d" "${::valnum_re} = ${hex} \"1\".*"
 }
 
 gdb_test "kill" "" "kill" "Kill the program being debugged. .y or n. " "y"
diff --git a/gdb/testsuite/gdb.server/inferior-args.exp b/gdb/testsuite/gdb.server/inferior-args.exp
index a9244dbed70..312e756f0d8 100644
--- a/gdb/testsuite/gdb.server/inferior-args.exp
+++ b/gdb/testsuite/gdb.server/inferior-args.exp
@@ -93,12 +93,12 @@ proc do_test_inner { extended_p with_shell_p escape_p arglist re_list } {
 
     set expected_len [expr {1 + [llength $re_list]}]
     gdb_test "print argc" \
-	"\\\$$::decimal = $expected_len" "check argc"
+	"${::valnum_re} = $expected_len" "check argc"
 
     set i 1
     foreach arg $re_list {
 	gdb_test "print argv\[$i\]" \
-	    "\\\$$::decimal = $::hex \"$arg\"" \
+	    "${::valnum_re} = $::hex \"$arg\"" \
 	    "check argv\[$i\]"
 	incr i
     }
diff --git a/gdb/testsuite/gdb.server/wrapper.exp b/gdb/testsuite/gdb.server/wrapper.exp
index d577f29f744..9478640c40e 100644
--- a/gdb/testsuite/gdb.server/wrapper.exp
+++ b/gdb/testsuite/gdb.server/wrapper.exp
@@ -57,4 +57,4 @@ gdb_breakpoint marker
 gdb_test "continue" "Breakpoint.* marker .*" "continue to marker"
 # Test env var TEST is correctly passed to the program through
 # --wrapper.
-gdb_test "print d" "\\$${decimal} = ${hex} \"1\".*"
+gdb_test "print d" "${::valnum_re} = ${hex} \"1\".*"
diff --git a/gdb/testsuite/gdb.threads/infcall-thread-announce.exp b/gdb/testsuite/gdb.threads/infcall-thread-announce.exp
index 17f233a099c..311daaca87c 100644
--- a/gdb/testsuite/gdb.threads/infcall-thread-announce.exp
+++ b/gdb/testsuite/gdb.threads/infcall-thread-announce.exp
@@ -36,7 +36,7 @@ proc check_thread_count { adjustment } {
     incr ::thr_count $adjustment
 
     gdb_test "p \$_inferior_thread_count" \
-	"^\\\$$::decimal = $::thr_count"
+	"^${::valnum_re} = $::thr_count"
 }
 
 with_test_prefix "starting threads" {
@@ -47,7 +47,7 @@ with_test_prefix "starting threads" {
 
     foreach_with_prefix call_type { print call } {
 	gdb_test "$call_type start_thread()" \
-	    "\\\[New Thread \[^\r\n\]+\\\]\r\n\\\$$decimal = 1" \
+	    "\\\[New Thread \[^\r\n\]+\\\]\r\n${::valnum_re} = 1" \
 	    "start another new thread"
 	check_thread_count +1
     }
@@ -61,7 +61,7 @@ with_test_prefix "stopping threads" {
 
     foreach_with_prefix call_type { print call } {
 	gdb_test "$call_type stop_thread()" \
-	    "\\\[Thread \[^\r\n\]+ exited\\\]\r\n\\\$$decimal = 1" \
+	    "\\\[Thread \[^\r\n\]+ exited\\\]\r\n${::valnum_re} = 1" \
 	    "stop another thread"
 	check_thread_count -1
     }
diff --git a/gdb/testsuite/gdb.threads/pthreads.exp b/gdb/testsuite/gdb.threads/pthreads.exp
index 9f2d04e2a51..d54e3ecf433 100644
--- a/gdb/testsuite/gdb.threads/pthreads.exp
+++ b/gdb/testsuite/gdb.threads/pthreads.exp
@@ -305,11 +305,11 @@ proc check_qcs {} {
 			 "" \
 			 "Thread $::thread2_id ${any}" \
 			 "#${number}${ws}${any} in thread2 ${any}" \
-			 "\\\$\[0-9]+ = ${number}${any}" \
+			 "${::valnum_re} = ${number}${any}" \
 			 "" \
 			 "Thread $::thread1_id ${any}" \
 			 "#${number}${ws}${any} in thread1 ${any}" \
-			 "\\\$\[0-9]+ = ${number}${any}" \
+			 "${::valnum_re} = ${number}${any}" \
 			] \
 		    "run a failing command except in one frame of thread 2,3, -s to silently continue"
 	    }
@@ -319,16 +319,16 @@ proc check_qcs {} {
     gdb_test "thread apply all -s -q frame apply all -s p i" \
 	[multi_line \
 	     "#${number}${ws}${any} in thread2 ${any}" \
-	     "\\\$\[0-9]+ = ${number}${any}" \
+	     "${::valnum_re} = ${number}${any}" \
 	     "#${number}${ws}${any} in thread1 ${any}" \
-	     "\\\$\[0-9]+ = ${number}${any}" \
+	     "${::valnum_re} = ${number}${any}" \
 	    ] \
 	"run a failing command except in one frame of thread 2,3, -s to silently continue.  Do not show thread information"
 
     gdb_test "thread apply all -s -q frame apply all -s -q p i" \
 	[multi_line \
-	     "\\\$\[0-9]+ = ${number}${any}" \
-	     "\\\$\[0-9]+ = ${number}${any}" \
+	     "${::valnum_re} = ${number}${any}" \
+	     "${::valnum_re} = ${number}${any}" \
 	    ] \
 	"run a failing command except in one frame of thread 2,3, -s to silently continue.  Do not show thread and frame info"
 
diff --git a/gdb/testsuite/gdb.threads/reconnect-signal.exp b/gdb/testsuite/gdb.threads/reconnect-signal.exp
index a33d31103f7..bbd5e651b7f 100644
--- a/gdb/testsuite/gdb.threads/reconnect-signal.exp
+++ b/gdb/testsuite/gdb.threads/reconnect-signal.exp
@@ -46,7 +46,7 @@ gdb_test "info threads" "\\* 2 .*" "thread 2 is selected"
 set msg "save \$pc after signal"
 set saved_pc ""
 gdb_test_multiple "print/x \$pc" $msg {
-    -re "\\\$$decimal = (\[^\r\n\]*)\r\n$gdb_prompt $" {
+    -re "${::valnum_re} = (\[^\r\n\]*)\r\n$gdb_prompt $" {
 	set saved_pc $expect_out(1,string)
 	pass $msg
     }
@@ -74,7 +74,7 @@ if { [lindex $res 0] == 0 } {
 gdb_test "info threads" "\\* 2 .*" "thread 2 is selected on reconnect"
 
 # Check that the program is still alive, and stopped in the same spot.
-gdb_test "print/x \$pc" "\\\$$decimal = $saved_pc" "check \$pc after signal"
+gdb_test "print/x \$pc" "${::valnum_re} = $saved_pc" "check \$pc after signal"
 
 # Check that we didn't lose the signal.
 gdb_test "info program" "stopped with signal SIGUSR1,.*"
diff --git a/gdb/testsuite/gdb.threads/schedlock.exp b/gdb/testsuite/gdb.threads/schedlock.exp
index 7c50aebd545..3f3da91947a 100644
--- a/gdb/testsuite/gdb.threads/schedlock.exp
+++ b/gdb/testsuite/gdb.threads/schedlock.exp
@@ -47,7 +47,7 @@ proc get_args { description } {
 
     set test "listed args, $description"
     gdb_test_multiple "print args" $test {
-	-re "\\\$\[0-9\]+ = {$pattern}.*$gdb_prompt $" {
+	-re "${::valnum_re} = {$pattern}.*$gdb_prompt $" {
 	    pass $test
 
 	    set result ""
diff --git a/gdb/testsuite/gdb.threads/thread-bp-deleted.exp b/gdb/testsuite/gdb.threads/thread-bp-deleted.exp
index e3a5b3df7d4..037e8288b62 100644
--- a/gdb/testsuite/gdb.threads/thread-bp-deleted.exp
+++ b/gdb/testsuite/gdb.threads/thread-bp-deleted.exp
@@ -190,7 +190,7 @@ gdb_test_lines "maint info breakpoints" "" ".*" \
 # Set the do_spin variable in the inferior.  This will cause it to drop out
 # of its spin loop and hit the next breakpoint.  Remember, at this point the
 # inferior is still executing.
-gdb_test "print do_spin = 0" "\\\$$decimal = 0"
+gdb_test "print do_spin = 0" "${::valnum_re} = 0"
 
 # Collect the notification that the inferior has stopped.
 gdb_test_multiple "" "wait for stop" {
diff --git a/gdb/testsuite/gdb.threads/threadapply.exp b/gdb/testsuite/gdb.threads/threadapply.exp
index a2fde0b0305..73b61056a19 100644
--- a/gdb/testsuite/gdb.threads/threadapply.exp
+++ b/gdb/testsuite/gdb.threads/threadapply.exp
@@ -55,13 +55,13 @@ gdb_test_multiple "define backthread" "defining macro" {
 # verify that the macro can get past the backtrace error and perform
 # subsequent commands.
 gdb_test_no_output "set backtrace limit 3"
-gdb_test "thread apply all backthread" "Thread ..*\\\$\[0-9]+ = 0x14.*Thread ..*\\\$\[0-9]+ = 0x14.*Thread ..*\\\$\[0-9]+ = 0x14.*Thread ..*\\\$\[0-9]+ = 0x14.*Thread ..*\\\$\[0-9]+ = 0x14.*Thread ..*\\\$\[0-9]+ = 0x14"
+gdb_test "thread apply all backthread" "Thread ..*${::valnum_re} = 0x14.*Thread ..*${::valnum_re} = 0x14.*Thread ..*${::valnum_re} = 0x14.*Thread ..*${::valnum_re} = 0x14.*Thread ..*${::valnum_re} = 0x14.*Thread ..*${::valnum_re} = 0x14"
 
 # Go into the thread_function to check that a simple "thread apply"
 # does not change the selected frame.
 gdb_test "step" "thread_function.*" "step to the thread_function"
 gdb_test "up" ".*in main.*" "go up in the stack frame"
-gdb_test "thread apply all print 1"  "Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1" "run a simple print command on all threads"
+gdb_test "thread apply all print 1"  "Thread ..*${::valnum_re} = 1.*Thread ..*${::valnum_re} = 1.*Thread ..*${::valnum_re} = 1.*Thread ..*${::valnum_re} = 1.*Thread ..*${::valnum_re} = 1.*Thread ..*${::valnum_re} = 1" "run a simple print command on all threads"
 gdb_test "down" "#0.*thread_function.*" "go down and check selected frame"
 
 # Make sure that GDB doesn't crash when the previously selected thread
diff --git a/gdb/testsuite/gdb.threads/tls-core.exp b/gdb/testsuite/gdb.threads/tls-core.exp
index 95aba7b3b17..e59f22b2454 100644
--- a/gdb/testsuite/gdb.threads/tls-core.exp
+++ b/gdb/testsuite/gdb.threads/tls-core.exp
@@ -60,7 +60,7 @@ proc tls_core_test {supported corefile} {
 	if {![string match $host_triplet $target_triplet]} {
 	    setup_kfail "threads/22381" "*-*-*"
 	}
-	gdb_test "p/x foo" "\\$\[0-9]+ = 0xdeadbeef" $test
+	gdb_test "p/x foo" "${::valnum_re} = 0xdeadbeef" $test
     } else {
 	unsupported $test
     }
diff --git a/gdb/testsuite/gdb.trace/collection.exp b/gdb/testsuite/gdb.trace/collection.exp
index 0b2c8cfe617..2ddfd210f0f 100644
--- a/gdb/testsuite/gdb.trace/collection.exp
+++ b/gdb/testsuite/gdb.trace/collection.exp
@@ -43,10 +43,10 @@ proc test_register { reg test_id } {
     global gdb_prompt
 
     gdb_test_multiple "print /x $reg" "" {
-	-re "\\$\[0-9\]+ = \[x0\]+\r\n$gdb_prompt $" {
+	-re "${::valnum_re} = \[x0\]+\r\n$gdb_prompt $" {
 	    fail "collect $test_id: collected $reg (zero)"
 	}
-	-re "\\$\[0-9\]+ = \[x0-9a-fA-F\]+\r\n$gdb_prompt $" {
+	-re "${::valnum_re} = \[x0-9a-fA-F\]+\r\n$gdb_prompt $" {
 	    pass "collect $test_id: collected $reg"
 	}
 	-re "\[Ee\]rror.*$gdb_prompt $" {
@@ -129,30 +129,30 @@ proc gdb_collect_args_test { myargs msg } {
 	}
 
 	gdb_test "print argc" \
-	    "\\$\[0-9\]+ = 1 '.001'" \
+	    "${::valnum_re} = 1 '.001'" \
 	    "collected arg char"
 	gdb_test "print argi" \
-	    "\\$\[0-9\]+ = 2" \
+	    "${::valnum_re} = 2" \
 	    "collected arg int"
 	gdb_test "print argf" \
-	    "\\$\[0-9\]+ = 3.\[23\]\[0-9\]*" \
+	    "${::valnum_re} = 3.\[23\]\[0-9\]*" \
 	    "collected arg float"
 	gdb_test "print argd" \
-	    "\\$\[0-9\]+ = 4.\[34\]\[0-9\]*" \
+	    "${::valnum_re} = 4.\[34\]\[0-9\]*" \
 	    "collected arg double"
 
 	# struct arg as one of several args (near end of list)
 	gdb_test "print argstruct.memberc" \
-	    "\\$\[0-9\]+ = 101 'e'" \
+	    "${::valnum_re} = 101 'e'" \
 	    "collected arg struct member char"
 	gdb_test "print argstruct.memberi" \
-	    "\\$\[0-9\]+ = 102" \
+	    "${::valnum_re} = 102" \
 	    "collected arg struct member int"
 	gdb_test "print argstruct.memberf" \
-	    "\\$\[0-9\]+ = 103.\[23\]\[0-9\]*" \
+	    "${::valnum_re} = 103.\[23\]\[0-9\]*" \
 	    "collected arg struct member float"
 	gdb_test "print argstruct.memberd" \
-	    "\\$\[0-9\]+ = 104.\[34\]\[0-9\]*" \
+	    "${::valnum_re} = 104.\[34\]\[0-9\]*" \
 	    "collected arg struct member double"
 
 	# array arg as one of several args (near end of list)
@@ -166,22 +166,22 @@ proc gdb_collect_args_test { myargs msg } {
 
 	setup_xfail "*-*-*"
 	gdb_test "print argarray\[0\]" \
-	    "\\$\[0-9\]+ = 111" \
+	    "${::valnum_re} = 111" \
 	    "collected argarray #0"
 
 	setup_xfail "*-*-*"
 	gdb_test "print argarray\[1\]" \
-	    "\\$\[0-9\]+ = 112" \
+	    "${::valnum_re} = 112" \
 	    "collected argarray #1"
 
 	setup_xfail "*-*-*"
 	gdb_test "print argarray\[2\]" \
-	    "\\$\[0-9\]+ = 113" \
+	    "${::valnum_re} = 113" \
 	    "collected argarray #2"
 
 	setup_xfail "*-*-*"
 	gdb_test "print argarray\[3\]" \
-	    "\\$\[0-9\]+ = 114" \
+	    "${::valnum_re} = 114" \
 	    "collected argarray #3"
 
 	gdb_test "tfind none" \
@@ -208,16 +208,16 @@ proc gdb_collect_argstruct_test { myargs msg } {
 
 	# struct argument as only argument
 	gdb_test "print argstruct.memberc" \
-	    "\\$\[0-9\]+ = 101 'e'" \
+	    "${::valnum_re} = 101 'e'" \
 	    "collected arg struct member char"
 	gdb_test "print argstruct.memberi" \
-	    "\\$\[0-9\]+ = 102" \
+	    "${::valnum_re} = 102" \
 	    "collected arg struct member int"
 	gdb_test "print argstruct.memberf" \
-	    "\\$\[0-9\]+ = 103.\[23\]\[0-9\]*" \
+	    "${::valnum_re} = 103.\[23\]\[0-9\]*" \
 	    "collected arg struct member float"
 	gdb_test "print argstruct.memberd" \
-	    "\\$\[0-9\]+ = 104.\[34\]\[0-9\]*" \
+	    "${::valnum_re} = 104.\[34\]\[0-9\]*" \
 	    "collected arg struct member double"
 
 	gdb_test "tfind none" \
@@ -255,22 +255,22 @@ proc gdb_collect_argarray_test { myargs msg } {
 
 	setup_xfail "*-*-*"
 	gdb_test "print argarray\[0\]" \
-	    "\\$\[0-9\]+ = 111" \
+	    "${::valnum_re} = 111" \
 	    "collected argarray #0"
 
 	setup_xfail "*-*-*"
 	gdb_test "print argarray\[1\]" \
-	    "\\$\[0-9\]+ = 112" \
+	    "${::valnum_re} = 112" \
 	    "collected argarray #1"
 
 	setup_xfail "*-*-*"
 	gdb_test "print argarray\[2\]" \
-	    "\\$\[0-9\]+ = 113" \
+	    "${::valnum_re} = 113" \
 	    "collected argarray #2"
 
 	setup_xfail "*-*-*"
 	gdb_test "print argarray\[3\]" \
-	    "\\$\[0-9\]+ = 114" \
+	    "${::valnum_re} = 114" \
 	    "collected argarray #3"
 
 	gdb_test "tfind none" \
@@ -314,42 +314,42 @@ proc gdb_collect_locals_test { func mylocs msg } {
 	run_trace_experiment $func
 
 	gdb_test "print locc" \
-	    "\\$\[0-9\]+ = 11 '.\[a-z0-7\]+'" \
+	    "${::valnum_re} = 11 '.\[a-z0-7\]+'" \
 	    "collected local char"
 	gdb_test "print loci" \
-	    "\\$\[0-9\]+ = 12" \
+	    "${::valnum_re} = 12" \
 	    "collected local int"
 	gdb_test "print locf" \
-	    "\\$\[0-9\]+ = 13.\[23\]\[0-9\]*" \
+	    "${::valnum_re} = 13.\[23\]\[0-9\]*" \
 	    "collected local float"
 	gdb_test "print locd" \
-	    "\\$\[0-9\]+ = 14.\[34\]\[0-9\]*" \
+	    "${::valnum_re} = 14.\[34\]\[0-9\]*" \
 	    "collected local double"
 
 	gdb_test "print locst.memberc" \
-	    "\\$\[0-9\]+ = 15 '.017'" \
+	    "${::valnum_re} = 15 '.017'" \
 	    "collected local member char"
 	gdb_test "print locst.memberi" \
-	    "\\$\[0-9\]+ = 16" \
+	    "${::valnum_re} = 16" \
 	    "collected local member int"
 	gdb_test "print locst.memberf" \
-	    "\\$\[0-9\]+ = 17.\[67\]\[0-9\]*" \
+	    "${::valnum_re} = 17.\[67\]\[0-9\]*" \
 	    "collected local member float"
 	gdb_test "print locst.memberd" \
-	    "\\$\[0-9\]+ = 18.\[78\]\[0-9\]*" \
+	    "${::valnum_re} = 18.\[78\]\[0-9\]*" \
 	    "collected local member double"
 
 	gdb_test "print locar\[0\]" \
-	    "\\$\[0-9\]+ = 121" \
+	    "${::valnum_re} = 121" \
 	    "collected locarray #0"
 	gdb_test "print locar\[1\]" \
-	    "\\$\[0-9\]+ = 122" \
+	    "${::valnum_re} = 122" \
 	    "collected locarray #1"
 	gdb_test "print locar\[2\]" \
-	    "\\$\[0-9\]+ = 123" \
+	    "${::valnum_re} = 123" \
 	    "collected locarray #2"
 	gdb_test "print locar\[3\]" \
-	    "\\$\[0-9\]+ = 124" \
+	    "${::valnum_re} = 124" \
 	    "collected locarray #3"
 
 	gdb_test "tfind none" \
@@ -422,7 +422,7 @@ proc gdb_collect_expression_test { func expr val msg } {
 	run_trace_experiment $func
 
 	gdb_test "print $expr" \
-	    "\\$\[0-9\]+ = $val" \
+	    "${::valnum_re} = $val" \
 	    "got expected value '$val'"
 
 	gdb_test "tfind none" \
@@ -483,49 +483,49 @@ proc gdb_collect_globals_test { } {
 	run_trace_experiment globals_test_func
 
 	gdb_test "print globalc" \
-	    "\\$\[0-9\]+ = 71 'G'" \
+	    "${::valnum_re} = 71 'G'" \
 	    "collected global char"
 	gdb_test "print globali" \
-	    "\\$\[0-9\]+ = 72" \
+	    "${::valnum_re} = 72" \
 	    "collected global int"
 	gdb_test "print globalf" \
-	    "\\$\[0-9\]+ = 73.\[23\]\[0-9\]*" \
+	    "${::valnum_re} = 73.\[23\]\[0-9\]*" \
 	    "collected global float"
 	gdb_test "print globald" \
-	    "\\$\[0-9\]+ = 74.\[34\]\[0-9\]*" \
+	    "${::valnum_re} = 74.\[34\]\[0-9\]*" \
 	    "collected global double"
 
 	gdb_test "print globalstruct.memberc" \
-	    "\\$\[0-9\]+ = 81 'Q'" \
+	    "${::valnum_re} = 81 'Q'" \
 	    "collected struct char member"
 	gdb_test "print globalstruct.memberi" \
-	    "\\$\[0-9\]+ = 82" \
+	    "${::valnum_re} = 82" \
 	    "collected struct member int"
 	gdb_test "print globalstruct.memberf" \
-	    "\\$\[0-9\]+ = 83.\[23\]\[0-9\]*" \
+	    "${::valnum_re} = 83.\[23\]\[0-9\]*" \
 	    "collected struct member float"
 	gdb_test "print globalstruct.memberd" \
-	    "\\$\[0-9\]+ = 84.\[34\]\[0-9\]*" \
+	    "${::valnum_re} = 84.\[34\]\[0-9\]*" \
 	    "collected struct member double"
 
 	gdb_test "print globalp == &globalstruct" \
-	    "\\$\[0-9\]+ = 1" \
+	    "${::valnum_re} = 1" \
 	    "collected global pointer"
 
 	gdb_test "print globalarr\[1\]" \
-	    "\\$\[0-9\]+ = 1" \
+	    "${::valnum_re} = 1" \
 	    "collected global array element #1"
 	gdb_test "print globalarr\[2\]" \
-	    "\\$\[0-9\]+ = 2" \
+	    "${::valnum_re} = 2" \
 	    "collected global array element #2"
 	gdb_test "print globalarr\[3\]" \
-	    "\\$\[0-9\]+ = 3" \
+	    "${::valnum_re} = 3" \
 	    "collected global array element #3"
 
 	# Check that we didn't mess up sort&merging memory ranges to
 	# collect.
 	gdb_test "print globalarr2" \
-	    "\\$\[0-9\]+ = \\{0, 1, 2, 3\\}" \
+	    "${::valnum_re} = \\{0, 1, 2, 3\\}" \
 	    "collected global array 2"
 
 	# GDB would internal error collecting UNOP_MEMVAL's whose address
@@ -533,7 +533,7 @@ proc gdb_collect_globals_test { } {
 	# corresponding 'collect' action above).  This just double checks
 	# we actually did collect what we wanted.
 	gdb_test "print globalarr3" \
-	    "\\$\[0-9\]+ = \\{3, 2, 1, 0\\}" \
+	    "${::valnum_re} = \\{3, 2, 1, 0\\}" \
 	    "collect globals: collected global array 3"
 
 	gdb_test "tfind none" \
@@ -656,7 +656,7 @@ proc gdb_collect_strings_test { func mystr myrslt mylim msg } {
 	run_trace_experiment $func
 
 	gdb_test "print $mystr" \
-	    "\\$\[0-9\]+ = $hex \"$myrslt\".*" \
+	    "${::valnum_re} = $hex \"$myrslt\".*" \
 	    "collected local string"
 
 	gdb_test "tfind none" \
diff --git a/gdb/testsuite/gdb.trace/disconnected-tracing.exp b/gdb/testsuite/gdb.trace/disconnected-tracing.exp
index 87d64e8f9f0..2b34c0a2378 100644
--- a/gdb/testsuite/gdb.trace/disconnected-tracing.exp
+++ b/gdb/testsuite/gdb.trace/disconnected-tracing.exp
@@ -127,18 +127,18 @@ proc disconnected_tfind {  } {
 	gdb_test_no_output "tstop"
 
 	gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
-	gdb_test "p \$trace_frame" ".*\\\$${decimal} = 0.*" \
+	gdb_test "p \$trace_frame" ".*${::valnum_re} = 0.*" \
 	    "p \$trace_frame before disconnected"
-	gdb_test "p \$tracepoint" ".*\\\$${decimal} = 2.*" \
+	gdb_test "p \$tracepoint" ".*${::valnum_re} = 2.*" \
 	    "p \$tracepoint before disconnected"
 
 	gdb_test "disconnect" "Ending remote debugging\\." "first disconnect"
 
-	gdb_test "p \$trace_frame" ".*\\\$${decimal} = -1.*"
-	gdb_test "p \$tracepoint" ".*\\\$${decimal} = -1.*"
-	gdb_test "p \$trace_line" ".*\\\$${decimal} = -1.*"
-	gdb_test "p \$trace_file" ".*\\\$${decimal} = void.*"
-	gdb_test "p \$trace_func" ".*\\\$${decimal} = void.*"
+	gdb_test "p \$trace_frame" ".*${::valnum_re} = -1.*"
+	gdb_test "p \$tracepoint" ".*${::valnum_re} = -1.*"
+	gdb_test "p \$trace_line" ".*${::valnum_re} = -1.*"
+	gdb_test "p \$trace_file" ".*${::valnum_re} = void.*"
+	gdb_test "p \$trace_func" ".*${::valnum_re} = void.*"
     }
 }
 
diff --git a/gdb/testsuite/gdb.trace/report.exp b/gdb/testsuite/gdb.trace/report.exp
index 55416d71376..57aac880333 100644
--- a/gdb/testsuite/gdb.trace/report.exp
+++ b/gdb/testsuite/gdb.trace/report.exp
@@ -265,10 +265,10 @@ proc use_collected_data { data_source } {
 	    "11.3: test \$trace_line"
 
 	gdb_test_multiple "print \$trace_file" "11.4: test \$trace_file" {
-	    -re "\\$\[0-9\]+ = \"$srcfile\"\[\r\n\]+$gdb_prompt $" {
+	    -re "${::valnum_re} = \"$srcfile\"\[\r\n\]+$gdb_prompt $" {
 		pass "11.4: test \$trace_file"
 	    }
-	    -re "\\$\[0-9\]+ = \"$srcdir/$subdir/$srcfile\"\[\r\n\]+$gdb_prompt $" {
+	    -re "${::valnum_re} = \"$srcdir/$subdir/$srcfile\"\[\r\n\]+$gdb_prompt $" {
 		pass "11.4: test \$trace_file"
 	    }
 	}
diff --git a/gdb/testsuite/gdb.trace/stap-trace.exp b/gdb/testsuite/gdb.trace/stap-trace.exp
index cfdfbe15ee5..3742c4d25f3 100644
--- a/gdb/testsuite/gdb.trace/stap-trace.exp
+++ b/gdb/testsuite/gdb.trace/stap-trace.exp
@@ -95,7 +95,7 @@ proc gdb_collect_probe_arg { msg probe val_arg0 } {
     run_trace_experiment $msg $probe
 
     gdb_test "print \$_probe_arg0" \
-	    "\\$\[0-9\]+ = $val_arg0" \
+	    "${::valnum_re} = $val_arg0" \
 	    "collect $msg: collected probe arg0"
 }
 
diff --git a/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp b/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp
index 4f8449c7d96..39b71b35877 100644
--- a/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp
+++ b/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp
@@ -312,9 +312,9 @@ with_test_prefix "tracing foo" {
     gdb_test_no_output "tstop"
 
     gdb_test "tfind 0" "Found trace frame 0, tracepoint .*"
-    gdb_test "p/d x" "\\\$${decimal} = {a = 0, b = 0, c = <unavailable>}"
-    gdb_test "p/d y" "\\\$${decimal} = {a = 0, b = <unavailable>, c = 0}"
-    gdb_test "p/d z" "\\\$${decimal} = {a = <unavailable>, b = 0, c = 0}"
+    gdb_test "p/d x" "${::valnum_re} = {a = 0, b = 0, c = <unavailable>}"
+    gdb_test "p/d y" "${::valnum_re} = {a = 0, b = <unavailable>, c = 0}"
+    gdb_test "p/d z" "${::valnum_re} = {a = <unavailable>, b = 0, c = 0}"
 
     gdb_test "tfind none" "No longer looking at any trace frame.*"
 }
@@ -329,13 +329,13 @@ with_test_prefix "tracing bar" {
 
     gdb_test "tfind 0" "Found trace frame 0, tracepoint .*"
     if { $endian == "little" } {
-	gdb_test "p/d x" "\\\$${decimal} = {a = 0, b = <unavailable>, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0}"
-	gdb_test "p/d y" "\\\$${decimal} = {a = 0, b = 0, c = 0, d = 0, e = <unavailable>, f = 0, g = 0, h = 0, i = 0, j = 0}"
-	gdb_test "p/d z" "\\\$${decimal} = {a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = <unavailable>, j = 0}"
+	gdb_test "p/d x" "${::valnum_re} = {a = 0, b = <unavailable>, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0}"
+	gdb_test "p/d y" "${::valnum_re} = {a = 0, b = 0, c = 0, d = 0, e = <unavailable>, f = 0, g = 0, h = 0, i = 0, j = 0}"
+	gdb_test "p/d z" "${::valnum_re} = {a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = <unavailable>, j = 0}"
     } else {
-	gdb_test "p/d x" "\\\$${decimal} = {a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = <unavailable>, j = 0}"
-	gdb_test "p/d y" "\\\$${decimal} = {a = 0, b = 0, c = 0, d = 0, e = 0, f = <unavailable>, g = 0, h = 0, i = 0, j = 0}"
-	gdb_test "p/d z" "\\\$${decimal} = {a = 0, b = <unavailable>, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0}"
+	gdb_test "p/d x" "${::valnum_re} = {a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = <unavailable>, j = 0}"
+	gdb_test "p/d y" "${::valnum_re} = {a = 0, b = 0, c = 0, d = 0, e = 0, f = <unavailable>, g = 0, h = 0, i = 0, j = 0}"
+	gdb_test "p/d z" "${::valnum_re} = {a = 0, b = <unavailable>, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0}"
     }
 
     gdb_test "tfind none" "No longer looking at any trace frame.*"
diff --git a/gdb/testsuite/gdb.trace/unavailable.exp b/gdb/testsuite/gdb.trace/unavailable.exp
index 8e00334af85..5d4309f3750 100644
--- a/gdb/testsuite/gdb.trace/unavailable.exp
+++ b/gdb/testsuite/gdb.trace/unavailable.exp
@@ -34,10 +34,10 @@ proc test_register { reg } {
     global hex
 
     gdb_test_multiple "print /x $reg" "collected $reg" {
-	-re "\\$\[0-9\]+ = \[x0\]+\r\n$gdb_prompt $" {
+	-re "${::valnum_re} = \[x0\]+\r\n$gdb_prompt $" {
 	    fail "collected $reg (zero)"
 	}
-	-re "\\$\[0-9\]+ = $hex\r\n$gdb_prompt $" {
+	-re "${::valnum_re} = $hex\r\n$gdb_prompt $" {
 	    pass "collected $reg"
 	}
 	-re "\[Ee\]rror.*$gdb_prompt $" {
@@ -514,7 +514,7 @@ proc gdb_collect_globals_test_1 { } {
 	"global reference shows address but not value"
 
     gdb_test "print *&g_ref" \
-	"\\$\[0-9\]+ = <unavailable>" \
+	"${::valnum_re} = <unavailable>" \
 	"referenced integer was not collected (taking address of reference)"
 
     gdb_test "print *g_structref_p" " = <unavailable>"
@@ -536,7 +536,7 @@ proc gdb_collect_globals_test_1 { } {
 
     # Incomplete strings print as an array.
     gdb_test "print g_string_partial" \
-	"\\$\[0-9\]+ = \{<unavailable>, 101 'e', 108 'l', <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>\}" \
+	"${::valnum_re} = \{<unavailable>, 101 'e', 108 'l', <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>, <unavailable>\}" \
 	"printing partially collected string"
 
     # It is important for this test that the last examined value is
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index acef1ad6310..f6bdfcdb60c 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3503,7 +3503,7 @@ proc with_gdb_cwd { dir body } {
 	    exp_continue
 	}
 
-	-re "^\\\$$::decimal = 123\r\n" {
+	-re "^${::valnum_re} = 123\r\n" {
 	    set saw_result true
 	    exp_continue
 	}
@@ -9536,7 +9536,7 @@ proc get_var_address { var } {
     # $6 = (int (*)()) 0x24 <function_bar>
 
     gdb_test_multiple "print &${var}" "get address of ${var}" {
-	-re "\\\$\[0-9\]+ = \\(.*\\) (0|$hex)( <${var}>)?\[\r\n\]+${gdb_prompt} $"
+	-re "${::valnum_re} = \\(.*\\) (0|$hex)( <${var}>)?\[\r\n\]+${gdb_prompt} $"
 	{
 	    pass "get address of ${var}"
 	    if { $expect_out(1,string) == "0" } {
-- 
2.51.0


  parent reply	other threads:[~2026-01-28 12:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-28 12:06 [PATCH 0/5] [gdb/testsuite] Use valnum_re more often Tom de Vries
2026-01-28 12:06 ` [PATCH 1/5] [gdb/testsuite] Remove superfluous definition of valnum_re in gdb.base/commands.exp Tom de Vries
2026-01-28 12:06 ` Tom de Vries [this message]
2026-01-28 12:06 ` [PATCH 3/5] [gdb/testsuite] Use valnum_re more often (part 2) Tom de Vries
2026-01-28 12:06 ` [PATCH 4/5] [gdb/testsuite] Use valnum_re more often (part 3) Tom de Vries
2026-01-28 12:06 ` [PATCH 5/5] [gdb/testsuite] Use valnum_re more often (part 4) Tom de Vries
2026-02-02 17:05 ` [PATCH 0/5] [gdb/testsuite] Use valnum_re more often Kevin Buettner
2026-02-03 11:14 ` Tom de Vries

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260128120626.1032047-3-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox