aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base/internal-string-values.exp
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/gdb.base/internal-string-values.exp')
-rw-r--r--gdb/testsuite/gdb.base/internal-string-values.exp80
1 files changed, 80 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.base/internal-string-values.exp b/gdb/testsuite/gdb.base/internal-string-values.exp
index 0748ab0..3380d9d 100644
--- a/gdb/testsuite/gdb.base/internal-string-values.exp
+++ b/gdb/testsuite/gdb.base/internal-string-values.exp
@@ -118,6 +118,86 @@ proc_with_prefix test_setting { } {
gdb_test_no_output {set $v = $_gdb_setting_str("remotetimeout")}
check_v_string "2"
}
+
+ # Test string values made by $_gdb_setting & co. in all languages.
+ with_test_prefix "all langs" {
+ # Get list of supported languages.
+ set langs {}
+ gdb_test_multiple "complete set language " "" {
+ -re "set language (\[^\r\n\]+)" {
+ lappend langs $expect_out(1,string)
+ exp_continue
+ }
+ -re "$::gdb_prompt $" {
+ pass $gdb_test_name
+ }
+ }
+
+ proc quote {str} {
+ upvar lang lang
+
+ if {$lang == "fortran"} {
+ return "'$str'"
+ } else {
+ return "\"$str\""
+ }
+ }
+
+ gdb_test "maintenance set test-settings string foo"
+ foreach_with_prefix lang $langs {
+ gdb_test_no_output "set language $lang"
+
+ if {$lang == "modula-2"} {
+ gdb_test "print \"foo\"" "strings are not implemented"
+ continue
+ }
+
+ if {$lang == "rust"} {
+ gdb_test "print \"foo\"" \
+ "evaluation of this expression requires the target program to be active"
+
+ # We could get the above working by starting the
+ # program, but how to make the below work?
+ gdb_test "print \$_gdb_maint_setting(\"test-settings string\")" \
+ "',' or '\\)' expected"
+ continue
+ }
+
+ if {$lang == "unknown"} {
+ # Skipped because of PR gdb/28093 -- GDB would crash.
+ continue
+ }
+
+ set print_output ""
+ set ptype_output ""
+
+ set foo_str [quote foo]
+ gdb_test_multiple "print $foo_str" "" {
+ -wrap -re " = (.*)" {
+ set print_output $expect_out(1,string)
+ pass $gdb_test_name
+ }
+ }
+
+ gdb_test_multiple "ptype $foo_str" "" {
+ -wrap -re " = (.*)" {
+ set ptype_output $expect_out(1,string)
+ pass $gdb_test_name
+ }
+ }
+
+ set cmd_str [quote "test-settings string"]
+ set ptype_output_re [string_to_regexp $ptype_output]
+ set print_output_re [string_to_regexp $print_output]
+
+ foreach_with_prefix conv_func {$_gdb_maint_setting $_gdb_maint_setting_str} {
+ gdb_test "print ${conv_func}($cmd_str)" \
+ " = $print_output_re"
+ gdb_test "ptype \$" \
+ " = $ptype_output_re"
+ }
+ }
+ }
}
# Test with a string value created by gdb.Value in Python.