Fix fallback code that gets decl file + line.
authorGreg Clayton <gclayton@fb.com>
Fri, 20 Aug 2021 23:36:06 +0000 (16:36 -0700)
committerGreg Clayton <gclayton@fb.com>
Mon, 23 Aug 2021 18:06:15 +0000 (11:06 -0700)
commite100a41bbe61713b25abf27216775334585b477c
tree18b1a1c81c1144f5240533a02ad8a7ff73c1d87c
parenta2c8e176580867bec9897761079343451d0f6287
Fix fallback code that gets decl file + line.

When a function has no line table, but does have debug info (DW_TAG_subprogram), we fall back to creating a line table with a single line entry that has the start address of the function and the source file and line of the function declaration. The bug in this code was that we might have a DW_TAG_subprogram that uses a DW_AT_specification or DW_AT_abstract_origin that points to another DIE, and that DIE might be in another compile unit. The bug was we were grabbing the file index value from the DIE, and that index could be from the other DIE in another compile unit that has its own and compleltely different file table, so we might be using a file index from one compile unit with the file table from another. This was causing a crash in llvm-gsymuil when run against dSYM files. dsymutil, the Apple DWARF linker, will often unique types and can end up with more absolute references across different compile units.

The fix is to use the DWARFDie::getDeclFile(...) accessor as it does fetch this information correctly.

Differential Revision: https://reviews.llvm.org/D108497
llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp