本文整理汇总了C++中DataExtractor::GetU16方法的典型用法代码示例。如果您正苦于以下问题:C++ DataExtractor::GetU16方法的具体用法?C++ DataExtractor::GetU16怎么用?C++ DataExtractor::GetU16使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataExtractor
的用法示例。
在下文中一共展示了DataExtractor::GetU16方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: data
void
SystemRuntimeMacOSX::ReadLibpthreadOffsets ()
{
if (m_libpthread_offsets.IsValid())
return;
ReadLibpthreadOffsetsAddress ();
if (m_libpthread_layout_offsets_addr != LLDB_INVALID_ADDRESS)
{
uint8_t memory_buffer[sizeof (struct LibpthreadOffsets)];
DataExtractor data (memory_buffer,
sizeof(memory_buffer),
m_process->GetByteOrder(),
m_process->GetAddressByteSize());
Error error;
if (m_process->ReadMemory (m_libpthread_layout_offsets_addr, memory_buffer, sizeof(memory_buffer), error) == sizeof(memory_buffer))
{
lldb::offset_t data_offset = 0;
// The struct LibpthreadOffsets is a series of uint16_t's - extract them all
// in one big go.
data.GetU16 (&data_offset, &m_libpthread_offsets.plo_version, sizeof (struct LibpthreadOffsets) / sizeof (uint16_t));
}
}
}
示例2: GetSize
Error
ELFLinuxPrStatus::Parse(DataExtractor &data, ArchSpec &arch)
{
Error error;
ByteOrder byteorder = data.GetByteOrder();
if (GetSize(arch) > data.GetByteSize())
{
error.SetErrorStringWithFormat("NT_PRSTATUS 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(ELFLinuxPrStatus), 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
offset_t offset = 0;
si_signo = data.GetU32(&offset);
si_code = data.GetU32(&offset);
si_errno = data.GetU32(&offset);
pr_cursig = data.GetU16(&offset);
offset += 2; // pad
pr_sigpend = data.GetU32(&offset);
pr_sighold = data.GetU32(&offset);
pr_pid = data.GetU32(&offset);
pr_ppid = data.GetU32(&offset);
pr_pgrp = data.GetU32(&offset);
pr_sid = data.GetU32(&offset);
pr_utime.tv_sec = data.GetU32(&offset);
pr_utime.tv_usec = data.GetU32(&offset);
pr_stime.tv_sec = data.GetU32(&offset);
pr_stime.tv_usec = data.GetU32(&offset);
pr_cutime.tv_sec = data.GetU32(&offset);
pr_cutime.tv_usec = data.GetU32(&offset);
pr_cstime.tv_sec = data.GetU32(&offset);
pr_cstime.tv_usec = data.GetU32(&offset);
break;
}
default:
error.SetErrorStringWithFormat("ELFLinuxPrStatus::%s Unknown architecture", __FUNCTION__);
break;
}
return error;
}
示例3: 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;
}
示例4: 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;
}
示例5: CheckForPacket
bool CommunicationKDP::CheckForPacket(const uint8_t *src, size_t src_len,
DataExtractor &packet) {
// Put the packet data into the buffer in a thread safe fashion
std::lock_guard<std::recursive_mutex> guard(m_bytes_mutex);
Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PACKETS));
if (src && src_len > 0) {
if (log && log->GetVerbose()) {
PacketStreamType log_strm;
DumpHexBytes(&log_strm, src, src_len, UINT32_MAX, LLDB_INVALID_ADDRESS);
log->Printf("CommunicationKDP::%s adding %u bytes: %s", __FUNCTION__,
(uint32_t)src_len, log_strm.GetData());
}
m_bytes.append((const char *)src, src_len);
}
// Make sure we at least have enough bytes for a packet header
const size_t bytes_available = m_bytes.size();
if (bytes_available >= 8) {
packet.SetData(&m_bytes[0], bytes_available, m_byte_order);
lldb::offset_t offset = 0;
uint8_t reply_command = packet.GetU8(&offset);
switch (reply_command) {
case ePacketTypeRequest | KDP_EXCEPTION:
case ePacketTypeRequest | KDP_TERMINATION:
// We got an exception request, so be sure to send an ACK
{
PacketStreamType request_ack_packet(Stream::eBinary, m_addr_byte_size,
m_byte_order);
// Set the reply but and make the ACK packet
request_ack_packet.PutHex8(reply_command | ePacketTypeReply);
request_ack_packet.PutHex8(packet.GetU8(&offset));
request_ack_packet.PutHex16(packet.GetU16(&offset));
request_ack_packet.PutHex32(packet.GetU32(&offset));
m_is_running.SetValue(false, eBroadcastAlways);
// Ack to the exception or termination
SendRequestPacketNoLock(request_ack_packet);
}
// Fall through to case below to get packet contents
LLVM_FALLTHROUGH;
case ePacketTypeReply | KDP_CONNECT:
case ePacketTypeReply | KDP_DISCONNECT:
case ePacketTypeReply | KDP_HOSTINFO:
case ePacketTypeReply | KDP_VERSION:
case ePacketTypeReply | KDP_MAXBYTES:
case ePacketTypeReply | KDP_READMEM:
case ePacketTypeReply | KDP_WRITEMEM:
case ePacketTypeReply | KDP_READREGS:
case ePacketTypeReply | KDP_WRITEREGS:
case ePacketTypeReply | KDP_LOAD:
case ePacketTypeReply | KDP_IMAGEPATH:
case ePacketTypeReply | KDP_SUSPEND:
case ePacketTypeReply | KDP_RESUMECPUS:
case ePacketTypeReply | KDP_BREAKPOINT_SET:
case ePacketTypeReply | KDP_BREAKPOINT_REMOVE:
case ePacketTypeReply | KDP_REGIONS:
case ePacketTypeReply | KDP_REATTACH:
case ePacketTypeReply | KDP_HOSTREBOOT:
case ePacketTypeReply | KDP_READMEM64:
case ePacketTypeReply | KDP_WRITEMEM64:
case ePacketTypeReply | KDP_BREAKPOINT_SET64:
case ePacketTypeReply | KDP_BREAKPOINT_REMOVE64:
case ePacketTypeReply | KDP_KERNELVERSION:
case ePacketTypeReply | KDP_READPHYSMEM64:
case ePacketTypeReply | KDP_WRITEPHYSMEM64:
case ePacketTypeReply | KDP_READIOPORT:
case ePacketTypeReply | KDP_WRITEIOPORT:
case ePacketTypeReply | KDP_READMSR64:
case ePacketTypeReply | KDP_WRITEMSR64:
case ePacketTypeReply | KDP_DUMPINFO: {
offset = 2;
const uint16_t length = packet.GetU16(&offset);
if (length <= bytes_available) {
// We have an entire packet ready, we need to copy the data bytes into
// a buffer that will be owned by the packet and erase the bytes from
// our communcation buffer "m_bytes"
packet.SetData(DataBufferSP(new DataBufferHeap(&m_bytes[0], length)));
m_bytes.erase(0, length);
if (log) {
PacketStreamType log_strm;
DumpPacket(log_strm, packet);
log->Printf("%.*s", (uint32_t)log_strm.GetSize(), log_strm.GetData());
}
return true;
}
} break;
default:
// Unrecognized reply command byte, erase this byte and try to get back
// on track
if (log)
log->Printf("CommunicationKDP::%s: tossing junk byte: 0x%2.2x",
__FUNCTION__, (uint8_t)m_bytes[0]);
m_bytes.erase(0, 1);
break;
}
}
//.........这里部分代码省略.........
示例6: CalculateMnemonicOperandsAndComment
virtual void
CalculateMnemonicOperandsAndComment (const lldb_private::ExecutionContext *exe_ctx)
{
DataExtractor data;
const AddressClass address_class = GetAddressClass ();
if (m_opcode.GetData(data, address_class))
{
char out_string[512];
::LLVMDisasmContextRef disasm_context;
if (address_class == eAddressClassCodeAlternateISA)
disasm_context = m_disasm.m_alternate_disasm_context;
else
disasm_context = m_disasm.m_disasm_context;
lldb::addr_t pc = LLDB_INVALID_ADDRESS;
if (exe_ctx)
{
Target *target = exe_ctx->GetTargetPtr();
if (target)
pc = m_address.GetLoadAddress(target);
}
if (pc == LLDB_INVALID_ADDRESS)
pc = m_address.GetFileAddress();
m_disasm.Lock(this, exe_ctx);
uint8_t *opcode_data = const_cast<uint8_t *>(data.PeekData (0, 1));
const size_t opcode_data_len = data.GetByteSize();
size_t inst_size = ::LLVMDisasmInstruction (disasm_context,
opcode_data,
opcode_data_len,
pc,
out_string,
sizeof(out_string));
m_disasm.Unlock();
if (inst_size == 0)
{
m_comment.assign ("unknown opcode");
inst_size = m_opcode.GetByteSize();
StreamString mnemonic_strm;
uint32_t offset = 0;
switch (inst_size)
{
case 1:
{
const uint8_t uval8 = data.GetU8 (&offset);
m_opcode.SetOpcode8 (uval8);
m_opcode_name.assign (".byte");
mnemonic_strm.Printf("0x%2.2x", uval8);
}
break;
case 2:
{
const uint16_t uval16 = data.GetU16(&offset);
m_opcode.SetOpcode16(uval16);
m_opcode_name.assign (".short");
mnemonic_strm.Printf("0x%4.4x", uval16);
}
break;
case 4:
{
const uint32_t uval32 = data.GetU32(&offset);
m_opcode.SetOpcode32(uval32);
m_opcode_name.assign (".long");
mnemonic_strm.Printf("0x%8.8x", uval32);
}
break;
case 8:
{
const uint64_t uval64 = data.GetU64(&offset);
m_opcode.SetOpcode64(uval64);
m_opcode_name.assign (".quad");
mnemonic_strm.Printf("0x%16.16llx", uval64);
}
break;
default:
if (inst_size == 0)
return;
else
{
const uint8_t *bytes = data.PeekData(offset, inst_size);
if (bytes == NULL)
return;
m_opcode_name.assign (".byte");
m_opcode.SetOpcodeBytes(bytes, inst_size);
mnemonic_strm.Printf("0x%2.2x", bytes[0]);
for (uint32_t i=1; i<inst_size; ++i)
mnemonic_strm.Printf(" 0x%2.2x", bytes[i]);
}
break;
}
m_mnemocics.swap(mnemonic_strm.GetString());
return;
}
//.........这里部分代码省略.........
示例7: data
void
SystemRuntimeMacOSX::ReadLibdispatchTSDIndexes ()
{
if (m_libdispatch_tsd_indexes.IsValid())
return;
ReadLibdispatchTSDIndexesAddress ();
if (m_dispatch_tsd_indexes_addr != LLDB_INVALID_ADDRESS)
{
size_t maximum_tsd_indexes_struct_size;
Address dti_struct_addr;
uint16_t dti_version = 2;
if (m_process->GetTarget().ResolveLoadAddress(m_dispatch_tsd_indexes_addr, dti_struct_addr))
{
Error error;
uint16_t version = m_process->GetTarget().ReadUnsignedIntegerFromMemory (dti_struct_addr, false, 2, UINT16_MAX, error);
if (error.Success() && dti_version != UINT16_MAX)
{
dti_version = version;
}
}
if (dti_version == 1)
{
if (m_process->GetAddressByteSize() == 4)
{
maximum_tsd_indexes_struct_size = 4 + 4 + 4 + 4;
}
else
{
maximum_tsd_indexes_struct_size = 8 + 8 + 8 + 8;
}
}
else
{
maximum_tsd_indexes_struct_size = 2 + 2 + 2 + 2;
}
uint8_t memory_buffer[maximum_tsd_indexes_struct_size];
DataExtractor data (memory_buffer,
sizeof(memory_buffer),
m_process->GetByteOrder(),
m_process->GetAddressByteSize());
Error error;
if (m_process->ReadMemory (m_dispatch_tsd_indexes_addr, memory_buffer, sizeof(memory_buffer), error) == sizeof(memory_buffer))
{
lldb::offset_t offset = 0;
if (dti_version == 1)
{
m_libdispatch_tsd_indexes.dti_version = data.GetU16 (&offset);
// word alignment to next item
if (m_process->GetAddressByteSize() == 4)
{
offset += 2;
}
else
{
offset += 6;
}
m_libdispatch_tsd_indexes.dti_queue_index = data.GetPointer (&offset);
m_libdispatch_tsd_indexes.dti_voucher_index = data.GetPointer (&offset);
m_libdispatch_tsd_indexes.dti_qos_class_index = data.GetPointer (&offset);
}
else
{
m_libdispatch_tsd_indexes.dti_version = data.GetU16 (&offset);
m_libdispatch_tsd_indexes.dti_queue_index = data.GetU16 (&offset);
m_libdispatch_tsd_indexes.dti_voucher_index = data.GetU16 (&offset);
m_libdispatch_tsd_indexes.dti_qos_class_index = data.GetU16 (&offset);
}
}
}
}
示例8: SkipValue
bool
DWARFFormValue::SkipValue(dw_form_t form, const DataExtractor& debug_info_data, lldb::offset_t *offset_ptr, const DWARFCompileUnit* cu)
{
switch (form)
{
// Blocks if inlined data that have a length field and the data bytes
// inlined in the .debug_info
case DW_FORM_exprloc:
case DW_FORM_block: { dw_uleb128_t size = debug_info_data.GetULEB128(offset_ptr); *offset_ptr += size; } return true;
case DW_FORM_block1: { dw_uleb128_t size = debug_info_data.GetU8(offset_ptr); *offset_ptr += size; } return true;
case DW_FORM_block2: { dw_uleb128_t size = debug_info_data.GetU16(offset_ptr); *offset_ptr += size; } return true;
case DW_FORM_block4: { dw_uleb128_t size = debug_info_data.GetU32(offset_ptr); *offset_ptr += size; } return true;
// Inlined NULL terminated C-strings
case DW_FORM_string:
debug_info_data.GetCStr(offset_ptr);
return true;
// Compile unit address sized values
case DW_FORM_addr:
*offset_ptr += DWARFCompileUnit::GetAddressByteSize(cu);
return true;
case DW_FORM_ref_addr:
if (cu->GetVersion() <= 2)
*offset_ptr += DWARFCompileUnit::GetAddressByteSize(cu);
else
*offset_ptr += 4;// 4 for DWARF32, 8 for DWARF64, but we don't support DWARF64 yet
return true;
// 0 bytes values (implied from DW_FORM)
case DW_FORM_flag_present:
return true;
// 1 byte values
case DW_FORM_data1:
case DW_FORM_flag:
case DW_FORM_ref1:
*offset_ptr += 1;
return true;
// 2 byte values
case DW_FORM_data2:
case DW_FORM_ref2:
*offset_ptr += 2;
return true;
// 32 bit for DWARF 32, 64 for DWARF 64
case DW_FORM_sec_offset:
*offset_ptr += 4;
return true;
// 4 byte values
case DW_FORM_strp:
case DW_FORM_data4:
case DW_FORM_ref4:
*offset_ptr += 4;
return true;
// 8 byte values
case DW_FORM_data8:
case DW_FORM_ref8:
case DW_FORM_ref_sig8:
*offset_ptr += 8;
return true;
// signed or unsigned LEB 128 values
case DW_FORM_sdata:
case DW_FORM_udata:
case DW_FORM_ref_udata:
debug_info_data.Skip_LEB128(offset_ptr);
return true;
case DW_FORM_indirect:
{
dw_form_t indirect_form = debug_info_data.GetULEB128(offset_ptr);
return DWARFFormValue::SkipValue (indirect_form,
debug_info_data,
offset_ptr,
cu);
}
default:
break;
}
return false;
}
示例9: 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);
//.........这里部分代码省略.........
示例10: ldi_header_symbol
void
SystemRuntimeMacOSX::ParseLdiHeaders ()
{
if (m_ldi_header.initialized)
return;
static ConstString ldi_header_symbol ("ldi_infos");
SymbolContextList sc_list;
if (m_process->GetTarget().GetImages().FindSymbolsWithNameAndType (ldi_header_symbol, eSymbolTypeData, sc_list) > 0)
{
SymbolContext sc;
sc_list.GetContextAtIndex (0, sc);
AddressRange addr_range;
sc.GetAddressRange (eSymbolContextSymbol, 0, false, addr_range);
Error error;
Address ldi_header_addr = addr_range.GetBaseAddress();
uint8_t version_buf[6]; // version, ldi_header_size, initialized fields
DataExtractor data (version_buf, sizeof(version_buf), m_process->GetByteOrder(), m_process->GetAddressByteSize());
const size_t count = sizeof (version_buf);
const bool prefer_file_cache = false;
if (m_process->GetTarget().ReadMemory (ldi_header_addr, prefer_file_cache, version_buf, count, error) == sizeof (version_buf))
{
int version, initialized, ldi_header_size;
offset_t offset = 0;
version = data.GetU16(&offset);
ldi_header_size = data.GetU16(&offset);
initialized = data.GetU16(&offset);
if (initialized)
{
DataBufferHeap ldi_header (ldi_header_size, 0);
DataExtractor ldi_extractor (ldi_header.GetBytes(), ldi_header.GetByteSize(), m_process->GetByteOrder(), m_process->GetAddressByteSize());
if (m_process->GetTarget().ReadMemory (ldi_header_addr, prefer_file_cache, ldi_header.GetBytes(), ldi_header.GetByteSize(), error) == ldi_header.GetByteSize())
{
offset = 0;
m_ldi_header.version = ldi_extractor.GetU16(&offset);
m_ldi_header.ldi_header_size = ldi_extractor.GetU16(&offset);
m_ldi_header.initialized = ldi_extractor.GetU16(&offset);
m_ldi_header.queue_size = ldi_extractor.GetU16(&offset);
m_ldi_header.item_size = ldi_extractor.GetU16(&offset);
// 6 bytes of padding here
offset += 6;
m_ldi_header.queues_head_ptr_address = ldi_extractor.GetU64(&offset);
m_ldi_header.items_head_ptr_address = ldi_extractor.GetU64(&offset);
m_ldi_header.queue_offsets.next = ldi_extractor.GetU16(&offset);
m_ldi_header.queue_offsets.prev = ldi_extractor.GetU16(&offset);
m_ldi_header.queue_offsets.queue_id = ldi_extractor.GetU16(&offset);
m_ldi_header.queue_offsets.current_item_ptr = ldi_extractor.GetU16(&offset);
m_ldi_header.item_offsets.next = ldi_extractor.GetU16(&offset);
m_ldi_header.item_offsets.prev = ldi_extractor.GetU16(&offset);
m_ldi_header.item_offsets.type = ldi_extractor.GetU16(&offset);
m_ldi_header.item_offsets.identifier = ldi_extractor.GetU16(&offset);
m_ldi_header.item_offsets.stop_id = ldi_extractor.GetU16(&offset);
m_ldi_header.item_offsets.backtrace_length = ldi_extractor.GetU16(&offset);
m_ldi_header.item_offsets.backtrace_ptr = ldi_extractor.GetU16(&offset);
m_ldi_header.item_offsets.thread_name_ptr = ldi_extractor.GetU16(&offset);
m_ldi_header.item_offsets.queue_name_ptr = ldi_extractor.GetU16(&offset);
m_ldi_header.item_offsets.unique_thread_id = ldi_extractor.GetU16(&offset);
m_ldi_header.item_offsets.pthread_id = ldi_extractor.GetU16(&offset);
m_ldi_header.item_offsets.enqueueing_thread_dispatch_queue_t = ldi_extractor.GetU16(&offset);
m_ldi_header.item_offsets.enqueueing_thread_dispatch_block_ptr = ldi_extractor.GetU16(&offset);
if (ldi_header.GetByteSize () > offset)
{
m_ldi_header.item_offsets.queue_id_from_thread_info = ldi_extractor.GetU16(&offset);
}
else
{
m_ldi_header.item_offsets.queue_id_from_thread_info = 0xffff;
}
}
}
}
}
}
示例11: while
bool
DWARFDebugArangeSet::Extract(const DataExtractor &data, lldb::offset_t *offset_ptr)
{
if (data.ValidOffset(*offset_ptr))
{
m_arange_descriptors.clear();
m_offset = *offset_ptr;
// 7.20 Address Range Table
//
// Each set of entries in the table of address ranges contained in
// the .debug_aranges section begins with a header consisting of: a
// 4-byte length containing the length of the set of entries for this
// compilation unit, not including the length field itself; a 2-byte
// version identifier containing the value 2 for DWARF Version 2; a
// 4-byte offset into the.debug_infosection; a 1-byte unsigned integer
// containing the size in bytes of an address (or the offset portion of
// an address for segmented addressing) on the target system; and a
// 1-byte unsigned integer containing the size in bytes of a segment
// descriptor on the target system. This header is followed by a series
// of tuples. Each tuple consists of an address and a length, each in
// the size appropriate for an address on the target architecture.
m_header.length = data.GetU32(offset_ptr);
m_header.version = data.GetU16(offset_ptr);
m_header.cu_offset = data.GetU32(offset_ptr);
m_header.addr_size = data.GetU8(offset_ptr);
m_header.seg_size = data.GetU8(offset_ptr);
// The first tuple following the header in each set begins at an offset
// that is a multiple of the size of a single tuple (that is, twice the
// size of an address). The header is padded, if necessary, to the
// appropriate boundary.
const uint32_t header_size = *offset_ptr - m_offset;
const uint32_t tuple_size = m_header.addr_size << 1;
uint32_t first_tuple_offset = 0;
while (first_tuple_offset < header_size)
first_tuple_offset += tuple_size;
*offset_ptr = m_offset + first_tuple_offset;
Descriptor arangeDescriptor;
assert(sizeof(arangeDescriptor.address) == sizeof(arangeDescriptor.length));
assert(sizeof(arangeDescriptor.address) >= m_header.addr_size);
while (data.ValidOffset(*offset_ptr))
{
arangeDescriptor.address = data.GetMaxU64(offset_ptr, m_header.addr_size);
arangeDescriptor.length = data.GetMaxU64(offset_ptr, m_header.addr_size);
// Each set of tuples is terminated by a 0 for the address and 0
// for the length.
if (arangeDescriptor.address || arangeDescriptor.length)
m_arange_descriptors.push_back(arangeDescriptor);
else
break; // We are done if we get a zero address and length
}
return !m_arange_descriptors.empty();
}
return false;
}
示例12: DumpPacket
void CommunicationKDP::DumpPacket(Stream &s, const DataExtractor &packet) {
const char *error_desc = NULL;
if (packet.GetByteSize() < 8) {
error_desc = "error: invalid packet (too short): ";
} else {
lldb::offset_t offset = 0;
const uint8_t first_packet_byte = packet.GetU8(&offset);
const uint8_t sequence_id = packet.GetU8(&offset);
const uint16_t length = packet.GetU16(&offset);
const uint32_t key = packet.GetU32(&offset);
const CommandType command = ExtractCommand(first_packet_byte);
const char *command_name = GetCommandAsCString(command);
if (command_name) {
const bool is_reply = ExtractIsReply(first_packet_byte);
s.Printf("(running=%i) %s %24s: 0x%2.2x 0x%2.2x 0x%4.4x 0x%8.8x ",
IsRunning(), is_reply ? "<--" : "-->", command_name,
first_packet_byte, sequence_id, length, key);
if (is_reply) {
// Dump request reply packets
switch (command) {
// Commands that return a single 32 bit error
case KDP_CONNECT:
case KDP_WRITEMEM:
case KDP_WRITEMEM64:
case KDP_BREAKPOINT_SET:
case KDP_BREAKPOINT_REMOVE:
case KDP_BREAKPOINT_SET64:
case KDP_BREAKPOINT_REMOVE64:
case KDP_WRITEREGS:
case KDP_LOAD:
case KDP_WRITEIOPORT:
case KDP_WRITEMSR64: {
const uint32_t error = packet.GetU32(&offset);
s.Printf(" (error=0x%8.8x)", error);
} break;
case KDP_DISCONNECT:
case KDP_REATTACH:
case KDP_HOSTREBOOT:
case KDP_SUSPEND:
case KDP_RESUMECPUS:
case KDP_EXCEPTION:
case KDP_TERMINATION:
// No return value for the reply, just the header to ack
s.PutCString(" ()");
break;
case KDP_HOSTINFO: {
const uint32_t cpu_mask = packet.GetU32(&offset);
const uint32_t cpu_type = packet.GetU32(&offset);
const uint32_t cpu_subtype = packet.GetU32(&offset);
s.Printf(" (cpu_mask=0x%8.8x, cpu_type=0x%8.8x, cpu_subtype=0x%8.8x)",
cpu_mask, cpu_type, cpu_subtype);
} break;
case KDP_VERSION: {
const uint32_t version = packet.GetU32(&offset);
const uint32_t feature = packet.GetU32(&offset);
s.Printf(" (version=0x%8.8x, feature=0x%8.8x)", version, feature);
} break;
case KDP_REGIONS: {
const uint32_t region_count = packet.GetU32(&offset);
s.Printf(" (count = %u", region_count);
for (uint32_t i = 0; i < region_count; ++i) {
const addr_t region_addr = packet.GetPointer(&offset);
const uint32_t region_size = packet.GetU32(&offset);
const uint32_t region_prot = packet.GetU32(&offset);
s.Printf("\n\tregion[%" PRIu64 "] = { range = [0x%16.16" PRIx64
" - 0x%16.16" PRIx64 "), size = 0x%8.8x, prot = %s }",
region_addr, region_addr, region_addr + region_size,
region_size, GetPermissionsAsCString(region_prot));
}
} break;
case KDP_READMEM:
case KDP_READMEM64:
case KDP_READPHYSMEM64: {
const uint32_t error = packet.GetU32(&offset);
const uint32_t count = packet.GetByteSize() - offset;
s.Printf(" (error = 0x%8.8x:\n", error);
if (count > 0)
DumpDataExtractor(packet,
&s, // Stream to dump to
offset, // Offset within "packet"
eFormatBytesWithASCII, // Format to use
1, // Size of each item
// in bytes
count, // Number of items
16, // Number per line
m_last_read_memory_addr, // Don't show addresses
// before each line
0, 0); // No bitfields
} break;
case KDP_READREGS: {
const uint32_t error = packet.GetU32(&offset);
const uint32_t count = packet.GetByteSize() - offset;
s.Printf(" (error = 0x%8.8x regs:\n", error);
//.........这里部分代码省略.........
示例13: DumpDataExtractor
//.........这里部分代码省略.........
clang::ASTContext *ast = clang_ast->getASTContext();
if (ast) {
llvm::SmallVector<char, 256> sv;
// Show full precision when printing float values
const unsigned format_precision = 0;
const unsigned format_max_padding = 100;
size_t item_bit_size = item_byte_size * 8;
if (item_bit_size == ast->getTypeSize(ast->FloatTy)) {
llvm::APInt apint(item_bit_size,
DE.GetMaxU64(&offset, item_byte_size));
llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->FloatTy),
apint);
apfloat.toString(sv, format_precision, format_max_padding);
} else if (item_bit_size == ast->getTypeSize(ast->DoubleTy)) {
llvm::APInt apint;
if (GetAPInt(DE, &offset, item_byte_size, apint)) {
llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->DoubleTy),
apint);
apfloat.toString(sv, format_precision, format_max_padding);
}
} else if (item_bit_size == ast->getTypeSize(ast->LongDoubleTy)) {
const auto &semantics =
ast->getFloatTypeSemantics(ast->LongDoubleTy);
const auto byte_size =
(llvm::APFloat::getSizeInBits(semantics) + 7) / 8;
llvm::APInt apint;
if (GetAPInt(DE, &offset, byte_size, apint)) {
llvm::APFloat apfloat(semantics, apint);
apfloat.toString(sv, format_precision, format_max_padding);
}
} else if (item_bit_size == ast->getTypeSize(ast->HalfTy)) {
llvm::APInt apint(item_bit_size, DE.GetU16(&offset));
llvm::APFloat apfloat(ast->getFloatTypeSemantics(ast->HalfTy),
apint);
apfloat.toString(sv, format_precision, format_max_padding);
}
if (!sv.empty()) {
s->Printf("%*.*s", (int)sv.size(), (int)sv.size(), sv.data());
used_apfloat = true;
}
}
}
}
if (!used_apfloat) {
std::ostringstream ss;
if (item_byte_size == sizeof(float) || item_byte_size == 2) {
float f;
if (item_byte_size == 2) {
uint16_t half = DE.GetU16(&offset);
f = half2float(half);
} else {
f = DE.GetFloat(&offset);
}
ss.precision(std::numeric_limits<float>::digits10);
ss << f;
} else if (item_byte_size == sizeof(double)) {
ss.precision(std::numeric_limits<double>::digits10);
ss << DE.GetDouble(&offset);
} else if (item_byte_size == sizeof(long double) ||
item_byte_size == 10) {
ss.precision(std::numeric_limits<long double>::digits10);
ss << DE.GetLongDouble(&offset);
示例14: 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;
}
示例15: 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;
}