Split the GDBRemoteCommunication class into three classes:
GDBRemoteCommunication - The base GDB remote communication class
GDBRemoteCommunicationClient - designed to be used for clients the connect to
                               a remote GDB server
GDBRemoteCommunicationServer - designed to be used on the server side of a
                               GDB server implementation.





git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@128070 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
index dbd1bd0..858f67c 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
@@ -18,10 +18,7 @@
 // Other libraries and framework includes
 // Project includes
 #include "lldb/lldb-private.h"
-#include "lldb/Core/ArchSpec.h"
 #include "lldb/Core/Communication.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Error.h"
 #include "lldb/Core/Listener.h"
 #include "lldb/Host/Mutex.h"
 #include "lldb/Host/Predicate.h"
@@ -30,8 +27,7 @@
 
 class ProcessGDBRemote;
 
-class GDBRemoteCommunication :
-    public lldb_private::Communication
+class GDBRemoteCommunication : public lldb_private::Communication
 {
 public:
     enum
@@ -41,7 +37,7 @@
     //------------------------------------------------------------------
     // Constructors and Destructors
     //------------------------------------------------------------------
-    GDBRemoteCommunication();
+    GDBRemoteCommunication(const char *comm_name, const char *listener_name);
 
     virtual
     ~GDBRemoteCommunication();
@@ -53,23 +49,6 @@
     SendPacket (const char *payload,
                 size_t payload_length);
 
-    size_t
-    SendPacketAndWaitForResponse (const char *send_payload,
-                                  StringExtractorGDBRemote &response,
-                                  bool send_async);
-
-    size_t
-    SendPacketAndWaitForResponse (const char *send_payload,
-                                  size_t send_length,
-                                  StringExtractorGDBRemote &response,
-                                  bool send_async);
-
-    lldb::StateType
-    SendContinuePacketAndWaitForResponse (ProcessGDBRemote *process,
-                                          const char *packet_payload,
-                                          size_t packet_length,
-                                          StringExtractorGDBRemote &response);
-
     // Wait for a packet within 'nsec' seconds
     size_t
     WaitForPacket (StringExtractorGDBRemote &response,
@@ -90,24 +69,11 @@
     size_t
     SendNack ();
 
-
     char
     CalculcateChecksum (const char *payload,
                         size_t payload_length);
 
     bool
-    GetThreadSuffixSupported ();
-
-    bool
-    SendAsyncSignal (int signo);
-
-    bool
-    SendInterrupt (lldb_private::Mutex::Locker &locker, 
-                   uint32_t seconds_to_wait_for_stop, 
-                   bool &sent_interrupt, 
-                   bool &timed_out);
-
-    bool
     GetSequenceMutex(lldb_private::Mutex::Locker& locker);
 
     //------------------------------------------------------------------
@@ -116,167 +82,29 @@
     virtual void
     AppendBytesToCache (const uint8_t *src, size_t src_len, bool broadcast, lldb::ConnectionStatus status);
 
-
-    lldb::pid_t
-    GetCurrentProcessID ();
-
-    bool
-    GetLaunchSuccess (std::string &error_str);
-
-    //------------------------------------------------------------------
-    /// Sends a GDB remote protocol 'A' packet that delivers program
-    /// arguments to the remote server.
-    ///
-    /// @param[in] argv
-    ///     A NULL terminated array of const C strings to use as the
-    ///     arguments.
-    ///
-    /// @return
-    ///     Zero if the response was "OK", a positive value if the
-    ///     the response was "Exx" where xx are two hex digits, or
-    ///     -1 if the call is unsupported or any other unexpected
-    ///     response was received.
-    //------------------------------------------------------------------
-    int
-    SendArgumentsPacket (char const *argv[]);
-
-    //------------------------------------------------------------------
-    /// Sends a "QEnvironment:NAME=VALUE" packet that will build up the
-    /// environment that will get used when launching an application
-    /// in conjunction with the 'A' packet. This function can be called
-    /// multiple times in a row in order to pass on the desired
-    /// environment that the inferior should be launched with.
-    ///
-    /// @param[in] name_equal_value
-    ///     A NULL terminated C string that contains a single environment
-    ///     in the format "NAME=VALUE".
-    ///
-    /// @return
-    ///     Zero if the response was "OK", a positive value if the
-    ///     the response was "Exx" where xx are two hex digits, or
-    ///     -1 if the call is unsupported or any other unexpected
-    ///     response was received.
-    //------------------------------------------------------------------
-    int
-    SendEnvironmentPacket (char const *name_equal_value);
-
-    //------------------------------------------------------------------
-    /// Sends a "vAttach:PID" where PID is in hex. 
-    ///
-    /// @param[in] pid
-    ///     A process ID for the remote gdb server to attach to.
-    ///
-    /// @param[out] response
-    ///     The response received from the gdb server. If the return
-    ///     value is zero, \a response will contain a stop reply 
-    ///     packet.
-    ///
-    /// @return
-    ///     Zero if the attach was successful, or an error indicating
-    ///     an error code.
-    //------------------------------------------------------------------
-    int
-    SendAttach (lldb::pid_t pid, 
-                StringExtractorGDBRemote& response);
-
-
-    //------------------------------------------------------------------
-    /// Sets the path to use for stdin/out/err for a process
-    /// that will be launched with the 'A' packet.
-    ///
-    /// @param[in] path
-    ///     The path to use for stdin/out/err
-    ///
-    /// @return
-    ///     Zero if the for success, or an error code for failure.
-    //------------------------------------------------------------------
-    int
-    SetSTDIN (char const *path);
-    int
-    SetSTDOUT (char const *path);
-    int
-    SetSTDERR (char const *path);
-
-    //------------------------------------------------------------------
-    /// Sets the disable ASLR flag to \a enable for a process that will 
-    /// be launched with the 'A' packet.
-    ///
-    /// @param[in] enable
-    ///     A boolean value indicating wether to disable ASLR or not.
-    ///
-    /// @return
-    ///     Zero if the for success, or an error code for failure.
-    //------------------------------------------------------------------
-    int
-    SetDisableASLR (bool enable);
-
-    //------------------------------------------------------------------
-    /// Sets the working directory to \a path for a process that will 
-    /// be launched with the 'A' packet.
-    ///
-    /// @param[in] path
-    ///     The path to a directory to use when launching our processs
-    ///
-    /// @return
-    ///     Zero if the for success, or an error code for failure.
-    //------------------------------------------------------------------
-    int
-    SetWorkingDir (char const *path);
-
-    lldb::addr_t
-    AllocateMemory (size_t size, uint32_t permissions);
-
-    bool
-    DeallocateMemory (lldb::addr_t addr);
-
     bool
     IsRunning() const
     {
         return m_public_is_running.GetValue();
     }
 
-    const lldb_private::ArchSpec &
-    GetHostArchitecture ();
-    
-    const lldb_private::ConstString &
-    GetOSString ();
-    
-    const lldb_private::ConstString &
-    GetVendorString();
-    
-    lldb::ByteOrder
-    GetByteOrder ();
+    //------------------------------------------------------------------
+    // Client and server must implement these pure virtual functions
+    //------------------------------------------------------------------
+    virtual bool
+    GetThreadSuffixSupported () = 0;
 
-    uint32_t
-    GetAddressByteSize ();
-
-    bool
-    GetVContSupported (char flavor);
-
-    void
-    ResetDiscoverableSettings();
-
-    bool
-    GetHostInfo ();
+    virtual bool
+    GetSendAcks () = 0;
     
-    bool
-    GetSendAcks ();
-    
-    bool
-    GetSupportsThreadSuffix ();
-
-    bool
-    HasFullVContSupport ()
-    {
-        return GetVContSupported ('A');
-    }
-
-    bool
-    HasAnyVContSupport ()
-    {
-        return GetVContSupported ('a');
-    }
-    
+    //------------------------------------------------------------------
+    // Set the global packet timeout.
+    //
+    // For clients, this is the timeout that gets used when sending
+    // packets and waiting for responses. For servers, this might not
+    // get used, and if it doesn't this should be moved to the
+    // GDBRemoteCommunicationClient.
+    //------------------------------------------------------------------
     uint32_t 
     SetPacketTimeout (uint32_t packet_timeout)
     {
@@ -299,46 +127,15 @@
     bool
     WaitForNotRunningPrivate (const lldb_private::TimeValue *timeout_ptr);
 
-    bool
-    HostInfoIsValid () const
-    {
-        return m_supports_qHostInfo != lldb::eLazyBoolCalculate;
-    }
-
     //------------------------------------------------------------------
     // Classes that inherit from GDBRemoteCommunication can see and modify these
     //------------------------------------------------------------------
     uint32_t m_packet_timeout;
-    lldb::LazyBool m_supports_not_sending_acks;
-    lldb::LazyBool m_supports_thread_suffix;
-    lldb::LazyBool m_supports_qHostInfo;
-    lldb::LazyBool m_supports_vCont_all;
-    lldb::LazyBool m_supports_vCont_any;
-    lldb::LazyBool m_supports_vCont_c;
-    lldb::LazyBool m_supports_vCont_C;
-    lldb::LazyBool m_supports_vCont_s;
-    lldb::LazyBool m_supports_vCont_S;
     lldb_private::Listener m_rx_packet_listener;
     lldb_private::Mutex m_sequence_mutex;    // Restrict access to sending/receiving packets to a single thread at a time
     lldb_private::Predicate<bool> m_public_is_running;
     lldb_private::Predicate<bool> m_private_is_running;
 
-    // If we need to send a packet while the target is running, the m_async_XXX
-    // member variables take care of making this happen.
-    lldb_private::Mutex m_async_mutex;
-    lldb_private::Predicate<bool> m_async_packet_predicate;
-    std::string m_async_packet;
-    StringExtractorGDBRemote m_async_response;
-    int m_async_signal; // We were asked to deliver a signal to the inferior process.
-    
-    lldb_private::ArchSpec m_arch;      // Results from the qHostInfo call
-    uint32_t m_cpusubtype;              // Results from the qHostInfo call
-    lldb_private::ConstString m_os;     // Results from the qHostInfo call
-    lldb_private::ConstString m_vendor; // Results from the qHostInfo call
-    lldb::ByteOrder m_byte_order;       // Results from the qHostInfo call
-    uint32_t m_pointer_byte_size;       // Results from the qHostInfo call
-    
-    
 private:
     //------------------------------------------------------------------
     // For GDBRemoteCommunication only