This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Wrong mappin of registers in location lists


> as far as I can see gcc outputs wrong information to .debug_loc on 
> x86-64. This is the assembler output:
> 
> main:
> .LVL22:
>         pushq   %rbx
>         movl    %edi, %ebx
> .LVL23:
>         leal    1(%rbx), %edi
>         subq    $416, %rsp
> [...]
> 
> This is DIE of argc:
>         .uleb128 0x3    # (DIE (0xef) DW_TAG_formal_parameter)
>         .long   .LASF4  # DW_AT_name: "argc"
>         .byte   0x1     # DW_AT_decl_file
>         .byte   0x17    # DW_AT_decl_line
>         .long   0x8f    # DW_AT_type
>         .long   .LLST3-.Ldebug_loc0     # DW_AT_location
> 
> And finally location list of argc:
> .LLST3:
>         .quad   .LVL22-.text    # Location list begin address (*.LLST3)
>         .quad   .LVL23-.text    # Location list end address (*.LLST3)
>         .value  0x1     # Location expression size
>         .byte   0x55    # DW_OP_reg5
>         .quad   .LVL23-.text    # Location list begin address (*.LLST3)
>         .quad   .LFE7-.text     # Location list end address (*.LLST3)
>         .value  0x1     # Location expression size
>         .byte   0x53    # DW_OP_reg3
>         .quad   0x0     # Location list terminator begin (*.LLST3)
>         .quad   0x0     # Location list terminator end (*.LLST3)
> 
> At the entry of the function (.LVL22), argc is dwarf2 register 5 
> (DW_OP_reg5), ie %rdi on x86-64. From .LVL23 on it is saved in %rbx, ie. 
> DW_OP_reg1. However debug information says it's in DW_OP_reg3, ie. %rdx.

I do not know the register numbers for dwarf, but in gcc core the numbering is this:

(from gcc/gcc/config/i386/i386.h:)
#define ADDITIONAL_REGISTER_NAMES \
{ { "eax", 0 }, { "edx", 1 }, { "ecx", 2 }, { "ebx", 3 },       \
  { "esi", 4 }, { "edi", 5 }, { "ebp", 6 }, { "esp", 7 },       \

Josef


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]