本文整理汇总了C++中DataExtractor::GetByteOrder方法的典型用法代码示例。如果您正苦于以下问题:C++ DataExtractor::GetByteOrder方法的具体用法?C++ DataExtractor::GetByteOrder怎么用?C++ DataExtractor::GetByteOrder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataExtractor
的用法示例。
在下文中一共展示了DataExtractor::GetByteOrder方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DataBufferHeap
RegisterContextCorePOSIX_powerpc::RegisterContextCorePOSIX_powerpc(Thread &thread,
RegisterInfoInterface *register_info,
const DataExtractor &gpregset,
const DataExtractor &fpregset)
: RegisterContextPOSIX_powerpc(thread, 0, register_info)
{
m_gpr_buffer.reset(new DataBufferHeap(gpregset.GetDataStart(), gpregset.GetByteSize()));
m_gpr.SetData(m_gpr_buffer);
m_gpr.SetByteOrder(gpregset.GetByteOrder());
m_fpr_buffer.reset(new DataBufferHeap(fpregset.GetDataStart(), fpregset.GetByteSize()));
m_fpr.SetData(m_fpr_buffer);
m_fpr.SetByteOrder(fpregset.GetByteOrder());
}
示例2: switch
bool
Value::GetData (DataExtractor &data)
{
switch (m_value_type)
{
default:
break;
case eValueTypeScalar:
if (m_value.GetData (data))
return true;
break;
case eValueTypeLoadAddress:
case eValueTypeFileAddress:
case eValueTypeHostAddress:
if (m_data_buffer.GetByteSize())
{
data.SetData(m_data_buffer.GetBytes(), m_data_buffer.GetByteSize(), data.GetByteOrder());
return true;
}
break;
}
return false;
}
示例3: 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;
}
示例4: DataBufferHeap
RegisterContextCorePOSIX_mips64::RegisterContextCorePOSIX_mips64(Thread &thread,
RegisterInfoInterface *register_info,
const DataExtractor &gpregset,
const DataExtractor &fpregset,
const DataExtractor &capregset)
: RegisterContextPOSIX_mips64(thread, 0, register_info)
{
m_gpr_buffer.reset(new DataBufferHeap(gpregset.GetDataStart(), gpregset.GetByteSize()));
m_gpr.SetData(m_gpr_buffer);
m_gpr.SetByteOrder(gpregset.GetByteOrder());
m_cr_buffer.reset(new DataBufferHeap(capregset.GetDataStart(), capregset.GetByteSize()));
m_cr.SetData(m_cr_buffer);
m_cr.SetByteOrder(capregset.GetByteOrder());
m_in_bd = lldb_private::eLazyBoolCalculate;
}
示例5: DataBufferHeap
RegisterContextCorePOSIX_arm64::RegisterContextCorePOSIX_arm64(
Thread &thread, RegisterInfoInterface *register_info,
const DataExtractor &gpregset, llvm::ArrayRef<CoreNote> notes)
: RegisterContextPOSIX_arm64(thread, 0, register_info) {
m_gpr_buffer.reset(
new DataBufferHeap(gpregset.GetDataStart(), gpregset.GetByteSize()));
m_gpr.SetData(m_gpr_buffer);
m_gpr.SetByteOrder(gpregset.GetByteOrder());
}
示例6: switch
bool
ELFLinuxPrPsInfo::Parse(DataExtractor &data, ArchSpec &arch)
{
ByteOrder byteorder = data.GetByteOrder();
size_t len;
switch(arch.GetCore())
{
case ArchSpec::eCore_x86_64_x86_64:
len = data.ExtractBytes(0, ELFLINUXPRPSINFO64_SIZE, byteorder, this);
return len == ELFLINUXPRPSINFO64_SIZE;
default:
return false;
}
}
示例7: GetAPInt
static bool GetAPInt(const DataExtractor &data, lldb::offset_t *offset_ptr,
lldb::offset_t byte_size, llvm::APInt &result) {
llvm::SmallVector<uint64_t, 2> uint64_array;
lldb::offset_t bytes_left = byte_size;
uint64_t u64;
const lldb::ByteOrder byte_order = data.GetByteOrder();
if (byte_order == lldb::eByteOrderLittle) {
while (bytes_left > 0) {
if (bytes_left >= 8) {
u64 = data.GetU64(offset_ptr);
bytes_left -= 8;
} else {
u64 = data.GetMaxU64(offset_ptr, (uint32_t)bytes_left);
bytes_left = 0;
}
uint64_array.push_back(u64);
}
result = llvm::APInt(byte_size * 8, llvm::ArrayRef<uint64_t>(uint64_array));
return true;
} else if (byte_order == lldb::eByteOrderBig) {
lldb::offset_t be_offset = *offset_ptr + byte_size;
lldb::offset_t temp_offset;
while (bytes_left > 0) {
if (bytes_left >= 8) {
be_offset -= 8;
temp_offset = be_offset;
u64 = data.GetU64(&temp_offset);
bytes_left -= 8;
} else {
be_offset -= bytes_left;
temp_offset = be_offset;
u64 = data.GetMaxU64(&temp_offset, (uint32_t)bytes_left);
bytes_left = 0;
}
uint64_array.push_back(u64);
}
*offset_ptr += byte_size;
result = llvm::APInt(byte_size * 8, llvm::ArrayRef<uint64_t>(uint64_array));
return true;
}
return false;
}
示例8: s_regex
virtual void
CalculateMnemonicOperandsAndComment (const lldb_private::ExecutionContext *exe_ctx)
{
DataExtractor data;
const AddressClass address_class = GetAddressClass ();
if (m_opcode.GetData(data))
{
char out_string[512];
DisassemblerLLVMC &llvm_disasm = GetDisassemblerLLVMC();
DisassemblerLLVMC::LLVMCDisassembler *mc_disasm_ptr;
if (address_class == eAddressClassCodeAlternateISA)
mc_disasm_ptr = llvm_disasm.m_alternate_disasm_ap.get();
else
mc_disasm_ptr = llvm_disasm.m_disasm_ap.get();
lldb::addr_t pc = m_address.GetFileAddress();
m_using_file_addr = true;
const bool data_from_file = GetDisassemblerLLVMC().m_data_from_file;
bool use_hex_immediates = true;
Disassembler::HexImmediateStyle hex_style = Disassembler::eHexStyleC;
if (exe_ctx)
{
Target *target = exe_ctx->GetTargetPtr();
if (target)
{
use_hex_immediates = target->GetUseHexImmediates();
hex_style = target->GetHexImmediateStyle();
if (!data_from_file)
{
const lldb::addr_t load_addr = m_address.GetLoadAddress(target);
if (load_addr != LLDB_INVALID_ADDRESS)
{
pc = load_addr;
m_using_file_addr = false;
}
}
}
}
llvm_disasm.Lock(this, exe_ctx);
const uint8_t *opcode_data = data.GetDataStart();
const size_t opcode_data_len = data.GetByteSize();
llvm::MCInst inst;
size_t inst_size = mc_disasm_ptr->GetMCInst (opcode_data,
opcode_data_len,
pc,
inst);
if (inst_size > 0)
{
mc_disasm_ptr->SetStyle(use_hex_immediates, hex_style);
mc_disasm_ptr->PrintMCInst(inst, out_string, sizeof(out_string));
}
llvm_disasm.Unlock();
if (inst_size == 0)
{
m_comment.assign ("unknown opcode");
inst_size = m_opcode.GetByteSize();
StreamString mnemonic_strm;
lldb::offset_t offset = 0;
lldb::ByteOrder byte_order = data.GetByteOrder();
switch (inst_size)
{
case 1:
{
const uint8_t uval8 = data.GetU8 (&offset);
m_opcode.SetOpcode8 (uval8, byte_order);
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, byte_order);
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, byte_order);
m_opcode_name.assign (".long");
mnemonic_strm.Printf("0x%8.8x", uval32);
}
break;
case 8:
{
const uint64_t uval64 = data.GetU64(&offset);
//.........这里部分代码省略.........
示例9: if
Status ABISysV_ppc64::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
lldb::ValueObjectSP &new_value_sp) {
Status error;
if (!new_value_sp) {
error.SetErrorString("Empty value object for return value.");
return error;
}
CompilerType compiler_type = new_value_sp->GetCompilerType();
if (!compiler_type) {
error.SetErrorString("Null clang type for return value.");
return error;
}
Thread *thread = frame_sp->GetThread().get();
bool is_signed;
uint32_t count;
bool is_complex;
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
bool set_it_simple = false;
if (compiler_type.IsIntegerOrEnumerationType(is_signed) ||
compiler_type.IsPointerType()) {
const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName("r3", 0);
DataExtractor data;
Status data_error;
size_t num_bytes = new_value_sp->GetData(data, data_error);
if (data_error.Fail()) {
error.SetErrorStringWithFormat(
"Couldn't convert return value to raw data: %s",
data_error.AsCString());
return error;
}
lldb::offset_t offset = 0;
if (num_bytes <= 8) {
uint64_t raw_value = data.GetMaxU64(&offset, num_bytes);
if (reg_ctx->WriteRegisterFromUnsigned(reg_info, raw_value))
set_it_simple = true;
} else {
error.SetErrorString("We don't support returning longer than 64 bit "
"integer values at present.");
}
} else if (compiler_type.IsFloatingPointType(count, is_complex)) {
if (is_complex)
error.SetErrorString(
"We don't support returning complex values at present");
else {
size_t bit_width = compiler_type.GetBitSize(frame_sp.get());
if (bit_width <= 64) {
DataExtractor data;
Status data_error;
size_t num_bytes = new_value_sp->GetData(data, data_error);
if (data_error.Fail()) {
error.SetErrorStringWithFormat(
"Couldn't convert return value to raw data: %s",
data_error.AsCString());
return error;
}
unsigned char buffer[16];
ByteOrder byte_order = data.GetByteOrder();
data.CopyByteOrderedData(0, num_bytes, buffer, 16, byte_order);
set_it_simple = true;
} else {
// FIXME - don't know how to do 80 bit long doubles yet.
error.SetErrorString(
"We don't support returning float values > 64 bits at present");
}
}
}
if (!set_it_simple) {
// Okay we've got a structure or something that doesn't fit in a simple
// register.
// We should figure out where it really goes, but we don't support this yet.
error.SetErrorString("We only support setting simple integer and float "
"return types at present.");
}
return error;
}
示例10: memset
Error
RegisterValue::SetValueFromData (const RegisterInfo *reg_info, DataExtractor &src, lldb::offset_t src_offset, bool partial_data_ok)
{
Error error;
if (src.GetByteSize() == 0)
{
error.SetErrorString ("empty data.");
return error;
}
if (reg_info->byte_size == 0)
{
error.SetErrorString ("invalid register info.");
return error;
}
uint32_t src_len = src.GetByteSize() - src_offset;
if (!partial_data_ok && (src_len < reg_info->byte_size))
{
error.SetErrorString ("not enough data.");
return error;
}
// Cap the data length if there is more than enough bytes for this register
// value
if (src_len > reg_info->byte_size)
src_len = reg_info->byte_size;
// Zero out the value in case we get partial data...
memset (m_data.buffer.bytes, 0, sizeof (m_data.buffer.bytes));
switch (SetType (reg_info))
{
case eTypeInvalid:
error.SetErrorString("");
break;
case eTypeUInt8: SetUInt8 (src.GetMaxU32 (&src_offset, src_len)); break;
case eTypeUInt16: SetUInt16 (src.GetMaxU32 (&src_offset, src_len)); break;
case eTypeUInt32: SetUInt32 (src.GetMaxU32 (&src_offset, src_len)); break;
case eTypeUInt64: SetUInt64 (src.GetMaxU64 (&src_offset, src_len)); break;
#if defined (ENABLE_128_BIT_SUPPORT)
case eTypeUInt128:
{
__uint128_t data1 = src.GetU64 (&src_offset);
__uint128_t data2 = src.GetU64 (&src_offset);
if (src.GetByteSize() == eByteOrderBig)
SetUInt128 (data1 << 64 + data2);
else
SetUInt128 (data2 << 64 + data1);
}
break;
#endif
case eTypeFloat: SetFloat (src.GetFloat (&src_offset)); break;
case eTypeDouble: SetDouble(src.GetDouble (&src_offset)); break;
case eTypeLongDouble: SetFloat (src.GetLongDouble (&src_offset)); break;
case eTypeBytes:
{
m_data.buffer.length = reg_info->byte_size;
m_data.buffer.byte_order = src.GetByteOrder();
assert (m_data.buffer.length <= kMaxRegisterByteSize);
if (m_data.buffer.length > kMaxRegisterByteSize)
m_data.buffer.length = kMaxRegisterByteSize;
if (src.CopyByteOrderedData (src_offset, // offset within "src" to start extracting data
src_len, // src length
m_data.buffer.bytes, // dst buffer
m_data.buffer.length, // dst length
m_data.buffer.byte_order) == 0)// dst byte order
{
error.SetErrorString ("data copy failed data.");
return error;
}
}
}
return error;
}
示例11: DumpDataExtractor
//.........这里部分代码省略.........
long double ld64_2 = DE.GetLongDouble(&offset);
s->Printf("%Lg + %Lgi", ld64_1, ld64_2);
break;
} else {
s->Printf("error: unsupported byte size (%" PRIu64
") for complex float format",
(uint64_t)item_byte_size);
return offset;
}
break;
default:
case eFormatDefault:
case eFormatHex:
case eFormatHexUppercase: {
bool wantsuppercase = (item_format == eFormatHexUppercase);
switch (item_byte_size) {
case 1:
case 2:
case 4:
case 8:
s->Printf(wantsuppercase ? "0x%*.*" PRIX64 : "0x%*.*" PRIx64,
(int)(2 * item_byte_size), (int)(2 * item_byte_size),
DE.GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size,
item_bit_offset));
break;
default: {
assert(item_bit_size == 0 && item_bit_offset == 0);
const uint8_t *bytes =
(const uint8_t *)DE.GetData(&offset, item_byte_size);
if (bytes) {
s->PutCString("0x");
uint32_t idx;
if (DE.GetByteOrder() == eByteOrderBig) {
for (idx = 0; idx < item_byte_size; ++idx)
s->Printf(wantsuppercase ? "%2.2X" : "%2.2x", bytes[idx]);
} else {
for (idx = 0; idx < item_byte_size; ++idx)
s->Printf(wantsuppercase ? "%2.2X" : "%2.2x",
bytes[item_byte_size - 1 - idx]);
}
}
} break;
}
} break;
case eFormatFloat: {
TargetSP target_sp;
bool used_apfloat = false;
if (exe_scope)
target_sp = exe_scope->CalculateTarget();
if (target_sp) {
ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
if (clang_ast) {
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),
示例12: SetValueFromData
Error RegisterValue::SetValueFromData(const RegisterInfo *reg_info,
DataExtractor &src,
lldb::offset_t src_offset,
bool partial_data_ok) {
Error error;
if (src.GetByteSize() == 0) {
error.SetErrorString("empty data.");
return error;
}
if (reg_info->byte_size == 0) {
error.SetErrorString("invalid register info.");
return error;
}
uint32_t src_len = src.GetByteSize() - src_offset;
if (!partial_data_ok && (src_len < reg_info->byte_size)) {
error.SetErrorString("not enough data.");
return error;
}
// Cap the data length if there is more than enough bytes for this register
// value
if (src_len > reg_info->byte_size)
src_len = reg_info->byte_size;
// Zero out the value in case we get partial data...
memset(buffer.bytes, 0, sizeof(buffer.bytes));
type128 int128;
m_type = eTypeInvalid;
switch (reg_info->encoding) {
case eEncodingInvalid:
break;
case eEncodingUint:
case eEncodingSint:
if (reg_info->byte_size == 1)
SetUInt8(src.GetMaxU32(&src_offset, src_len));
else if (reg_info->byte_size <= 2)
SetUInt16(src.GetMaxU32(&src_offset, src_len));
else if (reg_info->byte_size <= 4)
SetUInt32(src.GetMaxU32(&src_offset, src_len));
else if (reg_info->byte_size <= 8)
SetUInt64(src.GetMaxU64(&src_offset, src_len));
else if (reg_info->byte_size <= 16) {
uint64_t data1 = src.GetU64(&src_offset);
uint64_t data2 = src.GetU64(&src_offset);
if (src.GetByteSize() == eByteOrderBig) {
int128.x[0] = data1;
int128.x[1] = data2;
} else {
int128.x[0] = data2;
int128.x[1] = data1;
}
SetUInt128(llvm::APInt(128, 2, int128.x));
}
break;
case eEncodingIEEE754:
if (reg_info->byte_size == sizeof(float))
SetFloat(src.GetFloat(&src_offset));
else if (reg_info->byte_size == sizeof(double))
SetDouble(src.GetDouble(&src_offset));
else if (reg_info->byte_size == sizeof(long double))
SetLongDouble(src.GetLongDouble(&src_offset));
break;
case eEncodingVector: {
m_type = eTypeBytes;
buffer.length = reg_info->byte_size;
buffer.byte_order = src.GetByteOrder();
assert(buffer.length <= kMaxRegisterByteSize);
if (buffer.length > kMaxRegisterByteSize)
buffer.length = kMaxRegisterByteSize;
if (src.CopyByteOrderedData(
src_offset, // offset within "src" to start extracting data
src_len, // src length
buffer.bytes, // dst buffer
buffer.length, // dst length
buffer.byte_order) == 0) // dst byte order
{
error.SetErrorStringWithFormat(
"failed to copy data for register write of %s", reg_info->name);
return error;
}
}
}
if (m_type == eTypeInvalid)
error.SetErrorStringWithFormat(
"invalid register value type for register %s", reg_info->name);
return error;
}