Index: source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp @@ -446,26 +446,39 @@ const lldb::ModuleSP &module_sp, const DWARFDataExtractor &debug_line_data, const lldb_private::FileSpec &cu_comp_dir, dw_offset_t stmt_list, FileSpecList &support_files) { + lldb::offset_t data_end = debug_line_data.GetByteSize(); lldb::offset_t offset = stmt_list; - Prologue prologue; - if (!ParsePrologue(debug_line_data, &offset, &prologue)) { - Host::SystemLog(Host::eSystemLogError, "error: parsing line table prologue " - "at 0x%8.8x (parsing ended around " - "0x%8.8" PRIx64 "\n", - stmt_list, offset); - return false; - } + // This loop runs once for regular compile units and may run multiple times + // for LTO optimized ones. + do { + Prologue prologue; + lldb::offset_t prologue_start = offset; + + if (!ParsePrologue(debug_line_data, &offset, &prologue)) { + Host::SystemLog(Host::eSystemLogError, "error: parsing line table prologue " + "at 0x%8.8x (parsing ended around " + "0x%8.8" PRIx64 "\n", + stmt_list, offset); + return false; + } - FileSpec file_spec; - std::string remapped_file; + FileSpec file_spec; + std::string remapped_file; + + for (uint32_t file_idx = 1; + prologue.GetFile(file_idx, cu_comp_dir, file_spec); ++file_idx) { + if (module_sp->RemapSourceFile(file_spec.GetPath(), remapped_file)) + file_spec.SetFile(remapped_file, false, FileSpec::Style::native); + support_files.Append(file_spec); + } + + // We don't parse the entire prologue, but skip the statement program. + // The prologue's total_length does not include the length field itself. + // It can be 4 or 8 bytes, see DWARFDataExtractor::GetDWARFInitialLength(). + offset = prologue_start + prologue.total_length + 4; + } while (offset < data_end); - for (uint32_t file_idx = 1; - prologue.GetFile(file_idx, cu_comp_dir, file_spec); ++file_idx) { - if (module_sp->RemapSourceFile(file_spec.GetPath(), remapped_file)) - file_spec.SetFile(remapped_file, false, FileSpec::Style::native); - support_files.Append(file_spec); - } return true; }