10335 mdb: fix fpcw2str()

Review Request #1424 — Created March 2, 2019 and submitted

domag02
illumos-gate
10335
general

10335 mdb: fix fpcw2str()

The implementation of fpcw2str() (both in usr/src/cmd/mdb/intel/mdb/proc_amd64dep.c and in usr/src/cmd/mdb/intel/mdb/proc_ia32dep.c) has multiple problems:

  1. FPPC, FPRC and FPIC macro constants should be used as bitfield masks, meaningless to print those out because the masked bits aren't simple yes-no values
  2. To decode precision, rounding and infinity options, cw should be masked with the corresponding bit-mask first, then use equality check instead of bitwise &.

This bug has been found during the review of #10132: smatch fixes for MDB.

Build, install and run.

Example output before the patch:

root@openindiana:~# uname -snrvmapioX
SunOS openindiana 5.11 illumos-bc586359b7 i86pc i386 i86pc illumosSystem = SunOS
Node = openindiana
Release = 5.11
KernelID = illumos-bc586359b7
Machine = i86pc
BusType = <unknown>
Serial = <unknown>
Users = <unknown>
OEM# = 0
Origin# = 1
NumCPU = 2

root@openindiana:~# ps aux 2611
USER       PID %CPU %MEM   SZ  RSS TT       S    START  TIME COMMAND
root      2611  0.0  0.1 9756 1876 ?        S 23:56:50  0:00 /usr/lib/ssh/sshd
root@openindiana:~# mdb -p 2611
Loading modules: [ ld.so.1 libc.so.1 libuutil.so.1 libnvpair.so.1 libavl.so.1 ]
> ::fpregs
AMD64 (80486 chip with SSE)
cw     0x133f (IM|DM|ZM|OM|UM|PM|PC|IC|SIG53|SIG64|RTN|A)
sw     0x0000 (TOP=0t0) (0)
xcp sw 0x0000 (0)

fop    0x0
rip    0x0
rdp    0x0

%st0   0x0000.0000000000000000 = +0.0000000000000000e+00 empty
%st1   0x0000.0000000000000000 = +0.0000000000000000e+00 empty
%st2   0x0000.0000000000000000 = +0.0000000000000000e+00 empty
%st3   0x0000.0000000000000000 = +0.0000000000000000e+00 empty
%st4   0x0000.0000000000000000 = +0.0000000000000000e+00 empty
%st5   0x0000.0000000000000000 = +0.0000000000000000e+00 empty
%st6   0x0000.0000000000000000 = +0.0000000000000000e+00 empty
%st7   0x0000.0000000000000000 = +0.0000000000000000e+00 empty

mxcsr  0x1f80 (IM|DM|ZM|OM|UM|PM|RTN)
xcp    0x0000 (RTN)

%xmm0  0x00000000000000000000000000000000
%xmm1  0x00ffffffffffffffffffffffffffffff
%xmm2  0x0074736570616475422f65706f727545
%xmm3  0x6c75727869736f70002f6f666e69656e
%xmm4  0x00000000000000000000000000000000
%xmm5  0x00000000000000000000000000000000
%xmm6  0x00000000000000000000000000000000
%xmm7  0x00000000000000000000000000000000
> $q

root@openindiana:~# 

Note: |SIG53 and |SIG64 can't be present at the same time!

After the patch:

root@openindiana:~# uname -snrvmapioX
SunOS openindiana 5.11 master-0-g92c1a61163 i86pc i386 i86pc illumosSystem = SunOS
Node = openindiana
Release = 5.11
KernelID = master-0-g92c1a61163
Machine = i86pc
BusType = <unknown>
Serial = <unknown>
Users = <unknown>
OEM# = 0
Origin# = 1
NumCPU = 2

root@openindiana:~# ps aux 101174
USER        PID %CPU %MEM   SZ  RSS TT       S    START  TIME COMMAND
root     101174  0.0  0.1 9796 1840 ?        S 06:52:31  0:00 /usr/lib/ssh/sshd
root@openindiana:~# mdb -p 101174
Loading modules: [ ld.so.1 libc.so.1 libuutil.so.1 libnvpair.so.1 libavl.so.1 ]
> ::fpregs
AMD64 (80486 chip with SSE)
cw     0x133f (IM|DM|ZM|OM|UM|PM|SIG64|RTN|A)
sw     0x0000 (TOP=0t0) (0)
xcp sw 0x0000 (0)

fop    0x0
rip    0x0
rdp    0x0

%st0   0x0000.0000000000000000 = +0.0000000000000000e+00 empty
%st1   0x0000.0000000000000000 = +0.0000000000000000e+00 empty
%st2   0x0000.0000000000000000 = +0.0000000000000000e+00 empty
%st3   0x0000.0000000000000000 = +0.0000000000000000e+00 empty
%st4   0x0000.0000000000000000 = +0.0000000000000000e+00 empty
%st5   0x0000.0000000000000000 = +0.0000000000000000e+00 empty
%st6   0x0000.0000000000000000 = +0.0000000000000000e+00 empty
%st7   0x0000.0000000000000000 = +0.0000000000000000e+00 empty

mxcsr  0x1f80 (IM|DM|ZM|OM|UM|PM|RTN)
xcp    0x0000 (RTN)

%xmm0  0x00000000000000000000000000000000
%xmm1  0x00ffffffffffffffffffffffffffffff
%xmm2  0x0074736570616475422f65706f727545
%xmm3  0x652f0073656c75727869736f70002f6f
%xmm4  0x00000000000000000000000000000000
%xmm5  0x00000000000000000000000000000000
%xmm6  0x00000000000000000000000000000000
%xmm7  0x00000000000000000000000000000000
> $q

root@openindiana:~# 
  • 0
  • 0
  • 1
  • 0
  • 1
Description From Last Updated
tsoome
  1. 
      
  2. it does not seem like we have tab there and below? was this code checked with pbchk?:)

    1. Thanks!
      I don't know why (and how) this part of code modified.
  3. 
      
domag02
jlevon
  1. Thanks for fixing this up

  2. 
      
citrus
  1. Ship It!
  2. 
      
tsoome
  1. Ship It!
  2. 
      
domag02
Review request changed

Status: Closed (submitted)

Loading...