diff options
author | Pedro Alves <pedro@palves.net> | 2021-07-15 10:47:56 +0100 |
---|---|---|
committer | Pedro Alves <pedro@palves.net> | 2021-07-15 15:10:59 +0100 |
commit | 50991aaf22b03a9925ae37155f16bc8257f95242 (patch) | |
tree | db0d641ebab1211d0f79c5dc00062c0708ad5b60 /gdb/testsuite/gdb.base | |
parent | 67ea24cb99efcd50d8acb6ce3e3ffbd8c97f0829 (diff) | |
download | binutils-users/palves/value_string.zip binutils-users/palves/value_string.tar.gz binutils-users/palves/value_string.tar.bz2 |
all languagesusers/palves/value_string
Change-Id: I79ef914087dbf85e1cbc19263843a6034383afe7
Diffstat (limited to 'gdb/testsuite/gdb.base')
-rw-r--r-- | gdb/testsuite/gdb.base/internal-string-values.exp | 80 |
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. |