From: Tom de Vries via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Subject: [committed][gdb/testsuite] Use hex_for_lang in gdb.base/parse_number.exp
Date: Wed, 18 May 2022 12:12:53 +0200 [thread overview]
Message-ID: <20220518101251.GA4915@delia> (raw)
Hi,
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.
Committed to trunk.
Thanks,
- Tom
[gdb/testsuite] Use hex_for_lang in gdb.base/parse_number.exp
---
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\""
reply other threads:[~2022-05-18 10:13 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220518101251.GA4915@delia \
--to=gdb-patches@sourceware.org \
--cc=tdevries@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox