public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Fix bug in ada_print_floating
@ 2022-03-07 15:35 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2022-03-07 15:35 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=aacf24b4db3422632d6b62d473faf71f4e737072
commit aacf24b4db3422632d6b62d473faf71f4e737072
Author: Tom Tromey <tromey@adacore.com>
Date: Wed Feb 16 12:33:45 2022 -0700
Fix bug in ada_print_floating
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.
Diff:
---
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>"
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-03-07 15:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-07 15:35 [binutils-gdb] Fix bug in ada_print_floating Tom Tromey
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).