From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH 3/3] Fix bug in ada_print_floating
Date: Tue, 1 Mar 2022 10:00:55 -0700 [thread overview]
Message-ID: <20220301170055.1520935-4-tromey@adacore.com> (raw)
In-Reply-To: <20220301170055.1520935-1-tromey@adacore.com>
ada_print_floating rewrites a floating-point string representation to
conform to Ada syntax. However, if you managed to get a floating
point error, you might see:
(gdb) print whatever
$2 = <invalid float valu.0e>
What's happening here is that ada_print_floating doesn't recognize
this error case, and proceeds to modify the error text.
This patch fixes this problem.
---
gdb/ada-valprint.c | 7 +++++++
gdb/testsuite/gdb.ada/float-bits.exp | 3 +++
2 files changed, 10 insertions(+)
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index bf95719f040..e113088491c 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -314,6 +314,13 @@ ada_print_floating (const gdb_byte *valaddr, struct type *type,
std::string s = tmp_stream.release ();
size_t skip_count = 0;
+ /* Don't try to modify a result representing an error. */
+ if (s[0] == '<')
+ {
+ fputs_filtered (s.c_str (), stream);
+ return;
+ }
+
/* Modify for Ada rules. */
size_t pos = s.find ("inf");
diff --git a/gdb/testsuite/gdb.ada/float-bits.exp b/gdb/testsuite/gdb.ada/float-bits.exp
index 61db5f325ad..c98afb53c06 100644
--- a/gdb/testsuite/gdb.ada/float-bits.exp
+++ b/gdb/testsuite/gdb.ada/float-bits.exp
@@ -48,3 +48,6 @@ gdb_test "print val_long_double := 16llf#7FFFF7FF4054A56FA5B99019A5C8#" \
" = 5.0e\\+25"
gdb_test "print val_long_double" " = 5.0e\\+25" \
"print val_long_double after assignment"
+
+gdb_test "print 16llf#a56fa5b99019a5c800007ffff7ff4054#" \
+ " = <invalid float value>"
--
2.31.1
next prev parent reply other threads:[~2022-03-01 17:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-01 17:00 [PATCH 0/3] Floating-point literal syntax extension for Ada Tom Tromey
2022-03-01 17:00 ` [PATCH 1/3] Fix Ada integer literals with exponents Tom Tromey
2022-03-01 17:00 ` [PATCH 2/3] Implement real literal extension for Ada Tom Tromey
2022-03-01 17:22 ` Eli Zaretskii
2022-03-07 15:28 ` Tom Tromey
2022-03-16 14:33 ` Luis Machado
2022-03-18 18:05 ` Tom Tromey
2022-03-21 9:28 ` Luis Machado
2022-03-29 8:13 ` Luis Machado
2022-03-01 17:00 ` Tom Tromey [this message]
2022-03-07 15:28 ` [PATCH 0/3] Floating-point literal syntax " Tom Tromey
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=20220301170055.1520935-4-tromey@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).