本文整理汇总了C++中DataExtractor::getU8方法的典型用法代码示例。如果您正苦于以下问题:C++ DataExtractor::getU8方法的具体用法?C++ DataExtractor::getU8怎么用?C++ DataExtractor::getU8使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataExtractor
的用法示例。
在下文中一共展示了DataExtractor::getU8方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
bool
DWARFDebugLine::parsePrologue(DataExtractor debug_line_data,
uint32_t *offset_ptr, Prologue *prologue) {
const uint32_t prologue_offset = *offset_ptr;
prologue->clear();
prologue->TotalLength = debug_line_data.getU32(offset_ptr);
prologue->Version = debug_line_data.getU16(offset_ptr);
if (prologue->Version != 2)
return false;
prologue->PrologueLength = debug_line_data.getU32(offset_ptr);
const uint32_t end_prologue_offset = prologue->PrologueLength + *offset_ptr;
prologue->MinInstLength = debug_line_data.getU8(offset_ptr);
prologue->DefaultIsStmt = debug_line_data.getU8(offset_ptr);
prologue->LineBase = debug_line_data.getU8(offset_ptr);
prologue->LineRange = debug_line_data.getU8(offset_ptr);
prologue->OpcodeBase = debug_line_data.getU8(offset_ptr);
prologue->StandardOpcodeLengths.reserve(prologue->OpcodeBase-1);
for (uint32_t i = 1; i < prologue->OpcodeBase; ++i) {
uint8_t op_len = debug_line_data.getU8(offset_ptr);
prologue->StandardOpcodeLengths.push_back(op_len);
}
while (*offset_ptr < end_prologue_offset) {
const char *s = debug_line_data.getCStr(offset_ptr);
if (s && s[0])
prologue->IncludeDirectories.push_back(s);
else
break;
}
while (*offset_ptr < end_prologue_offset) {
const char *name = debug_line_data.getCStr(offset_ptr);
if (name && name[0]) {
FileNameEntry fileEntry;
fileEntry.Name = name;
fileEntry.DirIdx = debug_line_data.getULEB128(offset_ptr);
fileEntry.ModTime = debug_line_data.getULEB128(offset_ptr);
fileEntry.Length = debug_line_data.getULEB128(offset_ptr);
prologue->FileNames.push_back(fileEntry);
} else {
break;
}
}
if (*offset_ptr != end_prologue_offset) {
fprintf(stderr, "warning: parsing line table prologue at 0x%8.8x should"
" have ended at 0x%8.8x but it ended at 0x%8.8x\n",
prologue_offset, end_prologue_offset, *offset_ptr);
return false;
}
return true;
}
示例2: while
bool
DWARFAbbreviationDeclaration::extract(DataExtractor data, uint32_t* offset_ptr,
uint32_t code) {
Code = code;
Attribute.clear();
if (Code) {
Tag = data.getULEB128(offset_ptr);
HasChildren = data.getU8(offset_ptr);
while (data.isValidOffset(*offset_ptr)) {
uint16_t attr = data.getULEB128(offset_ptr);
uint16_t form = data.getULEB128(offset_ptr);
if (attr && form)
Attribute.push_back(DWARFAttribute(attr, form));
else
break;
}
return Tag != 0;
} else {
Tag = 0;
HasChildren = false;
}
return false;
}
示例3: parse
void DWARFDebugLocDWO::parse(DataExtractor data) {
uint32_t Offset = 0;
while (data.isValidOffset(Offset)) {
Locations.resize(Locations.size() + 1);
LocationList &Loc = Locations.back();
Loc.Offset = Offset;
dwarf::LocationListEntry Kind;
while ((Kind = static_cast<dwarf::LocationListEntry>(
data.getU8(&Offset))) != dwarf::DW_LLE_end_of_list) {
if (Kind != dwarf::DW_LLE_startx_length) {
llvm::errs() << "error: dumping support for LLE of kind " << (int)Kind
<< " not implemented\n";
return;
}
Entry E;
E.Start = data.getULEB128(&Offset);
E.Length = data.getU32(&Offset);
unsigned Bytes = data.getU16(&Offset);
// A single location description describing the location of the object...
StringRef str = data.getData().substr(Offset, Bytes);
Offset += Bytes;
E.Loc.resize(str.size());
std::copy(str.begin(), str.end(), E.Loc.begin());
Loc.Entries.push_back(std::move(E));
}
}
}
示例4: extractImpl
bool DWARFUnit::extractImpl(DataExtractor debug_info, uint32_t *offset_ptr) {
Length = debug_info.getU32(offset_ptr);
Version = debug_info.getU16(offset_ptr);
uint64_t AbbrOffset = debug_info.getU32(offset_ptr);
if (IndexEntry) {
if (AbbrOffset)
return false;
auto *UnitContrib = IndexEntry->getOffset();
if (!UnitContrib || UnitContrib->Length != (Length + 4))
return false;
auto *AbbrEntry = IndexEntry->getOffset(DW_SECT_ABBREV);
if (!AbbrEntry)
return false;
AbbrOffset = AbbrEntry->Offset;
}
AddrSize = debug_info.getU8(offset_ptr);
bool LengthOK = debug_info.isValidOffset(getNextUnitOffset() - 1);
bool VersionOK = DWARFContext::isSupportedVersion(Version);
bool AddrSizeOK = AddrSize == 4 || AddrSize == 8;
if (!LengthOK || !VersionOK || !AddrSizeOK)
return false;
Abbrevs = Abbrev->getAbbreviationDeclarationSet(AbbrOffset);
return Abbrevs != nullptr;
}
示例5: while
Optional<DWARFDebugLocDWO::LocationList>
DWARFDebugLocDWO::parseOneLocationList(DataExtractor Data, unsigned *Offset) {
LocationList LL;
LL.Offset = *Offset;
// dwarf::DW_LLE_end_of_list_entry is 0 and indicates the end of the list.
while (auto Kind =
static_cast<dwarf::LocationListEntry>(Data.getU8(Offset))) {
if (Kind != dwarf::DW_LLE_startx_length) {
llvm::errs() << "error: dumping support for LLE of kind " << (int)Kind
<< " not implemented\n";
return None;
}
Entry E;
E.Start = Data.getULEB128(Offset);
E.Length = Data.getU32(Offset);
unsigned Bytes = Data.getU16(Offset);
// A single location description describing the location of the object...
StringRef str = Data.getData().substr(*Offset, Bytes);
*Offset += Bytes;
E.Loc.resize(str.size());
std::copy(str.begin(), str.end(), E.Loc.begin());
LL.Entries.push_back(std::move(E));
}
return LL;
}
示例6: extract
bool DWARFCompileUnit::extract(DataExtractor debug_info, uint32_t *offset_ptr) {
clear();
Offset = *offset_ptr;
if (debug_info.isValidOffset(*offset_ptr)) {
uint64_t abbrOffset;
Length = debug_info.getU32(offset_ptr);
Version = debug_info.getU16(offset_ptr);
abbrOffset = debug_info.getU32(offset_ptr);
AddrSize = debug_info.getU8(offset_ptr);
bool lengthOK = debug_info.isValidOffset(getNextCompileUnitOffset()-1);
bool versionOK = DWARFContext::isSupportedVersion(Version);
bool abbrOffsetOK = AbbrevSection.size() > abbrOffset;
bool addrSizeOK = AddrSize == 4 || AddrSize == 8;
if (lengthOK && versionOK && addrSizeOK && abbrOffsetOK && Abbrev != NULL) {
Abbrevs = Abbrev->getAbbreviationDeclarationSet(abbrOffset);
return true;
}
// reset the offset to where we tried to parse from if anything went wrong
*offset_ptr = Offset;
}
return false;
}
示例7: dumpDataAux
static void LLVM_ATTRIBUTE_UNUSED dumpDataAux(DataExtractor Data,
uint32_t Offset, int Length) {
errs() << "DUMP: ";
for (int i = 0; i < Length; ++i) {
uint8_t c = Data.getU8(&Offset);
errs().write_hex(c); errs() << " ";
}
errs() << "\n";
}
示例8: extractImpl
bool DWARFUnit::extractImpl(DataExtractor debug_info, uint32_t *offset_ptr) {
Length = debug_info.getU32(offset_ptr);
// FIXME: Support DWARF64.
FormParams.Format = DWARF32;
FormParams.Version = debug_info.getU16(offset_ptr);
if (FormParams.Version >= 5) {
UnitType = debug_info.getU8(offset_ptr);
FormParams.AddrSize = debug_info.getU8(offset_ptr);
AbbrOffset = debug_info.getU32(offset_ptr);
} else {
AbbrOffset = debug_info.getU32(offset_ptr);
FormParams.AddrSize = debug_info.getU8(offset_ptr);
}
if (IndexEntry) {
if (AbbrOffset)
return false;
auto *UnitContrib = IndexEntry->getOffset();
if (!UnitContrib || UnitContrib->Length != (Length + 4))
return false;
auto *AbbrEntry = IndexEntry->getOffset(DW_SECT_ABBREV);
if (!AbbrEntry)
return false;
AbbrOffset = AbbrEntry->Offset;
}
bool LengthOK = debug_info.isValidOffset(getNextUnitOffset() - 1);
bool VersionOK = DWARFContext::isSupportedVersion(getVersion());
bool AddrSizeOK = getAddressByteSize() == 4 || getAddressByteSize() == 8;
if (!LengthOK || !VersionOK || !AddrSizeOK)
return false;
// Keep track of the highest DWARF version we encounter across all units.
Context.setMaxVersionIfGreater(getVersion());
return true;
}
示例9: extractImpl
bool DWARFUnit::extractImpl(DataExtractor debug_info, uint32_t *offset_ptr) {
Length = debug_info.getU32(offset_ptr);
Version = debug_info.getU16(offset_ptr);
uint64_t abbrOffset = debug_info.getU32(offset_ptr);
AddrSize = debug_info.getU8(offset_ptr);
bool lengthOK = debug_info.isValidOffset(getNextUnitOffset() - 1);
bool versionOK = DWARFContext::isSupportedVersion(Version);
bool abbrOffsetOK = AbbrevSection.size() > abbrOffset;
bool addrSizeOK = AddrSize == 4 || AddrSize == 8;
if (!lengthOK || !versionOK || !addrSizeOK || !abbrOffsetOK)
return false;
Abbrevs = Abbrev->getAbbreviationDeclarationSet(abbrOffset);
return true;
}
示例10: extractImpl
bool DWARFUnit::extractImpl(DataExtractor debug_info, uint32_t *offset_ptr) {
Length = debug_info.getU32(offset_ptr);
Version = debug_info.getU16(offset_ptr);
uint64_t AbbrOffset = debug_info.getU32(offset_ptr);
AddrSize = debug_info.getU8(offset_ptr);
bool LengthOK = debug_info.isValidOffset(getNextUnitOffset() - 1);
bool VersionOK = DWARFContext::isSupportedVersion(Version);
bool AddrSizeOK = AddrSize == 4 || AddrSize == 8;
if (!LengthOK || !VersionOK || !AddrSizeOK)
return false;
Abbrevs = Abbrev->getAbbreviationDeclarationSet(AbbrOffset);
if (Abbrevs == nullptr)
return false;
return true;
}
示例11: clear
uint32_t
DWARFCompileUnit::extract(uint32_t offset, DataExtractor debug_info_data,
const DWARFAbbreviationDeclarationSet *abbrevs) {
clear();
Offset = offset;
if (debug_info_data.isValidOffset(offset)) {
Length = debug_info_data.getU32(&offset);
Version = debug_info_data.getU16(&offset);
bool abbrevsOK = debug_info_data.getU32(&offset) == abbrevs->getOffset();
Abbrevs = abbrevs;
AddrSize = debug_info_data.getU8(&offset);
bool versionOK = DWARFContext::isSupportedVersion(Version);
bool addrSizeOK = AddrSize == 4 || AddrSize == 8;
if (versionOK && addrSizeOK && abbrevsOK &&
debug_info_data.isValidOffset(offset))
return offset;
}
return 0;
}
示例12: clear
bool DWARFDebugLine::Prologue::parse(DataExtractor debug_line_data,
uint32_t *offset_ptr) {
const uint64_t prologue_offset = *offset_ptr;
clear();
TotalLength = debug_line_data.getU32(offset_ptr);
if (TotalLength == UINT32_MAX) {
IsDWARF64 = true;
TotalLength = debug_line_data.getU64(offset_ptr);
} else if (TotalLength > 0xffffff00) {
return false;
}
Version = debug_line_data.getU16(offset_ptr);
if (Version < 2)
return false;
PrologueLength =
debug_line_data.getUnsigned(offset_ptr, sizeofPrologueLength());
const uint64_t end_prologue_offset = PrologueLength + *offset_ptr;
MinInstLength = debug_line_data.getU8(offset_ptr);
if (Version >= 4)
MaxOpsPerInst = debug_line_data.getU8(offset_ptr);
DefaultIsStmt = debug_line_data.getU8(offset_ptr);
LineBase = debug_line_data.getU8(offset_ptr);
LineRange = debug_line_data.getU8(offset_ptr);
OpcodeBase = debug_line_data.getU8(offset_ptr);
StandardOpcodeLengths.reserve(OpcodeBase - 1);
for (uint32_t i = 1; i < OpcodeBase; ++i) {
uint8_t op_len = debug_line_data.getU8(offset_ptr);
StandardOpcodeLengths.push_back(op_len);
}
while (*offset_ptr < end_prologue_offset) {
const char *s = debug_line_data.getCStr(offset_ptr);
if (s && s[0])
IncludeDirectories.push_back(s);
else
break;
}
while (*offset_ptr < end_prologue_offset) {
const char *name = debug_line_data.getCStr(offset_ptr);
if (name && name[0]) {
FileNameEntry fileEntry;
fileEntry.Name = name;
fileEntry.DirIdx = debug_line_data.getULEB128(offset_ptr);
fileEntry.ModTime = debug_line_data.getULEB128(offset_ptr);
fileEntry.Length = debug_line_data.getULEB128(offset_ptr);
FileNames.push_back(fileEntry);
} else {
break;
}
}
if (*offset_ptr != end_prologue_offset) {
fprintf(stderr, "warning: parsing line table prologue at 0x%8.8" PRIx64
" should have ended at 0x%8.8" PRIx64
" but it ended at 0x%8.8" PRIx64 "\n",
prologue_offset, end_prologue_offset, (uint64_t)*offset_ptr);
return false;
}
return true;
}
示例13: parse
void DWARFDebugFrame::parse(DataExtractor Data) {
uint32_t Offset = 0;
DenseMap<uint32_t, CIE *> CIEs;
while (Data.isValidOffset(Offset)) {
uint32_t StartOffset = Offset;
auto ReportError = [StartOffset](const char *ErrorMsg) {
std::string Str;
raw_string_ostream OS(Str);
OS << format(ErrorMsg, StartOffset);
OS.flush();
report_fatal_error(Str);
};
bool IsDWARF64 = false;
uint64_t Length = Data.getU32(&Offset);
uint64_t Id;
if (Length == UINT32_MAX) {
// DWARF-64 is distinguished by the first 32 bits of the initial length
// field being 0xffffffff. Then, the next 64 bits are the actual entry
// length.
IsDWARF64 = true;
Length = Data.getU64(&Offset);
}
// At this point, Offset points to the next field after Length.
// Length is the structure size excluding itself. Compute an offset one
// past the end of the structure (needed to know how many instructions to
// read).
// TODO: For honest DWARF64 support, DataExtractor will have to treat
// offset_ptr as uint64_t*
uint32_t StartStructureOffset = Offset;
uint32_t EndStructureOffset = Offset + static_cast<uint32_t>(Length);
// The Id field's size depends on the DWARF format
Id = Data.getUnsigned(&Offset, (IsDWARF64 && !IsEH) ? 8 : 4);
bool IsCIE = ((IsDWARF64 && Id == DW64_CIE_ID) ||
Id == DW_CIE_ID ||
(IsEH && !Id));
if (IsCIE) {
uint8_t Version = Data.getU8(&Offset);
const char *Augmentation = Data.getCStr(&Offset);
StringRef AugmentationString(Augmentation ? Augmentation : "");
uint8_t AddressSize = Version < 4 ? Data.getAddressSize() :
Data.getU8(&Offset);
Data.setAddressSize(AddressSize);
uint8_t SegmentDescriptorSize = Version < 4 ? 0 : Data.getU8(&Offset);
uint64_t CodeAlignmentFactor = Data.getULEB128(&Offset);
int64_t DataAlignmentFactor = Data.getSLEB128(&Offset);
uint64_t ReturnAddressRegister = Data.getULEB128(&Offset);
// Parse the augmentation data for EH CIEs
StringRef AugmentationData("");
uint32_t FDEPointerEncoding = DW_EH_PE_omit;
uint32_t LSDAPointerEncoding = DW_EH_PE_omit;
if (IsEH) {
Optional<uint32_t> PersonalityEncoding;
Optional<uint64_t> Personality;
Optional<uint64_t> AugmentationLength;
uint32_t StartAugmentationOffset;
uint32_t EndAugmentationOffset;
// Walk the augmentation string to get all the augmentation data.
for (unsigned i = 0, e = AugmentationString.size(); i != e; ++i) {
switch (AugmentationString[i]) {
default:
ReportError("Unknown augmentation character in entry at %lx");
case 'L':
LSDAPointerEncoding = Data.getU8(&Offset);
break;
case 'P': {
if (Personality)
ReportError("Duplicate personality in entry at %lx");
PersonalityEncoding = Data.getU8(&Offset);
Personality = readPointer(Data, Offset, *PersonalityEncoding);
break;
}
case 'R':
FDEPointerEncoding = Data.getU8(&Offset);
break;
case 'z':
if (i)
ReportError("'z' must be the first character at %lx");
// Parse the augmentation length first. We only parse it if
// the string contains a 'z'.
AugmentationLength = Data.getULEB128(&Offset);
StartAugmentationOffset = Offset;
EndAugmentationOffset = Offset +
static_cast<uint32_t>(*AugmentationLength);
}
}
if (AugmentationLength.hasValue()) {
if (Offset != EndAugmentationOffset)
ReportError("Parsing augmentation data at %lx failed");
//.........这里部分代码省略.........
示例14: clear
bool
DWARFAbbreviationDeclaration::extract(DataExtractor Data,
uint32_t* OffsetPtr) {
clear();
const uint32_t Offset = *OffsetPtr;
Code = Data.getULEB128(OffsetPtr);
if (Code == 0) {
return false;
}
CodeByteSize = *OffsetPtr - Offset;
Tag = static_cast<llvm::dwarf::Tag>(Data.getULEB128(OffsetPtr));
if (Tag == DW_TAG_null) {
clear();
return false;
}
uint8_t ChildrenByte = Data.getU8(OffsetPtr);
HasChildren = (ChildrenByte == DW_CHILDREN_yes);
// Assign a value to our optional FixedAttributeSize member variable. If
// this member variable still has a value after the while loop below, then
// all attribute data in this abbreviation declaration has a fixed byte size.
FixedAttributeSize = FixedSizeInfo();
// Read all of the abbreviation attributes and forms.
while (true) {
auto A = static_cast<Attribute>(Data.getULEB128(OffsetPtr));
auto F = static_cast<Form>(Data.getULEB128(OffsetPtr));
if (A && F) {
auto FixedFormByteSize = DWARFFormValue::getFixedByteSize(F);
AttributeSpecs.push_back(AttributeSpec(A, F, FixedFormByteSize));
// If this abbrevation still has a fixed byte size, then update the
// FixedAttributeSize as needed.
if (FixedAttributeSize) {
if (FixedFormByteSize)
FixedAttributeSize->NumBytes += *FixedFormByteSize;
else {
switch (F) {
case DW_FORM_addr:
++FixedAttributeSize->NumAddrs;
break;
case DW_FORM_ref_addr:
++FixedAttributeSize->NumRefAddrs;
break;
case DW_FORM_strp:
case DW_FORM_GNU_ref_alt:
case DW_FORM_GNU_strp_alt:
case DW_FORM_line_strp:
case DW_FORM_sec_offset:
case DW_FORM_strp_sup:
case DW_FORM_ref_sup:
++FixedAttributeSize->NumDwarfOffsets;
break;
default:
// Indicate we no longer have a fixed byte size for this
// abbreviation by clearing the FixedAttributeSize optional value
// so it doesn't have a value.
FixedAttributeSize.reset();
break;
}
}
}
} else if (A == 0 && F == 0) {
// We successfully reached the end of this abbreviation declaration
// since both attribute and form are zero.
break;
} else {
// Attribute and form pairs must either both be non-zero, in which case
// they are added to the abbreviation declaration, or both be zero to
// terminate the abbrevation declaration. In this case only one was
// zero which is an error.
clear();
return false;
}
}
return true;
}
示例15: skipValue
bool DWARFFormValue::skipValue(dwarf::Form Form, DataExtractor DebugInfoData,
uint32_t *OffsetPtr,
const DWARFFormParams Params) {
bool Indirect = false;
do {
switch (Form) {
// Blocks of inlined data that have a length field and the data bytes
// inlined in the .debug_info.
case DW_FORM_exprloc:
case DW_FORM_block: {
uint64_t size = DebugInfoData.getULEB128(OffsetPtr);
*OffsetPtr += size;
return true;
}
case DW_FORM_block1: {
uint8_t size = DebugInfoData.getU8(OffsetPtr);
*OffsetPtr += size;
return true;
}
case DW_FORM_block2: {
uint16_t size = DebugInfoData.getU16(OffsetPtr);
*OffsetPtr += size;
return true;
}
case DW_FORM_block4: {
uint32_t size = DebugInfoData.getU32(OffsetPtr);
*OffsetPtr += size;
return true;
}
// Inlined NULL terminated C-strings.
case DW_FORM_string:
DebugInfoData.getCStr(OffsetPtr);
return true;
case DW_FORM_addr:
case DW_FORM_ref_addr:
case DW_FORM_flag_present:
case DW_FORM_data1:
case DW_FORM_data2:
case DW_FORM_data4:
case DW_FORM_data8:
case DW_FORM_data16:
case DW_FORM_flag:
case DW_FORM_ref1:
case DW_FORM_ref2:
case DW_FORM_ref4:
case DW_FORM_ref8:
case DW_FORM_ref_sig8:
case DW_FORM_ref_sup4:
case DW_FORM_ref_sup8:
case DW_FORM_strx1:
case DW_FORM_strx2:
case DW_FORM_strx4:
case DW_FORM_addrx1:
case DW_FORM_addrx2:
case DW_FORM_addrx4:
case DW_FORM_sec_offset:
case DW_FORM_strp:
case DW_FORM_strp_sup:
case DW_FORM_line_strp:
case DW_FORM_GNU_ref_alt:
case DW_FORM_GNU_strp_alt:
if (Optional<uint8_t> FixedSize =
DWARFFormValue::getFixedByteSize(Form, Params)) {
*OffsetPtr += *FixedSize;
return true;
}
return false;
// signed or unsigned LEB 128 values.
case DW_FORM_sdata:
DebugInfoData.getSLEB128(OffsetPtr);
return true;
case DW_FORM_udata:
case DW_FORM_ref_udata:
case DW_FORM_strx:
case DW_FORM_addrx:
case DW_FORM_loclistx:
case DW_FORM_rnglistx:
case DW_FORM_GNU_addr_index:
case DW_FORM_GNU_str_index:
DebugInfoData.getULEB128(OffsetPtr);
return true;
case DW_FORM_indirect:
Indirect = true;
Form = static_cast<dwarf::Form>(DebugInfoData.getULEB128(OffsetPtr));
break;
default:
return false;
}
} while (Indirect);
return true;
}