<rdar://problem/13362109>

LLDB was not parsing line tables correctly for DWARF in .o files after recent debug map changes. This has now been fixed. 

llvm-svn: 176592
This commit is contained in:
Greg Clayton 2013-03-06 23:23:27 +00:00
parent 4e7511efc7
commit 084fad6a51
2 changed files with 46 additions and 35 deletions

View File

@ -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; i<oso_index_count; ++i)
{
@ -1430,7 +1411,10 @@ SymbolFileDWARFDebugMap::FinalizeOSOFileRanges (CompileUnitInfo *cu_info)
#if defined(DEBUG_OSO_DMAP)
const FileRangeMap &oso_file_range_map = cu_info->GetFileRangeMap(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; i<n; ++i)
{
const FileRangeMap::Entry &entry = oso_file_range_map.GetEntryRef(i);

View File

@ -497,6 +497,7 @@ LineTable::LinkLineTable (const FileRangeMap &file_range_map)
const FileRangeMap::Entry *prev_file_range_entry = NULL;
lldb::addr_t prev_file_addr = LLDB_INVALID_ADDRESS;
bool prev_entry_was_linked = false;
bool range_changed = false;
for (size_t idx = 0; idx < count; ++idx)
{
const Entry& entry = m_entries[idx];
@ -507,17 +508,24 @@ LineTable::LinkLineTable (const FileRangeMap &file_range_map)
{
prev_file_range_entry = file_range_entry;
file_range_entry = file_range_map.FindEntryThatContains(lookup_file_addr);
range_changed = true;
}
lldb::addr_t prev_end_entry_linked_file_addr = LLDB_INVALID_ADDRESS;
lldb::addr_t entry_linked_file_addr = LLDB_INVALID_ADDRESS;
bool terminate_previous_entry = false;
if (file_range_entry)
{
// This entry has an address remapping and it needs to have its address relinked
sequence.m_entries.push_back(entry);
// Fix tha addresss
const lldb::addr_t linked_file_addr = entry.file_addr - file_range_entry->GetRangeBase() + 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<lldb::addr_t>(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<lldb::addr_t>(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<lldb::addr_t>(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;