当前位置: 首页>>代码示例>>C++>>正文


C++ DataExtractor::GetByteSize方法代码示例

本文整理汇总了C++中DataExtractor::GetByteSize方法的典型用法代码示例。如果您正苦于以下问题:C++ DataExtractor::GetByteSize方法的具体用法?C++ DataExtractor::GetByteSize怎么用?C++ DataExtractor::GetByteSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataExtractor的用法示例。


在下文中一共展示了DataExtractor::GetByteSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:Archer-sys,项目名称:lldb,代码行数:60,代码来源:ThreadElfCore.cpp

示例2: scoped_timer

bool
DWARFDebugPubnames::Extract(const DataExtractor& data)
{
    Timer scoped_timer (__PRETTY_FUNCTION__,
                        "DWARFDebugPubnames::Extract (byte_size = %zu)",
                        data.GetByteSize());
    LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_PUBNAMES));
    if (log)
        log->Printf("DWARFDebugPubnames::Extract (byte_size = %zu)", data.GetByteSize());

    if (data.ValidOffset(0))
    {
        uint32_t offset = 0;

        DWARFDebugPubnamesSet set;
        while (data.ValidOffset(offset))
        {
            if (set.Extract(data, &offset))
            {
                m_sets.push_back(set);
                offset = set.GetOffsetOfNextEntry();
            }
            else
                break;
        }
        if (log)
            Dump (log.get());
        return true;
    }
    return false;
}
开发者ID:fbsd,项目名称:old_lldb,代码行数:31,代码来源:DWARFDebugPubnames.cpp

示例3: WaitForPacketWithTimeoutMicroSecondsNoLock

size_t CommunicationKDP::WaitForPacketWithTimeoutMicroSecondsNoLock(
    DataExtractor &packet, uint32_t timeout_usec) {
  uint8_t buffer[8192];
  Status error;

  Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PACKETS));

  // Check for a packet from our cache first without trying any reading...
  if (CheckForPacket(NULL, 0, packet))
    return packet.GetByteSize();

  bool timed_out = false;
  while (IsConnected() && !timed_out) {
    lldb::ConnectionStatus status = eConnectionStatusNoConnection;
    size_t bytes_read = Read(buffer, sizeof(buffer),
                             timeout_usec == UINT32_MAX
                                 ? Timeout<std::micro>(llvm::None)
                                 : std::chrono::microseconds(timeout_usec),
                             status, &error);

    LLDB_LOGV(log, 
      "Read (buffer, sizeof(buffer), timeout_usec = 0x{0:x}, "
                  "status = {1}, error = {2}) => bytes_read = {4}",
                  timeout_usec,
                  Communication::ConnectionStatusAsCString(status),
                  error, bytes_read);

    if (bytes_read > 0) {
      if (CheckForPacket(buffer, bytes_read, packet))
        return packet.GetByteSize();
    } else {
      switch (status) {
      case eConnectionStatusInterrupted:
      case eConnectionStatusTimedOut:
        timed_out = true;
        break;
      case eConnectionStatusSuccess:
        // printf ("status = success but error = %s\n",
        // error.AsCString("<invalid>"));
        break;

      case eConnectionStatusEndOfFile:
      case eConnectionStatusNoConnection:
      case eConnectionStatusLostConnection:
      case eConnectionStatusError:
        Disconnect();
        break;
      }
    }
  }
  packet.Clear();
  return 0;
}
开发者ID:llvm-project,项目名称:lldb,代码行数:53,代码来源:CommunicationKDP.cpp

示例4: 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());
}
开发者ID:BlueRiverInteractive,项目名称:lldb,代码行数:13,代码来源:RegisterContextPOSIXCore_powerpc.cpp

示例5: ReadFromMemory

bool Type::ReadFromMemory(ExecutionContext *exe_ctx, lldb::addr_t addr,
                          AddressType address_type, DataExtractor &data) {
  if (address_type == eAddressTypeFile) {
    // Can't convert a file address to anything valid without more
    // context (which Module it came from)
    return false;
  }

  const uint64_t byte_size = GetByteSize();
  if (data.GetByteSize() < byte_size) {
    lldb::DataBufferSP data_sp(new DataBufferHeap(byte_size, '\0'));
    data.SetData(data_sp);
  }

  uint8_t *dst = const_cast<uint8_t *>(data.PeekData(0, byte_size));
  if (dst != nullptr) {
    if (address_type == eAddressTypeHost) {
      // The address is an address in this process, so just copy it
      if (addr == 0)
        return false;
      memcpy(dst, (uint8_t *)nullptr + addr, byte_size);
      return true;
    } else {
      if (exe_ctx) {
        Process *process = exe_ctx->GetProcessPtr();
        if (process) {
          Error error;
          return exe_ctx->GetProcessPtr()->ReadMemory(addr, dst, byte_size,
                                                      error) == byte_size;
        }
      }
    }
  }
  return false;
}
开发者ID:vargaz,项目名称:lldb,代码行数:35,代码来源:Type.cpp

示例6: 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);
}
开发者ID:JuliaLang,项目名称:lldb,代码行数:33,代码来源:ProcessElfCore.cpp

示例7: 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);
}
开发者ID:Galiro,项目名称:freebsd,代码行数:28,代码来源:ProcessElfCore.cpp

示例8: shared_data_buffer

ValueObjectConstResult::ValueObjectConstResult
(
    ExecutionContextScope *exe_scope,
    clang::ASTContext *clang_ast,
    void *clang_type,
    const ConstString &name,
    const DataExtractor &data,
    lldb::addr_t address
) :
    ValueObject (exe_scope),
    m_clang_ast (clang_ast),
    m_type_name (),
    m_byte_size (0),
    m_impl(this, address)
{
    m_data = data;
    
    if (!m_data.GetSharedDataBuffer())
    {
        DataBufferSP shared_data_buffer(new DataBufferHeap(data.GetDataStart(), data.GetByteSize()));
        m_data.SetData(shared_data_buffer);
    }
    
    m_value.GetScalar() = (uintptr_t)m_data.GetDataStart();
    m_value.SetValueType(Value::eValueTypeHostAddress);
    m_value.SetContext(Value::eContextTypeClangType, clang_type);
    m_name = name;
    SetIsConstant ();
    SetValueIsValid(true);
    SetAddressTypeOfChildren(eAddressTypeLoad);
}
开发者ID:fbsd,项目名称:old_lldb,代码行数:31,代码来源:ValueObjectConstResult.cpp

示例9: 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;
}
开发者ID:RichardsonAlex,项目名称:lldb,代码行数:17,代码来源:RegisterContextPOSIXCore_mips64.cpp

示例10: 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());
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:9,代码来源:RegisterContextPOSIXCore_arm64.cpp

示例11: data_sp

bool
RegisterContextMacOSXFrameBackchain::ReadRegisterBytes (uint32_t reg, DataExtractor &data)
{
    Scalar reg_value;

    if (ReadRegisterValue (reg, reg_value))
    {
        if (reg_value.GetData(data))
        {
            // "reg_value" is local and now "data" points to the data within
            // "reg_value", so we must make a copy that will live within "data"
            DataBufferSP data_sp (new DataBufferHeap (data.GetDataStart(), data.GetByteSize()));
            data.SetData (data_sp, 0, data.GetByteSize());
            return true;
        }
    }
    return false;
}
开发者ID:ice799,项目名称:lldb,代码行数:18,代码来源:RegisterContextMacOSXFrameBackchain.cpp

示例12: error

Scalar &
Value::ResolveValue(ExecutionContext *exe_ctx)
{
    const CompilerType &compiler_type = GetCompilerType();
    if (compiler_type.IsValid())
    {
        switch (m_value_type)
        {
        case eValueTypeScalar:               // raw scalar value
            break;

        default:
        case eValueTypeFileAddress:
        case eValueTypeLoadAddress:          // load address value
        case eValueTypeHostAddress:          // host address value (for memory in the process that is using liblldb)
            {
                DataExtractor data;
                lldb::addr_t addr = m_value.ULongLong(LLDB_INVALID_ADDRESS);
                Error error (GetValueAsData (exe_ctx, data, 0, NULL));
                if (error.Success())
                {
                    Scalar scalar;
                    if (compiler_type.GetValueAsScalar (data, 0, data.GetByteSize(), scalar))
                    {
                        m_value = scalar;
                        m_value_type = eValueTypeScalar;
                    }
                    else
                    {
                        if ((uintptr_t)addr != (uintptr_t)m_data_buffer.GetBytes())
                        {
                            m_value.Clear();
                            m_value_type = eValueTypeScalar;
                        }
                    }
                }
                else
                {
                    if ((uintptr_t)addr != (uintptr_t)m_data_buffer.GetBytes())
                    {
                        m_value.Clear();
                        m_value_type = eValueTypeScalar;
                    }
                }
            }
            break;
        }
    }
    return m_value;
}
开发者ID:2asoft,项目名称:freebsd,代码行数:50,代码来源:Value.cpp

示例13: inst_addr

size_t
DisassemblerLLVMC::DecodeInstructions (const Address &base_addr,
                                       const DataExtractor& data,
                                       lldb::offset_t data_offset,
                                       size_t num_instructions,
                                       bool append,
                                       bool data_from_file)
{
    if (!append)
        m_instruction_list.Clear();
    
    if (!IsValid())
        return 0;
    
    m_data_from_file = data_from_file;
    uint32_t data_cursor = data_offset;
    const size_t data_byte_size = data.GetByteSize();
    uint32_t instructions_parsed = 0;
    Address inst_addr(base_addr);
    
    while (data_cursor < data_byte_size && instructions_parsed < num_instructions)
    {
        
        AddressClass address_class = eAddressClassCode;
        
        if (m_alternate_disasm_ap.get() != NULL)
            address_class = inst_addr.GetAddressClass ();
        
        InstructionSP inst_sp(new InstructionLLVMC(*this,
                                                   inst_addr, 
                                                   address_class));
        
        if (!inst_sp)
            break;
        
        uint32_t inst_size = inst_sp->Decode(*this, data, data_cursor);
                
        if (inst_size == 0)
            break;

        m_instruction_list.Append(inst_sp);
        data_cursor += inst_size;
        inst_addr.Slide(inst_size);
        instructions_parsed++;
    }
    
    return data_cursor - data_offset;
}
开发者ID:VanirLLVM,项目名称:toolchain_lldb,代码行数:48,代码来源:DisassemblerLLVMC.cpp

示例14: DoesBranch

    virtual bool
    DoesBranch ()
    {
        if (m_does_branch == eLazyBoolCalculate)
        {
            GetDisassemblerLLVMC().Lock(this, NULL);
            DataExtractor data;
            if (m_opcode.GetData(data))
            {
                bool is_alternate_isa;
                lldb::addr_t pc = m_address.GetFileAddress();

                DisassemblerLLVMC::LLVMCDisassembler *mc_disasm_ptr = GetDisasmToUse (is_alternate_isa);
                const uint8_t *opcode_data = data.GetDataStart();
                const size_t opcode_data_len = data.GetByteSize();
                llvm::MCInst inst;
                const size_t inst_size = mc_disasm_ptr->GetMCInst (opcode_data,
                                                                   opcode_data_len,
                                                                   pc,
                                                                   inst);
                // Be conservative, if we didn't understand the instruction, say it might branch...
                if (inst_size == 0)
                    m_does_branch = eLazyBoolYes;
                else
                {
                    const bool can_branch = mc_disasm_ptr->CanBranch(inst);
                    if (can_branch)
                        m_does_branch = eLazyBoolYes;
                    else
                        m_does_branch = eLazyBoolNo;
                }
            }
            GetDisassemblerLLVMC().Unlock();
        }
        return m_does_branch == eLazyBoolYes;
    }
开发者ID:VanirLLVM,项目名称:toolchain_lldb,代码行数:36,代码来源:DisassemblerLLVMC.cpp

示例15: while

static bool
DumpUTFBufferToStream (ConversionResult (*ConvertFunction) (const SourceDataType**,
                       const SourceDataType*,
                       UTF8**,
                       UTF8*,
                       ConversionFlags),
                       const DataExtractor& data,
                       Stream& stream,
                       char prefix_token,
                       char quote,
                       uint32_t sourceSize,
                       bool escapeNonPrintables)
{
    if (prefix_token != 0)
        stream.Printf("%c",prefix_token);
    if (quote != 0)
        stream.Printf("%c",quote);
    if (data.GetByteSize() && data.GetDataStart() && data.GetDataEnd())
    {
        const int bufferSPSize = data.GetByteSize();
        if (sourceSize == 0)
        {
            const int origin_encoding = 8*sizeof(SourceDataType);
            sourceSize = bufferSPSize/(origin_encoding / 4);
        }

        const SourceDataType *data_ptr = (const SourceDataType*)data.GetDataStart();
        const SourceDataType *data_end_ptr = data_ptr + sourceSize;

        while (data_ptr < data_end_ptr)
        {
            if (!*data_ptr)
            {
                data_end_ptr = data_ptr;
                break;
            }
            data_ptr++;
        }

        data_ptr = (const SourceDataType*)data.GetDataStart();

        lldb::DataBufferSP utf8_data_buffer_sp;
        UTF8* utf8_data_ptr = nullptr;
        UTF8* utf8_data_end_ptr = nullptr;

        if (ConvertFunction)
        {
            utf8_data_buffer_sp.reset(new DataBufferHeap(4*bufferSPSize,0));
            utf8_data_ptr = (UTF8*)utf8_data_buffer_sp->GetBytes();
            utf8_data_end_ptr = utf8_data_ptr + utf8_data_buffer_sp->GetByteSize();
            ConvertFunction ( &data_ptr, data_end_ptr, &utf8_data_ptr, utf8_data_end_ptr, lenientConversion );
            utf8_data_ptr = (UTF8*)utf8_data_buffer_sp->GetBytes(); // needed because the ConvertFunction will change the value of the data_ptr
        }
        else
        {
            // just copy the pointers - the cast is necessary to make the compiler happy
            // but this should only happen if we are reading UTF8 data
            utf8_data_ptr = (UTF8*)data_ptr;
            utf8_data_end_ptr = (UTF8*)data_end_ptr;
        }

        // since we tend to accept partial data (and even partially malformed data)
        // we might end up with no NULL terminator before the end_ptr
        // hence we need to take a slower route and ensure we stay within boundaries
        for (; utf8_data_ptr < utf8_data_end_ptr;)
        {
            if (!*utf8_data_ptr)
                break;

            if (escapeNonPrintables)
            {
                uint8_t* next_data = nullptr;
                auto printable = GetPrintable(StringElementType::UTF8, utf8_data_ptr, utf8_data_end_ptr, next_data);
                auto printable_bytes = printable.GetBytes();
                auto printable_size = printable.GetSize();
                if (!printable_bytes || !next_data)
                {
                    // GetPrintable() failed on us - print one byte in a desperate resync attempt
                    printable_bytes = utf8_data_ptr;
                    printable_size = 1;
                    next_data = utf8_data_ptr+1;
                }
                for (unsigned c = 0; c < printable_size; c++)
                    stream.Printf("%c", *(printable_bytes+c));
                utf8_data_ptr = (uint8_t*)next_data;
            }
            else
            {
                stream.Printf("%c",*utf8_data_ptr);
                utf8_data_ptr++;
            }
        }
    }
    if (quote != 0)
        stream.Printf("%c",quote);
    return true;
}
开发者ID:cyrilmagsuci,项目名称:freebsd,代码行数:97,代码来源:StringPrinter.cpp


注:本文中的DataExtractor::GetByteSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。