本文整理汇总了C++中DataExtractor::isValidOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ DataExtractor::isValidOffset方法的具体用法?C++ DataExtractor::isValidOffset怎么用?C++ DataExtractor::isValidOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataExtractor
的用法示例。
在下文中一共展示了DataExtractor::isValidOffset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: extract
bool DWARFDebugAranges::extract(DataExtractor debug_aranges_data) {
if (debug_aranges_data.isValidOffset(0)) {
uint32_t offset = 0;
typedef std::vector<DWARFDebugArangeSet> SetCollection;
typedef SetCollection::const_iterator SetCollectionIter;
SetCollection sets;
DWARFDebugArangeSet set;
Range range;
while (set.extract(debug_aranges_data, &offset))
sets.push_back(set);
uint32_t count = 0;
std::for_each(sets.begin(), sets.end(), CountArangeDescriptors(count));
if (count > 0) {
Aranges.reserve(count);
AddArangeDescriptors range_adder(Aranges);
std::for_each(sets.begin(), sets.end(), range_adder);
}
}
return false;
}
示例4: 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;
}
示例5: 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));
}
}
}
示例6: extract
void DWARFDebugAranges::extract(DataExtractor DebugArangesData) {
if (!DebugArangesData.isValidOffset(0))
return;
uint32_t Offset = 0;
typedef std::vector<DWARFDebugArangeSet> RangeSetColl;
RangeSetColl Sets;
DWARFDebugArangeSet Set;
uint32_t TotalRanges = 0;
while (Set.extract(DebugArangesData, &Offset)) {
Sets.push_back(Set);
TotalRanges += Set.getNumDescriptors();
}
if (TotalRanges == 0)
return;
Aranges.reserve(TotalRanges);
for (RangeSetColl::const_iterator I = Sets.begin(), E = Sets.end(); I != E;
++I) {
uint32_t CUOffset = I->getCompileUnitDIEOffset();
for (uint32_t i = 0, n = I->getNumDescriptors(); i < n; ++i) {
const DWARFDebugArangeSet::Descriptor *ArangeDescPtr =
I->getDescriptor(i);
uint64_t LowPC = ArangeDescPtr->Address;
uint64_t HighPC = LowPC + ArangeDescPtr->Length;
appendRange(CUOffset, LowPC, HighPC);
}
}
}
示例7: extract
void DWARFDebugAbbrev::extract(DataExtractor Data) {
clear();
uint32_t Offset = 0;
DWARFAbbreviationDeclarationSet AbbrDecls;
while (Data.isValidOffset(Offset)) {
uint32_t CUAbbrOffset = Offset;
if (!AbbrDecls.extract(Data, &Offset))
break;
AbbrDeclSets[CUAbbrOffset] = std::move(AbbrDecls);
}
}
示例8: parse
void DWARFDebugLocDWO::parse(DataExtractor data) {
IsLittleEndian = data.isLittleEndian();
AddressSize = data.getAddressSize();
uint32_t Offset = 0;
while (data.isValidOffset(Offset)) {
if (auto LL = parseOneLocationList(data, &Offset))
Locations.push_back(std::move(*LL));
else
return;
}
}
示例9: parse
void DWARFDebugLoc::parse(DataExtractor data, unsigned AddressSize) {
uint32_t Offset = 0;
while (data.isValidOffset(Offset+AddressSize-1)) {
Locations.resize(Locations.size() + 1);
LocationList &Loc = Locations.back();
Loc.Offset = Offset;
// 2.6.2 Location Lists
// A location list entry consists of:
while (true) {
Entry E;
RelocAddrMap::const_iterator AI = RelocMap.find(Offset);
// 1. A beginning address offset. ...
E.Begin = data.getUnsigned(&Offset, AddressSize);
if (AI != RelocMap.end())
E.Begin += AI->second.second;
AI = RelocMap.find(Offset);
// 2. An ending address offset. ...
E.End = data.getUnsigned(&Offset, AddressSize);
if (AI != RelocMap.end())
E.End += AI->second.second;
// The end of any given location list is marked by an end of list entry,
// which consists of a 0 for the beginning address offset and a 0 for the
// ending address offset.
if (E.Begin == 0 && E.End == 0)
break;
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.reserve(str.size());
std::copy(str.begin(), str.end(), std::back_inserter(E.Loc));
Loc.Entries.push_back(llvm_move(E));
}
}
if (data.isValidOffset(Offset))
llvm::errs() << "error: failed to consume entire .debug_loc section\n";
}
示例10: 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;
}
示例11: extract
bool DWARFUnit::extract(DataExtractor debug_info, uint32_t *offset_ptr) {
clear();
Offset = *offset_ptr;
if (debug_info.isValidOffset(*offset_ptr)) {
if (extractImpl(debug_info, offset_ptr))
return true;
// reset the offset to where we tried to parse from if anything went wrong
*offset_ptr = Offset;
}
return false;
}
示例12: extract
void DWARFDebugAranges::extract(DataExtractor DebugArangesData) {
if (!DebugArangesData.isValidOffset(0))
return;
uint32_t Offset = 0;
DWARFDebugArangeSet Set;
while (Set.extract(DebugArangesData, &Offset)) {
uint32_t CUOffset = Set.getCompileUnitDIEOffset();
for (const auto &Desc : Set.descriptors()) {
uint64_t LowPC = Desc.Address;
uint64_t HighPC = Desc.getEndAddress();
appendRange(CUOffset, LowPC, HighPC);
}
ParsedCUOffsets.insert(CUOffset);
}
}
示例13: 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;
}
示例14: parse
void DWARFDebugMacro::parse(DataExtractor data) {
uint32_t Offset = 0;
while (data.isValidOffset(Offset)) {
// A macro list entry consists of:
Entry E;
// 1. Macinfo type
E.Type = data.getULEB128(&Offset);
if (E.Type == 0) {
// Reached end of ".debug_macinfo" section.
return;
}
switch (E.Type) {
default:
// Got a corrupted ".debug_macinfo" section (invalid macinfo type).
// Push the corrupted entry to the list and halt parsing.
E.Type = DW_MACINFO_invalid;
Macros.push_back(E);
return;
case DW_MACINFO_define:
case DW_MACINFO_undef:
// 2. Source line
E.Line = data.getULEB128(&Offset);
// 3. Macro string
E.MacroStr = data.getCStr(&Offset);
break;
case DW_MACINFO_start_file:
// 2. Source line
E.Line = data.getULEB128(&Offset);
// 3. Source file id
E.File = data.getULEB128(&Offset);
break;
case DW_MACINFO_end_file:
break;
case DW_MACINFO_vendor_ext:
// 2. Vendor extension constant
E.ExtConstant = data.getULEB128(&Offset);
// 3. Vendor extension string
E.ExtStr = data.getCStr(&Offset);
break;
}
Macros.push_back(E);
}
}
示例15: 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;
}