[Lldb-commits] [PATCH] Register Number in DWARFCallFrameInfo.cpp

Jason Molenda jmolenda at apple.com
Tue Aug 12 16:47:03 PDT 2014


I grubbed around and found some old gcc sources for an additional data point.



http://www.opensource.apple.com/source/gcc/gcc-5666.3/gcc/config/i386/i386.c

Here's the register numbers it uses for DWARF:

/* Define the register numbers to be used in Dwarf debugging information.
   The SVR4 reference port C compiler uses the following register numbers
   in its Dwarf output code:
        0 for %eax (gcc regno = 0)
        1 for %ecx (gcc regno = 2)
        2 for %edx (gcc regno = 1)
        3 for %ebx (gcc regno = 3)
        4 for %esp (gcc regno = 7)
        5 for %ebp (gcc regno = 6)
        6 for %esi (gcc regno = 4)
        7 for %edi (gcc regno = 5)


and in http://www.opensource.apple.com/source/gcc/gcc-5666.3/gcc/config/i386/darwin.h we find that the register remapping for eh_frame appears to be Darwin specific:

/* Unfortunately, the 32-bit EH information also doesn't use the standard
   DWARF register numbers.  */
#define DWARF2_FRAME_REG_OUT(n, for_eh)                                 \
  (! (for_eh) || write_symbols != DWARF2_DEBUG || TARGET_64BIT ? (n)    \
   : (n) == 5 ? 4                                                       \
   : (n) == 4 ? 5                                                       \
   : (n) >= 11 && (n) <= 18 ? (n) + 1                                   \
   : (n))



> On Aug 12, 2014, at 4:36 PM, Jason Molenda <jmolenda at apple.com> wrote:
> 
> Hm, one second here.
> 
> First, I don't see why you're swapping the DWARF register numbers in the patch.  It seems like we're only talking about the eh_frame numbers.
> 
> Second, what does the output of objdump -W include?  Are you sure you're not looking at the debug_frame output, as opposed to eh_frame output?
> 
> J
> 
> 
>> On Aug 12, 2014, at 4:32 PM, Tong Shen <endlessroad at google.com> wrote:
>> 
>> Got it. So much magic going on there.
>> 
>> +Todd Can you check this in? Thanks!
>> 
>> 
>> On Tue, Aug 12, 2014 at 4:23 PM, Jason Molenda <jmolenda at apple.com> wrote:
>> 
>>> On Aug 12, 2014, at 4:20 PM, Tong Shen <endlessroad at google.com> wrote:
>>> 
>>> There's this line in your dwarfdump output:
>>> DW_CFA_def_cfa (5 (esp), 4)
>>> DW_CFA_offset (8 (eip), -4)
>>> 
>>> On Ubuntu 14.04, objdump -W outputs this:
>>> DW_CFA_def_cfa: r4 (esp) ofs 4
>>> DW_CFA_offset: r8 (eip) at cfa-4
>>> 
>>> I believe this is the cause. On OSX, esp=5; on linux, esp=4
>> 
>> 
>> Yeah, I was starting to get that impression too.  I thought the old esp/ebp mixup was across all the gcc platforms - but who knows.  Feel free to fix the RegisterContext_x86 enum definitions for esp/ebp - on Mac OS X we'll still be using the debugserver-provided register definitions.  (and we don't use eh_frame very often on Mac OS X - we primarily use a local compact unwind format that I haven't written an importer for yet)
>> 
>> Normally this kind of thing would be defined in the processor ABI document -- but I've never been able to find a document like that for IA-32.
>> 
>> 
>> 
>> -- 
>> Best Regards, Tong Shen
>> <1.patch>
> 




More information about the lldb-commits mailing list