Fix wrong output of x87 registers due to truncation to double on amd64
authorRuslan Kabatsayev <b7.10110111@gmail.com>
Wed, 9 Dec 2015 12:17:40 +0000 (12:17 +0000)
committerPedro Alves <palves@redhat.com>
Wed, 9 Dec 2015 12:17:40 +0000 (12:17 +0000)
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  <b7.10110111@gmail.com>

PR gdb/18702
* configure.host: Fix detection of x86_64 host when setting
floatformats.

gdb/testsuite/ChangeLog:
2015-12-09  Ruslan Kabatsayev  <b7.10110111@gmail.com>
    Pedro Alves  <pedro@redhat.com>

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
gdb/configure.host
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.arch/i386-float.S
gdb/testsuite/gdb.arch/i386-float.exp

index b5d2431ddeaa6f0cf02e762726da89009da0ce41..8a8202cebb5fafc8607f9f9d94ae16b3b6d30477 100644 (file)
@@ -1,3 +1,9 @@
+2015-12-09  Ruslan Kabatsayev  <b7.10110111@gmail.com>  (tiny patch)
+
+       PR gdb/18702
+       * configure.host: Fix detection of x86_64 host when setting
+       floatformats.
+
 2015-12-08  Pierre-Marie de Rodat  <derodat@adacore.com>
 
        * NEWS: Announce this enhancement and the corresponding new
index 48714f48c5d0e1d1cbf1b520cb344362b60b51ad..ef265ebe293ba42445de3325e452ba71bc7873e8 100644 (file)
@@ -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"
index 8316d32773f8c731004ca84cf73ba34b9abcac69..d959e7b615818c9115ef808e7ebae1a55dd3bf95 100644 (file)
@@ -1,3 +1,13 @@
+2015-12-09  Ruslan Kabatsayev  <b7.10110111@gmail.com>
+           Pedro Alves  <pedro@redhat.com>
+
+       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  <derodat@adacore.com>
 
        * gdb.ada/fun_overload_menu.exp: New testcase.
index 76126c49b6ee442c3ecdd78b52f95bfe24d290d5..f5de8c2ab9d94981406374f1d65d32bc49c6131e 100644 (file)
 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
index e638cebc020e4b90ada643b0d6ff0e1cdea5049f..e3ae3ba6ad3ae0c5408fa4973cfdc2f152d183f9 100644 (file)
@@ -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.*"
+}
This page took 0.038116 seconds and 4 git commands to generate.