Esempio n. 1
0
bool
RegisterContextPOSIXProcessMonitor_x86_64::ReadAllRegisterValues(DataBufferSP &data_sp)
{
    bool success = false;
    data_sp.reset (new DataBufferHeap (REG_CONTEXT_SIZE, 0));
    if (data_sp && ReadGPR () && ReadFPR ())
    {
        uint8_t *dst = data_sp->GetBytes();
        success = dst != 0;

        if (success)
        {
            ::memcpy (dst, &m_gpr, GetGPRSize());
            dst += GetGPRSize();
        }
        if (GetFPRType() == eFXSAVE)
            ::memcpy (dst, &m_fpr.xstate.fxsave, sizeof(m_fpr.xstate.fxsave));
        
        if (GetFPRType() == eXSAVE) {
            ByteOrder byte_order = GetByteOrder();

            // Assemble the YMM register content from the register halves.
            for (uint32_t reg = fpu_ymm0; success && reg <= fpu_ymm15; ++reg)
                success = CopyXSTATEtoYMM(reg, byte_order);

            if (success) {
                // Copy the extended register state including the assembled ymm registers.
                ::memcpy (dst, &m_fpr, sizeof(m_fpr));
            }
        }
    }
    return success;
}
Esempio n. 2
0
//----------------------------------------------------------------------
// Assign the data for this object to be a subrange of the shared data in
// "data_sp" starting "data_offset" bytes into "data_sp" and ending
// "data_length" bytes later. If "data_offset" is not a valid offset into
// "data_sp", then this object will contain no bytes. If "data_offset" is
// within "data_sp" yet "data_length" is too large, the length will be capped
// at the number of bytes remaining in "data_sp". A ref counted pointer to the
// data in "data_sp" will be made in this object IF the number of bytes this
// object refers to in greater than zero (if at least one byte was available
// starting at "data_offset") to ensure the data stays around as long as it is
// needed. The address size and endian swap settings will remain unchanged from
// their current settings.
//----------------------------------------------------------------------
uint32_t DataEncoder::SetData(const DataBufferSP &data_sp, uint32_t data_offset,
                              uint32_t data_length) {
  m_start = m_end = nullptr;

  if (data_length > 0) {
    m_data_sp = data_sp;
    if (data_sp) {
      const size_t data_size = data_sp->GetByteSize();
      if (data_offset < data_size) {
        m_start = data_sp->GetBytes() + data_offset;
        const size_t bytes_left = data_size - data_offset;
        // Cap the length of we asked for too many
        if (data_length <= bytes_left)
          m_end = m_start + data_length; // We got all the bytes we wanted
        else
          m_end = m_start + bytes_left; // Not all the bytes requested were
                                        // available in the shared data
      }
    }
  }

  uint32_t new_size = GetByteSize();

  // Don't hold a shared pointer to the data buffer if we don't share any valid
  // bytes in the shared buffer.
  if (new_size == 0)
    m_data_sp.reset();

  return new_size;
}
bool RegisterContextPOSIXProcessMonitor_powerpc::ReadAllRegisterValues(
    DataBufferSP &data_sp) {
  bool success = false;
  data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
  if (data_sp && ReadGPR() && ReadFPR()) {
    uint8_t *dst = data_sp->GetBytes();
    success = dst != 0;

    if (success) {
      ::memcpy(dst, &m_gpr_powerpc, GetGPRSize());
      dst += GetGPRSize();
    }
  }
  return success;
}
Esempio n. 4
0
bool
RegisterContextMemory::WriteAllRegisterValues (const DataBufferSP &data_sp)
{
    if (m_reg_data_addr != LLDB_INVALID_ADDRESS)
    {
        ProcessSP process_sp (CalculateProcess());
        if (process_sp)
        {
            Error error;
            SetAllRegisterValid (false);
            if (process_sp->WriteMemory(m_reg_data_addr, data_sp->GetBytes(), data_sp->GetByteSize(), error) == data_sp->GetByteSize())
                return true;
        }
    }
    return false;
}
Esempio n. 5
0
Error
AdbClient::SendSyncRequest (const char *request_id, const uint32_t data_len, const void *data)
{
    const DataBufferSP data_sp (new DataBufferHeap (kSyncPacketLen, 0));
    DataEncoder encoder (data_sp, eByteOrderLittle, sizeof (void*));
    auto offset = encoder.PutData (0, request_id, strlen(request_id));
    encoder.PutU32 (offset, data_len);

    Error error;
    ConnectionStatus status;
    m_conn.Write (data_sp->GetBytes (), kSyncPacketLen, status, &error);
    if (error.Fail ())
        return error;

    if (data)
        m_conn.Write (data, data_len, status, &error);
    return error;
}
bool RegisterContextPOSIXProcessMonitor_powerpc::WriteAllRegisterValues(
    const DataBufferSP &data_sp) {
  bool success = false;
  if (data_sp && data_sp->GetByteSize() == REG_CONTEXT_SIZE) {
    uint8_t *src = data_sp->GetBytes();
    if (src) {
      ::memcpy(&m_gpr_powerpc, src, GetGPRSize());

      if (WriteGPR()) {
        src += GetGPRSize();
        ::memcpy(&m_fpr_powerpc, src, sizeof(m_fpr_powerpc));

        success = WriteFPR();
      }
    }
  }
  return success;
}
Esempio n. 7
0
bool
RegisterContextPOSIXProcessMonitor_x86_64::WriteAllRegisterValues(const DataBufferSP &data_sp)
{
    bool success = false;
    if (data_sp && data_sp->GetByteSize() == REG_CONTEXT_SIZE)
    {
        uint8_t *src = data_sp->GetBytes();
        if (src)
        {
            ::memcpy (&m_gpr, src, GetGPRSize());

            if (WriteGPR())
            {
                src += GetGPRSize();
                if (GetFPRType() == eFXSAVE)
                    ::memcpy (&m_fpr.xstate.fxsave, src, sizeof(m_fpr.xstate.fxsave));
                if (GetFPRType() == eXSAVE)
                    ::memcpy (&m_fpr.xstate.xsave, src, sizeof(m_fpr.xstate.xsave));

                success = WriteFPR();
                if (success)
                {
                    success = true;

                    if (GetFPRType() == eXSAVE)
                    {
                        ByteOrder byte_order = GetByteOrder();

                        // Parse the YMM register content from the register halves.
                        for (uint32_t reg = fpu_ymm0; success && reg <= fpu_ymm15; ++reg)
                            success = CopyYMMtoXSTATE(reg, byte_order);
                    }
                }
            }
        }
    }
    return success;
}