OK.

On Wed, Sep 26, 2018 at 9:30 AM, Richard Biener <rguent...@suse.de> wrote:
>
> This fixes mentioned PR (I should stop looking at generated debug
> info...) where it notes that concrete inline instance DW_TAG_lexical_block
> miss DW_AT_abstract_origin attributes pointing to the abstract instance
> and that inline instances of DW_TAG_lexical_block have
> DW_AT_abstract_origins pointing to other inline or concrete instances
> rather than the abstract instance.
>
> Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
>
> I even added a testcase.  Yay.
>
> OK?
>
> Thanks,
> Richard.
>
> 2018-09-26  Richard Biener  <rguent...@suse.de>
>
>         PR debug/87443
>         * dwarf2out.c (gen_lexical_block_die): Do not equate inline
>         or concrete instance DIE to the tree.  Create abstract origin
>         attributes also for concrete instances.
>
>         * gcc.dg/debug/dwarf2/inline5.c: New testcase.
>
> Index: gcc/dwarf2out.c
> ===================================================================
> --- gcc/dwarf2out.c     (revision 264594)
> +++ gcc/dwarf2out.c     (working copy)
> @@ -24091,18 +24091,16 @@ gen_lexical_block_die (tree stmt, dw_die
>      }
>    else if (BLOCK_ABSTRACT_ORIGIN (stmt))
>      {
> -      /* If this is an inlined instance, create a new lexical die for
> -        anything below to attach DW_AT_abstract_origin to.  */
> +      /* If this is an inlined or conrecte instance, create a new lexical
> +        die for anything below to attach DW_AT_abstract_origin to.  */
>        if (old_die)
> -       {
> -         stmt_die = new_die (DW_TAG_lexical_block, context_die, stmt);
> -         equate_block_to_die (stmt, stmt_die);
> -         old_die = NULL;
> -       }
> +       stmt_die = new_die (DW_TAG_lexical_block, context_die, stmt);
>
>        tree origin = block_ultimate_origin (stmt);
> -      if (origin != NULL_TREE && origin != stmt)
> +      if (origin != NULL_TREE && (origin != stmt || old_die))
>         add_abstract_origin_attribute (stmt_die, origin);
> +
> +      old_die = NULL;
>      }
>
>    if (old_die)
>
> Index: gcc/testsuite/gcc.dg/debug/dwarf2/inline5.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/debug/dwarf2/inline5.c (nonexistent)
> +++ gcc/testsuite/gcc.dg/debug/dwarf2/inline5.c (working copy)
> @@ -0,0 +1,26 @@
> +/* Verify that the concrete instance DW_TAG_lexical_block has an abstract
> +   origin.  Verify that the inline instance has the abstract instance as
> +   abstract origin rather than the concrete one.  */
> +/* { dg-options "-O -gdwarf -dA" } */
> +/* { dg-do compile } */
> +/* { dg-final { scan-assembler-times "DW_TAG_inlined_subroutine" 2 } } */
> +/* { dg-final { scan-assembler-times "DW_TAG_lexical_block\\)\[^#\]*# 
> DW_AT_abstract_origin" 2 } } */
> +/* { dg-final { scan-assembler-times "DW_TAG_lexical_block\\)\[^#\]*# \\(DIE 
> \\(0x\[0-9a-f\]*\\) DW_TAG_variable" 1 } } */
> +/* We do not know which is output first so look for both invalid abstract
> +   origins on the lexical blocks (knowing that the abstract instance has
> +   no attribute following the DW_TAG_lexical_block.  */
> +/* { dg-final { scan-assembler-not "\\(DIE \\(0x(\[0-9a-f\]*)\\) 
> DW_TAG_lexical_block\\)\[^#\]*# 
> \[^(\].*DW_TAG_lexical_block\\)\[^#x\]*x\\1\[^#\]*# DW_AT_abstract_origin" } 
> } */
> +/* { dg-final { scan-assembler-not 
> "DW_TAG_lexical_block\\)\[^#x\]*x(\[0-9a-f\]*)\[^#\]*# 
> DW_AT_abstract_origin.*\\(DIE \\(0x\\1\\) DW_TAG_lexical_block\\)\[^#\]*# 
> DW_AT" } } */
> +
> +int foo (int i)
> +{
> +    {
> +      volatile int j = i + 3;
> +      return j - 2;
> +    }
> +}
> +int main()
> +{
> +  volatile int z = foo (-1);
> +  return z;
> +}

Reply via email to