https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87443

            Bug ID: 87443
           Summary: GCC mixes abstract and concrete instances in abstract
                    origins for inlines
           Product: gcc
           Version: 8.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

For

int foo (int i)
{
    {
      volatile int j = i + 3;
      return j - 2;
    }
}
int main()
{
  volatile int z = foo (-1);
  return z;
}

we create

 <2><12a>: Abbrev Number: 4 (DW_TAG_inlined_subroutine)
    <12b>   DW_AT_abstract_origin: <0x177>
    <12f>   DW_AT_low_pc      : 0x4004e1
    <137>   DW_AT_high_pc     : 0xf
    <13f>   DW_AT_call_file   : 1
    <140>   DW_AT_call_line   : 10
    <141>   DW_AT_call_column : 20
 <3><142>: Abbrev Number: 5 (DW_TAG_formal_parameter)
    <143>   DW_AT_abstract_origin: <0x188>
    <147>   DW_AT_location    : 0x0 (location list)
 <3><14b>: Abbrev Number: 6 (DW_TAG_lexical_block)
    <14c>   DW_AT_abstract_origin: <0x1bf>
    <150>   DW_AT_low_pc      : 0x4004e1
    <158>   DW_AT_high_pc     : 0xf
 <4><160>: Abbrev Number: 7 (DW_TAG_variable)
    <161>   DW_AT_abstract_origin: <0x193>
    <165>   DW_AT_location    : 2 byte block: 91 70     (DW_OP_fbreg: -16)
 <4><168>: Abbrev Number: 0
 <3><169>: Abbrev Number: 0
...

 <1><19f>: Abbrev Number: 14 (DW_TAG_subprogram)
    <1a0>   DW_AT_abstract_origin: <0x177>
    <1a4>   DW_AT_low_pc      : 0x4004d2
    <1ac>   DW_AT_high_pc     : 0xf
    <1b4>   DW_AT_frame_base  : 1 byte block: 9c        (DW_OP_call_frame_cfa)
    <1b6>   DW_AT_GNU_all_call_sites: 1
 <2><1b6>: Abbrev Number: 5 (DW_TAG_formal_parameter)
    <1b7>   DW_AT_abstract_origin: <0x188>
    <1bb>   DW_AT_location    : 0x25 (location list)
 <2><1bf>: Abbrev Number: 15 (DW_TAG_lexical_block)
    <1c0>   DW_AT_low_pc      : 0x4004d2
    <1c8>   DW_AT_high_pc     : 0xe
 <3><1d0>: Abbrev Number: 7 (DW_TAG_variable)
    <1d1>   DW_AT_abstract_origin: <0x193>
    <1d5>   DW_AT_location    : 2 byte block: 91 74     (DW_OP_fbreg: -12)
 <3><1d8>: Abbrev Number: 0


note how the DW_TAG_inlined_subroutine abstract origin points to the
abstract instance (likewise the formal parameter) but the DW_AT_lexcial_block
and points to the concrete instance.  Note how the concrete instance
fails to point to the abstract instance for its DW_AT_lexical_block.

I fixed that for the DW_TAG_variable (GCC 7 is still broken) so a similar
fix is probably needed for DW_TAG_lexical_block ...

Reply via email to