diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index 26b2d77a4453..203068515527 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -74,13 +74,6 @@ SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap(SymbolFileDWARFDebugMa Symtab *exe_symtab = exe_symfile->GetObjectFile()->GetSymtab(); ModuleSP oso_module_sp (oso_objfile->GetModule()); Symtab *oso_symtab = oso_objfile->GetSymtab(); -#if defined(DEBUG_OSO_DMAP) - StreamFile s(stdout, false); - s << "OSO symtab:\n"; - oso_symtab->Dump(&s, NULL, eSortOrderNone); - s << "OSO sections before:\n"; - oso_objfile->GetSectionList()->Dump(&s, NULL, true, UINT32_MAX); -#endif ///const uint32_t fun_resolve_flags = SymbolContext::Module | eSymbolContextCompUnit | eSymbolContextFunction; //SectionList *oso_sections = oso_objfile->Sections(); @@ -171,10 +164,6 @@ SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap(SymbolFileDWARFDebugMa } exe_symfile->FinalizeOSOFileRanges (this); -#if defined(DEBUG_OSO_DMAP) - s << "OSO sections after:\n"; - oso_objfile->GetSectionList()->Dump(&s, NULL, true, UINT32_MAX); -#endif // We don't need the symbols anymore for the .o files oso_objfile->ClearSymtab(); } @@ -378,15 +367,7 @@ SymbolFileDWARFDebugMap::InitOSO() } m_debug_map.Sort(); -#if defined(DEBUG_OSO_DMAP) - StreamFile s(stdout, false); - symtab->Dump(&s, NULL, m_func_indexes); - symtab->Dump(&s, NULL, m_glob_indexes); -#endif m_compile_unit_infos.resize(oso_index_count); - -// s.Printf("%s N_OSO symbols:\n", __PRETTY_FUNCTION__); -// symtab->Dump(&s, oso_indexes); for (uint32_t i=0; iGetFileRangeMap(this); const size_t n = oso_file_range_map.GetSize(); - printf ("SymbolFileDWARFDebugMap::FinalizeOSOFileRanges (cu_info = %p)\n", cu_info); + printf ("SymbolFileDWARFDebugMap::FinalizeOSOFileRanges (cu_info = %p) %s/%s\n", + cu_info, + cu_info->oso_sp->module_sp->GetFileSpec().GetDirectory().GetCString(), + cu_info->oso_sp->module_sp->GetFileSpec().GetFilename().GetCString()); for (size_t i=0; iGetRangeBase() + file_range_entry->data; -// if (linked_file_addr == 0x000000000128b7d5) -// puts("remove this"); - sequence.m_entries.back().file_addr = linked_file_addr; + entry_linked_file_addr = entry.file_addr - file_range_entry->GetRangeBase() + file_range_entry->data; + // Determine if we need to terminate the previous entry when the previous + // entry was not contguous with this one after being linked. + if (range_changed && prev_file_range_entry) + { + prev_end_entry_linked_file_addr = std::min(entry.file_addr, prev_file_range_entry->GetRangeEnd()) - prev_file_range_entry->GetRangeBase() + prev_file_range_entry->data; + if (prev_end_entry_linked_file_addr != entry_linked_file_addr) + terminate_previous_entry = true; + } } else if (prev_entry_was_linked) { @@ -528,14 +536,33 @@ LineTable::LinkLineTable (const FileRangeMap &file_range_map) !sequence.m_entries.empty() && !sequence.m_entries.back().is_terminal_entry) { - assert (prev_file_addr != LLDB_INVALID_ADDRESS); - sequence.m_entries.push_back(sequence.m_entries.back()); - const lldb::addr_t linked_file_addr = std::min(entry.file_addr,prev_file_range_entry->GetRangeEnd()) - prev_file_range_entry->GetRangeBase() + prev_file_range_entry->data; - sequence.m_entries.back().file_addr = linked_file_addr; - sequence.m_entries.back().is_terminal_entry = true; + terminate_previous_entry = true; } } + if (terminate_previous_entry) + { + assert (prev_file_addr != LLDB_INVALID_ADDRESS); + sequence.m_entries.push_back(sequence.m_entries.back()); + if (prev_end_entry_linked_file_addr == LLDB_INVALID_ADDRESS) + prev_end_entry_linked_file_addr = std::min(entry.file_addr,prev_file_range_entry->GetRangeEnd()) - prev_file_range_entry->GetRangeBase() + prev_file_range_entry->data; + sequence.m_entries.back().file_addr = prev_end_entry_linked_file_addr; + sequence.m_entries.back().is_terminal_entry = true; + + // Append the sequence since we just terminated the previous one + line_table_ap->InsertSequence (&sequence); + sequence.Clear(); + prev_entry_was_linked = false; + } + + // Now link the current entry + if (file_range_entry) + { + // This entry has an address remapping and it needs to have its address relinked + sequence.m_entries.push_back(entry); + sequence.m_entries.back().file_addr = entry_linked_file_addr; + } + // If we have items in the sequence and the last entry is a terminal entry, // insert this sequence into our new line table. if (!sequence.m_entries.empty() && sequence.m_entries.back().is_terminal_entry) @@ -543,13 +570,13 @@ LineTable::LinkLineTable (const FileRangeMap &file_range_map) line_table_ap->InsertSequence (&sequence); sequence.Clear(); prev_entry_was_linked = false; - prev_file_addr = LLDB_INVALID_ADDRESS; } else { prev_entry_was_linked = file_range_entry != NULL; - prev_file_addr = entry.file_addr; } + prev_file_addr = entry.file_addr; + range_changed = false; } if (line_table_ap->m_entries.empty()) return NULL;