LLDB mainline
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
CommunicationKDP Class Reference

#include <CommunicationKDP.h>

Inheritance diagram for CommunicationKDP:
Inheritance graph
[legend]

Public Types

enum  CommandType {
  KDP_CONNECT = 0u , KDP_DISCONNECT , KDP_HOSTINFO , KDP_VERSION ,
  KDP_MAXBYTES , KDP_READMEM , KDP_WRITEMEM , KDP_READREGS ,
  KDP_WRITEREGS , KDP_LOAD , KDP_IMAGEPATH , KDP_SUSPEND ,
  KDP_RESUMECPUS , KDP_EXCEPTION , KDP_TERMINATION , KDP_BREAKPOINT_SET ,
  KDP_BREAKPOINT_REMOVE , KDP_REGIONS , KDP_REATTACH , KDP_HOSTREBOOT ,
  KDP_READMEM64 , KDP_WRITEMEM64 , KDP_BREAKPOINT_SET64 , KDP_BREAKPOINT_REMOVE64 ,
  KDP_KERNELVERSION , KDP_READPHYSMEM64 , KDP_WRITEPHYSMEM64 , KDP_READIOPORT ,
  KDP_WRITEIOPORT , KDP_READMSR64 , KDP_WRITEMSR64 , KDP_DUMPINFO
}
 
enum  { KDP_FEATURE_BP = (1u << 0) }
 
enum  KDPError { KDP_PROTERR_SUCCESS = 0 , KDP_PROTERR_ALREADY_CONNECTED , KDP_PROTERR_BAD_NBYTES , KDP_PROTERR_BADFLAVOR }
 
enum  PacketType { ePacketTypeRequest = 0x00u , ePacketTypeReply = 0x80u , ePacketTypeMask = 0x80u , eCommandTypeMask = 0x7fu }
 
typedef lldb_private::StreamBuffer< 4096 > PacketStreamType
 

Public Member Functions

 CommunicationKDP (const char *comm_name)
 
 ~CommunicationKDP () override
 
bool SendRequestPacket (const PacketStreamType &request_packet)
 
size_t WaitForPacketWithTimeoutMicroSeconds (lldb_private::DataExtractor &response, uint32_t usec)
 
bool GetSequenceMutex (std::unique_lock< std::recursive_mutex > &lock)
 
bool CheckForPacket (const uint8_t *src, size_t src_len, lldb_private::DataExtractor &packet)
 
bool IsRunning () const
 
std::chrono::seconds SetPacketTimeout (std::chrono::seconds packet_timeout)
 
std::chrono::seconds GetPacketTimeout () const
 
bool SendRequestConnect (uint16_t reply_port, uint16_t exc_port, const char *greeting)
 
bool SendRequestReattach (uint16_t reply_port)
 
bool SendRequestDisconnect ()
 
uint32_t SendRequestReadMemory (lldb::addr_t addr, void *dst, uint32_t dst_size, lldb_private::Status &error)
 
uint32_t SendRequestWriteMemory (lldb::addr_t addr, const void *src, uint32_t src_len, lldb_private::Status &error)
 
bool SendRawRequest (uint8_t command_byte, const void *src, uint32_t src_len, lldb_private::DataExtractor &reply, lldb_private::Status &error)
 
uint32_t SendRequestReadRegisters (uint32_t cpu, uint32_t flavor, void *dst, uint32_t dst_size, lldb_private::Status &error)
 
uint32_t SendRequestWriteRegisters (uint32_t cpu, uint32_t flavor, const void *src, uint32_t src_size, lldb_private::Status &error)
 
const char * GetKernelVersion ()
 
uint32_t GetVersion ()
 
uint32_t GetFeatureFlags ()
 
bool LocalBreakpointsAreSupported ()
 
uint32_t GetCPUMask ()
 
uint32_t GetCPUType ()
 
uint32_t GetCPUSubtype ()
 
lldb_private::UUID GetUUID ()
 
bool RemoteIsEFI ()
 
bool RemoteIsDarwinKernel ()
 
lldb::addr_t GetLoadAddress ()
 
bool SendRequestResume ()
 
bool SendRequestSuspend ()
 
bool SendRequestBreakpoint (bool set, lldb::addr_t addr)
 
- Public Member Functions inherited from lldb_private::Communication
 Communication ()
 Construct the Communication object.
 
virtual ~Communication ()
 Destructor.
 
virtual void Clear ()
 
lldb::ConnectionStatus Connect (const char *url, Status *error_ptr)
 Connect using the current connection by passing url to its connect function.
 
virtual lldb::ConnectionStatus Disconnect (Status *error_ptr=nullptr)
 Disconnect the communications connection if one is currently connected.
 
bool IsConnected () const
 Check if the connection is valid.
 
bool HasConnection () const
 
lldb_private::ConnectionGetConnection ()
 
virtual size_t Read (void *dst, size_t dst_len, const Timeout< std::micro > &timeout, lldb::ConnectionStatus &status, Status *error_ptr)
 Read bytes from the current connection.
 
size_t Write (const void *src, size_t src_len, lldb::ConnectionStatus &status, Status *error_ptr)
 The actual write function that attempts to write to the communications protocol.
 
size_t WriteAll (const void *src, size_t src_len, lldb::ConnectionStatus &status, Status *error_ptr)
 Repeatedly attempt writing until either src_len bytes are written or a permanent failure occurs.
 
virtual void SetConnection (std::unique_ptr< Connection > connection)
 Sets the connection that it to be used by this class.
 
bool GetCloseOnEOF () const
 
void SetCloseOnEOF (bool b)
 

Static Public Attributes

static const uint32_t kMaxPacketSize = 1200
 
static const uint32_t kMaxDataSize = 1024
 

Protected Member Functions

bool SendRequestPacketNoLock (const PacketStreamType &request_packet)
 
size_t WaitForPacketWithTimeoutMicroSecondsNoLock (lldb_private::DataExtractor &response, uint32_t timeout_usec)
 
bool WaitForNotRunningPrivate (const std::chrono::microseconds &timeout)
 
void MakeRequestPacketHeader (CommandType request_type, PacketStreamType &request_packet, uint16_t request_length)
 
bool SendRequestVersion ()
 
bool SendRequestHostInfo ()
 
bool SendRequestKernelVersion ()
 
void DumpPacket (lldb_private::Stream &s, const void *data, uint32_t data_len)
 
void DumpPacket (lldb_private::Stream &s, const lldb_private::DataExtractor &extractor)
 
bool VersionIsValid () const
 
bool HostInfoIsValid () const
 
bool ExtractIsReply (uint8_t first_packet_byte) const
 
CommandType ExtractCommand (uint8_t first_packet_byte) const
 
void ClearKDPSettings ()
 
bool SendRequestAndGetReply (const CommandType command, const PacketStreamType &request_packet, lldb_private::DataExtractor &reply_packet)
 
- Protected Member Functions inherited from lldb_private::Communication
size_t ReadFromConnection (void *dst, size_t dst_len, const Timeout< std::micro > &timeout, lldb::ConnectionStatus &status, Status *error_ptr)
 

Static Protected Member Functions

static const char * GetCommandAsCString (uint8_t command)
 

Protected Attributes

uint32_t m_addr_byte_size
 
lldb::ByteOrder m_byte_order
 
std::string m_bytes
 
std::recursive_mutex m_bytes_mutex
 
std::chrono::seconds m_packet_timeout
 
std::recursive_mutex m_sequence_mutex
 
lldb_private::Predicate< bool > m_is_running
 
uint32_t m_session_key
 
uint8_t m_request_sequence_id
 
uint8_t m_exception_sequence_id
 
uint32_t m_kdp_version_version
 
uint32_t m_kdp_version_feature
 
uint32_t m_kdp_hostinfo_cpu_mask
 
uint32_t m_kdp_hostinfo_cpu_type
 
uint32_t m_kdp_hostinfo_cpu_subtype
 
std::string m_kernel_version
 
lldb::addr_t m_last_read_memory_addr
 
- Protected Attributes inherited from lldb_private::Communication
lldb::ConnectionSP m_connection_sp
 The connection that is current in use by this communications class.
 
std::mutex m_write_mutex
 Don't let multiple threads write at the same time...
 
bool m_close_on_eof
 

Private Member Functions

 CommunicationKDP (const CommunicationKDP &)=delete
 
const CommunicationKDPoperator= (const CommunicationKDP &)=delete
 

Additional Inherited Members

- Static Public Member Functions inherited from lldb_private::Communication
static std::string ConnectionStatusAsString (lldb::ConnectionStatus status)
 

Detailed Description

Definition at line 22 of file CommunicationKDP.h.

Member Typedef Documentation

◆ PacketStreamType

Definition at line 26 of file CommunicationKDP.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
KDP_FEATURE_BP 

Definition at line 62 of file CommunicationKDP.h.

◆ CommandType

Enumerator
KDP_CONNECT 
KDP_DISCONNECT 
KDP_HOSTINFO 
KDP_VERSION 
KDP_MAXBYTES 
KDP_READMEM 
KDP_WRITEMEM 
KDP_READREGS 
KDP_WRITEREGS 
KDP_LOAD 
KDP_IMAGEPATH 
KDP_SUSPEND 
KDP_RESUMECPUS 
KDP_EXCEPTION 
KDP_TERMINATION 
KDP_BREAKPOINT_SET 
KDP_BREAKPOINT_REMOVE 
KDP_REGIONS 
KDP_REATTACH 
KDP_HOSTREBOOT 
KDP_READMEM64 
KDP_WRITEMEM64 
KDP_BREAKPOINT_SET64 
KDP_BREAKPOINT_REMOVE64 
KDP_KERNELVERSION 
KDP_READPHYSMEM64 
KDP_WRITEPHYSMEM64 
KDP_READIOPORT 
KDP_WRITEIOPORT 
KDP_READMSR64 
KDP_WRITEMSR64 
KDP_DUMPINFO 

Definition at line 27 of file CommunicationKDP.h.

◆ KDPError

Enumerator
KDP_PROTERR_SUCCESS 
KDP_PROTERR_ALREADY_CONNECTED 
KDP_PROTERR_BAD_NBYTES 
KDP_PROTERR_BADFLAVOR 

Definition at line 64 of file CommunicationKDP.h.

◆ PacketType

Enumerator
ePacketTypeRequest 
ePacketTypeReply 
ePacketTypeMask 
eCommandTypeMask 

Definition at line 71 of file CommunicationKDP.h.

Constructor & Destructor Documentation

◆ CommunicationKDP() [1/2]

CommunicationKDP::CommunicationKDP ( const char *  comm_name)

Definition at line 31 of file CommunicationKDP.cpp.

◆ ~CommunicationKDP()

CommunicationKDP::~CommunicationKDP ( )
override

◆ CommunicationKDP() [2/2]

CommunicationKDP::CommunicationKDP ( const CommunicationKDP )
privatedelete

Member Function Documentation

◆ CheckForPacket()

bool CommunicationKDP::CheckForPacket ( const uint8_t *  src,
size_t  src_len,
lldb_private::DataExtractor packet 
)

◆ ClearKDPSettings()

void CommunicationKDP::ClearKDPSettings ( )
protected

◆ DumpPacket() [1/2]

void CommunicationKDP::DumpPacket ( lldb_private::Stream s,
const lldb_private::DataExtractor extractor 
)
protected

◆ DumpPacket() [2/2]

void CommunicationKDP::DumpPacket ( lldb_private::Stream s,
const void *  data,
uint32_t  data_len 
)
protected

◆ ExtractCommand()

CommandType CommunicationKDP::ExtractCommand ( uint8_t  first_packet_byte) const
inlineprotected

Definition at line 209 of file CommunicationKDP.h.

References eCommandTypeMask.

Referenced by DumpPacket().

◆ ExtractIsReply()

bool CommunicationKDP::ExtractIsReply ( uint8_t  first_packet_byte) const
inlineprotected

Definition at line 204 of file CommunicationKDP.h.

References ePacketTypeMask.

Referenced by DumpPacket().

◆ GetCommandAsCString()

const char * CommunicationKDP::GetCommandAsCString ( uint8_t  command)
staticprotected

◆ GetCPUMask()

uint32_t CommunicationKDP::GetCPUMask ( )

◆ GetCPUSubtype()

uint32_t CommunicationKDP::GetCPUSubtype ( )

◆ GetCPUType()

uint32_t CommunicationKDP::GetCPUType ( )

◆ GetFeatureFlags()

uint32_t CommunicationKDP::GetFeatureFlags ( )

◆ GetKernelVersion()

const char * CommunicationKDP::GetKernelVersion ( )

◆ GetLoadAddress()

lldb::addr_t CommunicationKDP::GetLoadAddress ( )

◆ GetPacketTimeout()

std::chrono::seconds CommunicationKDP::GetPacketTimeout ( ) const
inline

Definition at line 107 of file CommunicationKDP.h.

References m_packet_timeout.

Referenced by SendRequestAndGetReply().

◆ GetSequenceMutex()

bool CommunicationKDP::GetSequenceMutex ( std::unique_lock< std::recursive_mutex > &  lock)

Definition at line 157 of file CommunicationKDP.cpp.

References m_sequence_mutex.

◆ GetUUID()

lldb_private::UUID CommunicationKDP::GetUUID ( )

◆ GetVersion()

uint32_t CommunicationKDP::GetVersion ( )

◆ HostInfoIsValid()

bool CommunicationKDP::HostInfoIsValid ( ) const
inlineprotected

Definition at line 202 of file CommunicationKDP.h.

References m_kdp_hostinfo_cpu_type.

Referenced by GetCPUMask(), GetCPUSubtype(), and GetCPUType().

◆ IsRunning()

bool CommunicationKDP::IsRunning ( ) const
inline

◆ LocalBreakpointsAreSupported()

bool CommunicationKDP::LocalBreakpointsAreSupported ( )
inline

◆ MakeRequestPacketHeader()

void CommunicationKDP::MakeRequestPacketHeader ( CommandType  request_type,
PacketStreamType request_packet,
uint16_t  request_length 
)
protected

◆ operator=()

const CommunicationKDP & CommunicationKDP::operator= ( const CommunicationKDP )
privatedelete

◆ RemoteIsDarwinKernel()

bool CommunicationKDP::RemoteIsDarwinKernel ( )

Definition at line 461 of file CommunicationKDP.cpp.

References GetKernelVersion(), and m_kernel_version.

Referenced by ProcessKDP::DoConnectRemote().

◆ RemoteIsEFI()

bool CommunicationKDP::RemoteIsEFI ( )

Definition at line 455 of file CommunicationKDP.cpp.

References GetKernelVersion(), and m_kernel_version.

Referenced by ProcessKDP::DoConnectRemote().

◆ SendRawRequest()

bool CommunicationKDP::SendRawRequest ( uint8_t  command_byte,
const void *  src,
uint32_t  src_len,
lldb_private::DataExtractor reply,
lldb_private::Status error 
)

◆ SendRequestAndGetReply()

bool CommunicationKDP::SendRequestAndGetReply ( const CommandType  command,
const PacketStreamType request_packet,
lldb_private::DataExtractor reply_packet 
)
protected

◆ SendRequestBreakpoint()

bool CommunicationKDP::SendRequestBreakpoint ( bool  set,
lldb::addr_t  addr 
)

◆ SendRequestConnect()

bool CommunicationKDP::SendRequestConnect ( uint16_t  reply_port,
uint16_t  exc_port,
const char *  greeting 
)

◆ SendRequestDisconnect()

bool CommunicationKDP::SendRequestDisconnect ( )

◆ SendRequestHostInfo()

bool CommunicationKDP::SendRequestHostInfo ( )
protected

◆ SendRequestKernelVersion()

bool CommunicationKDP::SendRequestKernelVersion ( )
protected

◆ SendRequestPacket()

bool CommunicationKDP::SendRequestPacket ( const PacketStreamType request_packet)

Definition at line 46 of file CommunicationKDP.cpp.

References m_sequence_mutex, and SendRequestPacketNoLock().

◆ SendRequestPacketNoLock()

bool CommunicationKDP::SendRequestPacketNoLock ( const PacketStreamType request_packet)
protected

◆ SendRequestReadMemory()

uint32_t CommunicationKDP::SendRequestReadMemory ( lldb::addr_t  addr,
void *  dst,
uint32_t  dst_size,
lldb_private::Status error 
)

◆ SendRequestReadRegisters()

uint32_t CommunicationKDP::SendRequestReadRegisters ( uint32_t  cpu,
uint32_t  flavor,
void *  dst,
uint32_t  dst_size,
lldb_private::Status error 
)

◆ SendRequestReattach()

bool CommunicationKDP::SendRequestReattach ( uint16_t  reply_port)

◆ SendRequestResume()

bool CommunicationKDP::SendRequestResume ( )

◆ SendRequestSuspend()

bool CommunicationKDP::SendRequestSuspend ( )

◆ SendRequestVersion()

bool CommunicationKDP::SendRequestVersion ( )
protected

◆ SendRequestWriteMemory()

uint32_t CommunicationKDP::SendRequestWriteMemory ( lldb::addr_t  addr,
const void *  src,
uint32_t  src_len,
lldb_private::Status error 
)

◆ SendRequestWriteRegisters()

uint32_t CommunicationKDP::SendRequestWriteRegisters ( uint32_t  cpu,
uint32_t  flavor,
const void *  src,
uint32_t  src_size,
lldb_private::Status error 
)

◆ SetPacketTimeout()

std::chrono::seconds CommunicationKDP::SetPacketTimeout ( std::chrono::seconds  packet_timeout)
inline

Definition at line 101 of file CommunicationKDP.h.

References m_packet_timeout.

Referenced by ProcessKDP::ProcessKDP().

◆ VersionIsValid()

bool CommunicationKDP::VersionIsValid ( ) const
inlineprotected

Definition at line 200 of file CommunicationKDP.h.

References m_kdp_version_version.

Referenced by GetFeatureFlags(), and GetVersion().

◆ WaitForNotRunningPrivate()

bool CommunicationKDP::WaitForNotRunningPrivate ( const std::chrono::microseconds &  timeout)
protected

◆ WaitForPacketWithTimeoutMicroSeconds()

size_t CommunicationKDP::WaitForPacketWithTimeoutMicroSeconds ( lldb_private::DataExtractor response,
uint32_t  usec 
)

◆ WaitForPacketWithTimeoutMicroSecondsNoLock()

size_t CommunicationKDP::WaitForPacketWithTimeoutMicroSecondsNoLock ( lldb_private::DataExtractor response,
uint32_t  timeout_usec 
)
protected

Member Data Documentation

◆ kMaxDataSize

const uint32_t CommunicationKDP::kMaxDataSize = 1024
static

Definition at line 25 of file CommunicationKDP.h.

◆ kMaxPacketSize

const uint32_t CommunicationKDP::kMaxPacketSize = 1200
static

Definition at line 24 of file CommunicationKDP.h.

◆ m_addr_byte_size

uint32_t CommunicationKDP::m_addr_byte_size
protected

◆ m_byte_order

lldb::ByteOrder CommunicationKDP::m_byte_order
protected

◆ m_bytes

std::string CommunicationKDP::m_bytes
protected

Definition at line 224 of file CommunicationKDP.h.

Referenced by CheckForPacket().

◆ m_bytes_mutex

std::recursive_mutex CommunicationKDP::m_bytes_mutex
protected

Definition at line 225 of file CommunicationKDP.h.

Referenced by CheckForPacket().

◆ m_exception_sequence_id

uint8_t CommunicationKDP::m_exception_sequence_id
protected

Definition at line 232 of file CommunicationKDP.h.

◆ m_is_running

lldb_private::Predicate<bool> CommunicationKDP::m_is_running
protected

◆ m_kdp_hostinfo_cpu_mask

uint32_t CommunicationKDP::m_kdp_hostinfo_cpu_mask
protected

Definition at line 235 of file CommunicationKDP.h.

Referenced by ClearKDPSettings(), GetCPUMask(), and SendRequestHostInfo().

◆ m_kdp_hostinfo_cpu_subtype

uint32_t CommunicationKDP::m_kdp_hostinfo_cpu_subtype
protected

Definition at line 237 of file CommunicationKDP.h.

Referenced by ClearKDPSettings(), GetCPUSubtype(), and SendRequestHostInfo().

◆ m_kdp_hostinfo_cpu_type

uint32_t CommunicationKDP::m_kdp_hostinfo_cpu_type
protected

◆ m_kdp_version_feature

uint32_t CommunicationKDP::m_kdp_version_feature
protected

Definition at line 234 of file CommunicationKDP.h.

Referenced by ClearKDPSettings(), GetFeatureFlags(), and SendRequestVersion().

◆ m_kdp_version_version

uint32_t CommunicationKDP::m_kdp_version_version
protected

◆ m_kernel_version

std::string CommunicationKDP::m_kernel_version
protected

◆ m_last_read_memory_addr

lldb::addr_t CommunicationKDP::m_last_read_memory_addr
protected

Definition at line 241 of file CommunicationKDP.h.

Referenced by DumpPacket().

◆ m_packet_timeout

std::chrono::seconds CommunicationKDP::m_packet_timeout
protected

Definition at line 226 of file CommunicationKDP.h.

Referenced by GetPacketTimeout(), and SetPacketTimeout().

◆ m_request_sequence_id

uint8_t CommunicationKDP::m_request_sequence_id
protected

Definition at line 231 of file CommunicationKDP.h.

Referenced by ClearKDPSettings(), and MakeRequestPacketHeader().

◆ m_sequence_mutex

std::recursive_mutex CommunicationKDP::m_sequence_mutex
protected

◆ m_session_key

uint32_t CommunicationKDP::m_session_key
protected

Definition at line 230 of file CommunicationKDP.h.

Referenced by MakeRequestPacketHeader(), and SendRequestReattach().


The documentation for this class was generated from the following files: