Added the ability to save core files:

(lldb) file /bin/ls
(lldb) b malloc
(lldb) run
(lldb) process save-core /tmp/ls.core

Each ObjectFile plug-in now has the option to save core files by registering a new static callback.

llvm-svn: 210864
diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp
index b4ee07a..dbf7139 100644
--- a/lldb/source/Core/PluginManager.cpp
+++ b/lldb/source/Core/PluginManager.cpp
@@ -1078,7 +1078,8 @@
         description(),
         create_callback(NULL),
         create_memory_callback (NULL),
-        get_module_specifications (NULL)
+        get_module_specifications (NULL),
+        save_core (NULL)
     {
     }
 
@@ -1087,6 +1088,7 @@
     ObjectFileCreateInstance create_callback;
     ObjectFileCreateMemoryInstance create_memory_callback;
     ObjectFileGetModuleSpecifications get_module_specifications;
+    ObjectFileSaveCore save_core;
 };
 
 typedef std::vector<ObjectFileInstance> ObjectFileInstances;
@@ -1111,7 +1113,8 @@
                                const char *description,
                                ObjectFileCreateInstance create_callback,
                                ObjectFileCreateMemoryInstance create_memory_callback,
-                               ObjectFileGetModuleSpecifications get_module_specifications)
+                               ObjectFileGetModuleSpecifications get_module_specifications,
+                               ObjectFileSaveCore save_core)
 {
     if (create_callback)
     {
@@ -1122,6 +1125,7 @@
             instance.description = description;
         instance.create_callback = create_callback;
         instance.create_memory_callback = create_memory_callback;
+        instance.save_core = save_core;
         instance.get_module_specifications = get_module_specifications;
         Mutex::Locker locker (GetObjectFileMutex ());
         GetObjectFileInstances ().push_back (instance);
@@ -1218,7 +1222,22 @@
     return NULL;
 }
 
-
+Error
+PluginManager::SaveCore (const lldb::ProcessSP &process_sp, const FileSpec &outfile)
+{
+    Error error;
+    Mutex::Locker locker (GetObjectFileMutex ());
+    ObjectFileInstances &instances = GetObjectFileInstances ();
+    
+    ObjectFileInstances::iterator pos, end = instances.end();
+    for (pos = instances.begin(); pos != end; ++ pos)
+    {
+        if (pos->save_core && pos->save_core (process_sp, outfile, error))
+            return error;
+    }
+    error.SetErrorString("no ObjectFile plugins were able to save a core for this process");
+    return error;
+}
 
 #pragma mark ObjectContainer