LLDB  mainline
Public Member Functions | Protected Types | Static Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
lldb_private::process_gdb_remote::GDBRemoteCommunicationReplayServer Class Reference

Dummy GDB server that replays packets from the GDB Remote Communication history. More...

#include <GDBRemoteCommunicationReplayServer.h>

Inheritance diagram for lldb_private::process_gdb_remote::GDBRemoteCommunicationReplayServer:
Inheritance graph
Collaboration diagram for lldb_private::process_gdb_remote::GDBRemoteCommunicationReplayServer:
Collaboration graph

Public Member Functions

 GDBRemoteCommunicationReplayServer ()
 ~GDBRemoteCommunicationReplayServer () override
PacketResult GetPacketAndSendResponse (Timeout< std::micro > timeout, Status &error, bool &interrupt, bool &quit)
bool HandshakeWithClient ()
llvm::Error LoadReplayHistory (const FileSpec &path)
bool StartAsyncThread ()
void StopAsyncThread ()
Status Connect (process_gdb_remote::GDBRemoteCommunicationClient &client)
- Public Member Functions inherited from lldb_private::process_gdb_remote::GDBRemoteCommunication
 GDBRemoteCommunication (const char *comm_name, const char *listener_name)
 ~GDBRemoteCommunication () override
PacketResult GetAck ()
size_t SendAck ()
size_t SendNack ()
char CalculcateChecksum (llvm::StringRef payload)
PacketType CheckForPacket (const uint8_t *src, size_t src_len, StringExtractorGDBRemote &packet)
bool GetSendAcks ()
std::chrono::seconds SetPacketTimeout (std::chrono::seconds packet_timeout)
std::chrono::seconds GetPacketTimeout () const
Status StartDebugserverProcess (const char *url, Platform *platform, ProcessLaunchInfo &launch_info, uint16_t *port, const Args *inferior_args, int pass_comm_fd)
void DumpHistory (Stream &strm)
void SetPacketRecorder (repro::PacketRecorder *recorder)
- Public Member Functions inherited from lldb_private::Communication
 Communication (const char *broadcaster_name)
 Construct the Communication object with the specified name for the Broadcaster that this object inherits from. More...
 ~Communication () override
 Destructor. More...
void Clear ()
lldb::ConnectionStatus Connect (const char *url, Status *error_ptr)
 Connect using the current connection by passing url to its connect function. More...
lldb::ConnectionStatus Disconnect (Status *error_ptr=nullptr)
 Disconnect the communications connection if one is currently connected. More...
bool IsConnected () const
 Check if the connection is valid. More...
bool HasConnection () const
lldb_private::ConnectionGetConnection ()
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. More...
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. More...
void SetConnection (std::unique_ptr< Connection > connection)
 Sets the connection that it to be used by this class. More...
virtual bool StartReadThread (Status *error_ptr=nullptr)
 Starts a read thread whose sole purpose it to read bytes from the current connection. More...
virtual bool StopReadThread (Status *error_ptr=nullptr)
 Stops the read thread by cancelling it. More...
virtual bool JoinReadThread (Status *error_ptr=nullptr)
bool ReadThreadIsRunning ()
 Checks if there is a currently running read thread. More...
void SetReadThreadBytesReceivedCallback (ReadThreadBytesReceived callback, void *callback_baton)
void SynchronizeWithReadThread ()
 Wait for the read thread to process all outstanding data. More...
bool GetCloseOnEOF () const
void SetCloseOnEOF (bool b)
ConstStringGetBroadcasterClass () const override
 This needs to be filled in if you are going to register the broadcaster with the broadcaster manager and do broadcaster class matching. More...
- Public Member Functions inherited from lldb_private::Broadcaster
 Broadcaster (lldb::BroadcasterManagerSP manager_sp, const char *name)
 Construct with a broadcaster with a name. More...
virtual ~Broadcaster ()
 Destructor. More...
void CheckInWithManager ()
void BroadcastEvent (lldb::EventSP &event_sp)
 Broadcast an event which has no associated data. More...
void BroadcastEventIfUnique (lldb::EventSP &event_sp)
void BroadcastEvent (uint32_t event_type, const lldb::EventDataSP &event_data_sp)
void BroadcastEvent (uint32_t event_type, EventData *event_data=nullptr)
void BroadcastEventIfUnique (uint32_t event_type, EventData *event_data=nullptr)
void Clear ()
virtual void AddInitialEventsToListener (const lldb::ListenerSP &listener_sp, uint32_t requested_events)
uint32_t AddListener (const lldb::ListenerSP &listener_sp, uint32_t event_mask)
 Listen for any events specified by event_mask. More...
ConstString GetBroadcasterName ()
 Get the NULL terminated C string name of this Broadcaster object. More...
bool GetEventNames (Stream &s, const uint32_t event_mask, bool prefix_with_broadcaster_name) const
 Get the event name(s) for one or more event bits. More...
void SetEventName (uint32_t event_mask, const char *name)
 Set the name for an event bit. More...
const char * GetEventName (uint32_t event_mask) const
bool EventTypeHasListeners (uint32_t event_type)
bool RemoveListener (const lldb::ListenerSP &listener_sp, uint32_t event_mask=UINT32_MAX)
 Removes a Listener from this broadcasters list and frees the event bits specified by event_mask that were previously acquired by listener (assuming listener was listening to this object) for other listener objects to use. More...
bool HijackBroadcaster (const lldb::ListenerSP &listener_sp, uint32_t event_mask=UINT32_MAX)
 Provides a simple mechanism to temporarily redirect events from broadcaster. More...
bool IsHijackedForEvent (uint32_t event_mask)
void RestoreBroadcaster ()
 Restore the state of the Broadcaster from a previous hijack attempt. More...
lldb::BroadcasterManagerSP GetManager ()

Protected Types

enum  { eBroadcastBitAsyncContinue = (1 << 0), eBroadcastBitAsyncThreadShouldExit = (1 << 1) }
- Protected Types inherited from lldb_private::Broadcaster
typedef std::shared_ptr< BroadcasterImplBroadcasterImplSP
typedef std::weak_ptr< BroadcasterImplBroadcasterImplWP

Static Protected Member Functions

static void ReceivePacket (GDBRemoteCommunicationReplayServer &server, bool &done)
static lldb::thread_result_t AsyncThread (void *arg)
- Static Protected Member Functions inherited from lldb_private::process_gdb_remote::GDBRemoteCommunication
static lldb::thread_result_t ListenThread (lldb::thread_arg_t arg)

Protected Attributes

std::vector< GDBRemotePacketm_packet_history
 Replay history with the oldest packet at the end. More...
Broadcaster m_async_broadcaster
 Server thread. More...
lldb::ListenerSP m_async_listener_sp
HostThread m_async_thread
std::recursive_mutex m_async_thread_state_mutex
bool m_skip_acks = false
- Protected Attributes inherited from lldb_private::process_gdb_remote::GDBRemoteCommunication
std::chrono::seconds m_packet_timeout
uint32_t m_echo_number
LazyBool m_supports_qEcho
GDBRemoteCommunicationHistory m_history
bool m_send_acks
bool m_is_platform
CompressionType m_compression_type
- Protected Attributes inherited from lldb_private::Communication
lldb::ConnectionSP m_connection_sp
 The connection that is current in use by this communications class. More...
HostThread m_read_thread
 The read thread handle in case we need to cancel the thread. More...
std::atomic< bool > m_read_thread_enabled
std::atomic< bool > m_read_thread_did_exit
std::string m_bytes
 A buffer to cache bytes read in the ReadThread function. More...
std::recursive_mutex m_bytes_mutex
 A mutex to protect multi-threaded access to the cached bytes. More...
std::mutex m_write_mutex
 Don't let multiple threads write at the same time... More...
std::mutex m_synchronize_mutex
ReadThreadBytesReceived m_callback
void * m_callback_baton
bool m_close_on_eof

Private Member Functions

 GDBRemoteCommunicationReplayServer (const GDBRemoteCommunicationReplayServer &)=delete
const GDBRemoteCommunicationReplayServeroperator= (const GDBRemoteCommunicationReplayServer &)=delete

Additional Inherited Members

- Public Types inherited from lldb_private::process_gdb_remote::GDBRemoteCommunication
enum  { eBroadcastBitRunPacketSent = kLoUserBroadcastBit, eBroadcastBitGdbReadThreadGotNotify }
enum  PacketType { PacketType::Invalid = 0, PacketType::Standard, PacketType::Notify }
enum  PacketResult {
  PacketResult::Success = 0, PacketResult::ErrorSendFailed, PacketResult::ErrorSendAck, PacketResult::ErrorReplyFailed,
  PacketResult::ErrorReplyTimeout, PacketResult::ErrorReplyInvalid, PacketResult::ErrorReplyAck, PacketResult::ErrorDisconnected,
- Public Types inherited from lldb_private::Communication
typedef void(* ReadThreadBytesReceived) (void *baton, const void *src, size_t src_len)
- Static Public Member Functions inherited from lldb_private::process_gdb_remote::GDBRemoteCommunication
static llvm::Error ConnectLocally (GDBRemoteCommunication &client, GDBRemoteCommunication &server)
static std::string ExpandRLE (std::string)
 Expand GDB run-length encoding. More...
- Static Public Member Functions inherited from lldb_private::Communication
static lldb::thread_result_t ReadThread (lldb::thread_arg_t comm_ptr)
 The static read thread function. More...
static std::string ConnectionStatusAsString (lldb::ConnectionStatus status)
static ConstStringGetStaticBroadcasterClass ()
- Protected Member Functions inherited from lldb_private::process_gdb_remote::GDBRemoteCommunication
PacketResult SendPacketNoLock (llvm::StringRef payload)
PacketResult SendRawPacketNoLock (llvm::StringRef payload, bool skip_ack=false)
PacketResult ReadPacket (StringExtractorGDBRemote &response, Timeout< std::micro > timeout, bool sync_on_timeout)
PacketResult ReadPacketWithOutputSupport (StringExtractorGDBRemote &response, Timeout< std::micro > timeout, bool sync_on_timeout, llvm::function_ref< void(llvm::StringRef)> output_callback)
PacketResult PopPacketFromQueue (StringExtractorGDBRemote &response, Timeout< std::micro > timeout)
PacketResult WaitForPacketNoLock (StringExtractorGDBRemote &response, Timeout< std::micro > timeout, bool sync_on_timeout)
bool CompressionIsEnabled ()
bool DecompressPacket ()
Status StartListenThread (const char *hostname="", uint16_t port=0)
bool JoinListenThread ()
void AppendBytesToCache (const uint8_t *bytes, size_t len, bool broadcast, lldb::ConnectionStatus status) override
 Append new bytes that get read from the read thread into the internal object byte cache. More...
- 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)
size_t GetCachedBytes (void *dst, size_t dst_len)
 Get any available bytes from our data cache. More...
- Protected Member Functions inherited from lldb_private::Broadcaster
BroadcasterImplSP GetBroadcasterImpl ()
const char * GetHijackingListenerName ()

Detailed Description

Dummy GDB server that replays packets from the GDB Remote Communication history.

This is used to replay GDB packets.

Definition at line 38 of file GDBRemoteCommunicationReplayServer.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Definition at line 58 of file GDBRemoteCommunicationReplayServer.h.

Constructor & Destructor Documentation

◆ GDBRemoteCommunicationReplayServer() [1/2]

GDBRemoteCommunicationReplayServer::GDBRemoteCommunicationReplayServer ( )

◆ ~GDBRemoteCommunicationReplayServer()

GDBRemoteCommunicationReplayServer::~GDBRemoteCommunicationReplayServer ( )

Definition at line 89 of file GDBRemoteCommunicationReplayServer.cpp.

References StopAsyncThread().

◆ GDBRemoteCommunicationReplayServer() [2/2]

lldb_private::process_gdb_remote::GDBRemoteCommunicationReplayServer::GDBRemoteCommunicationReplayServer ( const GDBRemoteCommunicationReplayServer )

Member Function Documentation

◆ AsyncThread()

thread_result_t GDBRemoteCommunicationReplayServer::AsyncThread ( void *  arg)

◆ Connect()

Status GDBRemoteCommunicationReplayServer::Connect ( process_gdb_remote::GDBRemoteCommunicationClient client)

◆ GetPacketAndSendResponse()

GDBRemoteCommunication::PacketResult GDBRemoteCommunicationReplayServer::GetPacketAndSendResponse ( Timeout< std::micro >  timeout,
Status error,
bool &  interrupt,
bool &  quit 

◆ HandshakeWithClient()

bool lldb_private::process_gdb_remote::GDBRemoteCommunicationReplayServer::HandshakeWithClient ( )

◆ LoadReplayHistory()

llvm::Error GDBRemoteCommunicationReplayServer::LoadReplayHistory ( const FileSpec path)

Definition at line 191 of file GDBRemoteCommunicationReplayServer.cpp.

References lldb_private::FileSpec::GetPath(), and m_packet_history.

Referenced by Connect().

◆ operator=()

const GDBRemoteCommunicationReplayServer& lldb_private::process_gdb_remote::GDBRemoteCommunicationReplayServer::operator= ( const GDBRemoteCommunicationReplayServer )

◆ ReceivePacket()

void GDBRemoteCommunicationReplayServer::ReceivePacket ( GDBRemoteCommunicationReplayServer server,
bool &  done 

◆ StartAsyncThread()

bool GDBRemoteCommunicationReplayServer::StartAsyncThread ( )

◆ StopAsyncThread()

void GDBRemoteCommunicationReplayServer::StopAsyncThread ( )

Member Data Documentation

◆ m_async_broadcaster

Broadcaster lldb_private::process_gdb_remote::GDBRemoteCommunicationReplayServer::m_async_broadcaster

◆ m_async_listener_sp

lldb::ListenerSP lldb_private::process_gdb_remote::GDBRemoteCommunicationReplayServer::m_async_listener_sp

◆ m_async_thread

HostThread lldb_private::process_gdb_remote::GDBRemoteCommunicationReplayServer::m_async_thread

Definition at line 73 of file GDBRemoteCommunicationReplayServer.h.

Referenced by StartAsyncThread(), and StopAsyncThread().

◆ m_async_thread_state_mutex

std::recursive_mutex lldb_private::process_gdb_remote::GDBRemoteCommunicationReplayServer::m_async_thread_state_mutex

◆ m_packet_history

std::vector<GDBRemotePacket> lldb_private::process_gdb_remote::GDBRemoteCommunicationReplayServer::m_packet_history

Replay history with the oldest packet at the end.

Definition at line 68 of file GDBRemoteCommunicationReplayServer.h.

Referenced by GetPacketAndSendResponse(), and LoadReplayHistory().

◆ m_skip_acks

bool lldb_private::process_gdb_remote::GDBRemoteCommunicationReplayServer::m_skip_acks = false

Definition at line 76 of file GDBRemoteCommunicationReplayServer.h.

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