diff --git a/gdb/testsuite/gdb.base/settings.exp b/gdb/testsuite/gdb.base/settings.exp
index 102e0c57a43..b597bd6c0ad 100644
--- a/gdb/testsuite/gdb.base/settings.exp
+++ b/gdb/testsuite/gdb.base/settings.exp
@@ -52,49 +52,53 @@ if { ![readline_is_used] } {
 # EXPECTED_RE is made part of the test name.
 proc show_setting {show_cmd expected_re {expected_re_quoted 0} {reset_value 0}} {
     global gdb_prompt
-    gdb_test "$show_cmd" $expected_re "$show_cmd: $expected_re"
 
-    # Remove the first two words (such as "maint show") to have the
-    # setting name to use for $_gdb_maint_setting_str.
-    regsub "\[^ \]+ +\[^ \]+ +\(.*\)" $show_cmd "\\1" maint_setting
-    if {$expected_re_quoted == 1} {
-	set quoted_expected_re $expected_re
-    } else {
-	regsub -all "\"" $expected_re "\\\\\\\"" quoted_expected_re
-    }
-    set test "print \$_gdb_maint_setting_str(\"$maint_setting\") $quoted_expected_re $expected_re"
-    gdb_test_multiple "print \$_gdb_maint_setting_str(\"$maint_setting\")" $test {
-	-re ".*= \"\($quoted_expected_re\)\".*$gdb_prompt $" {
-	    set setting_str_value $expect_out(1,string)
-	    regsub -all "\\\\" $expect_out(1,string) "" setting_str_value
-	    pass "$test value $setting_str_value" 
-	}
-    }
+    with_test_prefix "$show_cmd $expected_re" {
+	gdb_test "$show_cmd" $expected_re "show"
 
-    # Change the setting value to RESET_VALUE, set it back to setting_str_value
-    # and check we still have the original value.
-    gdb_test_no_output "maintenance set $maint_setting $reset_value" "str reset $show_cmd: $expected_re"
-    gdb_test_no_output "maintenance set $maint_setting $setting_str_value" "str set again $show_cmd: $expected_re"
-    gdb_test "$show_cmd" $expected_re "str $show_cmd: $expected_re after reset+set again"
-
-    # Same test, but with value captured from $_gdb_maint_setting.
-    set test "print \$_gdb_maint_setting(\"$maint_setting\") $quoted_expected_re $expected_re"
-    gdb_test_multiple "print \$_gdb_maint_setting(\"$maint_setting\")" $test {
-	-re ".*= \"\(.*\)\".*$gdb_prompt $" {
-	    set setting_value $expect_out(1,string)
-	    regsub -all "\\\\" $expect_out(1,string) "" setting_value
-	    pass "$test quoted value $setting_value" 
+	# Remove the first two words (such as "maint show") to have the
+	# setting name to use for $_gdb_maint_setting_str.
+	regsub "\[^ \]+ +\[^ \]+ +\(.*\)" $show_cmd "\\1" maint_setting
+	if {$expected_re_quoted == 1} {
+	    set quoted_expected_re $expected_re
+	} else {
+	    regsub -all "\"" $expected_re "\\\\\\\"" quoted_expected_re
 	}
-	-re ".*= \(.*\)\r\n$gdb_prompt $" {
-	    set setting_value $expect_out(1,string)
-	    pass "$test non quoted value $setting_value" 
+	set test "print \$_gdb_maint_setting_str"
+	set setting_str_value "xxxYYYxxx"
+	gdb_test_multiple "print \$_gdb_maint_setting_str(\"$maint_setting\")" $test {
+	    -re " = \"\($quoted_expected_re\)\".*$gdb_prompt $" {
+		set setting_str_value $expect_out(1,string)
+		regsub -all "\\\\" $expect_out(1,string) "" setting_str_value
+		pass $test
+	    }
 	}
-    }
 
-    gdb_test_no_output "maintenance set $maint_setting $reset_value" "reset $show_cmd: $expected_re"
-    gdb_test_no_output "maintenance set $maint_setting $setting_value" "set again $show_cmd: $expected_re"
-    gdb_test "$show_cmd" $expected_re "$show_cmd: $expected_re after reset+set again"
+	# Change the setting value to RESET_VALUE, set it back to setting_str_value
+	# and check we still have the original value.
+	gdb_test_no_output "maintenance set $maint_setting $reset_value" "str reset $reset_value"
+	gdb_test_no_output "maintenance set $maint_setting $setting_str_value" "str set again"
+	gdb_test "$show_cmd" $expected_re "str show after reset+set again"
+
+	# Same test, but with value captured from $_gdb_maint_setting.
+	set test "print \$_gdb_maint_setting"
+	set setting_value "xxxYYYxxx"
+	gdb_test_multiple "print \$_gdb_maint_setting(\"$maint_setting\")" $test {
+	    -re " = \"\(.*\)\".*$gdb_prompt $" {
+		set setting_value $expect_out(1,string)
+		regsub -all "\\\\" $expect_out(1,string) "" setting_value
+		pass $test
+	    }
+	    -re " = \(.*\)\r\n$gdb_prompt $" {
+		set setting_value $expect_out(1,string)
+		pass $test
+	    }
+	}
 
+	gdb_test_no_output "maintenance set $maint_setting $reset_value" "reset $reset_value"
+	gdb_test_no_output "maintenance set $maint_setting $setting_value" "set again"
+	gdb_test "$show_cmd" $expected_re "show after reset+set again"
+    }
 }
 
 
