Modified the LocateMacOSXFilesUsingDebugSymbols(...) function to locate
an executable file if it is right next to a dSYM file that is found using
DebugSymbols. The code also looks into a bundle if the dSYM file is right
next to a bundle.

Modified the MacOSX kernel dynamic loader plug-in to correctly set the load
address for kext sections. This is a tad tricky because of how LLDB chooses
to treat mach-o segments with no name. Also modified the loader to properly
handle the older version 1 kext summary info.

Fixed a crasher in the Mach-o object file parser when it is trying to set
the section size correctly for dSYM sections.

Added packet dumpers to the CommunicationKDP class. We now also properly 
detect address byte sizes based on the cpu type and subtype that is provided.
Added a read memory and read register support to CommunicationKDP. Added a
ThreadKDP class that now uses subclasses of the RegisterContextDarwin_XXX for
arm, i386 and x86_64. 

Fixed some register numbering issues in the RegisterContextDarwin_arm class
and added ARM GDB numbers to the ARM_GCC_Registers.h file.

Change the RegisterContextMach_XXX classes over to subclassing their
RegisterContextDarwin_XXX counterparts so we can share the mach register 
contexts between the user and kernel plug-ins.




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@135466 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h b/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
index 83c8790..8e9d8b2 100644
--- a/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
+++ b/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h
@@ -140,6 +140,9 @@
                              lldb_private::ProcessLaunchInfo &launch_info); 
 
     
+    //------------------------------------------------------------------
+    // Public Request Packets
+    //------------------------------------------------------------------
     bool
     SendRequestConnect (uint16_t reply_port, 
                         uint16_t exc_port, 
@@ -152,6 +155,24 @@
     SendRequestDisconnect ();
     
     uint32_t
+    SendRequestReadMemory (lldb::addr_t addr, 
+                           void *buf, 
+                           uint32_t size,
+                           lldb_private::Error &error);
+
+    uint32_t
+    SendRequestReadRegisters (uint32_t cpu,
+                              uint32_t flavor,
+                              void *dst, 
+                              uint32_t dst_size,
+                              lldb_private::Error &error);
+//    size_t
+//    SendRequestWriteMemory (lldb::addr_t addr, 
+//                            const void *buf, 
+//                            size_t size,
+//                            lldb_private::Error &error);
+    
+    uint32_t
     GetVersion ();
 
     uint32_t
@@ -184,9 +205,25 @@
                              PacketStreamType &request_packet,
                              uint16_t request_length);
 
+    //------------------------------------------------------------------
+    // Protected Request Packets (use public accessors which will cache
+    // results.
+    //------------------------------------------------------------------
     bool
     SendRequestVersion ();
     
+    bool
+    SendRequestHostInfo ();
+
+    
+    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
@@ -201,7 +238,21 @@
     }
 
     bool
-    SendRequestHostInfo ();
+    ExtractIsReply (uint8_t first_packet_byte) const
+    {
+        // TODO: handle big endian...
+        return (first_packet_byte & ePacketTypeMask) != 0;
+    }
+
+    CommandType
+    ExtractCommand (uint8_t first_packet_byte) const
+    {
+        // TODO: handle big endian...
+        return (CommandType)(first_packet_byte & eCommandTypeMask);
+    }
+    
+    static const char *
+    GetCommandAsCString (uint8_t command);
 
     void
     ClearKDPSettings ();
@@ -214,6 +265,7 @@
     //------------------------------------------------------------------
     // Classes that inherit from CommunicationKDP can see and modify these
     //------------------------------------------------------------------
+    uint32_t m_addr_byte_size;
     lldb::ByteOrder m_byte_order;
     uint32_t m_packet_timeout;
     lldb_private::Mutex m_sequence_mutex;    // Restrict access to sending/receiving packets to a single thread at a time