本文整理汇总了C++中DataExtractor::GetCStr方法的典型用法代码示例。如果您正苦于以下问题:C++ DataExtractor::GetCStr方法的具体用法?C++ DataExtractor::GetCStr怎么用?C++ DataExtractor::GetCStr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataExtractor
的用法示例。
在下文中一共展示了DataExtractor::GetCStr方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: data
static bool
GetNetBSDProcessArgs (const ProcessInstanceInfoMatch *match_info_ptr,
ProcessInstanceInfo &process_info)
{
if (!process_info.ProcessIDIsValid())
return false;
int pid = process_info.GetProcessID();
int mib[4] = { CTL_KERN, KERN_PROC_ARGS, pid, KERN_PROC_ARGV };
char arg_data[8192];
size_t arg_data_size = sizeof(arg_data);
if (::sysctl (mib, 4, arg_data, &arg_data_size , NULL, 0) != 0)
return false;
DataExtractor data (arg_data, arg_data_size, lldb::endian::InlHostByteOrder(), sizeof(void *));
lldb::offset_t offset = 0;
const char *cstr;
cstr = data.GetCStr (&offset);
if (!cstr)
return false;
process_info.GetExecutableFile().SetFile(cstr, false);
if (!(match_info_ptr == NULL ||
NameMatches (process_info.GetExecutableFile().GetFilename().GetCString(),
match_info_ptr->GetNameMatchType(),
match_info_ptr->GetProcessInfo().GetName())))
return false;
Args &proc_args = process_info.GetArguments();
while (1)
{
const uint8_t *p = data.PeekData(offset, 1);
while ((p != NULL) && (*p == '\0') && offset < arg_data_size)
{
++offset;
p = data.PeekData(offset, 1);
}
if (p == NULL || offset >= arg_data_size)
break;
cstr = data.GetCStr(&offset);
if (!cstr)
break;
proc_args.AppendArgument(cstr);
}
return true;
}
示例2: switch
bool
DWARFDebugMacinfoEntry::Extract(const DataExtractor& mac_info_data, dw_offset_t* offset_ptr)
{
if (mac_info_data.ValidOffset(*offset_ptr))
{
m_type_code = mac_info_data.GetU8(offset_ptr);
switch (m_type_code)
{
case DW_MACINFO_define:
case DW_MACINFO_undef:
// 2 operands:
// Arg 1: operand encodes the line number of the source line on which
// the relevant defining or undefining pre-processor directives
// appeared.
m_line = mac_info_data.GetULEB128(offset_ptr);
// Arg 2: define string
m_op2.cstr = mac_info_data.GetCStr(offset_ptr);
break;
case DW_MACINFO_start_file:
// 2 operands:
// Op 1: line number of the source line on which the inclusion
// pre-processor directive occurred.
m_line = mac_info_data.GetULEB128(offset_ptr);
// Op 2: a source file name index to a file number in the statement
// information table for the relevant compilation unit.
m_op2.file_idx = mac_info_data.GetULEB128(offset_ptr);
break;
case 0: // End of list
case DW_MACINFO_end_file:
// No operands
m_line = DW_INVALID_OFFSET;
m_op2.cstr = NULL;
break;
default:
// Vendor specific entries always have a ULEB128 and a string
m_line = mac_info_data.GetULEB128(offset_ptr);
m_op2.cstr = mac_info_data.GetCStr(offset_ptr);
break;
}
return true;
}
else
m_type_code = 0;
return false;
}
示例3:
static void
ParseFreeBSDThrMisc(ThreadData *thread_data, DataExtractor &data)
{
lldb::offset_t offset = 0;
thread_data->name = data.GetCStr(&offset, 20);
}
示例4: DumpPacket
//.........这里部分代码省略.........
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);
if (count > 0)
DumpDataExtractor(packet,
&s, // Stream to dump to
offset, // Offset within "packet"
eFormatHex, // Format to use
m_addr_byte_size, // Size of each item
// in bytes
count / m_addr_byte_size, // Number of items
16 / m_addr_byte_size, // Number per line
LLDB_INVALID_ADDRESS,
// Don't
// show addresses before
// each line
0, 0); // No bitfields
} break;
case KDP_KERNELVERSION: {
const char *kernel_version = packet.PeekCStr(8);
s.Printf(" (version = \"%s\")", kernel_version);
} break;
case KDP_MAXBYTES: {
const uint32_t max_bytes = packet.GetU32(&offset);
s.Printf(" (max_bytes = 0x%8.8x (%u))", max_bytes, max_bytes);
} break;
case KDP_IMAGEPATH: {
const char *path = packet.GetCStr(&offset);
s.Printf(" (path = \"%s\")", path);
} break;
case KDP_READIOPORT:
case KDP_READMSR64: {
const uint32_t error = packet.GetU32(&offset);
const uint32_t count = packet.GetByteSize() - offset;
s.Printf(" (error = 0x%8.8x io:\n", error);
if (count > 0)
DumpDataExtractor(packet,
&s, // Stream to dump to
offset, // Offset within "packet"
eFormatHex, // Format to use
1, // Size of each item in bytes
count, // Number of items
16, // Number per line
LLDB_INVALID_ADDRESS, // Don't show addresses
// before each line
0, 0); // No bitfields
} break;
case KDP_DUMPINFO: {
const uint32_t count = packet.GetByteSize() - offset;
s.Printf(" (count = %u, bytes = \n", count);
if (count > 0)
DumpDataExtractor(packet,
&s, // Stream to dump to
offset, // Offset within "packet"
eFormatHex, // Format to use
1, // Size of each item in
// bytes
count, // Number of items
16, // Number per line
示例5: 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++;
}
}
}
示例6: DumpDataExtractor
//.........这里部分代码省略.........
s->Printf("\\a");
break;
case '\b':
s->Printf("\\b");
break;
case '\f':
s->Printf("\\f");
break;
case '\n':
s->Printf("\\n");
break;
case '\r':
s->Printf("\\r");
break;
case '\t':
s->Printf("\\t");
break;
case '\v':
s->Printf("\\v");
break;
case '\0':
s->Printf("\\0");
break;
default:
s->Printf("\\x%2.2x", ch);
break;
}
}
}
s->PutChar('\'');
} break;
case eFormatCString: {
const char *cstr = DE.GetCStr(&offset);
if (!cstr) {
s->Printf("NULL");
offset = LLDB_INVALID_OFFSET;
} else {
s->PutChar('\"');
while (const char c = *cstr) {
if (isprint(c)) {
s->PutChar(c);
} else {
switch (c) {
case '\033':
s->Printf("\\e");
break;
case '\a':
s->Printf("\\a");
break;
case '\b':
s->Printf("\\b");
break;
case '\f':
s->Printf("\\f");
break;
case '\n':
s->Printf("\\n");
break;
case '\r':
s->Printf("\\r");
break;
case '\t':
s->Printf("\\t");
示例7: 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;
}
示例8: switch
bool
DWARFFormValue::ExtractValue(const DataExtractor& data, lldb::offset_t* offset_ptr, const DWARFCompileUnit* cu)
{
bool indirect = false;
bool is_block = false;
m_value.data = NULL;
// Read the value for the form into value and follow and DW_FORM_indirect instances we run into
do
{
indirect = false;
switch (m_form)
{
case DW_FORM_addr: m_value.value.uval = data.GetMaxU64(offset_ptr, DWARFCompileUnit::GetAddressByteSize(cu)); break;
case DW_FORM_block2: m_value.value.uval = data.GetU16(offset_ptr); is_block = true; break;
case DW_FORM_block4: m_value.value.uval = data.GetU32(offset_ptr); is_block = true; break;
case DW_FORM_data2: m_value.value.uval = data.GetU16(offset_ptr); break;
case DW_FORM_data4: m_value.value.uval = data.GetU32(offset_ptr); break;
case DW_FORM_data8: m_value.value.uval = data.GetU64(offset_ptr); break;
case DW_FORM_string: m_value.value.cstr = data.GetCStr(offset_ptr);
// Set the string value to also be the data for inlined cstr form values only
// so we can tell the differnence between DW_FORM_string and DW_FORM_strp form
// values;
m_value.data = (uint8_t*)m_value.value.cstr; break;
case DW_FORM_exprloc:
case DW_FORM_block: m_value.value.uval = data.GetULEB128(offset_ptr); is_block = true; break;
case DW_FORM_block1: m_value.value.uval = data.GetU8(offset_ptr); is_block = true; break;
case DW_FORM_data1: m_value.value.uval = data.GetU8(offset_ptr); break;
case DW_FORM_flag: m_value.value.uval = data.GetU8(offset_ptr); break;
case DW_FORM_sdata: m_value.value.sval = data.GetSLEB128(offset_ptr); break;
case DW_FORM_strp: m_value.value.uval = data.GetU32(offset_ptr); break;
// case DW_FORM_APPLE_db_str:
case DW_FORM_udata: m_value.value.uval = data.GetULEB128(offset_ptr); break;
case DW_FORM_ref_addr:
if (cu->GetVersion() <= 2)
m_value.value.uval = data.GetMaxU64(offset_ptr, DWARFCompileUnit::GetAddressByteSize(cu));
else
m_value.value.uval = data.GetU32(offset_ptr); // 4 for DWARF32, 8 for DWARF64, but we don't support DWARF64 yet
break;
case DW_FORM_ref1: m_value.value.uval = data.GetU8(offset_ptr); break;
case DW_FORM_ref2: m_value.value.uval = data.GetU16(offset_ptr); break;
case DW_FORM_ref4: m_value.value.uval = data.GetU32(offset_ptr); break;
case DW_FORM_ref8: m_value.value.uval = data.GetU64(offset_ptr); break;
case DW_FORM_ref_udata: m_value.value.uval = data.GetULEB128(offset_ptr); break;
case DW_FORM_indirect:
m_form = data.GetULEB128(offset_ptr);
indirect = true;
break;
case DW_FORM_sec_offset: m_value.value.uval = data.GetU32(offset_ptr); break;
case DW_FORM_flag_present: m_value.value.uval = 1; break;
case DW_FORM_ref_sig8: m_value.value.uval = data.GetU64(offset_ptr); break;
default:
return false;
break;
}
} while (indirect);
if (is_block)
{
m_value.data = data.PeekData(*offset_ptr, m_value.value.uval);
if (m_value.data != NULL)
{
*offset_ptr += m_value.value.uval;
}
}
return true;
}