Skip to content

No DW_AT_abstract_origin emitted for a DW_TAG_lexical_block in an inlined function #49297

Closed
@barisaktemur

Description

@barisaktemur
Bugzilla Link 49953
Version 11.0
OS Linux
CC @dwblaikie,@JDevlieghere,@jmorse,@walkerkd,@pogo59,@zygoloid

Extended Description

Suppose we have

attribute((always_inline))
static void aFunction() {
int a = 42;
if(a > 2) {
int value = a;
value += 10;
}
}

The debug info for the concrete inlined instance of this function does not
contain DW_AT_abstract_origin attributes in the DW_TAG_lexical_block
entries. E.g. the DIE of the inlined function above is

0x00000087: DW_TAG_inlined_subroutine
DW_AT_abstract_origin (0x0000002a "aFunction")
DW_AT_low_pc (0x00000000004004b2)
DW_AT_high_pc (0x00000000004004d2)
DW_AT_call_file ("/tmp/test.c")
DW_AT_call_line (11)
DW_AT_call_column (0x03)

0x0000009b: DW_TAG_variable
DW_AT_location (DW_OP_fbreg -4)
DW_AT_abstract_origin (0x00000032 "a")

0x000000a3: DW_TAG_lexical_block
DW_AT_low_pc (0x00000000004004c3)
DW_AT_high_pc (0x00000000004004d2)

0x000000b0: DW_TAG_variable
DW_AT_location (DW_OP_fbreg -8)
DW_AT_abstract_origin (0x0000003e "value")

whereas the abstract DIE is

0x0000002a: DW_TAG_subprogram
DW_AT_name ("aFunction")
DW_AT_decl_file ("/tmp/test.c")
DW_AT_decl_line (2)
DW_AT_inline (DW_INL_inlined)

0x00000032: DW_TAG_variable
DW_AT_name ("a")
DW_AT_decl_file ("/tmp/test.c")
DW_AT_decl_line (3)
DW_AT_type (0x0000004b "int")

0x0000003d: DW_TAG_lexical_block

0x0000003e: DW_TAG_variable
DW_AT_name ("value")
DW_AT_decl_file ("/tmp/test.c")
DW_AT_decl_line (5)
DW_AT_type (0x0000004b "int")

I'm not 100% sure that omitting the DW_AT_abstract_origin is a bug.
However, the DWARF 5 spec states in Section 3.3.8.2 that

A concrete instance tree may contain entries which do not correspond to
entries in the abstract instance tree to describe new entities that are specific to
a particular inlined expansion. In that case, they will not have associated
entries in the abstract instance tree, do not contain DW_AT_abstract_origin
attributes, and must contain all their own attributes directly.

If I read this backward, I interpret that an entry without a DW_AT_abstract_origin
attribute denotes an entry that does not exist in the abstract instance tree.
This makes me believe that Clang's behavior is a bug.

When the DW_AT_abstract_origin attribute is missing, a consumer may try
to find the corresponding abstract origin, but this may not be a bullet-proof
process in general. If Clang emitted it explicitly, the association could be
done with precision.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions