Added the ability to connect using "tcp://<host>:<port>" which is the
same as the old "connect://<host>:<port>". Also added the ability to
connect using "udp://<host>:<port>" which will open a connected 
datagram socket. I need to find a way to specify a non connected
datagram socket as well. 

We might need to start setting some settings in the URL itself, 
maybe something like:

udp://<host>:<port>?connected=yes
udp://<host>:<port>?connected=no

I am open to suggestions for URL settings.

Also did more work on the KDP darwin kernel plug-in.

 



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@135277 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h b/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
index ee626a6..c04083c 100644
--- a/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
+++ b/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
@@ -33,6 +33,53 @@
     {
         eBroadcastBitRunPacketSent = kLoUserBroadcastBit
     };
+    
+    const static uint32_t kMaxPacketSize = 1200;
+    const static uint32_t kMaxDataSize = 1024;
+    
+    typedef enum 
+    {
+        eRequestTypeConnect = 0u,
+        eRequestTypeDisconnect,
+        eRequestTypeHostInfo,
+        eRequestTypeVersion,
+        eRequestTypeMaxBytes,
+        eRequestTypeReadMemory,
+        eRequestTypeWriteMemory,
+        eRequestTypeReadRegisters,
+        eRequestTypeWriteRegisters,
+        eRequestTypeLoad,
+        eRequestTypeImagePath,
+        eRequestTypeSuspend,
+        eRequestTypeResume,
+        eRequestTypeException,
+        eRequestTypeTermination,
+        eRequestTypeBreakpointSet,
+        eRequestTypeBreakpointRemove,
+        eRequestTypeRegions,
+        eRequestTypeReattach,
+        eRequestTypeHostReboot,
+        eRequestTypeReadMemory64,
+        eRequestTypeWriteMemory64,
+        eRequestTypeBreakpointSet64,
+        eRequestTypeBreakpointRemove64,
+        eRequestTypeKernelVersion
+    } RequestType;
+
+    typedef enum 
+    {
+        eErrorSuccess = 0,
+        eErrorAlreadyConnected,
+        eErrorPacketToBig,
+        eErrorInvalidRegisterFlavor,
+        eErrorUnimplemented
+    } ErrorType;
+    
+    typedef enum
+    {
+        ePacketTypeRequest  = 0u,
+        ePacketTypeReply    = 1u
+    } PacketType;
     //------------------------------------------------------------------
     // Constructors and Destructors
     //------------------------------------------------------------------
@@ -41,34 +88,14 @@
     virtual
     ~CommunicationKDP();
 
-    size_t
-    SendPacket (const char *payload);
-
-    size_t
-    SendPacket (const char *payload,
-                size_t payload_length);
-
-    size_t
-    SendPacket (lldb_private::StreamString &response);
+    bool
+    SendRequestPacket (const lldb_private::StreamString &request_packet);
 
     // Wait for a packet within 'nsec' seconds
     size_t
     WaitForPacketWithTimeoutMicroSeconds (StringExtractor &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);
 
@@ -82,12 +109,6 @@
         return m_public_is_running.GetValue();
     }
 
-    bool
-    GetSendAcks ()
-    {
-        return m_send_acks;
-    }
-
     //------------------------------------------------------------------
     // Set the global packet timeout.
     //
@@ -119,12 +140,19 @@
                              lldb_private::ProcessLaunchInfo &launch_info); 
 
     
+    ErrorType
+    Connect (uint16_t reply_port, 
+             uint16_t exc_port, 
+             const char *greeting);
+
+    ErrorType
+    Disconnect ();
+
 protected:
     typedef std::list<std::string> packet_collection;
 
-    size_t
-    SendPacketNoLock (const char *payload, 
-                      size_t payload_length);
+    bool
+    SendRequestPacketNoLock (const lldb_private::StreamString &request_packet);
 
     size_t
     WaitForPacketWithTimeoutMicroSecondsNoLock (StringExtractor &response, 
@@ -133,6 +161,10 @@
     bool
     WaitForNotRunningPrivate (const lldb_private::TimeValue *timeout_ptr);
 
+    void
+    MakeRequestPacketHeader (RequestType request_type, 
+                             lldb_private::StreamString &request_packet);
+
     //------------------------------------------------------------------
     // Classes that inherit from CommunicationKDP can see and modify these
     //------------------------------------------------------------------
@@ -140,8 +172,9 @@
     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;
-    bool m_send_acks;
-
+    uint32_t m_session_key;
+    uint8_t m_request_sequence_id;
+    uint8_t m_exception_sequence_id;
 private:
     //------------------------------------------------------------------
     // For CommunicationKDP only