Bug 26971

Summary: FAIL: gdb.arch/amd64-init-x87-values.exp: check_x87_regs_around_init: check post FLD1 value of $fop
Product: gdb Reporter: Tom de Vries <vries>
Component: testsuiteAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal    
Priority: P2    
Version: HEAD   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:

Description Tom de Vries 2020-11-28 14:45:52 UTC
On SLE-11, I run into:
...
(gdb) p/x $fop^M
$27 = 0x1e8^M
(gdb) FAIL: gdb.arch/amd64-init-x87-values.exp: check_x87_regs_around_init: check post FLD1 value of $fop
...

The expected value is 0.

Can be reproduced on the command line:
...
$ gdb -batch /outputs/gdb.arch/amd64-init-x87-values/amd64-init-x87-values \
  -ex start \
  -ex n -ex n -ex n \
  -ex "p /x \$fop" \
  -ex n \
  -ex "p /x \$fop" \
  -ex "info float"
Temporary breakpoint 1 at 0x4000d5: file amd64-init-x87-values.S, line 27.

Temporary breakpoint 1, main () at amd64-init-x87-values.S:27
27              nop
28              fwait
29              nop
30              fld1
$1 = 0x0
31              nop
$2 = 0x1e8
=>R7: Valid   0x3fff8000000000000000 +1                         
  R6: Empty   0x00000000000000000000
  R5: Empty   0x00000000000000000000
  R4: Empty   0x00000000000000000000
  R3: Empty   0x00000000000000000000
  R2: Empty   0x00000000000000000000
  R1: Empty   0x00000000000000000000
  R0: Empty   0x00000000000000000000

Status Word:         0x3800                                            
                       TOP: 7
Control Word:        0x037f   IM DM ZM OM UM PM
                       PC: Extended Precision (64-bits)
                       RC: Round to nearest
Tag Word:            0x3fff
Instruction Pointer: 0x00:0x004000d8
Operand Pointer:     0x00:0x00000000
Opcode:              0xd9e8
...

Interesting is that info float prints the opcode somewhat modified, such that we have: 0xd9e8, which is precisely the opcode:
...
00000000004000d5 <main>:
  4000d5:       90                      nop
  4000d6:       9b                      fwait
  4000d7:       90                      nop
  4000d8:       d9 e8                   fld1   
  4000da:       90                      nop
...

I wonder whether we should print $fop also as "0xd9e8", it would be somewhat clearer.

Either way, it seems we get the correct opcode, which should be allow in the test-case.
Comment 1 Tom de Vries 2020-11-28 14:54:33 UTC
Tentative patch:
...
diff --git a/gdb/testsuite/gdb.arch/amd64-init-x87-values.exp b/gdb/testsuite/gdb.arch/amd64-init-x87-values.exp
index 264c98b..6ad3430 100644
--- a/gdb/testsuite/gdb.arch/amd64-init-x87-values.exp
+++ b/gdb/testsuite/gdb.arch/amd64-init-x87-values.exp
@@ -105,7 +105,7 @@ proc_with_prefix check_x87_regs_around_init {} {
                                     "fioff" $addr \
                                     "foseg" "0x0" \
                                     "fooff" "0x0" \
-                                    "fop" "0x0" \
+                                    "fop" "0x0|0x1e8" \
                                     "mxcsr" "0x1f80" ] {
        gdb_test "p/x \$${regname}" " = ${regvalue}"  "check post FLD1 value of \$${regname}"
     }
...