Moved the execution context that was in the Debugger into
the CommandInterpreter where it was always being used.

Make sure that Modules can track their object file offsets correctly to
allow opening of sub object files (like the "__commpage" on darwin).

Modified the Platforms to be able to launch processes. The first part of this
move is the platform soon will become the entity that launches your program
and when it does, it uses a new ProcessLaunchInfo class which encapsulates
all process launching settings. This simplifies the internal APIs needed for
launching. I want to slowly phase out process launching from the process
classes, so for now we can still launch just as we used to, but eventually
the platform is the object that should do the launching.

Modified the Host::LaunchProcess in the MacOSX Host.mm to correctly be able
to launch processes with all of the new eLaunchFlag settings. Modified any
code that was manually launching processes to use the Host::LaunchProcess
functions.

Fixed an issue where lldb_private::Args had implicitly defined copy 
constructors that could do the wrong thing. This has now been fixed by adding
an appropriate copy constructor and assignment operator.

Make sure we don't add empty ModuleSP entries to a module list.

Fixed the commpage module creation on MacOSX, but we still need to train
the MacOSX dynamic loader to not get rid of it when it doesn't have an entry
in the all image infos.

Abstracted many more calls from in ProcessGDBRemote down into the 
GDBRemoteCommunicationClient subclass to make the classes cleaner and more
efficient.

Fixed the default iOS ARM register context to be correct and also added support
for targets that don't support the qThreadStopInfo packet by selecting the
current thread (only if needed) and then sending a stop reply packet.

Debugserver can now start up with a --unix-socket (-u for short) and can 
then bind to port zero and send the port it bound to to a listening process
on the other end. This allows the GDB remote platform to spawn new GDB server
instances (debugserver) to allow platform debugging.







git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@129351 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/Platform.cpp b/source/Target/Platform.cpp
index cddd37f..34c7337 100644
--- a/source/Target/Platform.cpp
+++ b/source/Target/Platform.cpp
@@ -14,9 +14,11 @@
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Core/Error.h"
+#include "lldb/Core/Log.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Host/FileSpec.h"
 #include "lldb/Host/Host.h"
+#include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
 
 using namespace lldb;
@@ -165,6 +167,9 @@
     m_max_uid_name_len (0),
     m_max_gid_name_len (0)
 {
+    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
+    if (log)
+        log->Printf ("%p Platform::Platform()", this);
 }
 
 //------------------------------------------------------------------
@@ -175,6 +180,9 @@
 //------------------------------------------------------------------
 Platform::~Platform()
 {
+    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
+    if (log)
+        log->Printf ("%p Platform::~Platform()", this);
 }
 
 void
@@ -300,6 +308,15 @@
 }
 
 const char *
+Platform::GetName ()
+{
+    const char *name = GetHostname();
+    if (name == NULL || name[0] == '\0')
+        name = GetShortPluginName();
+    return name;
+}
+
+const char *
 Platform::GetHostname ()
 {
     if (IsHost() && m_name.empty())
@@ -498,21 +515,66 @@
 }
 
 bool
-Platform::GetProcessInfo (lldb::pid_t pid, ProcessInfo &process_info)
+Platform::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
 {
     // Take care of the host case so that each subclass can just 
-    // call Platform::GetProcessInfo (pid, process_info)
+    // call this function to get the host functionality.
     if (IsHost())
         return Host::GetProcessInfo (pid, process_info);
     return false;
 }
 
 uint32_t
-Platform::FindProcesses (const ProcessInfoMatch &match_info,
-                         ProcessInfoList &process_infos)
+Platform::FindProcesses (const ProcessInstanceInfoMatch &match_info,
+                         ProcessInstanceInfoList &process_infos)
 {
+    // Take care of the host case so that each subclass can just 
+    // call this function to get the host functionality.
     uint32_t match_count = 0;
     if (IsHost())
         match_count = Host::FindProcesses (match_info, process_infos);
     return match_count;    
 }
+
+
+Error
+Platform::LaunchProcess (ProcessLaunchInfo &launch_info)
+{
+    Error error;
+    // Take care of the host case so that each subclass can just 
+    // call this function to get the host functionality.
+    if (IsHost())
+        error = Host::LaunchProcess (launch_info);
+    else
+        error.SetErrorString ("base lldb_private::Platform class can't launch remote processes");
+    return error;
+}
+
+lldb::ProcessSP
+Platform::DebugProcess (ProcessLaunchInfo &launch_info, 
+                        Debugger &debugger,
+                        Target *target,       // Can be NULL, if NULL create a new target, else use existing one
+                        Listener &listener,
+                        Error &error)
+{
+    ProcessSP process_sp;
+    // Make sure we stop at the entry point
+    launch_info.GetFlags ().Set (eLaunchFlagDebug);
+    error = LaunchProcess (launch_info);
+    if (error.Success())
+    {
+        lldb::pid_t pid = launch_info.GetProcessID();
+        if (pid != LLDB_INVALID_PROCESS_ID)
+        {
+            process_sp = Attach (pid, debugger, target, listener, error);
+            
+//            if (process_sp)
+//            {
+//                if (launch_info.GetFlags().IsClear (eLaunchFlagStopAtEntry))
+//                    process_sp->Resume();
+//            }
+        }
+    }
+    return process_sp;
+}
+