The DW_AT_LLVM_stmt_sequence attribute is an attribute that can be added
to a DW_TAG_subprogram DIE to uniquely identify the exact line tables
entries for a given function. This helps when we merge functions in the
same compile unit and end up with multiple sequences in the line table
that describe the same address range. Having this attribute on a
function allows us to select the right line table entries for a
function. This also helps us convert to GSYM and always get the line
tables right.
We have seen a large amount of errors when binaries have
DW_AT_LLVM_stmt_sequence attributes on functions but their values have
invalid .debug_line sequence offsets. When this would happen, the
conversion to GSYM would not emit any line table entries for that
function. This patch tries to use the DW_AT_LLVM_stmt_sequence attribute
when finding all line entries for a function, but it will fall back to
not using and requiring it to be correct. This ensures we always get the
most information in the GSYM even when DW_AT_LLVM_stmt_sequence values
are not valid. Others are working on fixing the compiler or LTO/Bolt
issues that cause invalid DW_AT_LLVM_stmt_sequence values to be in a
final executable, but this patch will help track and mitigate the issue.