GDBRemoteCommunication.h [plain text]
#ifndef liblldb_GDBRemoteCommunication_h_
#define liblldb_GDBRemoteCommunication_h_
#include <list>
#include <string>
#include "lldb/lldb-private.h"
#include "lldb/Core/Communication.h"
#include "lldb/Core/Listener.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Host/Predicate.h"
#include "lldb/Host/TimeValue.h"
#include "Utility/StringExtractorGDBRemote.h"
class ProcessGDBRemote;
class GDBRemoteCommunication : public lldb_private::Communication
{
public:
enum
{
eBroadcastBitRunPacketSent = kLoUserBroadcastBit
};
GDBRemoteCommunication(const char *comm_name,
const char *listener_name,
bool is_platform);
virtual
~GDBRemoteCommunication();
size_t
SendPacket (const char *payload);
size_t
SendPacket (const char *payload,
size_t payload_length);
size_t
SendPacket (lldb_private::StreamString &response);
size_t
WaitForPacketWithTimeoutMicroSeconds (StringExtractorGDBRemote &response,
uint32_t usec);
char
GetAck ();
size_t
SendAck ();
size_t
SendNack ();
char
CalculcateChecksum (const char *payload,
size_t payload_length);
bool
GetSequenceMutex(lldb_private::Mutex::Locker& locker);
bool
CheckForPacket (const uint8_t *src,
size_t src_len,
StringExtractorGDBRemote &packet);
bool
IsRunning() const
{
return m_public_is_running.GetValue();
}
bool
GetSendAcks ()
{
return m_send_acks;
}
virtual bool
GetThreadSuffixSupported () = 0;
uint32_t
SetPacketTimeout (uint32_t packet_timeout)
{
const uint32_t old_packet_timeout = m_packet_timeout;
m_packet_timeout = packet_timeout;
return old_packet_timeout;
}
uint32_t
GetPacketTimeoutInMicroSeconds () const
{
return m_packet_timeout * lldb_private::TimeValue::MicroSecPerSec;
}
lldb_private::Error
StartDebugserverProcess (const char *connect_url,
const char *unix_socket_name,
lldb_private::ProcessLaunchInfo &launch_info);
protected:
typedef std::list<std::string> packet_collection;
size_t
SendPacketNoLock (const char *payload,
size_t payload_length);
size_t
WaitForPacketWithTimeoutMicroSecondsNoLock (StringExtractorGDBRemote &response,
uint32_t timeout_usec);
bool
WaitForNotRunningPrivate (const lldb_private::TimeValue *timeout_ptr);
uint32_t m_packet_timeout;
lldb_private::Mutex m_sequence_mutex; lldb_private::Predicate<bool> m_public_is_running;
lldb_private::Predicate<bool> m_private_is_running;
bool m_send_acks;
bool m_is_platform;
private:
DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunication);
};
#endif // liblldb_GDBRemoteCommunication_h_