public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] [gdb/testsuite] Use hex_for_lang in gdb.base/parse_number.exp
@ 2022-05-18 10:12 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2022-05-18 10:12 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=71630188adffa1222ff3341b54700f537e0f2e07

commit 71630188adffa1222ff3341b54700f537e0f2e07
Author: Tom de Vries <tdevries@suse.de>
Date:   Wed May 18 12:12:29 2022 +0200

    [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.

Diff:
---
 gdb/testsuite/gdb.base/parse_number.exp | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.base/parse_number.exp b/gdb/testsuite/gdb.base/parse_number.exp
index ccef3f09655..9668099bd82 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\""


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-18 10:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-18 10:12 [binutils-gdb] [gdb/testsuite] Use hex_for_lang in gdb.base/parse_number.exp Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).