本文整理汇总了C++中DataExtractor::GetU32方法的典型用法代码示例。如果您正苦于以下问题:C++ DataExtractor::GetU32方法的具体用法?C++ DataExtractor::GetU32怎么用?C++ DataExtractor::GetU32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataExtractor
的用法示例。
在下文中一共展示了DataExtractor::GetU32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Clear
bool
DWARFCompileUnit::Extract(const DataExtractor &debug_info, uint32_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.GetU32(offset_ptr);
m_version = debug_info.GetU16(offset_ptr);
abbr_offset = debug_info.GetU32(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;
}
示例2: Error
Error
AdbClient::Stat (const FileSpec &remote_file, uint32_t &mode, uint32_t &size, uint32_t &mtime)
{
auto error = StartSync ();
if (error.Fail ())
return error;
const std::string remote_file_path (remote_file.GetPath (false));
error = SendSyncRequest (kSTAT, remote_file_path.length (), remote_file_path.c_str ());
if (error.Fail ())
return Error ("Failed to send request: %s", error.AsCString ());
static const size_t stat_len = strlen (kSTAT);
static const size_t response_len = stat_len + (sizeof (uint32_t) * 3);
std::vector<char> buffer (response_len);
error = ReadAllBytes (&buffer[0], buffer.size ());
if (error.Fail ())
return Error ("Failed to read response: %s", error.AsCString ());
DataExtractor extractor (&buffer[0], buffer.size (), eByteOrderLittle, sizeof (void*));
offset_t offset = 0;
const void* command = extractor.GetData (&offset, stat_len);
if (!command)
return Error ("Failed to get response command");
const char* command_str = static_cast<const char*> (command);
if (strncmp (command_str, kSTAT, stat_len))
return Error ("Got invalid stat command: %s", command_str);
mode = extractor.GetU32 (&offset);
size = extractor.GetU32 (&offset);
mtime = extractor.GetU32 (&offset);
return Error ();
}
示例3: DataExtractor
// Parse a FreeBSD NT_PRSTATUS note - see FreeBSD sys/procfs.h for details.
static void
ParseFreeBSDPrStatus(ThreadData *thread_data, DataExtractor &data,
ArchSpec &arch)
{
lldb::offset_t offset = 0;
bool have_padding = (arch.GetMachine() == llvm::Triple::mips64 ||
arch.GetMachine() == llvm::Triple::x86_64);
int pr_version = data.GetU32(&offset);
Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
if (log)
{
if (pr_version > 1)
log->Printf("FreeBSD PRSTATUS unexpected version %d", pr_version);
}
if (have_padding)
offset += 4;
offset += 28; // pr_statussz, pr_gregsetsz, pr_fpregsetsz, pr_osreldate
thread_data->signo = data.GetU32(&offset); // pr_cursig
offset += 4; // pr_pid
if (have_padding)
offset += 4;
size_t len = data.GetByteSize() - offset;
thread_data->gpregset = DataExtractor(data, offset, len);
}
示例4: DataExtractor
// Parse a FreeBSD NT_PRSTATUS note - see FreeBSD sys/procfs.h for details.
static void
ParseFreeBSDPrStatus(ThreadData &thread_data, DataExtractor &data,
ArchSpec &arch)
{
lldb::offset_t offset = 0;
bool lp64 = (arch.GetMachine() == llvm::Triple::aarch64 ||
arch.GetMachine() == llvm::Triple::mips64 ||
arch.GetMachine() == llvm::Triple::ppc64 ||
arch.GetMachine() == llvm::Triple::x86_64);
int pr_version = data.GetU32(&offset);
Log *log (GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
if (log)
{
if (pr_version > 1)
log->Printf("FreeBSD PRSTATUS unexpected version %d", pr_version);
}
// Skip padding, pr_statussz, pr_gregsetsz, pr_fpregsetsz, pr_osreldate
if (lp64)
offset += 32;
else
offset += 16;
thread_data.signo = data.GetU32(&offset); // pr_cursig
thread_data.tid = data.GetU32(&offset); // pr_pid
if (lp64)
offset += 4;
size_t len = data.GetByteSize() - offset;
thread_data.gpregset = DataExtractor(data, offset, len);
}
示例5: GetSize
Error
ELFLinuxPrPsInfo::Parse(DataExtractor &data, ArchSpec &arch)
{
Error error;
ByteOrder byteorder = data.GetByteOrder();
if (GetSize(arch) > data.GetByteSize())
{
error.SetErrorStringWithFormat("NT_PRPSINFO size should be %lu, but the remaining bytes are: %lu",
GetSize(arch), data.GetByteSize());
return error;
}
switch(arch.GetCore())
{
case ArchSpec::eCore_s390x_generic:
case ArchSpec::eCore_x86_64_x86_64:
data.ExtractBytes(0, sizeof(ELFLinuxPrPsInfo), byteorder, this);
break;
case ArchSpec::eCore_x86_32_i386:
case ArchSpec::eCore_x86_32_i486:
{
// Parsing from a 32 bit ELF core file, and populating/reusing the structure
// properly, because the struct is for the 64 bit version
size_t size = 0;
offset_t offset = 0;
pr_state = data.GetU8(&offset);
pr_sname = data.GetU8(&offset);
pr_zomb = data.GetU8(&offset);
pr_nice = data.GetU8(&offset);
pr_flag = data.GetU32(&offset);
pr_uid = data.GetU16(&offset);
pr_gid = data.GetU16(&offset);
pr_pid = data.GetU32(&offset);
pr_ppid = data.GetU32(&offset);
pr_pgrp = data.GetU32(&offset);
pr_sid = data.GetU32(&offset);
size = 16;
data.ExtractBytes(offset, size, byteorder, pr_fname);
offset += size;
size = 80;
data.ExtractBytes(offset, size, byteorder, pr_psargs);
offset += size;
break;
}
default:
error.SetErrorStringWithFormat("ELFLinuxPrPsInfo::%s Unknown architecture", __FUNCTION__);
break;
}
return error;
}
示例6: locker
bool
DynamicLoaderDarwinKernel::ReadKextSummaryHeader ()
{
Mutex::Locker locker(m_mutex);
// the all image infos is already valid for this process stop ID
m_kext_summaries.clear();
if (m_kext_summary_header_ptr_addr.IsValid())
{
const uint32_t addr_size = m_kernel.GetAddressByteSize ();
const ByteOrder byte_order = m_kernel.GetByteOrder();
Error error;
// Read enough bytes for a "OSKextLoadedKextSummaryHeader" structure
// which is currenty 4 uint32_t and a pointer.
uint8_t buf[24];
DataExtractor data (buf, sizeof(buf), byte_order, addr_size);
const size_t count = 4 * sizeof(uint32_t) + addr_size;
const bool prefer_file_cache = false;
if (m_process->GetTarget().ReadPointerFromMemory (m_kext_summary_header_ptr_addr,
prefer_file_cache,
error,
m_kext_summary_header_addr))
{
// We got a valid address for our kext summary header and make sure it isn't NULL
if (m_kext_summary_header_addr.IsValid() &&
m_kext_summary_header_addr.GetFileAddress() != 0)
{
const size_t bytes_read = m_process->GetTarget().ReadMemory (m_kext_summary_header_addr, prefer_file_cache, buf, count, error);
if (bytes_read == count)
{
uint32_t offset = 0;
m_kext_summary_header.version = data.GetU32(&offset);
if (m_kext_summary_header.version >= 2)
{
m_kext_summary_header.entry_size = data.GetU32(&offset);
}
else
{
// Versions less than 2 didn't have an entry size, it was hard coded
m_kext_summary_header.entry_size = KERNEL_MODULE_ENTRY_SIZE_VERSION_1;
}
m_kext_summary_header.entry_count = data.GetU32(&offset);
return true;
}
}
}
}
m_kext_summary_header_addr.Clear();
return false;
}
示例7: SendRawRequest
bool CommunicationKDP::SendRawRequest(
uint8_t command_byte,
const void *src, // Raw packet payload bytes
uint32_t src_len, // Raw packet payload length
DataExtractor &reply_packet, Status &error) {
PacketStreamType request_packet(Stream::eBinary, m_addr_byte_size,
m_byte_order);
// Size is header + address size + uint32_t length
const uint32_t command_length = 8 + src_len;
const CommandType command = (CommandType)command_byte;
MakeRequestPacketHeader(command, request_packet, command_length);
request_packet.PutRawBytes(src, src_len);
if (SendRequestAndGetReply(command, request_packet, reply_packet)) {
lldb::offset_t offset = 8;
uint32_t kdp_error = reply_packet.GetU32(&offset);
if (kdp_error && (command_byte != KDP_DUMPINFO))
error.SetErrorStringWithFormat("request packet 0x%8.8x failed (error %u)",
command_byte, kdp_error);
else {
error.Clear();
return true;
}
} else {
error.SetErrorString("failed to send packet");
}
return false;
}
示例8: ParseDOSHeader
//----------------------------------------------------------------------
// ParseDOSHeader
//----------------------------------------------------------------------
bool ObjectFilePECOFF::ParseDOSHeader(DataExtractor &data,
dos_header_t &dos_header) {
bool success = false;
lldb::offset_t offset = 0;
success = data.ValidOffsetForDataOfSize(0, sizeof(dos_header));
if (success) {
dos_header.e_magic = data.GetU16(&offset); // Magic number
success = dos_header.e_magic == IMAGE_DOS_SIGNATURE;
if (success) {
dos_header.e_cblp = data.GetU16(&offset); // Bytes on last page of file
dos_header.e_cp = data.GetU16(&offset); // Pages in file
dos_header.e_crlc = data.GetU16(&offset); // Relocations
dos_header.e_cparhdr =
data.GetU16(&offset); // Size of header in paragraphs
dos_header.e_minalloc =
data.GetU16(&offset); // Minimum extra paragraphs needed
dos_header.e_maxalloc =
data.GetU16(&offset); // Maximum extra paragraphs needed
dos_header.e_ss = data.GetU16(&offset); // Initial (relative) SS value
dos_header.e_sp = data.GetU16(&offset); // Initial SP value
dos_header.e_csum = data.GetU16(&offset); // Checksum
dos_header.e_ip = data.GetU16(&offset); // Initial IP value
dos_header.e_cs = data.GetU16(&offset); // Initial (relative) CS value
dos_header.e_lfarlc =
data.GetU16(&offset); // File address of relocation table
dos_header.e_ovno = data.GetU16(&offset); // Overlay number
dos_header.e_res[0] = data.GetU16(&offset); // Reserved words
dos_header.e_res[1] = data.GetU16(&offset); // Reserved words
dos_header.e_res[2] = data.GetU16(&offset); // Reserved words
dos_header.e_res[3] = data.GetU16(&offset); // Reserved words
dos_header.e_oemid =
data.GetU16(&offset); // OEM identifier (for e_oeminfo)
dos_header.e_oeminfo =
data.GetU16(&offset); // OEM information; e_oemid specific
dos_header.e_res2[0] = data.GetU16(&offset); // Reserved words
dos_header.e_res2[1] = data.GetU16(&offset); // Reserved words
dos_header.e_res2[2] = data.GetU16(&offset); // Reserved words
dos_header.e_res2[3] = data.GetU16(&offset); // Reserved words
dos_header.e_res2[4] = data.GetU16(&offset); // Reserved words
dos_header.e_res2[5] = data.GetU16(&offset); // Reserved words
dos_header.e_res2[6] = data.GetU16(&offset); // Reserved words
dos_header.e_res2[7] = data.GetU16(&offset); // Reserved words
dos_header.e_res2[8] = data.GetU16(&offset); // Reserved words
dos_header.e_res2[9] = data.GetU16(&offset); // Reserved words
dos_header.e_lfanew =
data.GetU32(&offset); // File address of new exe header
}
}
if (!success)
memset(&dos_header, 0, sizeof(dos_header));
return success;
}
示例9: ParseCOFFHeader
//----------------------------------------------------------------------
// ParserCOFFHeader
//----------------------------------------------------------------------
bool ObjectFilePECOFF::ParseCOFFHeader(DataExtractor &data,
lldb::offset_t *offset_ptr,
coff_header_t &coff_header) {
bool success =
data.ValidOffsetForDataOfSize(*offset_ptr, sizeof(coff_header));
if (success) {
coff_header.machine = data.GetU16(offset_ptr);
coff_header.nsects = data.GetU16(offset_ptr);
coff_header.modtime = data.GetU32(offset_ptr);
coff_header.symoff = data.GetU32(offset_ptr);
coff_header.nsyms = data.GetU32(offset_ptr);
coff_header.hdrsize = data.GetU16(offset_ptr);
coff_header.flags = data.GetU16(offset_ptr);
}
if (!success)
memset(&coff_header, 0, sizeof(coff_header));
return success;
}
示例10:
void
ThreadKDP::SetStopInfoFrom_KDP_EXCEPTION (const DataExtractor &exc_reply_packet)
{
lldb::offset_t offset = 0;
uint8_t reply_command = exc_reply_packet.GetU8(&offset);
if (reply_command == CommunicationKDP::KDP_EXCEPTION)
{
offset = 8;
const uint32_t count = exc_reply_packet.GetU32 (&offset);
if (count >= 1)
{
//const uint32_t cpu = exc_reply_packet.GetU32 (&offset);
offset += 4; // Skip the useless CPU field
const uint32_t exc_type = exc_reply_packet.GetU32 (&offset);
const uint32_t exc_code = exc_reply_packet.GetU32 (&offset);
const uint32_t exc_subcode = exc_reply_packet.GetU32 (&offset);
// We have to make a copy of the stop info because the thread list
// will iterate through the threads and clear all stop infos..
// Let the StopInfoMachException::CreateStopReasonWithMachException()
// function update the PC if needed as we might hit a software breakpoint
// and need to decrement the PC (i386 and x86_64 need this) and KDP
// doesn't do this for us.
const bool pc_already_adjusted = false;
const bool adjust_pc_if_needed = true;
m_cached_stop_info_sp = StopInfoMachException::CreateStopReasonWithMachException (*this,
exc_type,
2,
exc_code,
exc_subcode,
0,
pc_already_adjusted,
adjust_pc_if_needed);
}
}
}
示例11: extractor
Error
AdbClient::ReadSyncHeader (std::string &response_id, uint32_t &data_len)
{
char buffer[kSyncPacketLen];
auto error = ReadAllBytes (buffer, kSyncPacketLen);
if (error.Success ())
{
response_id.assign (&buffer[0], 4);
DataExtractor extractor (&buffer[4], 4, eByteOrderLittle, sizeof (void*));
offset_t offset = 0;
data_len = extractor.GetU32 (&offset);
}
return error;
}
示例12: if
size_t
ObjectFilePECOFF::GetModuleSpecifications (const lldb_private::FileSpec& file,
lldb::DataBufferSP& data_sp,
lldb::offset_t data_offset,
lldb::offset_t file_offset,
lldb::offset_t length,
lldb_private::ModuleSpecList &specs)
{
const size_t initial_count = specs.GetSize();
if (ObjectFilePECOFF::MagicBytesMatch(data_sp))
{
DataExtractor data;
data.SetData(data_sp, data_offset, length);
data.SetByteOrder(eByteOrderLittle);
dos_header_t dos_header;
coff_header_t coff_header;
if (ParseDOSHeader(data, dos_header))
{
lldb::offset_t offset = dos_header.e_lfanew;
uint32_t pe_signature = data.GetU32(&offset);
if (pe_signature != IMAGE_NT_SIGNATURE)
return false;
if (ParseCOFFHeader(data, &offset, coff_header))
{
ArchSpec spec;
if (coff_header.machine == MachineAmd64)
{
spec.SetTriple("x86_64-pc-windows");
specs.Append(ModuleSpec(file, spec));
}
else if (coff_header.machine == MachineX86)
{
spec.SetTriple("i386-pc-windows");
specs.Append(ModuleSpec(file, spec));
spec.SetTriple("i686-pc-windows");
specs.Append(ModuleSpec(file, spec));
}
}
}
}
return specs.GetSize() - initial_count;
}
示例13: data_buffer_sp
static bool
FileAtPathContainsArchAndUUID
(
const FileSpec &file_spec,
const ArchSpec *arch,
const lldb_private::UUID *uuid
)
{
DataExtractor data;
off_t file_offset = 0;
DataBufferSP data_buffer_sp (file_spec.ReadFileContents (file_offset, 0x1000));
if (data_buffer_sp && data_buffer_sp->GetByteSize() > 0)
{
data.SetData(data_buffer_sp);
uint32_t data_offset = 0;
uint32_t magic = data.GetU32(&data_offset);
switch (magic)
{
// 32 bit mach-o file
case HeaderMagic32:
case HeaderMagic32Swapped:
case HeaderMagic64:
case HeaderMagic64Swapped:
return SkinnyMachOFileContainsArchAndUUID (file_spec, arch, uuid, file_offset, data, data_offset, magic);
// fat mach-o file
case UniversalMagic:
case UniversalMagicSwapped:
return UniversalMachOFileContainsArchAndUUID (file_spec, arch, uuid, file_offset, data, data_offset, magic);
default:
break;
}
}
return false;
}
示例14: WriteRegisterSet
bool
RegisterContextMach_i386::WriteRegisterBytes (uint32_t reg, DataExtractor &data, uint32_t data_offset)
{
int set = GetSetForNativeRegNum (reg);
if (set == -1)
return false;
if (ReadRegisterSet(set, false) != KERN_SUCCESS)
return false;
const RegisterInfo * reg_info = GetRegisterInfoAtIndex (reg);
if (reg_info == NULL && data.ValidOffsetForDataOfSize(data_offset, reg_info->byte_size))
return false;
uint32_t offset = data_offset;
switch (reg)
{
case gpr_eax:
case gpr_ebx:
case gpr_ecx:
case gpr_edx:
case gpr_edi:
case gpr_esi:
case gpr_ebp:
case gpr_esp:
case gpr_ss:
case gpr_eflags:
case gpr_eip:
case gpr_cs:
case gpr_ds:
case gpr_es:
case gpr_fs:
case gpr_gs:
(&gpr.eax)[reg - gpr_eax] = data.GetU32 (&offset);
break;
case fpu_fcw:
fpu.fcw = data.GetU16(&offset);
break;
case fpu_fsw:
fpu.fsw = data.GetU16(&offset);
break;
case fpu_ftw:
fpu.ftw = data.GetU8(&offset);
break;
case fpu_fop:
fpu.fop = data.GetU16(&offset);
break;
case fpu_ip:
fpu.ip = data.GetU32(&offset);
break;
case fpu_cs:
fpu.cs = data.GetU16(&offset);
break;
case fpu_dp:
fpu.dp = data.GetU32(&offset);
break;
case fpu_ds:
fpu.ds = data.GetU16(&offset);
break;
case fpu_mxcsr:
fpu.mxcsr = data.GetU32(&offset);
break;
case fpu_mxcsrmask:
fpu.mxcsrmask = data.GetU32(&offset);
break;
case fpu_stmm0:
case fpu_stmm1:
case fpu_stmm2:
case fpu_stmm3:
case fpu_stmm4:
case fpu_stmm5:
case fpu_stmm6:
case fpu_stmm7:
::memcpy (fpu.stmm[reg - fpu_stmm0].bytes, data.PeekData(offset, reg_info->byte_size), reg_info->byte_size);
return false;
case fpu_xmm0:
case fpu_xmm1:
case fpu_xmm2:
case fpu_xmm3:
case fpu_xmm4:
case fpu_xmm5:
case fpu_xmm6:
case fpu_xmm7:
// These values don't fit into scalar types, RegisterContext::ReadRegisterBytes()
// must be used for these registers
::memcpy (fpu.xmm[reg - fpu_xmm0].bytes, data.PeekData(offset, reg_info->byte_size), reg_info->byte_size);
//.........这里部分代码省略.........
示例15: switch
//.........这里部分代码省略.........
sint = data.GetSLEB128(offset_ptr);
s.Printf("%llu %lli", uint, sint);
return 0;
}
if (opcode_class != DRC_ONEOPERAND)
{
s.Printf("UNKNOWN OP %u", opcode);
return 1;
}
switch (opcode)
{
case DW_OP_addr: size = address_size; break;
case DW_OP_const1u: size = 1; break;
case DW_OP_const1s: size = -1; break;
case DW_OP_const2u: size = 2; break;
case DW_OP_const2s: size = -2; break;
case DW_OP_const4u: size = 4; break;
case DW_OP_const4s: size = -4; break;
case DW_OP_const8u: size = 8; break;
case DW_OP_const8s: size = -8; break;
case DW_OP_constu: size = 128; break;
case DW_OP_consts: size = -128; break;
case DW_OP_fbreg: size = -128; break;
case DW_OP_breg0:
case DW_OP_breg1:
case DW_OP_breg2:
case DW_OP_breg3:
case DW_OP_breg4:
case DW_OP_breg5:
case DW_OP_breg6:
case DW_OP_breg7:
case DW_OP_breg8:
case DW_OP_breg9:
case DW_OP_breg10:
case DW_OP_breg11:
case DW_OP_breg12:
case DW_OP_breg13:
case DW_OP_breg14:
case DW_OP_breg15:
case DW_OP_breg16:
case DW_OP_breg17:
case DW_OP_breg18:
case DW_OP_breg19:
case DW_OP_breg20:
case DW_OP_breg21:
case DW_OP_breg22:
case DW_OP_breg23:
case DW_OP_breg24:
case DW_OP_breg25:
case DW_OP_breg26:
case DW_OP_breg27:
case DW_OP_breg28:
case DW_OP_breg29:
case DW_OP_breg30:
case DW_OP_breg31:
size = -128; break;
case DW_OP_pick:
size = 1; break;
case DW_OP_deref_size:
size = 1; break;
case DW_OP_xderef_size:
size = 1; break;
case DW_OP_plus_uconst:
size = 128; break;
case DW_OP_skip:
size = -2; break;
case DW_OP_bra:
size = -2; break;
case DW_OP_call2:
size = 2; break;
case DW_OP_call4:
size = 4; break;
case DW_OP_call_ref:
size = dwarf_ref_size; break;
case DW_OP_piece:
size = 128; break;
case DW_OP_regx:
size = 128; break;
default:
s.Printf("UNKNOWN ONE-OPERAND OPCODE, #%u", opcode);
return 1;
}
switch (size)
{
case -1: sint = (int8_t) data.GetU8(offset_ptr); s.Printf("%+lli", sint); break;
case -2: sint = (int16_t) data.GetU16(offset_ptr); s.Printf("%+lli", sint); break;
case -4: sint = (int32_t) data.GetU32(offset_ptr); s.Printf("%+lli", sint); break;
case -8: sint = (int64_t) data.GetU64(offset_ptr); s.Printf("%+lli", sint); break;
case -128: sint = data.GetSLEB128(offset_ptr); s.Printf("%+lli", sint); break;
case 1: uint = data.GetU8(offset_ptr); s.Printf("0x%2.2llx", uint); break;
case 2: uint = data.GetU16(offset_ptr); s.Printf("0x%4.4llx", uint); break;
case 4: uint = data.GetU32(offset_ptr); s.Printf("0x%8.8llx", uint); break;
case 8: uint = data.GetU64(offset_ptr); s.Printf("0x%16.16llx", uint); break;
case 128: uint = data.GetULEB128(offset_ptr); s.Printf("0x%llx", uint); break;
}
return 0;
}