本文整理汇总了C++中DataExtractor::GetPointer方法的典型用法代码示例。如果您正苦于以下问题:C++ DataExtractor::GetPointer方法的具体用法?C++ DataExtractor::GetPointer怎么用?C++ DataExtractor::GetPointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataExtractor
的用法示例。
在下文中一共展示了DataExtractor::GetPointer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetData
bool ValueObjectDynamicValue::SetData(DataExtractor &data, Status &error) {
if (!UpdateValueIfNeeded(false)) {
error.SetErrorString("unable to read value");
return false;
}
uint64_t my_value = GetValueAsUnsigned(UINT64_MAX);
uint64_t parent_value = m_parent->GetValueAsUnsigned(UINT64_MAX);
if (my_value == UINT64_MAX || parent_value == UINT64_MAX) {
error.SetErrorString("unable to read value");
return false;
}
// if we are at an offset from our parent, in order to set ourselves
// correctly we would need to change the new value so that it refers to the
// correct dynamic type. we choose not to deal with that - if anything more
// than a value overwrite is required, you should be using the expression
// parser instead of the value editing facility
if (my_value != parent_value) {
// but NULL'ing out a value should always be allowed
lldb::offset_t offset = 0;
if (data.GetPointer(&offset) != 0) {
error.SetErrorString(
"unable to modify dynamic value, use 'expression' command");
return false;
}
}
bool ret_val = m_parent->SetData(data, error);
SetNeedsUpdate();
return ret_val;
}
示例2: 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);
//.........这里部分代码省略.........
示例3: data
void
SystemRuntimeMacOSX::PopulateQueuesUsingLibBTR (lldb::addr_t queues_buffer, uint64_t queues_buffer_size,
uint64_t count, lldb_private::QueueList &queue_list)
{
Error error;
DataBufferHeap data (queues_buffer_size, 0);
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SYSTEM_RUNTIME));
if (m_process->ReadMemory (queues_buffer, data.GetBytes(), queues_buffer_size, error) == queues_buffer_size && error.Success())
{
// We've read the information out of inferior memory; free it on the next call we make
m_page_to_free = queues_buffer;
m_page_to_free_size = queues_buffer_size;
DataExtractor extractor (data.GetBytes(), data.GetByteSize(), m_process->GetByteOrder(), m_process->GetAddressByteSize());
offset_t offset = 0;
uint64_t queues_read = 0;
// The information about the queues is stored in this format (v1):
// typedef struct introspection_dispatch_queue_info_s {
// uint32_t offset_to_next;
// dispatch_queue_t queue;
// uint64_t serialnum; // queue's serialnum in the process, as provided by libdispatch
// uint32_t running_work_items_count;
// uint32_t pending_work_items_count;
//
// char data[]; // Starting here, we have variable-length data:
// // char queue_label[];
// } introspection_dispatch_queue_info_s;
while (queues_read < count && offset < queues_buffer_size)
{
offset_t start_of_this_item = offset;
uint32_t offset_to_next = extractor.GetU32 (&offset);
offset += 4; // Skip over the 4 bytes of reserved space
addr_t queue = extractor.GetPointer (&offset);
uint64_t serialnum = extractor.GetU64 (&offset);
uint32_t running_work_items_count = extractor.GetU32 (&offset);
uint32_t pending_work_items_count = extractor.GetU32 (&offset);
// Read the first field of the variable length data
offset = start_of_this_item + m_lib_backtrace_recording_info.queue_info_data_offset;
const char *queue_label = extractor.GetCStr (&offset);
if (queue_label == NULL)
queue_label = "";
offset_t start_of_next_item = start_of_this_item + offset_to_next;
offset = start_of_next_item;
if (log)
log->Printf ("SystemRuntimeMacOSX::PopulateQueuesUsingLibBTR added queue with dispatch_queue_t 0x%" PRIx64 ", serial number 0x%" PRIx64 ", running items %d, pending items %d, name '%s'", queue, serialnum, running_work_items_count, pending_work_items_count, queue_label);
QueueSP queue_sp (new Queue (m_process->shared_from_this(), serialnum, queue_label));
queue_sp->SetNumRunningWorkItems (running_work_items_count);
queue_sp->SetNumPendingWorkItems (pending_work_items_count);
queue_sp->SetLibdispatchQueueAddress (queue);
queue_sp->SetKind (GetQueueKind (queue));
queue_list.AddQueue (queue_sp);
queues_read++;
}
}
}
示例4: cur_thread_sp
SystemRuntimeMacOSX::PendingItemsForQueue
SystemRuntimeMacOSX::GetPendingItemRefsForQueue (lldb::addr_t queue)
{
PendingItemsForQueue pending_item_refs;
AppleGetPendingItemsHandler::GetPendingItemsReturnInfo pending_items_pointer;
ThreadSP cur_thread_sp (m_process->GetThreadList().GetSelectedThread());
if (cur_thread_sp)
{
Error error;
pending_items_pointer = m_get_pending_items_handler.GetPendingItems (*cur_thread_sp.get(), queue, m_page_to_free, m_page_to_free_size, error);
m_page_to_free = LLDB_INVALID_ADDRESS;
m_page_to_free_size = 0;
if (error.Success())
{
if (pending_items_pointer.count > 0
&& pending_items_pointer.items_buffer_size > 0
&& pending_items_pointer.items_buffer_ptr != 0
&& pending_items_pointer.items_buffer_ptr != LLDB_INVALID_ADDRESS)
{
DataBufferHeap data (pending_items_pointer.items_buffer_size, 0);
if (m_process->ReadMemory (pending_items_pointer.items_buffer_ptr, data.GetBytes(), pending_items_pointer.items_buffer_size, error))
{
DataExtractor extractor (data.GetBytes(), data.GetByteSize(), m_process->GetByteOrder(), m_process->GetAddressByteSize());
// We either have an array of
// void* item_ref
// (old style) or we have a structure returned which looks like
//
// struct introspection_dispatch_pending_item_info_s {
// void *item_ref;
// void *function_or_block;
// };
//
// struct introspection_dispatch_pending_items_array_s {
// uint32_t version;
// uint32_t size_of_item_info;
// introspection_dispatch_pending_item_info_s items[];
// }
offset_t offset = 0;
int i = 0;
uint32_t version = extractor.GetU32(&offset);
if (version == 1)
{
pending_item_refs.new_style = true;
uint32_t item_size = extractor.GetU32(&offset);
uint32_t start_of_array_offset = offset;
while (offset < pending_items_pointer.items_buffer_size &&
static_cast<size_t>(i) < pending_items_pointer.count)
{
offset = start_of_array_offset + (i * item_size);
ItemRefAndCodeAddress item;
item.item_ref = extractor.GetPointer (&offset);
item.code_address = extractor.GetPointer (&offset);
pending_item_refs.item_refs_and_code_addresses.push_back (item);
i++;
}
}
else
{
offset = 0;
pending_item_refs.new_style = false;
while (offset < pending_items_pointer.items_buffer_size &&
static_cast<size_t>(i) < pending_items_pointer.count)
{
ItemRefAndCodeAddress item;
item.item_ref = extractor.GetPointer (&offset);
item.code_address = LLDB_INVALID_ADDRESS;
pending_item_refs.item_refs_and_code_addresses.push_back (item);
i++;
}
}
}
m_page_to_free = pending_items_pointer.items_buffer_ptr;
m_page_to_free_size = pending_items_pointer.items_buffer_size;
}
}
}
return pending_item_refs;
}
示例5: objc_module_sp
void
AppleObjCRuntimeV1::UpdateISAToDescriptorMapIfNeeded()
{
// TODO: implement HashTableSignature...
Process *process = GetProcess();
if (process)
{
// Update the process stop ID that indicates the last time we updated the
// map, whether it was successful or not.
m_isa_to_descriptor_stop_id = process->GetStopID();
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
ProcessSP process_sp = process->shared_from_this();
ModuleSP objc_module_sp(GetObjCModule());
if (!objc_module_sp)
return;
uint32_t isa_count = 0;
lldb::addr_t hash_table_ptr = GetISAHashTablePointer ();
if (hash_table_ptr != LLDB_INVALID_ADDRESS)
{
// Read the NXHashTable struct:
//
// typedef struct {
// const NXHashTablePrototype *prototype;
// unsigned count;
// unsigned nbBuckets;
// void *buckets;
// const void *info;
// } NXHashTable;
Error error;
DataBufferHeap buffer(1024, 0);
if (process->ReadMemory(hash_table_ptr, buffer.GetBytes(), 20, error) == 20)
{
const uint32_t addr_size = m_process->GetAddressByteSize();
const ByteOrder byte_order = m_process->GetByteOrder();
DataExtractor data (buffer.GetBytes(), buffer.GetByteSize(), byte_order, addr_size);
lldb::offset_t offset = addr_size; // Skip prototype
const uint32_t count = data.GetU32(&offset);
const uint32_t num_buckets = data.GetU32(&offset);
const addr_t buckets_ptr = data.GetPointer(&offset);
if (m_hash_signature.NeedsUpdate (count, num_buckets, buckets_ptr))
{
m_hash_signature.UpdateSignature (count, num_buckets, buckets_ptr);
const uint32_t data_size = num_buckets * 2 * sizeof(uint32_t);
buffer.SetByteSize(data_size);
if (process->ReadMemory(buckets_ptr, buffer.GetBytes(), data_size, error) == data_size)
{
data.SetData(buffer.GetBytes(), buffer.GetByteSize(), byte_order);
offset = 0;
for (uint32_t bucket_idx = 0; bucket_idx < num_buckets; ++bucket_idx)
{
const uint32_t bucket_isa_count = data.GetU32 (&offset);
const lldb::addr_t bucket_data = data.GetU32 (&offset);
if (bucket_isa_count == 0)
continue;
isa_count += bucket_isa_count;
ObjCISA isa;
if (bucket_isa_count == 1)
{
// When we only have one entry in the bucket, the bucket data is the "isa"
isa = bucket_data;
if (isa)
{
if (!ISAIsCached(isa))
{
ClassDescriptorSP descriptor_sp (new ClassDescriptorV1(isa, process_sp));
if (log && log->GetVerbose())
log->Printf("AppleObjCRuntimeV1 added (ObjCISA)0x%" PRIx64 " from _objc_debug_class_hash to isa->descriptor cache", isa);
AddClass (isa, descriptor_sp);
}
}
}
else
{
// When we have more than one entry in the bucket, the bucket data is a pointer
// to an array of "isa" values
addr_t isa_addr = bucket_data;
for (uint32_t isa_idx = 0; isa_idx < bucket_isa_count; ++isa_idx, isa_addr += addr_size)
{
isa = m_process->ReadPointerFromMemory(isa_addr, error);
if (isa && isa != LLDB_INVALID_ADDRESS)
{
if (!ISAIsCached(isa))
{
//.........这里部分代码省略.........
示例6: 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);
}
}
}
}
示例7: data
bool
DynamicLoaderMacOSXDYLD::ReadAllImageInfosStructure ()
{
std::lock_guard<std::recursive_mutex> guard(m_mutex);
// the all image infos is already valid for this process stop ID
if (m_process->GetStopID() == m_dyld_all_image_infos_stop_id)
return true;
m_dyld_all_image_infos.Clear();
if (m_dyld_all_image_infos_addr != LLDB_INVALID_ADDRESS)
{
ByteOrder byte_order = m_process->GetTarget().GetArchitecture().GetByteOrder();
uint32_t addr_size = 4;
if (m_dyld_all_image_infos_addr > UINT32_MAX)
addr_size = 8;
uint8_t buf[256];
DataExtractor data (buf, sizeof(buf), byte_order, addr_size);
lldb::offset_t offset = 0;
const size_t count_v2 = sizeof (uint32_t) + // version
sizeof (uint32_t) + // infoArrayCount
addr_size + // infoArray
addr_size + // notification
addr_size + // processDetachedFromSharedRegion + libSystemInitialized + pad
addr_size; // dyldImageLoadAddress
const size_t count_v11 = count_v2 +
addr_size + // jitInfo
addr_size + // dyldVersion
addr_size + // errorMessage
addr_size + // terminationFlags
addr_size + // coreSymbolicationShmPage
addr_size + // systemOrderFlag
addr_size + // uuidArrayCount
addr_size + // uuidArray
addr_size + // dyldAllImageInfosAddress
addr_size + // initialImageCount
addr_size + // errorKind
addr_size + // errorClientOfDylibPath
addr_size + // errorTargetDylibPath
addr_size; // errorSymbol
const size_t count_v13 = count_v11 +
addr_size + // sharedCacheSlide
sizeof (uuid_t); // sharedCacheUUID
UNUSED_IF_ASSERT_DISABLED(count_v13);
assert (sizeof (buf) >= count_v13);
Error error;
if (m_process->ReadMemory (m_dyld_all_image_infos_addr, buf, 4, error) == 4)
{
m_dyld_all_image_infos.version = data.GetU32(&offset);
// If anything in the high byte is set, we probably got the byte
// order incorrect (the process might not have it set correctly
// yet due to attaching to a program without a specified file).
if (m_dyld_all_image_infos.version & 0xff000000)
{
// We have guessed the wrong byte order. Swap it and try
// reading the version again.
if (byte_order == eByteOrderLittle)
byte_order = eByteOrderBig;
else
byte_order = eByteOrderLittle;
data.SetByteOrder (byte_order);
offset = 0;
m_dyld_all_image_infos.version = data.GetU32(&offset);
}
}
else
{
return false;
}
const size_t count = (m_dyld_all_image_infos.version >= 11) ? count_v11 : count_v2;
const size_t bytes_read = m_process->ReadMemory (m_dyld_all_image_infos_addr, buf, count, error);
if (bytes_read == count)
{
offset = 0;
m_dyld_all_image_infos.version = data.GetU32(&offset);
m_dyld_all_image_infos.dylib_info_count = data.GetU32(&offset);
m_dyld_all_image_infos.dylib_info_addr = data.GetPointer(&offset);
m_dyld_all_image_infos.notification = data.GetPointer(&offset);
m_dyld_all_image_infos.processDetachedFromSharedRegion = data.GetU8(&offset);
m_dyld_all_image_infos.libSystemInitialized = data.GetU8(&offset);
// Adjust for padding.
offset += addr_size - 2;
m_dyld_all_image_infos.dyldImageLoadAddress = data.GetPointer(&offset);
if (m_dyld_all_image_infos.version >= 11)
{
offset += addr_size * 8;
uint64_t dyld_all_image_infos_addr = data.GetPointer(&offset);
// When we started, we were given the actual address of the all_image_infos
// struct (probably via TASK_DYLD_INFO) in memory - this address is stored in
// m_dyld_all_image_infos_addr and is the most accurate address we have.
// We read the dyld_all_image_infos struct from memory; it contains its own address.
// If the address in the struct does not match the actual address,
//.........这里部分代码省略.........