本文整理汇总了C++中DWARFDataExtractor::getAddressSize方法的典型用法代码示例。如果您正苦于以下问题:C++ DWARFDataExtractor::getAddressSize方法的具体用法?C++ DWARFDataExtractor::getAddressSize怎么用?C++ DWARFDataExtractor::getAddressSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DWARFDataExtractor
的用法示例。
在下文中一共展示了DWARFDataExtractor::getAddressSize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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";
}
示例2: 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;
}
示例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: while
Optional<DWARFDebugLoc::LocationList>
DWARFDebugLoc::parseOneLocationList(DWARFDataExtractor Data, unsigned *Offset) {
LocationList LL;
LL.Offset = *Offset;
// 2.6.2 Location Lists
// A location list entry consists of:
while (true) {
Entry E;
if (!Data.isValidOffsetForDataOfSize(*Offset, 2 * Data.getAddressSize())) {
llvm::errs() << "Location list overflows the debug_loc section.\n";
return None;
}
// 1. A beginning address offset. ...
E.Begin = Data.getRelocatedAddress(Offset);
// 2. An ending address offset. ...
E.End = Data.getRelocatedAddress(Offset);
// 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)
return LL;
if (!Data.isValidOffsetForDataOfSize(*Offset, 2)) {
llvm::errs() << "Location list overflows the debug_loc section.\n";
return None;
}
unsigned Bytes = Data.getU16(Offset);
if (!Data.isValidOffsetForDataOfSize(*Offset, Bytes)) {
llvm::errs() << "Location list overflows the debug_loc section.\n";
return None;
}
// 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));
LL.Entries.push_back(std::move(E));
}
}
示例5: State
bool DWARFDebugLine::LineTable::parse(DWARFDataExtractor &DebugLineData,
uint32_t *OffsetPtr, const DWARFUnit *U,
raw_ostream *OS) {
const uint32_t DebugLineOffset = *OffsetPtr;
clear();
if (!Prologue.parse(DebugLineData, OffsetPtr, U)) {
// Restore our offset and return false to indicate failure!
*OffsetPtr = DebugLineOffset;
return false;
}
if (OS)
Prologue.dump(*OS);
const uint32_t EndOffset =
DebugLineOffset + Prologue.TotalLength + Prologue.sizeofTotalLength();
// See if we should tell the data extractor the address size.
if (DebugLineData.getAddressSize() == 0)
DebugLineData.setAddressSize(Prologue.getAddressSize());
else
assert(Prologue.getAddressSize() == 0 ||
Prologue.getAddressSize() == DebugLineData.getAddressSize());
ParsingState State(this);
while (*OffsetPtr < EndOffset) {
if (OS)
*OS << format("0x%08.08" PRIx32 ": ", *OffsetPtr);
uint8_t Opcode = DebugLineData.getU8(OffsetPtr);
if (OS)
*OS << format("%02.02" PRIx8 " ", Opcode);
if (Opcode == 0) {
// Extended Opcodes always start with a zero opcode followed by
// a uleb128 length so you can skip ones you don't know about
uint64_t Len = DebugLineData.getULEB128(OffsetPtr);
uint32_t ExtOffset = *OffsetPtr;
// Tolerate zero-length; assume length is correct and soldier on.
if (Len == 0) {
if (OS)
*OS << "Badly formed extended line op (length 0)\n";
continue;
}
uint8_t SubOpcode = DebugLineData.getU8(OffsetPtr);
if (OS)
*OS << LNExtendedString(SubOpcode);
switch (SubOpcode) {
case DW_LNE_end_sequence:
// Set the end_sequence register of the state machine to true and
// append a row to the matrix using the current values of the
// state-machine registers. Then reset the registers to the initial
// values specified above. Every statement program sequence must end
// with a DW_LNE_end_sequence instruction which creates a row whose
// address is that of the byte after the last target machine instruction
// of the sequence.
State.Row.EndSequence = true;
State.appendRowToMatrix(*OffsetPtr);
if (OS) {
*OS << "\n";
OS->indent(12);
State.Row.dump(*OS);
}
State.resetRowAndSequence();
break;
case DW_LNE_set_address:
// Takes a single relocatable address as an operand. The size of the
// operand is the size appropriate to hold an address on the target
// machine. Set the address register to the value given by the
// relocatable address. All of the other statement program opcodes
// that affect the address register add a delta to it. This instruction
// stores a relocatable value into it instead.
//
// Make sure the extractor knows the address size. If not, infer it
// from the size of the operand.
if (DebugLineData.getAddressSize() == 0)
DebugLineData.setAddressSize(Len - 1);
else
assert(DebugLineData.getAddressSize() == Len - 1);
State.Row.Address = DebugLineData.getRelocatedAddress(OffsetPtr);
if (OS)
*OS << format(" (0x%16.16" PRIx64 ")", State.Row.Address);
break;
case DW_LNE_define_file:
// Takes 4 arguments. The first is a null terminated string containing
// a source file name. The second is an unsigned LEB128 number
// representing the directory index of the directory in which the file
// was found. The third is an unsigned LEB128 number representing the
// time of last modification of the file. The fourth is an unsigned
// LEB128 number representing the length in bytes of the file. The time
// and length fields may contain LEB128(0) if the information is not
// available.
//.........这里部分代码省略.........
示例6: clear
bool DWARFDebugLine::Prologue::parse(const DWARFDataExtractor &DebugLineData,
uint32_t *OffsetPtr, const DWARFUnit *U) {
const uint64_t PrologueOffset = *OffsetPtr;
clear();
TotalLength = DebugLineData.getU32(OffsetPtr);
if (TotalLength == UINT32_MAX) {
FormParams.Format = dwarf::DWARF64;
TotalLength = DebugLineData.getU64(OffsetPtr);
} else if (TotalLength >= 0xffffff00) {
return false;
}
FormParams.Version = DebugLineData.getU16(OffsetPtr);
if (getVersion() < 2)
return false;
if (getVersion() >= 5) {
FormParams.AddrSize = DebugLineData.getU8(OffsetPtr);
assert((DebugLineData.getAddressSize() == 0 ||
DebugLineData.getAddressSize() == getAddressSize()) &&
"Line table header and data extractor disagree");
SegSelectorSize = DebugLineData.getU8(OffsetPtr);
}
PrologueLength = DebugLineData.getUnsigned(OffsetPtr, sizeofPrologueLength());
const uint64_t EndPrologueOffset = PrologueLength + *OffsetPtr;
MinInstLength = DebugLineData.getU8(OffsetPtr);
if (getVersion() >= 4)
MaxOpsPerInst = DebugLineData.getU8(OffsetPtr);
DefaultIsStmt = DebugLineData.getU8(OffsetPtr);
LineBase = DebugLineData.getU8(OffsetPtr);
LineRange = DebugLineData.getU8(OffsetPtr);
OpcodeBase = DebugLineData.getU8(OffsetPtr);
StandardOpcodeLengths.reserve(OpcodeBase - 1);
for (uint32_t I = 1; I < OpcodeBase; ++I) {
uint8_t OpLen = DebugLineData.getU8(OffsetPtr);
StandardOpcodeLengths.push_back(OpLen);
}
if (getVersion() >= 5) {
if (!parseV5DirFileTables(DebugLineData, OffsetPtr, EndPrologueOffset,
FormParams, U, HasMD5, IncludeDirectories,
FileNames)) {
fprintf(stderr,
"warning: parsing line table prologue at 0x%8.8" PRIx64
" found an invalid directory or file table description at"
" 0x%8.8" PRIx64 "\n", PrologueOffset, (uint64_t)*OffsetPtr);
return false;
}
} else
parseV2DirFileTables(DebugLineData, OffsetPtr, EndPrologueOffset,
IncludeDirectories, FileNames);
if (*OffsetPtr != EndPrologueOffset) {
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",
PrologueOffset, EndPrologueOffset, (uint64_t)*OffsetPtr);
return false;
}
return true;
}
示例7: createStringError
Error DWARFDebugLine::Prologue::parse(const DWARFDataExtractor &DebugLineData,
uint32_t *OffsetPtr,
const DWARFContext &Ctx,
const DWARFUnit *U) {
const uint64_t PrologueOffset = *OffsetPtr;
clear();
TotalLength = DebugLineData.getU32(OffsetPtr);
if (TotalLength == UINT32_MAX) {
FormParams.Format = dwarf::DWARF64;
TotalLength = DebugLineData.getU64(OffsetPtr);
} else if (TotalLength >= 0xffffff00) {
return createStringError(errc::invalid_argument,
"parsing line table prologue at offset 0x%8.8" PRIx64
" unsupported reserved unit length found of value 0x%8.8" PRIx64,
PrologueOffset, TotalLength);
}
FormParams.Version = DebugLineData.getU16(OffsetPtr);
if (getVersion() < 2)
return createStringError(errc::not_supported,
"parsing line table prologue at offset 0x%8.8" PRIx64
" found unsupported version 0x%2.2" PRIx16,
PrologueOffset, getVersion());
if (getVersion() >= 5) {
FormParams.AddrSize = DebugLineData.getU8(OffsetPtr);
assert((DebugLineData.getAddressSize() == 0 ||
DebugLineData.getAddressSize() == getAddressSize()) &&
"Line table header and data extractor disagree");
SegSelectorSize = DebugLineData.getU8(OffsetPtr);
}
PrologueLength = DebugLineData.getUnsigned(OffsetPtr, sizeofPrologueLength());
const uint64_t EndPrologueOffset = PrologueLength + *OffsetPtr;
MinInstLength = DebugLineData.getU8(OffsetPtr);
if (getVersion() >= 4)
MaxOpsPerInst = DebugLineData.getU8(OffsetPtr);
DefaultIsStmt = DebugLineData.getU8(OffsetPtr);
LineBase = DebugLineData.getU8(OffsetPtr);
LineRange = DebugLineData.getU8(OffsetPtr);
OpcodeBase = DebugLineData.getU8(OffsetPtr);
StandardOpcodeLengths.reserve(OpcodeBase - 1);
for (uint32_t I = 1; I < OpcodeBase; ++I) {
uint8_t OpLen = DebugLineData.getU8(OffsetPtr);
StandardOpcodeLengths.push_back(OpLen);
}
if (getVersion() >= 5) {
if (!parseV5DirFileTables(DebugLineData, OffsetPtr, EndPrologueOffset,
FormParams, Ctx, U, ContentTypes,
IncludeDirectories, FileNames)) {
return createStringError(errc::invalid_argument,
"parsing line table prologue at 0x%8.8" PRIx64
" found an invalid directory or file table description at"
" 0x%8.8" PRIx64,
PrologueOffset, (uint64_t)*OffsetPtr);
}
} else
parseV2DirFileTables(DebugLineData, OffsetPtr, EndPrologueOffset,
ContentTypes, IncludeDirectories, FileNames);
if (*OffsetPtr != EndPrologueOffset)
return createStringError(errc::invalid_argument,
"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,
PrologueOffset, EndPrologueOffset, (uint64_t)*OffsetPtr);
return Error::success();
}
示例8: extract
Error RangeListEntry::extract(DWARFDataExtractor Data, uint32_t End,
uint32_t *OffsetPtr) {
Offset = *OffsetPtr;
SectionIndex = -1ULL;
// The caller should guarantee that we have at least 1 byte available, so
// we just assert instead of revalidate.
assert(*OffsetPtr < End &&
"not enough space to extract a rangelist encoding");
uint8_t Encoding = Data.getU8(OffsetPtr);
switch (Encoding) {
case dwarf::DW_RLE_end_of_list:
Value0 = Value1 = 0;
break;
// TODO: Support other encodings.
case dwarf::DW_RLE_base_addressx:
return createError("unsupported rnglists encoding DW_RLE_base_addressx "
"at offset 0x%" PRIx32,
*OffsetPtr - 1);
case dwarf::DW_RLE_startx_endx:
return createError("unsupported rnglists encoding DW_RLE_startx_endx at "
"offset 0x%" PRIx32,
*OffsetPtr - 1);
case dwarf::DW_RLE_startx_length:
return createError("unsupported rnglists encoding DW_RLE_startx_length "
"at offset 0x%" PRIx32,
*OffsetPtr - 1);
case dwarf::DW_RLE_offset_pair: {
uint32_t PreviousOffset = *OffsetPtr - 1;
Value0 = Data.getULEB128(OffsetPtr);
Value1 = Data.getULEB128(OffsetPtr);
if (End < *OffsetPtr)
return createError("read past end of table when reading "
"DW_RLE_offset_pair encoding at offset 0x%" PRIx32,
PreviousOffset);
break;
}
case dwarf::DW_RLE_base_address: {
if ((End - *OffsetPtr) < Data.getAddressSize())
return createError("insufficient space remaining in table for "
"DW_RLE_base_address encoding at offset 0x%" PRIx32,
*OffsetPtr - 1);
Value0 = Data.getRelocatedAddress(OffsetPtr, &SectionIndex);
break;
}
case dwarf::DW_RLE_start_end: {
if ((End - *OffsetPtr) < unsigned(Data.getAddressSize() * 2))
return createError("insufficient space remaining in table for "
"DW_RLE_start_end encoding "
"at offset 0x%" PRIx32,
*OffsetPtr - 1);
Value0 = Data.getRelocatedAddress(OffsetPtr, &SectionIndex);
Value1 = Data.getRelocatedAddress(OffsetPtr);
break;
}
case dwarf::DW_RLE_start_length: {
uint32_t PreviousOffset = *OffsetPtr - 1;
Value0 = Data.getRelocatedAddress(OffsetPtr, &SectionIndex);
Value1 = Data.getULEB128(OffsetPtr);
if (End < *OffsetPtr)
return createError("read past end of table when reading "
"DW_RLE_start_length encoding at offset 0x%" PRIx32,
PreviousOffset);
break;
}
default:
return createError("unknown rnglists encoding 0x%" PRIx32
" at offset 0x%" PRIx32,
uint32_t(Encoding), *OffsetPtr - 1);
}
EntryKind = Encoding;
return Error::success();
}