From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id DE62E385840E; Mon, 7 Mar 2022 15:35:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DE62E385840E Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Fix bug in ada_print_floating X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 63fc2437deda87a566059444630ccc402945ae99 X-Git-Newrev: aacf24b4db3422632d6b62d473faf71f4e737072 Message-Id: <20220307153550.DE62E385840E@sourceware.org> Date: Mon, 7 Mar 2022 15:35:50 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Mar 2022 15:35:51 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Daacf24b4db34= 22632d6b62d473faf71f4e737072 commit aacf24b4db3422632d6b62d473faf71f4e737072 Author: Tom Tromey Date: Wed Feb 16 12:33:45 2022 -0700 Fix bug in ada_print_floating =20 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: =20 (gdb) print whatever $2 =3D =20 What's happening here is that ada_print_floating doesn't recognize this error case, and proceeds to modify the error text. =20 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 ty= pe *type, std::string s =3D tmp_stream.release (); size_t skip_count =3D 0; =20 + /* Don't try to modify a result representing an error. */ + if (s[0] =3D=3D '<') + { + fputs_filtered (s.c_str (), stream); + return; + } + /* Modify for Ada rules. */ =20 size_t pos =3D s.find ("inf"); diff --git a/gdb/testsuite/gdb.ada/float-bits.exp b/gdb/testsuite/gdb.ada/f= loat-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 :=3D 16llf#7FFFF7FF4054A5= 6FA5B99019A5C8#" \ " =3D 5.0e\\+25" gdb_test "print val_long_double" " =3D 5.0e\\+25" \ "print val_long_double after assignment" + +gdb_test "print 16llf#a56fa5b99019a5c800007ffff7ff4054#" \ + " =3D "