diff options
author | Tom de Vries <tdevries@suse.de> | 2022-05-18 12:12:29 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2022-05-18 12:12:29 +0200 |
commit | 71630188adffa1222ff3341b54700f537e0f2e07 (patch) | |
tree | f03a90db4446c700dc04b1e96a6f107546b0945f /gdb/testsuite/gdb.base/parse_number.exp | |
parent | 192257c998507f8a6ad9a85394b4fd4c627552cb (diff) | |
download | gdb-71630188adffa1222ff3341b54700f537e0f2e07.zip gdb-71630188adffa1222ff3341b54700f537e0f2e07.tar.gz gdb-71630188adffa1222ff3341b54700f537e0f2e07.tar.bz2 |
[gdb/testsuite] Use hex_for_lang in gdb.base/parse_number.exp
In gdb.base/parse_number.exp, add a new proc hex_for_lang that formats a hex
number appropriately for a given language.
Tested on x86_64-linux.
Diffstat (limited to 'gdb/testsuite/gdb.base/parse_number.exp')
-rw-r--r-- | gdb/testsuite/gdb.base/parse_number.exp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gdb/testsuite/gdb.base/parse_number.exp b/gdb/testsuite/gdb.base/parse_number.exp index ccef3f0..9668099 100644 --- a/gdb/testsuite/gdb.base/parse_number.exp +++ b/gdb/testsuite/gdb.base/parse_number.exp @@ -13,6 +13,18 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +# Format hex value VAL for language LANG. + +proc hex_for_lang { lang val } { + set val [regsub ^0x $val ""] + if { $lang == "modula-2" } { + set val 0[string toupper $val]H + } else { + set val 0x$val + } + return $val +} + # 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 @@ -53,11 +65,12 @@ proc test_parse_numbers {arch} { gdb_test_no_output "set language $lang" set val "0xffffffffffffffff" + set val [hex_for_lang $lang $val] if {$lang == "fortran"} { gdb_test "p/x $val" " = $fortran_value" gdb_test "ptype $val" " = $fortran_type" } elseif {$lang == "modula-2"} { - gdb_test "p/x 0FFFFFFFFFFFFFFFFH" "Overflow on numeric constant\\." + gdb_test "p/x $val" "Overflow on numeric constant\\." } elseif {$lang == "unknown"} { gdb_test "p/x $val" \ "expression parsing not implemented for language \"Unknown\"" |