[Lldb-commits] [PATCH] Renamed ip/dp registers to fip/fdp

Jason Molenda jmolenda at apple.com
Wed Aug 7 15:56:20 PDT 2013


Greg's off-line this week but it'd be worth checking with him about how the names on Darwin were chosen.  

I don't know if it's that important to maintain the exact same names for these types of registers.  The thread context structure (defined in the system header files) defines these as

        _STRUCT_FP_CONTROL      __fpu_fcw;              /* x87 FPU control word */
        _STRUCT_FP_STATUS       __fpu_fsw;              /* x87 FPU status word */
        __uint8_t               __fpu_ftw;              /* x87 FPU tag word */
        __uint8_t               __fpu_rsrv1;            /* reserved */ 
        __uint16_t              __fpu_fop;              /* x87 FPU Opcode */

        /* x87 FPU Instruction Pointer */
        __uint32_t              __fpu_ip;               /* offset */
        __uint16_t              __fpu_cs;               /* Selector */

        __uint16_t              __fpu_rsrv2;            /* reserved */

        /* x87 FPU Instruction Operand(Data) Pointer */
        __uint32_t              __fpu_dp;               /* offset */
        __uint16_t              __fpu_ds;               /* Selector */


The actual behavior on a Darwin system is,

(lldb) reg read -a
[...]
Floating Point Registers:
     fctrl = 0x037f
     fstat = 0x0020
      ftag = 0x00
       fop = 0x0000
     fioff = 0x8a114262
     fiseg = 0x002b
     fooff = 0x8a14bf30
     foseg = 0x0000
     mxcsr = 0x00001fa3
  mxcsrmask = 0x0000ffff
     stmm0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xff 0xff}
[...]
(lldb) reg read ip
error: Invalid register name 'ip'.
(lldb) reg read fpu_ip
error: Invalid register name 'fpu_ip'.
(lldb) reg read fioff
   fioff = 0x8a114262
(lldb) 




On Aug 7, 2013, at 11:43 AM, Richard Mitton <richard at codersnotes.com> wrote:

> Exactly, displaying an 'ip' register which is not the instruction pointer is very unhelpful.
> 
> The existing register names are currently different on posix-vs-Darwin anyway, so there shouldn't be any harm in making the change now. I think it's "fioff" on Darwin. It uses different display names vs. the internal variable names.
> 
> I agree that it would be nice to make it consistent everywhere. Personally I'm in favor of it matching the Intel names as closely as possible. I'm slightly puzzled by how many places in the codebase (re)define the register sets, it seems like making changes like this may not be straightforward.
> 
> Richard Mitton
> richard at codersnotes.com
> 
> On 08/07/2013 09:12 AM, Daniel Malea wrote:
>>   To clarify the original problem this patch addresses (Richard correct me if I'm wrong) the result of a user doing "register read ip" is that they would see the floating point register instead of the instruction pointer.
>> 
>>   This change makes the register names on POSIX platforms diverge from the Mac OS X ones.. Specifically, in the darwin plugins, the register in question is still called "ip".
>> 
>>   At the very least, this implies we should change TestRegisters.py as well (in its current form, it crashes) but i'm not sure that change is ideal as we'd have to use different names for the same hardware on different platforms.
>> 
>>   My gut feeling is we should probably keep register names consistent across platforms... so making this change to the POSIX side might require a corresponding change on the Darwin side -- maybe someone from Apple can chime in on the merits?
>> 
>> http://llvm-reviews.chandlerc.com/D1307
> 
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits




More information about the lldb-commits mailing list