本文整理汇总了C++中DWARFDataExtractor::getCStr方法的典型用法代码示例。如果您正苦于以下问题:C++ DWARFDataExtractor::getCStr方法的具体用法?C++ DWARFDataExtractor::getCStr怎么用?C++ DWARFDataExtractor::getCStr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DWARFDataExtractor
的用法示例。
在下文中一共展示了DWARFDataExtractor::getCStr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extractValue
bool DWARFFormValue::extractValue(const DWARFDataExtractor &Data,
uint32_t *OffsetPtr, DWARFFormParams FP,
const DWARFUnit *CU) {
U = CU;
bool Indirect = false;
bool IsBlock = false;
Value.data = nullptr;
// Read the value for the form into value and follow and DW_FORM_indirect
// instances we run into
do {
Indirect = false;
switch (Form) {
case DW_FORM_addr:
case DW_FORM_ref_addr: {
uint16_t Size =
(Form == DW_FORM_addr) ? FP.AddrSize : FP.getRefAddrByteSize();
Value.uval = Data.getRelocatedValue(Size, OffsetPtr, &Value.SectionIndex);
break;
}
case DW_FORM_exprloc:
case DW_FORM_block:
Value.uval = Data.getULEB128(OffsetPtr);
IsBlock = true;
break;
case DW_FORM_block1:
Value.uval = Data.getU8(OffsetPtr);
IsBlock = true;
break;
case DW_FORM_block2:
Value.uval = Data.getU16(OffsetPtr);
IsBlock = true;
break;
case DW_FORM_block4:
Value.uval = Data.getU32(OffsetPtr);
IsBlock = true;
break;
case DW_FORM_data1:
case DW_FORM_ref1:
case DW_FORM_flag:
case DW_FORM_strx1:
case DW_FORM_addrx1:
Value.uval = Data.getU8(OffsetPtr);
break;
case DW_FORM_data2:
case DW_FORM_ref2:
case DW_FORM_strx2:
case DW_FORM_addrx2:
Value.uval = Data.getU16(OffsetPtr);
break;
case DW_FORM_strx3:
Value.uval = Data.getU24(OffsetPtr);
break;
case DW_FORM_data4:
case DW_FORM_ref4:
case DW_FORM_ref_sup4:
case DW_FORM_strx4:
case DW_FORM_addrx4:
Value.uval = Data.getRelocatedValue(4, OffsetPtr);
break;
case DW_FORM_data8:
case DW_FORM_ref8:
case DW_FORM_ref_sup8:
Value.uval = Data.getU64(OffsetPtr);
break;
case DW_FORM_data16:
// Treat this like a 16-byte block.
Value.uval = 16;
IsBlock = true;
break;
case DW_FORM_sdata:
Value.sval = Data.getSLEB128(OffsetPtr);
break;
case DW_FORM_udata:
case DW_FORM_ref_udata:
Value.uval = Data.getULEB128(OffsetPtr);
break;
case DW_FORM_string:
Value.cstr = Data.getCStr(OffsetPtr);
break;
case DW_FORM_indirect:
Form = static_cast<dwarf::Form>(Data.getULEB128(OffsetPtr));
Indirect = true;
break;
case DW_FORM_strp:
case DW_FORM_sec_offset:
case DW_FORM_GNU_ref_alt:
case DW_FORM_GNU_strp_alt:
case DW_FORM_line_strp:
case DW_FORM_strp_sup: {
Value.uval =
Data.getRelocatedValue(FP.getDwarfOffsetByteSize(), OffsetPtr);
break;
}
case DW_FORM_flag_present:
Value.uval = 1;
break;
case DW_FORM_ref_sig8:
Value.uval = Data.getU64(OffsetPtr);
break;
case DW_FORM_GNU_addr_index:
//.........这里部分代码省略.........
示例2: State
//.........这里部分代码省略.........
// 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.
//
// The directory index represents an entry in the include_directories
// section of the statement program prologue. The index is LEB128(0)
// if the file was found in the current directory of the compilation,
// LEB128(1) if it was found in the first directory in the
// include_directories section, and so on. The directory index is
// ignored for file names that represent full path names.
//
// The files are numbered, starting at 1, in the order in which they
// appear; the names in the prologue come before names defined by
// the DW_LNE_define_file instruction. These numbers are used in the
// the file register of the state machine.
{
FileNameEntry FileEntry;
FileEntry.Name = DebugLineData.getCStr(OffsetPtr);
FileEntry.DirIdx = DebugLineData.getULEB128(OffsetPtr);
FileEntry.ModTime = DebugLineData.getULEB128(OffsetPtr);
FileEntry.Length = DebugLineData.getULEB128(OffsetPtr);
Prologue.FileNames.push_back(FileEntry);
if (OS)
*OS << " (" << FileEntry.Name.str()
<< ", dir=" << FileEntry.DirIdx << ", mod_time="
<< format("(0x%16.16" PRIx64 ")", FileEntry.ModTime)
<< ", length=" << FileEntry.Length << ")";
}
break;
case DW_LNE_set_discriminator:
State.Row.Discriminator = DebugLineData.getULEB128(OffsetPtr);
if (OS)
*OS << " (" << State.Row.Discriminator << ")";
break;
default:
if (OS)
*OS << format("Unrecognized extended op 0x%02.02" PRIx8, SubOpcode)
<< format(" length %" PRIx64, Len);
// Len doesn't include the zero opcode byte or the length itself, but
// it does include the sub_opcode, so we have to adjust for that.
(*OffsetPtr) += Len - 1;
break;
}
// Make sure the stated and parsed lengths are the same.
// Otherwise we have an unparseable line-number program.
if (*OffsetPtr - ExtOffset != Len) {
fprintf(stderr, "Unexpected line op length at offset 0x%8.8" PRIx32
" expected 0x%2.2" PRIx64 " found 0x%2.2" PRIx32 "\n",