diff options
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/gdb.base/all-architectures.exp.tcl | 32 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/parse_number.exp | 53 | ||||
-rw-r--r-- | gdb/testsuite/lib/gdb.exp | 20 |
3 files changed, 79 insertions, 26 deletions
diff --git a/gdb/testsuite/gdb.base/all-architectures.exp.tcl b/gdb/testsuite/gdb.base/all-architectures.exp.tcl index 94b5efe..d6679a1 100644 --- a/gdb/testsuite/gdb.base/all-architectures.exp.tcl +++ b/gdb/testsuite/gdb.base/all-architectures.exp.tcl @@ -91,45 +91,25 @@ proc gdb_test_internal {cmd pattern {message ""}} { gdb_test_internal "set max-completions unlimited" \ "^set max-completions unlimited" -# Return a list of all the accepted values of "set WHAT". - -proc get_set_option_choices {what} { - global gdb_prompt - - set values {} - - set test "complete set $what" - gdb_test_multiple "complete set $what " "$test" { - -re "set $what (\[^\r\n\]+)\r\n" { - lappend values $expect_out(1,string) - exp_continue - } - -re "$gdb_prompt " { - internal_pass $test - } - } - return $values -} - -set supported_archs [get_set_option_choices "architecture"] +set supported_archs [get_set_option_choices "set architecture"] # There should be at least one more than "auto". gdb_assert {[llength $supported_archs] > 1} "at least one architecture" -set supported_osabis [get_set_option_choices "osabi"] +set supported_osabis [get_set_option_choices "set osabi"] # There should be at least one more than "auto" and "default". gdb_assert {[llength $supported_osabis] > 2} "at least one osabi" if {[lsearch $supported_archs "mips"] >= 0} { - set supported_mipsfpu [get_set_option_choices "mipsfpu"] - set supported_mips_abi [get_set_option_choices "mips abi"] + set supported_mipsfpu [get_set_option_choices "set mipsfpu"] + set supported_mips_abi [get_set_option_choices "set mips abi"] gdb_assert {[llength $supported_mipsfpu] != 0} "at least one mipsfpu" gdb_assert {[llength $supported_mips_abi] != 0} "at least one mips abi" } if {[lsearch $supported_archs "arm"] >= 0} { - set supported_arm_fpu [get_set_option_choices "arm fpu"] - set supported_arm_abi [get_set_option_choices "arm abi"] + set supported_arm_fpu [get_set_option_choices "set arm fpu"] + set supported_arm_abi [get_set_option_choices "set arm abi"] gdb_assert {[llength $supported_arm_fpu] != 0} "at least one arm fpu" gdb_assert {[llength $supported_arm_abi] != 0} "at least one arm abi" diff --git a/gdb/testsuite/gdb.base/parse_number.exp b/gdb/testsuite/gdb.base/parse_number.exp new file mode 100644 index 0000000..8849c99 --- /dev/null +++ b/gdb/testsuite/gdb.base/parse_number.exp @@ -0,0 +1,53 @@ +# Copyright 2022 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Test parsing numbers. Several language parsers had the same bug +# around parsing large 64-bit numbers, hitting undefined behavior, and +# thus crashing a GDB built with UBSan. This testcase goes over all +# languages exercising printing the max 64-bit number, making sure +# that GDB doesn't crash. + +proc test_parse_numbers {} { + clean_restart + + set all_languages [get_set_option_choices "set language"] + foreach_with_prefix lang $all_languages { + gdb_test_no_output "set language $lang" + + set val "0xffffffffffffffff" + if {$lang == "ada"} { + gdb_test "p/x $val" "Integer literal out of range" + } elseif {$lang == "fortran"} { + gdb_test "p/x $val" " = 0xffffffff" + gdb_test "ptype $val" " = unsigned int" + } elseif {$lang == "modula-2"} { + gdb_test "p/x 0FFFFFFFFFFFFFFFFH" "Overflow on numeric constant\\." + } elseif {$lang == "unknown"} { + gdb_test "p/x $val" \ + "expression parsing not implemented for language \"Unknown\"" + } else { + gdb_test "p/x $val" " = $val" + if {$lang == "d"} { + gdb_test "ptype $val" " = ulong" + } elseif {$lang == "rust"} { + gdb_test "ptype $val" " = i64" + } else { + gdb_test "ptype $val" " = unsigned long long" + } + } + } +} + +test_parse_numbers diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 0ef7e12..2eb7117 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -8486,5 +8486,25 @@ gdb_caching_proc has_hw_wp_support { return $has_hw_wp_support } +# Return a list of all the accepted values of the set command SET_CMD. + +proc get_set_option_choices {set_cmd} { + global gdb_prompt + + set values {} + + set test "complete $set_cmd" + gdb_test_multiple "complete $set_cmd " "$test" { + -re "$set_cmd (\[^\r\n\]+)\r\n" { + lappend values $expect_out(1,string) + exp_continue + } + -re "$gdb_prompt " { + pass $test + } + } + return $values +} + # Always load compatibility stuff. load_lib future.exp |