Skip to content

Commit

Permalink
Add support for DW_FORM_GNU_[addr,str]_index
Browse files Browse the repository at this point in the history
These are 2 new value currently in experimental status used when split
debug info is enabled.

Differential revision: http://reviews.llvm.org/D12238

llvm-svn: 245931
  • Loading branch information
Tamas Berghammer committed Aug 25, 2015
1 parent b7c6465 commit c178d4c
Show file tree
Hide file tree
Showing 17 changed files with 208 additions and 120 deletions.
2 changes: 2 additions & 0 deletions lldb/include/lldb/lldb-enumerations.h
Expand Up @@ -595,6 +595,7 @@ namespace lldb {
eSectionTypeDataObjCMessageRefs, // Pointer to function pointer + selector
eSectionTypeDataObjCCFStrings, // Objective C const CFString/NSString objects
eSectionTypeDWARFDebugAbbrev,
eSectionTypeDWARFDebugAddr,
eSectionTypeDWARFDebugAranges,
eSectionTypeDWARFDebugFrame,
eSectionTypeDWARFDebugInfo,
Expand All @@ -605,6 +606,7 @@ namespace lldb {
eSectionTypeDWARFDebugPubTypes,
eSectionTypeDWARFDebugRanges,
eSectionTypeDWARFDebugStr,
eSectionTypeDWARFDebugStrOffsets,
eSectionTypeDWARFAppleNames,
eSectionTypeDWARFAppleTypes,
eSectionTypeDWARFAppleNamespaces,
Expand Down
6 changes: 6 additions & 0 deletions lldb/source/Expression/IRExecutionUnit.cpp
Expand Up @@ -488,6 +488,8 @@ IRExecutionUnit::GetSectionTypeFromSectionName (const llvm::StringRef &name, IRE
sect_type = lldb::eSectionTypeDWARFDebugAbbrev;
else if (dwarf_name.equals("aranges"))
sect_type = lldb::eSectionTypeDWARFDebugAranges;
else if (dwarf_name.equals("addr"))
sect_type = lldb::eSectionTypeDWARFDebugAddr;
break;

case 'f':
Expand Down Expand Up @@ -522,6 +524,8 @@ IRExecutionUnit::GetSectionTypeFromSectionName (const llvm::StringRef &name, IRE
case 's':
if (dwarf_name.equals("str"))
sect_type = lldb::eSectionTypeDWARFDebugStr;
else if (dwarf_name.equals("str_offsets"))
sect_type = lldb::eSectionTypeDWARFDebugStrOffsets;
break;

case 'r':
Expand Down Expand Up @@ -789,6 +793,7 @@ IRExecutionUnit::CommitAllocations (lldb::ProcessSP &process_sp)
{
case lldb::eSectionTypeInvalid:
case lldb::eSectionTypeDWARFDebugAbbrev:
case lldb::eSectionTypeDWARFDebugAddr:
case lldb::eSectionTypeDWARFDebugAranges:
case lldb::eSectionTypeDWARFDebugFrame:
case lldb::eSectionTypeDWARFDebugInfo:
Expand All @@ -799,6 +804,7 @@ IRExecutionUnit::CommitAllocations (lldb::ProcessSP &process_sp)
case lldb::eSectionTypeDWARFDebugPubTypes:
case lldb::eSectionTypeDWARFDebugRanges:
case lldb::eSectionTypeDWARFDebugStr:
case lldb::eSectionTypeDWARFDebugStrOffsets:
case lldb::eSectionTypeDWARFAppleNames:
case lldb::eSectionTypeDWARFAppleTypes:
case lldb::eSectionTypeDWARFAppleNamespaces:
Expand Down
36 changes: 21 additions & 15 deletions lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
Expand Up @@ -1672,6 +1672,7 @@ ObjectFileELF::CreateSections(SectionList &unified_section_list)
static ConstString g_sect_name_tdata (".tdata");
static ConstString g_sect_name_tbss (".tbss");
static ConstString g_sect_name_dwarf_debug_abbrev (".debug_abbrev");
static ConstString g_sect_name_dwarf_debug_addr (".debug_addr");
static ConstString g_sect_name_dwarf_debug_aranges (".debug_aranges");
static ConstString g_sect_name_dwarf_debug_frame (".debug_frame");
static ConstString g_sect_name_dwarf_debug_info (".debug_info");
Expand All @@ -1682,6 +1683,7 @@ ObjectFileELF::CreateSections(SectionList &unified_section_list)
static ConstString g_sect_name_dwarf_debug_pubtypes (".debug_pubtypes");
static ConstString g_sect_name_dwarf_debug_ranges (".debug_ranges");
static ConstString g_sect_name_dwarf_debug_str (".debug_str");
static ConstString g_sect_name_dwarf_debug_str_offsets (".debug_str_offsets");
static ConstString g_sect_name_eh_frame (".eh_frame");

SectionType sect_type = eSectionTypeOther;
Expand Down Expand Up @@ -1715,18 +1717,20 @@ ObjectFileELF::CreateSections(SectionList &unified_section_list)
// MISSING? .gnu_debugdata - "mini debuginfo / MiniDebugInfo" section, http://sourceware.org/gdb/onlinedocs/gdb/MiniDebugInfo.html
// MISSING? .debug-index - http://src.chromium.org/viewvc/chrome/trunk/src/build/gdb-add-index?pathrev=144644
// MISSING? .debug_types - Type descriptions from DWARF 4? See http://gcc.gnu.org/wiki/DwarfSeparateTypeInfo
else if (name == g_sect_name_dwarf_debug_abbrev) sect_type = eSectionTypeDWARFDebugAbbrev;
else if (name == g_sect_name_dwarf_debug_aranges) sect_type = eSectionTypeDWARFDebugAranges;
else if (name == g_sect_name_dwarf_debug_frame) sect_type = eSectionTypeDWARFDebugFrame;
else if (name == g_sect_name_dwarf_debug_info) sect_type = eSectionTypeDWARFDebugInfo;
else if (name == g_sect_name_dwarf_debug_line) sect_type = eSectionTypeDWARFDebugLine;
else if (name == g_sect_name_dwarf_debug_loc) sect_type = eSectionTypeDWARFDebugLoc;
else if (name == g_sect_name_dwarf_debug_macinfo) sect_type = eSectionTypeDWARFDebugMacInfo;
else if (name == g_sect_name_dwarf_debug_pubnames) sect_type = eSectionTypeDWARFDebugPubNames;
else if (name == g_sect_name_dwarf_debug_pubtypes) sect_type = eSectionTypeDWARFDebugPubTypes;
else if (name == g_sect_name_dwarf_debug_ranges) sect_type = eSectionTypeDWARFDebugRanges;
else if (name == g_sect_name_dwarf_debug_str) sect_type = eSectionTypeDWARFDebugStr;
else if (name == g_sect_name_eh_frame) sect_type = eSectionTypeEHFrame;
else if (name == g_sect_name_dwarf_debug_abbrev) sect_type = eSectionTypeDWARFDebugAbbrev;
else if (name == g_sect_name_dwarf_debug_addr) sect_type = eSectionTypeDWARFDebugAddr;
else if (name == g_sect_name_dwarf_debug_aranges) sect_type = eSectionTypeDWARFDebugAranges;
else if (name == g_sect_name_dwarf_debug_frame) sect_type = eSectionTypeDWARFDebugFrame;
else if (name == g_sect_name_dwarf_debug_info) sect_type = eSectionTypeDWARFDebugInfo;
else if (name == g_sect_name_dwarf_debug_line) sect_type = eSectionTypeDWARFDebugLine;
else if (name == g_sect_name_dwarf_debug_loc) sect_type = eSectionTypeDWARFDebugLoc;
else if (name == g_sect_name_dwarf_debug_macinfo) sect_type = eSectionTypeDWARFDebugMacInfo;
else if (name == g_sect_name_dwarf_debug_pubnames) sect_type = eSectionTypeDWARFDebugPubNames;
else if (name == g_sect_name_dwarf_debug_pubtypes) sect_type = eSectionTypeDWARFDebugPubTypes;
else if (name == g_sect_name_dwarf_debug_ranges) sect_type = eSectionTypeDWARFDebugRanges;
else if (name == g_sect_name_dwarf_debug_str) sect_type = eSectionTypeDWARFDebugStr;
else if (name == g_sect_name_dwarf_debug_str_offsets) sect_type = eSectionTypeDWARFDebugStrOffsets;
else if (name == g_sect_name_eh_frame) sect_type = eSectionTypeEHFrame;

switch (header.sh_type)
{
Expand Down Expand Up @@ -1791,17 +1795,19 @@ ObjectFileELF::CreateSections(SectionList &unified_section_list)
{
static const SectionType g_sections[] =
{
eSectionTypeDWARFDebugAranges,
eSectionTypeDWARFDebugInfo,
eSectionTypeDWARFDebugAbbrev,
eSectionTypeDWARFDebugAddr,
eSectionTypeDWARFDebugAranges,
eSectionTypeDWARFDebugFrame,
eSectionTypeDWARFDebugInfo,
eSectionTypeDWARFDebugLine,
eSectionTypeDWARFDebugStr,
eSectionTypeDWARFDebugLoc,
eSectionTypeDWARFDebugMacInfo,
eSectionTypeDWARFDebugPubNames,
eSectionTypeDWARFDebugPubTypes,
eSectionTypeDWARFDebugRanges,
eSectionTypeDWARFDebugStr,
eSectionTypeDWARFDebugStrOffsets,
eSectionTypeELFSymbolTable,
};
SectionList *elf_section_list = m_sections_ap.get();
Expand Down
2 changes: 2 additions & 0 deletions lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
Expand Up @@ -1322,6 +1322,7 @@ ObjectFileMachO::GetAddressClass (lldb::addr_t file_addr)

case eSectionTypeDebug:
case eSectionTypeDWARFDebugAbbrev:
case eSectionTypeDWARFDebugAddr:
case eSectionTypeDWARFDebugAranges:
case eSectionTypeDWARFDebugFrame:
case eSectionTypeDWARFDebugInfo:
Expand All @@ -1332,6 +1333,7 @@ ObjectFileMachO::GetAddressClass (lldb::addr_t file_addr)
case eSectionTypeDWARFDebugPubTypes:
case eSectionTypeDWARFDebugRanges:
case eSectionTypeDWARFDebugStr:
case eSectionTypeDWARFDebugStrOffsets:
case eSectionTypeDWARFAppleNames:
case eSectionTypeDWARFAppleTypes:
case eSectionTypeDWARFAppleNamespaces:
Expand Down
6 changes: 2 additions & 4 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
Expand Up @@ -660,8 +660,6 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
NameToDIE& types,
NameToDIE& namespaces)
{
const DWARFDataExtractor* debug_str = &m_dwarf2Data->get_debug_str_data();

DWARFFormValue::FixedFormSizes fixed_form_sizes =
DWARFFormValue::GetFixedFormSizesForAddressSize (GetAddressByteSize(), m_is_dwarf64);

Expand Down Expand Up @@ -727,7 +725,7 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
{
case DW_AT_name:
if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
name = form_value.AsCString(debug_str);
name = form_value.AsCString(m_dwarf2Data);
break;

case DW_AT_declaration:
Expand All @@ -743,7 +741,7 @@ DWARFCompileUnit::Index (const uint32_t cu_idx,
case DW_AT_MIPS_linkage_name:
case DW_AT_linkage_name:
if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
mangled_cstr = form_value.AsCString(debug_str);
mangled_cstr = form_value.AsCString(m_dwarf2Data);
break;

case DW_AT_low_pc:
Expand Down
1 change: 1 addition & 0 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
Expand Up @@ -53,6 +53,7 @@ class DWARFCompileUnit
dw_offset_t GetAbbrevOffset() const;
uint8_t GetAddressByteSize() const { return m_addr_size; }
dw_addr_t GetBaseAddress() const { return m_base_addr; }
dw_addr_t GetAddrBase() const { return 0; } // TODO: Read out DW_AT_addr_base from the parent compile unit
void ClearDIEs(bool keep_compile_unit_die);
void BuildAddressRangeTable (SymbolFileDWARF* dwarf2Data,
DWARFDebugAranges* debug_aranges);
Expand Down
68 changes: 36 additions & 32 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
Expand Up @@ -226,9 +226,11 @@ DWARFDebugInfoEntry::FastExtract
break;

// signed or unsigned LEB 128 values
case DW_FORM_sdata :
case DW_FORM_udata :
case DW_FORM_ref_udata :
case DW_FORM_sdata :
case DW_FORM_udata :
case DW_FORM_ref_udata :
case DW_FORM_GNU_addr_index:
case DW_FORM_GNU_str_index :
debug_info_data.Skip_LEB128 (&offset);
break;

Expand Down Expand Up @@ -389,9 +391,11 @@ DWARFDebugInfoEntry::Extract
break;

// signed or unsigned LEB 128 values
case DW_FORM_sdata :
case DW_FORM_udata :
case DW_FORM_ref_udata :
case DW_FORM_sdata :
case DW_FORM_udata :
case DW_FORM_ref_udata :
case DW_FORM_GNU_addr_index:
case DW_FORM_GNU_str_index :
debug_info_data.Skip_LEB128(&offset);
break;

Expand Down Expand Up @@ -819,13 +823,13 @@ DWARFDebugInfoEntry::GetDIENamesAndRanges

case DW_AT_name:
if (name == NULL)
name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
name = form_value.AsCString(dwarf2Data);
break;

case DW_AT_MIPS_linkage_name:
case DW_AT_linkage_name:
if (mangled == NULL)
mangled = form_value.AsCString(&dwarf2Data->get_debug_str_data());
mangled = form_value.AsCString(dwarf2Data);
break;

case DW_AT_abstract_origin:
Expand Down Expand Up @@ -1062,7 +1066,6 @@ DWARFDebugInfoEntry::DumpAttribute
bool verbose = s.GetVerbose();
bool show_form = s.GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowForm);

const DWARFDataExtractor* debug_str_data = dwarf2Data ? &dwarf2Data->get_debug_str_data() : NULL;
if (verbose)
s.Offset (*offset_ptr);
else
Expand Down Expand Up @@ -1094,7 +1097,7 @@ DWARFDebugInfoEntry::DumpAttribute
// Always dump form value if verbose is enabled
if (verbose)
{
form_value.Dump(s, debug_str_data);
form_value.Dump(s, dwarf2Data);
}


Expand Down Expand Up @@ -1127,7 +1130,7 @@ DWARFDebugInfoEntry::DumpAttribute
if (blockData)
{
if (!verbose)
form_value.Dump(s, debug_str_data);
form_value.Dump(s, dwarf2Data);

// Location description is inlined in data in the form value
DWARFDataExtractor locationData(debug_info_data, (*offset_ptr) - form_value.Unsigned(), form_value.Unsigned());
Expand All @@ -1144,7 +1147,7 @@ DWARFDebugInfoEntry::DumpAttribute
if (dwarf2Data)
{
if ( !verbose )
form_value.Dump(s, debug_str_data);
form_value.Dump(s, dwarf2Data);
DWARFLocationList::Dump(s, cu, dwarf2Data->get_debug_loc_data(), debug_loc_offset);
}
else
Expand All @@ -1160,7 +1163,7 @@ DWARFDebugInfoEntry::DumpAttribute
case DW_AT_specification:
{
uint64_t abstract_die_offset = form_value.Reference();
form_value.Dump(s, debug_str_data);
form_value.Dump(s, dwarf2Data);
// *ostrm_ptr << HEX32 << abstract_die_offset << " ( ";
if ( verbose ) s.PutCString(" ( ");
GetName(dwarf2Data, cu, abstract_die_offset, s);
Expand All @@ -1172,7 +1175,7 @@ DWARFDebugInfoEntry::DumpAttribute
{
uint64_t type_die_offset = form_value.Reference();
if (!verbose)
form_value.Dump(s, debug_str_data);
form_value.Dump(s, dwarf2Data);
s.PutCString(" ( ");
AppendTypeName(dwarf2Data, cu, type_die_offset, s);
s.PutCString(" )");
Expand All @@ -1182,7 +1185,7 @@ DWARFDebugInfoEntry::DumpAttribute
case DW_AT_ranges:
{
if ( !verbose )
form_value.Dump(s, debug_str_data);
form_value.Dump(s, dwarf2Data);
lldb::offset_t ranges_offset = form_value.Unsigned();
dw_addr_t base_addr = cu ? cu->GetBaseAddress() : 0;
if (dwarf2Data)
Expand All @@ -1192,7 +1195,7 @@ DWARFDebugInfoEntry::DumpAttribute

default:
if ( !verbose )
form_value.Dump(s, debug_str_data);
form_value.Dump(s, dwarf2Data);
break;
}

Expand Down Expand Up @@ -1360,7 +1363,7 @@ DWARFDebugInfoEntry::GetAttributeValueAsString
{
DWARFFormValue form_value;
if (GetAttributeValue(dwarf2Data, cu, attr, form_value))
return form_value.AsCString(&dwarf2Data->get_debug_str_data());
return form_value.AsCString(dwarf2Data);
return fail_value;
}

Expand Down Expand Up @@ -1443,13 +1446,14 @@ DWARFDebugInfoEntry::GetAttributeHighPC
) const
{
DWARFFormValue form_value;

if (GetAttributeValue(dwarf2Data, cu, DW_AT_high_pc, form_value))
{
dw_addr_t hi_pc = form_value.Unsigned();
if (form_value.Form() != DW_FORM_addr)
hi_pc += lo_pc; // DWARF4 can specify the hi_pc as an <offset-from-lowpc>
return hi_pc;
dw_form_t form = form_value.Form();
if (form == DW_FORM_addr || form == DW_FORM_GNU_addr_index)
return form_value.Address(dwarf2Data);

// DWARF4 can specify the hi_pc as an <offset-from-lowpc>
return lo_pc + form_value.Unsigned();
}
return fail_value;
}
Expand Down Expand Up @@ -1582,7 +1586,7 @@ DWARFDebugInfoEntry::GetName
{
DWARFFormValue form_value;
if (GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value))
return form_value.AsCString(&dwarf2Data->get_debug_str_data());
return form_value.AsCString(dwarf2Data);
else if (GetAttributeValue(dwarf2Data, cu, DW_AT_specification, form_value))
{
DWARFCompileUnitSP cu_sp_ptr;
Expand Down Expand Up @@ -1615,19 +1619,19 @@ DWARFDebugInfoEntry::GetMangledName
bool substitute_name_allowed
) const
{
const char* name = NULL;
const char* name = nullptr;
DWARFFormValue form_value;

if (GetAttributeValue(dwarf2Data, cu, DW_AT_MIPS_linkage_name, form_value))
name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
name = form_value.AsCString(dwarf2Data);

if (GetAttributeValue(dwarf2Data, cu, DW_AT_linkage_name, form_value))
name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
name = form_value.AsCString(dwarf2Data);

if (substitute_name_allowed && name == NULL)
if (substitute_name_allowed && name == nullptr)
{
if (GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value))
name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
name = form_value.AsCString(dwarf2Data);
}
return name;
}
Expand All @@ -1653,11 +1657,11 @@ DWARFDebugInfoEntry::GetPubname
DWARFFormValue form_value;

if (GetAttributeValue(dwarf2Data, cu, DW_AT_MIPS_linkage_name, form_value))
name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
name = form_value.AsCString(dwarf2Data);
else if (GetAttributeValue(dwarf2Data, cu, DW_AT_linkage_name, form_value))
name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
name = form_value.AsCString(dwarf2Data);
else if (GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value))
name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
name = form_value.AsCString(dwarf2Data);
else if (GetAttributeValue(dwarf2Data, cu, DW_AT_specification, form_value))
{
// The specification DIE may be in another compile unit so we need
Expand Down Expand Up @@ -1709,7 +1713,7 @@ DWARFDebugInfoEntry::GetName
DWARFFormValue form_value;
if (die.GetAttributeValue(dwarf2Data, cu, DW_AT_name, form_value))
{
const char* name = form_value.AsCString(&dwarf2Data->get_debug_str_data());
const char* name = form_value.AsCString(dwarf2Data);
if (name)
{
s.PutCString(name);
Expand Down

0 comments on commit c178d4c

Please sign in to comment.