In the attached testcase (which will be added to the GDB testsuite), func1 is
both emitted as a function and inlined into main and func2.  The generated
DWARF output looks like this with mainline:

 <1><1bf>: Abbrev Number: 2 (DW_TAG_subprogram)
    <1c0>   DW_AT_external    : 1
    <1c1>   DW_AT_name        : (indirect string, offset: 0x11b): func1
    <1c5>   DW_AT_decl_file   : 1
    <1c6>   DW_AT_decl_line   : 22
    <1c7>   DW_AT_prototyped  : 1
    <1c8>   DW_AT_type        : <0x1e8>
    <1cc>   DW_AT_inline      : 3       (declared as inline and inlined)
    <1cd>   DW_AT_sibling     : <0x1e8>
 <2><1d1>: Abbrev Number: 3 (DW_TAG_formal_parameter)
    <1d2>   DW_AT_name        : (indirect string, offset: 0x10c): arg1
    <1d6>   DW_AT_decl_file   : 1
    <1d7>   DW_AT_decl_line   : 22
    <1d8>   DW_AT_type        : <0x1e8>

 <1><202>: Abbrev Number: 9 (DW_TAG_subprogram)
    <203>   DW_AT_abstract_origin: <0x1bf>
    <207>   DW_AT_low_pc      : 0x4004a0
    <20f>   DW_AT_high_pc     : 0x4004e8
    <217>   DW_AT_frame_base  : 0x0     (location list)
    <21b>   DW_AT_sibling     : <0x230>
 <2><21f>: Abbrev Number: 10 (DW_TAG_formal_parameter)
    <220>   DW_AT_abstract_origin: <0x1d1>
    <224>   DW_AT_location    : 1 byte block: 53        (DW_OP_reg3)

 <2><272>: Abbrev Number: 12 (DW_TAG_inlined_subroutine)
    <273>   DW_AT_abstract_origin: <0x1bf>
    <277>   DW_AT_entry_pc    : 0x4004fa
    <27f>   DW_AT_ranges      : 0x50
    <283>   DW_AT_call_file   : 1
    <284>   DW_AT_call_line   : 34
 <3><285>: Abbrev Number: 13 (DW_TAG_formal_parameter)
    <286>   DW_AT_abstract_origin: <0x21f>

The problem is that the abstract origin of arg1 in the inlined copy (DIE at
0x285) refers to the outlined copy.  But this is not in the abstract subtree
referred to by the DIE at 0x272.

Two things go wrong in consequence.  GDB concludes that nothing in this subtree
refers to the DIE at 0x1d1 and stitches that DIE into the tree, resulting in a
second copy of arg1 (with no DW_AT_location).  This could be worked around in
GDB to compensate for the DWARF, but I'm convinced from the DWARF spec that the
nesting is invalid.  The other thing that goes wrong is even with the
workaround, we try to use the DW_AT_location from the outlined copy.  It works
by chance in 4.5; in 4.4 a location list was used instead of a register, so of
course the PC values in the location list do not apply.

Honza, Richi suggested on IRC that this might be related to your changes in
inline variable tracking.  Any idea?


-- 
           Summary: [4.4/4.5 Regression] DWARF for inlined subroutines
                    refers to the outlined copy
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: drow at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40573

Reply via email to