From: Tom de Vries Date: Wed, 22 Oct 2025 15:32:57 +0000 (+0200) Subject: [gdb/testsuite] Simplify gdb.cp/local-static.exp X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46eeb5132aed207cd4c822df15106b72c740b94d;p=thirdparty%2Fbinutils-gdb.git [gdb/testsuite] Simplify gdb.cp/local-static.exp Simplify test-case gdb.cp/local-static.exp in the following way. First rewrite this uplevel into a more usual form: ... -set print_quoted_re [uplevel 1 "subst_vars \"$print_quoted_re\""] +set print_quoted_re [uplevel 1 [list subst -nocommands $print_quoted_re]] ... This requires us to use "subst -nocommands" instead of subst_vars, to allow backslash substitution, which previously was happening implicitly because of the way uplevel was used. Then, declare globals hex and syntax_re, such that we no longer have to use uplevel: ... -set print_quoted_re [uplevel 1 [list subst -nocommands $print_quoted_re]] +set print_quoted_re [subst -nocommands $print_quoted_re] ... Finally, stop applying backslash substitution, simplifying cxx_scopes_list and c_scopes_list: ... -set print_quoted_re [subst -nocommands $print_quoted_re] +set print_quoted_re [subst_vars $print_quoted_re] ... While we're at it, simplify some regexps using string_to_regexp in a few places. Tested on x86_64-linux. Approved-By: Tom Tromey --- diff --git a/gdb/testsuite/gdb.cp/local-static.exp b/gdb/testsuite/gdb.cp/local-static.exp index 183dc8a4db6..abcf8bbe960 100644 --- a/gdb/testsuite/gdb.cp/local-static.exp +++ b/gdb/testsuite/gdb.cp/local-static.exp @@ -47,70 +47,70 @@ proc cannot_resolve {meth} { #SCOPE #PREFIX #PRINT-SCOPE-QUOTED #PRINT-SCOPE-UNQUOTED (opt) set cxx_scopes_list { - {"S::method()" "S_M" {= \\{void \\(S \\* const\\)\\} $hex } + {"S::method()" "S_M" {= \{void \(S \* const\)\} $hex } {[cannot_resolve "S::method"]}} - {"S::method() const" "S_M_C" {= \\{void \\(const S \\* const\\)\\} $hex } + {"S::method() const" "S_M_C" {= \{void \(const S \* const\)\} $hex } $syntax_re} - {"S::method() volatile" "S_M_V" {= \\{void \\(volatile S \\* const\\)\\} $hex } + {"S::method() volatile" "S_M_V" {= \{void \(volatile S \* const\)\} $hex } $syntax_re} - {"S::method() const volatile" "S_M_CV" {= \\{void \\(const volatile S \\* const\\)\\} $hex } + {"S::method() const volatile" "S_M_CV" {= \{void \(const volatile S \* const\)\} $hex } $syntax_re} - {"S::method() volatile const" "S_M_CV" {= \\{void \\(const volatile S \\* const\\)\\} $hex } + {"S::method() volatile const" "S_M_CV" {= \{void \(const volatile S \* const\)\} $hex } $syntax_re} - {"S::method(void)" "S_M" {= \\{void \\(S \\* const\\)\\} $hex }} - {"S::method(void) const" "S_M_C" {= \\{void \\(const S \\* const\\)\\} $hex }} - {"S::method(void) volatile" "S_M_V" {= \\{void \\(volatile S \\* const\\)\\} $hex }} - {"S::method(void) const volatile" "S_M_CV" {= \\{void \\(const volatile S \\* const\\)\\} $hex }} - {"S::method(void) volatile const" "S_M_CV" {= \\{void \\(const volatile S \\* const\\)\\} $hex }} + {"S::method(void)" "S_M" {= \{void \(S \* const\)\} $hex }} + {"S::method(void) const" "S_M_C" {= \{void \(const S \* const\)\} $hex }} + {"S::method(void) volatile" "S_M_V" {= \{void \(volatile S \* const\)\} $hex }} + {"S::method(void) const volatile" "S_M_CV" {= \{void \(const volatile S \* const\)\} $hex }} + {"S::method(void) volatile const" "S_M_CV" {= \{void \(const volatile S \* const\)\} $hex }} - {"S::static_method()" "S_SM" {= \\{void \\(void\\)\\} $hex } + {"S::static_method()" "S_SM" {= \{void \(void\)\} $hex } "void"} - {"S::static_method(void)" "S_SM" {= \\{void \\(void\\)\\} $hex }} + {"S::static_method(void)" "S_SM" {= \{void \(void\)\} $hex }} - {"S::inline_method()" "S_IM" {= \\{void \\(S \\* const\\)\\} $hex } + {"S::inline_method()" "S_IM" {= \{void \(S \* const\)\} $hex } {[cannot_resolve "S::inline_method"]}} - {"S::inline_method(void)" "S_IM" {= \\{void \\(S \\* const\\)\\} $hex }} + {"S::inline_method(void)" "S_IM" {= \{void \(S \* const\)\} $hex }} - {"S::static_inline_method()" "S_SIM" {= \\{void \\(void\\)\\} $hex } + {"S::static_inline_method()" "S_SIM" {= \{void \(void\)\} $hex } "void"} - {"S::static_inline_method(void)" "S_SIM" {= \\{void \\(void\\)\\} $hex }} + {"S::static_inline_method(void)" "S_SIM" {= \{void \(void\)\} $hex }} - {"S2::method()" "S2_M" {= \\{void \\(S2 \\* const\\)\\} $hex ::method\\(\\)>} + {"S2::method()" "S2_M" {= \{void \(S2 \* const\)\} $hex ::method\(\)>} {[cannot_resolve "S2::method"]}} - {"S2::static_method()" "S2_SM" {= \\{void \\(void\\)\\} $hex ::static_method\\(\\)>} + {"S2::static_method()" "S2_SM" {= \{void \(void\)\} $hex ::static_method\(\)>} "void"} - {"S2::inline_method()" "S2_IM" {= \\{void \\(S2 \\* const\\)\\} $hex ::inline_method\\(\\)>} + {"S2::inline_method()" "S2_IM" {= \{void \(S2 \* const\)\} $hex ::inline_method\(\)>} {[cannot_resolve "S2::inline_method"]}} - {"S2::static_inline_method()" "S2_SIM" {= \\{void \\(void\\)\\} $hex ::static_inline_method\\(\\)>} + {"S2::static_inline_method()" "S2_SIM" {= \{void \(void\)\} $hex ::static_inline_method\(\)>} "void"} - {"free_func" "FF" {= \\{void \\(void\\)\\} $hex }} + {"free_func" "FF" {= \{void \(void\)\} $hex }} - {"free_func()" "FF" {= \\{void \\(void\\)\\} $hex } + {"free_func()" "FF" {= \{void \(void\)\} $hex } "void"} - {"free_func(void)" "FF" {= \\{void \\(void\\)\\} $hex }} + {"free_func(void)" "FF" {= \{void \(void\)\} $hex }} - {"free_inline_func()" "FIF" {= \\{void \\(void\\)\\} $hex } + {"free_inline_func()" "FIF" {= \{void \(void\)\} $hex } "void"} - {"free_inline_func(void)" "FIF" {= \\{void \\(void\\)\\} $hex }} + {"free_inline_func(void)" "FIF" {= \{void \(void\)\} $hex }} } set c_scopes_list { - {"free_func" "FF" {= \\{void \\(void\\)\\} $hex }} - {"free_inline_func" "FIF" {= \\{void \\(void\\)\\} $hex }} + {"free_func" "FF" {= \{void \(void\)\} $hex }} + {"free_inline_func" "FIF" {= \{void \(void\)\} $hex }} } # A list of all the static varibles defined in each scope. The first @@ -131,6 +131,8 @@ proc do_test {lang} { global vars_list global srcfile testfile global gdb_prompt + global hex + global syntax_re set options {debug} @@ -153,7 +155,7 @@ proc do_test {lang} { return } - gdb_test "show language" " currently [string_to_regexp $lang]\"\\." + gdb_test "show language" [string_to_regexp [subst_vars {currently $lang".}]] if {$lang == "c"} { set scopes_list $c_scopes_list @@ -170,10 +172,10 @@ proc do_test {lang} { set scope [lindex $scope_line 0] set print_quoted_re [lindex $scope_line 2] - set print_quoted_re [uplevel 1 "subst_vars \"$print_quoted_re\""] + set print_quoted_re [subst_vars $print_quoted_re] set print_unquoted_re [lindex $scope_line 3] - set print_unquoted_re [uplevel 1 "subst_vars \"$print_unquoted_re\""] + set print_unquoted_re [subst_vars $print_unquoted_re] gdb_test "print '${scope}'" $print_quoted_re @@ -241,7 +243,8 @@ proc do_test {lang} { } } } else { - gdb_test "print '${sym}'" "No symbol \"$sym\" in current context\\." + gdb_test "print '${sym}'" \ + [string_to_regexp [subst_vars {No symbol "$sym" in current context.}]] } } }