本文整理汇总了C++中DWARFDataExtractor类的典型用法代码示例。如果您正苦于以下问题:C++ DWARFDataExtractor类的具体用法?C++ DWARFDataExtractor怎么用?C++ DWARFDataExtractor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DWARFDataExtractor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: section_sp
void
SymbolFileDWARFDwo::LoadSectionData (lldb::SectionType sect_type, DWARFDataExtractor& data)
{
const SectionList* section_list = m_obj_file->GetSectionList(false /* update_module_section_list */);
if (section_list)
{
SectionSP section_sp (section_list->FindSectionByType(sect_type, true));
if (section_sp)
{
// See if we memory mapped the DWARF segment?
if (m_dwarf_data.GetByteSize())
{
data.SetData(m_dwarf_data, section_sp->GetOffset(), section_sp->GetFileSize());
return;
}
if (m_obj_file->ReadSectionData(section_sp.get(), data) != 0)
return;
data.Clear();
}
}
SymbolFileDWARF::LoadSectionData(sect_type, data);
}
示例2: while
bool
DWARFAbbreviationDeclaration::Extract(const DWARFDataExtractor& data, lldb::offset_t *offset_ptr, dw_uleb128_t code)
{
m_code = code;
m_attributes.clear();
if (m_code)
{
m_tag = data.GetULEB128(offset_ptr);
m_has_children = data.GetU8(offset_ptr);
while (data.ValidOffset(*offset_ptr))
{
dw_attr_t attr = data.GetULEB128(offset_ptr);
dw_form_t form = data.GetULEB128(offset_ptr);
if (attr && form)
m_attributes.push_back(DWARFAttribute(attr, form));
else
break;
}
return m_tag != 0;
}
else
{
m_tag = 0;
m_has_children = 0;
}
return false;
}
示例3: extract
Error DWARFDebugRangeList::extract(const DWARFDataExtractor &data,
uint32_t *offset_ptr) {
clear();
if (!data.isValidOffset(*offset_ptr))
return createStringError(errc::invalid_argument,
"invalid range list offset 0x%" PRIx32, *offset_ptr);
AddressSize = data.getAddressSize();
if (AddressSize != 4 && AddressSize != 8)
return createStringError(errc::invalid_argument,
"invalid address size: %" PRIu8, AddressSize);
Offset = *offset_ptr;
while (true) {
RangeListEntry Entry;
Entry.SectionIndex = -1ULL;
uint32_t prev_offset = *offset_ptr;
Entry.StartAddress = data.getRelocatedAddress(offset_ptr);
Entry.EndAddress =
data.getRelocatedAddress(offset_ptr, &Entry.SectionIndex);
// Check that both values were extracted correctly.
if (*offset_ptr != prev_offset + 2 * AddressSize) {
clear();
return createStringError(errc::invalid_argument,
"invalid range list entry at offset 0x%" PRIx32,
prev_offset);
}
if (Entry.isEndOfListEntry())
break;
Entries.push_back(Entry);
}
return Error::success();
}
示例4: extract
bool DWARFDebugRangeList::extract(const DWARFDataExtractor &data,
uint32_t *offset_ptr) {
clear();
if (!data.isValidOffset(*offset_ptr))
return false;
AddressSize = data.getAddressSize();
if (AddressSize != 4 && AddressSize != 8)
return false;
Offset = *offset_ptr;
while (true) {
RangeListEntry entry;
uint32_t prev_offset = *offset_ptr;
entry.StartAddress =
data.getRelocatedAddress(offset_ptr, &entry.SectionIndex);
entry.EndAddress = data.getRelocatedAddress(offset_ptr);
// Check that both values were extracted correctly.
if (*offset_ptr != prev_offset + 2 * AddressSize) {
clear();
return false;
}
if (entry.isEndOfListEntry())
break;
Entries.push_back(entry);
}
return true;
}
示例5: parseV2DirFileTables
// Parse v2-v4 directory and file tables.
static void
parseV2DirFileTables(const DWARFDataExtractor &DebugLineData,
uint32_t *OffsetPtr, uint64_t EndPrologueOffset,
DWARFDebugLine::ContentTypeTracker &ContentTypes,
std::vector<DWARFFormValue> &IncludeDirectories,
std::vector<DWARFDebugLine::FileNameEntry> &FileNames) {
while (*OffsetPtr < EndPrologueOffset) {
StringRef S = DebugLineData.getCStrRef(OffsetPtr);
if (S.empty())
break;
DWARFFormValue Dir =
DWARFFormValue::createFromPValue(dwarf::DW_FORM_string, S.data());
IncludeDirectories.push_back(Dir);
}
while (*OffsetPtr < EndPrologueOffset) {
StringRef Name = DebugLineData.getCStrRef(OffsetPtr);
if (Name.empty())
break;
DWARFDebugLine::FileNameEntry FileEntry;
FileEntry.Name =
DWARFFormValue::createFromPValue(dwarf::DW_FORM_string, Name.data());
FileEntry.DirIdx = DebugLineData.getULEB128(OffsetPtr);
FileEntry.ModTime = DebugLineData.getULEB128(OffsetPtr);
FileEntry.Length = DebugLineData.getULEB128(OffsetPtr);
FileNames.push_back(FileEntry);
}
ContentTypes.HasModTime = true;
ContentTypes.HasLength = true;
}
示例6: scoped_timer
bool
DWARFDebugPubnames::Extract(const DWARFDataExtractor& data)
{
Timer scoped_timer (__PRETTY_FUNCTION__,
"DWARFDebugPubnames::Extract (byte_size = %" PRIu64 ")",
(uint64_t)data.GetByteSize());
Log *log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_PUBNAMES));
if (log)
log->Printf("DWARFDebugPubnames::Extract (byte_size = %" PRIu64 ")", (uint64_t)data.GetByteSize());
if (data.ValidOffset(0))
{
lldb::offset_t offset = 0;
DWARFDebugPubnamesSet set;
while (data.ValidOffset(offset))
{
if (set.Extract(data, &offset))
{
m_sets.push_back(set);
offset = set.GetOffsetOfNextEntry();
}
else
break;
}
if (log)
Dump (log);
return true;
}
return false;
}
示例7: extractImpl
bool DWARFTypeUnit::extractImpl(const DWARFDataExtractor &debug_info,
uint32_t *offset_ptr) {
if (!DWARFUnit::extractImpl(debug_info, offset_ptr))
return false;
TypeHash = debug_info.getU64(offset_ptr);
TypeOffset = debug_info.getU32(offset_ptr);
// TypeOffset is relative to the beginning of the header,
// so we have to account for the leading length field.
// FIXME: The size of the length field is 12 in DWARF64.
unsigned SizeOfLength = 4;
return TypeOffset < getLength() + SizeOfLength;
}
示例8: parseDWARF32StringOffsetsTableHeader
// Look for a DWARF32-formatted contribution to the string offsets table
// starting at a given offset and record it in a descriptor.
static Optional<StrOffsetsContributionDescriptor>
parseDWARF32StringOffsetsTableHeader(DWARFDataExtractor &DA, uint32_t Offset) {
if (!DA.isValidOffsetForDataOfSize(Offset, 8))
return None;
uint32_t ContributionSize = DA.getU32(&Offset);
if (ContributionSize >= 0xfffffff0)
return None;
uint8_t Version = DA.getU16(&Offset);
(void)DA.getU16(&Offset); // padding
// The encoded length includes the 2-byte version field and the 2-byte
// padding, so we need to subtract them out when we populate the descriptor.
return {{Offset, ContributionSize - 4, Version, DWARF32}};
}
示例9: parse
void DWARFDebugLoc::parse(const DWARFDataExtractor &data) {
IsLittleEndian = data.isLittleEndian();
AddressSize = data.getAddressSize();
uint32_t Offset = 0;
while (data.isValidOffset(Offset + data.getAddressSize() - 1)) {
if (auto LL = parseOneLocationList(data, &Offset))
Locations.push_back(std::move(*LL));
else
break;
}
if (data.isValidOffset(Offset))
errs() << "error: failed to consume entire .debug_loc section\n";
}
示例10: SkipOperandTable
void DWARFDebugMacroHeader::SkipOperandTable(
const DWARFDataExtractor &debug_macro_data, lldb::offset_t *offset) {
uint8_t entry_count = debug_macro_data.GetU8(offset);
for (uint8_t i = 0; i < entry_count; i++) {
// Skip over the opcode number.
debug_macro_data.GetU8(offset);
uint64_t operand_count = debug_macro_data.GetULEB128(offset);
for (uint64_t j = 0; j < operand_count; j++) {
// Skip over the operand form
debug_macro_data.GetU8(offset);
}
}
}
示例11: parseDWARF64StringOffsetsTableHeader
// Look for a DWARF64-formatted contribution to the string offsets table
// starting at a given offset and record it in a descriptor.
static Optional<StrOffsetsContributionDescriptor>
parseDWARF64StringOffsetsTableHeader(DWARFDataExtractor &DA, uint32_t Offset) {
if (!DA.isValidOffsetForDataOfSize(Offset, 16))
return Optional<StrOffsetsContributionDescriptor>();
if (DA.getU32(&Offset) != 0xffffffff)
return Optional<StrOffsetsContributionDescriptor>();
uint64_t Size = DA.getU64(&Offset);
uint8_t Version = DA.getU16(&Offset);
(void)DA.getU16(&Offset); // padding
// The encoded length includes the 2-byte version field and the 2-byte
// padding, so we need to subtract them out when we populate the descriptor.
return StrOffsetsContributionDescriptor(Offset, Size - 4, Version, DWARF64);
//return Optional<StrOffsetsContributionDescriptor>(Descriptor);
}
示例12: Clear
bool
DWARFCompileUnit::Extract(const DWARFDataExtractor &debug_info, lldb::offset_t *offset_ptr)
{
Clear();
m_offset = *offset_ptr;
if (debug_info.ValidOffset(*offset_ptr))
{
dw_offset_t abbr_offset;
const DWARFDebugAbbrev *abbr = m_dwarf2Data->DebugAbbrev();
m_length = debug_info.GetDWARFInitialLength(offset_ptr);
m_is_dwarf64 = debug_info.IsDWARF64();
m_version = debug_info.GetU16(offset_ptr);
abbr_offset = debug_info.GetDWARFOffset(offset_ptr);
m_addr_size = debug_info.GetU8 (offset_ptr);
bool length_OK = debug_info.ValidOffset(GetNextCompileUnitOffset()-1);
bool version_OK = SymbolFileDWARF::SupportedVersion(m_version);
bool abbr_offset_OK = m_dwarf2Data->get_debug_abbrev_data().ValidOffset(abbr_offset);
bool addr_size_OK = ((m_addr_size == 4) || (m_addr_size == 8));
if (length_OK && version_OK && addr_size_OK && abbr_offset_OK && abbr != NULL)
{
m_abbrevs = abbr->GetAbbreviationDeclarationSet(abbr_offset);
return true;
}
// reset the offset to where we tried to parse from if anything went wrong
*offset_ptr = m_offset;
}
return false;
}
示例13: parseV5EntryFormat
// Parse v5 directory/file entry content descriptions.
// Returns the descriptors, or an empty vector if we did not find a path or
// ran off the end of the prologue.
static ContentDescriptors
parseV5EntryFormat(const DWARFDataExtractor &DebugLineData, uint32_t *OffsetPtr,
uint64_t EndPrologueOffset, bool *HasMD5) {
ContentDescriptors Descriptors;
int FormatCount = DebugLineData.getU8(OffsetPtr);
bool HasPath = false;
for (int I = 0; I != FormatCount; ++I) {
if (*OffsetPtr >= EndPrologueOffset)
return ContentDescriptors();
ContentDescriptor Descriptor;
Descriptor.Type =
dwarf::LineNumberEntryFormat(DebugLineData.getULEB128(OffsetPtr));
Descriptor.Form = dwarf::Form(DebugLineData.getULEB128(OffsetPtr));
if (Descriptor.Type == dwarf::DW_LNCT_path)
HasPath = true;
else if (Descriptor.Type == dwarf::DW_LNCT_MD5 && HasMD5)
*HasMD5 = true;
Descriptors.push_back(Descriptor);
}
return HasPath ? Descriptors : ContentDescriptors();
}
示例14: getDwarfOffsetByteSize
Optional<StrOffsetsContributionDescriptor>
StrOffsetsContributionDescriptor::validateContributionSize(
DWARFDataExtractor &DA) {
uint8_t EntrySize = getDwarfOffsetByteSize();
// In order to ensure that we don't read a partial record at the end of
// the section we validate for a multiple of the entry size.
uint64_t ValidationSize = alignTo(Size, EntrySize);
// Guard against overflow.
if (ValidationSize >= Size)
if (DA.isValidOffsetForDataOfSize((uint32_t)Base, ValidationSize))
return *this;
return Optional<StrOffsetsContributionDescriptor>();
}
示例15: Parse
//----------------------------------------------------------------------
// DWARFDebugAbbrev::Parse()
//----------------------------------------------------------------------
void DWARFDebugAbbrev::Parse(const DWARFDataExtractor &data) {
lldb::offset_t offset = 0;
while (data.ValidOffset(offset)) {
uint32_t initial_cu_offset = offset;
DWARFAbbreviationDeclarationSet abbrevDeclSet;
if (abbrevDeclSet.Extract(data, &offset))
m_abbrevCollMap[initial_cu_offset] = abbrevDeclSet;
else
break;
}
m_prev_abbr_offset_pos = m_abbrevCollMap.end();
}