forked from OSchip/llvm-project
<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:
parent
4e7511efc7
commit
084fad6a51
|
@ -74,13 +74,6 @@ SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap(SymbolFileDWARFDebugMa
|
||||||
Symtab *exe_symtab = exe_symfile->GetObjectFile()->GetSymtab();
|
Symtab *exe_symtab = exe_symfile->GetObjectFile()->GetSymtab();
|
||||||
ModuleSP oso_module_sp (oso_objfile->GetModule());
|
ModuleSP oso_module_sp (oso_objfile->GetModule());
|
||||||
Symtab *oso_symtab = oso_objfile->GetSymtab();
|
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;
|
///const uint32_t fun_resolve_flags = SymbolContext::Module | eSymbolContextCompUnit | eSymbolContextFunction;
|
||||||
//SectionList *oso_sections = oso_objfile->Sections();
|
//SectionList *oso_sections = oso_objfile->Sections();
|
||||||
|
@ -171,10 +164,6 @@ SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap(SymbolFileDWARFDebugMa
|
||||||
}
|
}
|
||||||
|
|
||||||
exe_symfile->FinalizeOSOFileRanges (this);
|
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
|
// We don't need the symbols anymore for the .o files
|
||||||
oso_objfile->ClearSymtab();
|
oso_objfile->ClearSymtab();
|
||||||
}
|
}
|
||||||
|
@ -378,16 +367,8 @@ SymbolFileDWARFDebugMap::InitOSO()
|
||||||
}
|
}
|
||||||
m_debug_map.Sort();
|
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);
|
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)
|
for (uint32_t i=0; i<oso_index_count; ++i)
|
||||||
{
|
{
|
||||||
const uint32_t so_idx = oso_indexes[i] - 1;
|
const uint32_t so_idx = oso_indexes[i] - 1;
|
||||||
|
@ -1430,7 +1411,10 @@ SymbolFileDWARFDebugMap::FinalizeOSOFileRanges (CompileUnitInfo *cu_info)
|
||||||
#if defined(DEBUG_OSO_DMAP)
|
#if defined(DEBUG_OSO_DMAP)
|
||||||
const FileRangeMap &oso_file_range_map = cu_info->GetFileRangeMap(this);
|
const FileRangeMap &oso_file_range_map = cu_info->GetFileRangeMap(this);
|
||||||
const size_t n = oso_file_range_map.GetSize();
|
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)
|
for (size_t i=0; i<n; ++i)
|
||||||
{
|
{
|
||||||
const FileRangeMap::Entry &entry = oso_file_range_map.GetEntryRef(i);
|
const FileRangeMap::Entry &entry = oso_file_range_map.GetEntryRef(i);
|
||||||
|
|
|
@ -497,6 +497,7 @@ LineTable::LinkLineTable (const FileRangeMap &file_range_map)
|
||||||
const FileRangeMap::Entry *prev_file_range_entry = NULL;
|
const FileRangeMap::Entry *prev_file_range_entry = NULL;
|
||||||
lldb::addr_t prev_file_addr = LLDB_INVALID_ADDRESS;
|
lldb::addr_t prev_file_addr = LLDB_INVALID_ADDRESS;
|
||||||
bool prev_entry_was_linked = false;
|
bool prev_entry_was_linked = false;
|
||||||
|
bool range_changed = false;
|
||||||
for (size_t idx = 0; idx < count; ++idx)
|
for (size_t idx = 0; idx < count; ++idx)
|
||||||
{
|
{
|
||||||
const Entry& entry = m_entries[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;
|
prev_file_range_entry = file_range_entry;
|
||||||
file_range_entry = file_range_map.FindEntryThatContains(lookup_file_addr);
|
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)
|
if (file_range_entry)
|
||||||
{
|
{
|
||||||
// This entry has an address remapping and it needs to have its address relinked
|
entry_linked_file_addr = entry.file_addr - file_range_entry->GetRangeBase() + file_range_entry->data;
|
||||||
sequence.m_entries.push_back(entry);
|
// Determine if we need to terminate the previous entry when the previous
|
||||||
// Fix tha addresss
|
// entry was not contguous with this one after being linked.
|
||||||
const lldb::addr_t linked_file_addr = entry.file_addr - file_range_entry->GetRangeBase() + file_range_entry->data;
|
if (range_changed && prev_file_range_entry)
|
||||||
// if (linked_file_addr == 0x000000000128b7d5)
|
{
|
||||||
// puts("remove this");
|
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 = linked_file_addr;
|
if (prev_end_entry_linked_file_addr != entry_linked_file_addr)
|
||||||
|
terminate_previous_entry = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (prev_entry_was_linked)
|
else if (prev_entry_was_linked)
|
||||||
{
|
{
|
||||||
|
@ -527,13 +535,32 @@ LineTable::LinkLineTable (const FileRangeMap &file_range_map)
|
||||||
if (!entry.is_terminal_entry &&
|
if (!entry.is_terminal_entry &&
|
||||||
!sequence.m_entries.empty() &&
|
!sequence.m_entries.empty() &&
|
||||||
!sequence.m_entries.back().is_terminal_entry)
|
!sequence.m_entries.back().is_terminal_entry)
|
||||||
|
{
|
||||||
|
terminate_previous_entry = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (terminate_previous_entry)
|
||||||
{
|
{
|
||||||
assert (prev_file_addr != LLDB_INVALID_ADDRESS);
|
assert (prev_file_addr != LLDB_INVALID_ADDRESS);
|
||||||
sequence.m_entries.push_back(sequence.m_entries.back());
|
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;
|
if (prev_end_entry_linked_file_addr == LLDB_INVALID_ADDRESS)
|
||||||
sequence.m_entries.back().file_addr = linked_file_addr;
|
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;
|
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,
|
// If we have items in the sequence and the last entry is a terminal entry,
|
||||||
|
@ -543,13 +570,13 @@ LineTable::LinkLineTable (const FileRangeMap &file_range_map)
|
||||||
line_table_ap->InsertSequence (&sequence);
|
line_table_ap->InsertSequence (&sequence);
|
||||||
sequence.Clear();
|
sequence.Clear();
|
||||||
prev_entry_was_linked = false;
|
prev_entry_was_linked = false;
|
||||||
prev_file_addr = LLDB_INVALID_ADDRESS;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
prev_entry_was_linked = file_range_entry != NULL;
|
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())
|
if (line_table_ap->m_entries.empty())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue