From patchwork Wed Dec 9 12:23:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 9946 Received: (qmail 30615 invoked by alias); 9 Dec 2015 12:23:57 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 30603 invoked by uid 89); 9 Dec 2015 12:23:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, KAM_LOTSOFHASH, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 09 Dec 2015 12:23:55 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 59F6C219E; Wed, 9 Dec 2015 12:23:54 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tB9CNqiE006117; Wed, 9 Dec 2015 07:23:53 -0500 Message-ID: <56681D58.1040809@redhat.com> Date: Wed, 09 Dec 2015 12:23:52 +0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Ruslan Kabatsayev , Andrew Burgess CC: gdb-patches@sourceware.org Subject: Re: [PATCH][PR 18702] Fix wrong output of x87 registers due to truncation to double on amd64 References: <564F998D.5080406@gmail.com> <5660357F.4030605@redhat.com> <5661AD07.5090002@redhat.com> <5661B2A7.6020005@redhat.com> <5661BACA.50909@gmail.com> <20151205224129.GO4625@embecosm.com> <5663D5E7.5010409@gmail.com> In-Reply-To: <5663D5E7.5010409@gmail.com> On 12/06/2015 06:29 AM, Ruslan Kabatsayev wrote: > > > On 12/06/2015 01:41 AM, Andrew Burgess wrote: >> * Ruslan Kabatsayev [2015-12-04 19:09:46 +0300]: >> >>> When `info float` is used on an AMD64 system, GDB prints floating-point >>> values of x87 registers with raw contents like 0x361a867a8e0527397ce0 or >>> 0xc4f988454a1ddd3cfdab wrongly. This happens due to truncation to double, >>> after which the former becomes 0.0, and the latter becomes negative infinity. >>> This is caused by failed detection of x86-64 host, which results in setting >>> gdb_host_{float,double,long_double}_format to zeros. >>> This commit fixes this misdetection, and adds a test to make sure future >>> commits don't introduce a regression here. >>> >>> gdb/ChangeLog: >>> >>> * configure.host: Fix detection of x86_64 host when setting >>> floatformats. >>> * testsuite/gdb.arch/i386-float.S: Add a regression test for the fix. >>> * testsuite/gdb.arch/i386-float.exp: Add checking of the test results. >> >> There's a separate ChangeLog in the gdb/testsuite directory, so you >> need to split your entry over these two files. And remember files >> names in the testsuite ChangeLog don't need to have the testsuite/ >> prefix. > > gdb/ChangeLog: > > * configure.host: Fix detection of x86_64 host when setting > floatformats. > > gdb/testsuite/ChangeLog: > > * gdb.arch/i386-float.S: Add a regression test for the fix of > floatformats setup on x86_64 hosts. > * gdb.arch/i386-float.exp: Add checking of the test results for > floatformats setup on x86_64 hosts. Thanks! I tweaked the testsuite ChangeLog entry to mention what changed rather than why, as convention. Also, I noticed that the test has duplicated test messages, so I made it use with_test_prefix as well. Below's what I pushed. (BTW, "tiny patch" is just the GNU convention for marking patches that fall below the copyright assignment requirement. If you're going to contribute more to gdb (which would of course be great), let me know offlist so we can start the copyright assignment process.) From b593e3d9b00b09af43abf1e95d68e68200e3c2a5 Mon Sep 17 00:00:00 2001 From: Ruslan Kabatsayev Date: Wed, 9 Dec 2015 12:17:40 +0000 Subject: [PATCH] Fix wrong output of x87 registers due to truncation to double on amd64 When `info float` is used on an AMD64 system, GDB prints floating-point values of x87 registers with raw contents like 0x361a867a8e0527397ce0 or 0xc4f988454a1ddd3cfdab wrongly. This happens due to truncation to double, after which the former becomes 0.0, and the latter becomes negative infinity. This is caused by failed detection of x86-64 host, which results in setting gdb_host_{float,double,long_double}_format to zeros. This commit fixes this misdetection, and adds a test to make sure future commits don't introduce a regression here. gdb/ChangeLog: 2015-12-09 Ruslan Kabatsayev PR gdb/18702 * configure.host: Fix detection of x86_64 host when setting floatformats. gdb/testsuite/ChangeLog: 2015-12-09 Ruslan Kabatsayev Pedro Alves PR gdb/18702 Add checking of floatformats setup on x86_64 hosts. * gdb.arch/i386-float.S (main): Load bigval and smallval. (smallval, bigval): New labels/constants. * gdb.arch/i386-float.exp: Use with_test_prefix and test "info float" after loading bigval and smallval. --- gdb/ChangeLog | 6 ++++++ gdb/testsuite/ChangeLog | 10 ++++++++++ gdb/configure.host | 2 +- gdb/testsuite/gdb.arch/i386-float.S | 4 ++++ gdb/testsuite/gdb.arch/i386-float.exp | 20 ++++++++++++++++---- 5 files changed, 37 insertions(+), 5 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b5d2431..8a8202c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2015-12-09 Ruslan Kabatsayev (tiny patch) + + PR gdb/18702 + * configure.host: Fix detection of x86_64 host when setting + floatformats. + 2015-12-08 Pierre-Marie de Rodat * NEWS: Announce this enhancement and the corresponding new diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 8316d32..d959e7b 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2015-12-09 Ruslan Kabatsayev + Pedro Alves + + PR gdb/18702 + Add checking of floatformats setup on x86_64 hosts. + * gdb.arch/i386-float.S (main): Load bigval and smallval. + (smallval, bigval): New labels/constants. + * gdb.arch/i386-float.exp: Use with_test_prefix and test "info + float" after loading bigval and smallval. + 2015-12-07 Pierre-Marie de Rodat * gdb.ada/fun_overload_menu.exp: New testcase. diff --git a/gdb/configure.host b/gdb/configure.host index 48714f4..ef265eb 100644 --- a/gdb/configure.host +++ b/gdb/configure.host @@ -195,7 +195,7 @@ esac # "double" and "long double" types. case "${host}" in -i[34567]86-*-*) +i[34567]86-*-*|x86_64-*-*) gdb_host_float_format="&floatformat_ieee_single_little" gdb_host_double_format="&floatformat_ieee_double_little" gdb_host_long_double_format="&floatformat_i387_ext" diff --git a/gdb/testsuite/gdb.arch/i386-float.S b/gdb/testsuite/gdb.arch/i386-float.S index 76126c4..f5de8c2 100644 --- a/gdb/testsuite/gdb.arch/i386-float.S +++ b/gdb/testsuite/gdb.arch/i386-float.S @@ -29,6 +29,10 @@ SYMBOL(main): fninit fldt val + fldt bigval + fldt smallval ret .data val: .byte 0x00,0x00,0x45,0x07,0x11,0x19,0x22,0xe9,0xfe,0xbf + smallval: .byte 0xe9,0xd0,0xd7,0x65,0x81,0xb7,0x43,0xc6,0x5c,0x6a + bigval: .byte 0x6a,0x45,0x90,0xdc,0x03,0xc1,0xf8,0xc6,0xe5,0x03 diff --git a/gdb/testsuite/gdb.arch/i386-float.exp b/gdb/testsuite/gdb.arch/i386-float.exp index e638ceb..e3ae3ba 100644 --- a/gdb/testsuite/gdb.arch/i386-float.exp +++ b/gdb/testsuite/gdb.arch/i386-float.exp @@ -37,7 +37,19 @@ if ![runto_main] then { return 0 } -gdb_test "stepi" ".*fldt.*" "first stepi" -gdb_test "info float" ".*R7: Empty 0x00000000000000000000\r\n.*" -gdb_test "stepi" ".*ret.*" "second stepi" -gdb_test "info float" ".*=>R7: Valid 0xbffee922191107450000 .*" +with_test_prefix "zero" { + gdb_test "stepi" ".*fldt.*" + gdb_test "info float" "R7: Empty 0x00000000000000000000\r\n.*" +} +with_test_prefix "val" { + gdb_test "stepi" ".*fldt.*" + gdb_test "info float" "=>R7: Valid 0xbffee922191107450000 .*" +} +with_test_prefix "smallval" { + gdb_test "stepi" ".*fldt.*" + gdb_test "info float" "=>R6: Valid 0x03e5c6f8c103dc90456a \\+3.500000000000000007e-4632\r\n.*" +} +with_test_prefix "bigval" { + gdb_test "stepi" ".*ret.*" + gdb_test "info float" "=>R5: Valid 0x6a5cc643b78165d7d0e9 \\+7.250000000000000005e\\+3264\r\n.*" +}