<rdar://problem/13854277>
<rdar://problem/13594769>

Main changes in this patch include:
- cleanup plug-in interface and use ConstStrings for plug-in names
- Modfiied the BSD Archive plug-in to be able to pick out the correct .o file when .a files contain multiple .o files with the same name by using the timestamp
- Modified SymbolFileDWARFDebugMap to properly verify the timestamp on .o files it loads to ensure we don't load updated .o files and cause problems when debugging

The plug-in interface changes:

Modified the lldb_private::PluginInterface class that all plug-ins inherit from:

Changed:

virtual const char * GetPluginName() = 0;

To: 

virtual ConstString GetPluginName() = 0;

Removed:

virtual const char * GetShortPluginName() = 0;

- Fixed up all plug-in to adhere to the new interface and to return lldb_private::ConstString values for the plug-in names. 
- Fixed all plug-ins to return simple names with no prefixes. Some plug-ins had prefixes and most ones didn't, so now they all don't have prefixed names, just simple names like "linux", "gdb-remote", etc.

llvm-svn: 181631
diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp
index 0cc916b..a143b95d 100644
--- a/lldb/source/Core/PluginManager.cpp
+++ b/lldb/source/Core/PluginManager.cpp
@@ -233,7 +233,7 @@
     {
     }
 
-    std::string name;
+    ConstString name;
     std::string description;
     ABICreateInstance create_callback;
 };
@@ -257,7 +257,7 @@
 bool
 PluginManager::RegisterPlugin
 (
-    const char *name,
+    const ConstString &name,
     const char *description,
     ABICreateInstance create_callback
 )
@@ -265,8 +265,8 @@
     if (create_callback)
     {
         ABIInstance instance;
-        assert (name && name[0]);
-        instance.name.assign (name);
+        assert ((bool)name);
+        instance.name = name;
         if (description && description[0])
             instance.description = description;
         instance.create_callback = create_callback;
@@ -309,18 +309,17 @@
 }
 
 ABICreateInstance
-PluginManager::GetABICreateCallbackForPluginName (const char *name)
+PluginManager::GetABICreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
         Mutex::Locker locker (GetABIInstancesMutex ());
-        llvm::StringRef name_sref(name);
         ABIInstances &instances = GetABIInstances ();
 
         ABIInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -340,7 +339,7 @@
     {
     }
 
-    std::string name;
+    ConstString name;
     std::string description;
     DisassemblerCreateInstance create_callback;
 };
@@ -364,7 +363,7 @@
 bool
 PluginManager::RegisterPlugin
 (
-    const char *name,
+    const ConstString &name,
     const char *description,
     DisassemblerCreateInstance create_callback
 )
@@ -372,7 +371,7 @@
     if (create_callback)
     {
         DisassemblerInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
@@ -416,18 +415,17 @@
 }
 
 DisassemblerCreateInstance
-PluginManager::GetDisassemblerCreateCallbackForPluginName (const char *name)
+PluginManager::GetDisassemblerCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetDisassemblerMutex ());
         DisassemblerInstances &instances = GetDisassemblerInstances ();
         
         DisassemblerInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -449,7 +447,7 @@
     {
     }
 
-    std::string name;
+    ConstString name;
     std::string description;
     DynamicLoaderCreateInstance create_callback;
     DebuggerInitializeCallback debugger_init_callback;
@@ -476,7 +474,7 @@
 bool
 PluginManager::RegisterPlugin
 (
-    const char *name,
+    const ConstString &name,
     const char *description,
     DynamicLoaderCreateInstance create_callback,
     DebuggerInitializeCallback debugger_init_callback
@@ -485,7 +483,7 @@
     if (create_callback)
     {
         DynamicLoaderInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
@@ -529,18 +527,17 @@
 }
 
 DynamicLoaderCreateInstance
-PluginManager::GetDynamicLoaderCreateCallbackForPluginName (const char *name)
+PluginManager::GetDynamicLoaderCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetDynamicLoaderMutex ());
         DynamicLoaderInstances &instances = GetDynamicLoaderInstances ();
         
         DynamicLoaderInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -559,7 +556,7 @@
     {
     }
     
-    std::string name;
+    ConstString name;
     std::string description;
     EmulateInstructionCreateInstance create_callback;
 };
@@ -584,7 +581,7 @@
 bool
 PluginManager::RegisterPlugin
 (
-    const char *name,
+    const ConstString &name,
     const char *description,
     EmulateInstructionCreateInstance create_callback
 )
@@ -592,7 +589,7 @@
     if (create_callback)
     {
         EmulateInstructionInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
@@ -635,18 +632,17 @@
 }
 
 EmulateInstructionCreateInstance
-PluginManager::GetEmulateInstructionCreateCallbackForPluginName (const char *name)
+PluginManager::GetEmulateInstructionCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetEmulateInstructionMutex ());
         EmulateInstructionInstances &instances = GetEmulateInstructionInstances ();
         
         EmulateInstructionInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -664,7 +660,7 @@
     {
     }
     
-    std::string name;
+    ConstString name;
     std::string description;
     OperatingSystemCreateInstance create_callback;
 };
@@ -686,17 +682,14 @@
 }
 
 bool
-PluginManager::RegisterPlugin
-(
- const char *name,
- const char *description,
- OperatingSystemCreateInstance create_callback
- )
+PluginManager::RegisterPlugin (const ConstString &name,
+                               const char *description,
+                               OperatingSystemCreateInstance create_callback)
 {
     if (create_callback)
     {
         OperatingSystemInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
@@ -739,18 +732,17 @@
 }
 
 OperatingSystemCreateInstance
-PluginManager::GetOperatingSystemCreateCallbackForPluginName (const char *name)
+PluginManager::GetOperatingSystemCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetOperatingSystemMutex ());
         OperatingSystemInstances &instances = GetOperatingSystemInstances ();
         
         OperatingSystemInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -770,7 +762,7 @@
     {
     }
 
-    std::string name;
+    ConstString name;
     std::string description;
     LanguageRuntimeCreateInstance create_callback;
 };
@@ -794,7 +786,7 @@
 bool
 PluginManager::RegisterPlugin
 (
-    const char *name,
+    const ConstString &name,
     const char *description,
     LanguageRuntimeCreateInstance create_callback
 )
@@ -802,7 +794,7 @@
     if (create_callback)
     {
         LanguageRuntimeInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
@@ -845,18 +837,17 @@
 }
 
 LanguageRuntimeCreateInstance
-PluginManager::GetLanguageRuntimeCreateCallbackForPluginName (const char *name)
+PluginManager::GetLanguageRuntimeCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetLanguageRuntimeMutex ());
         LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances ();
         
         LanguageRuntimeInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -876,7 +867,7 @@
     {
     }
 
-    std::string name;
+    ConstString name;
     std::string description;
     ObjectFileCreateInstance create_callback;
     ObjectFileCreateMemoryInstance create_memory_callback;
@@ -901,7 +892,7 @@
 
 
 bool
-PluginManager::RegisterPlugin (const char *name,
+PluginManager::RegisterPlugin (const ConstString &name,
                                const char *description,
                                ObjectFileCreateInstance create_callback,
                                ObjectFileCreateMemoryInstance create_memory_callback,
@@ -910,7 +901,7 @@
     if (create_callback)
     {
         ObjectFileInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
@@ -976,18 +967,17 @@
 }
 
 ObjectFileCreateInstance
-PluginManager::GetObjectFileCreateCallbackForPluginName (const char *name)
+PluginManager::GetObjectFileCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetObjectFileMutex ());
         ObjectFileInstances &instances = GetObjectFileInstances ();
         
         ObjectFileInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -996,18 +986,17 @@
 
 
 ObjectFileCreateMemoryInstance
-PluginManager::GetObjectFileCreateMemoryCallbackForPluginName (const char *name)
+PluginManager::GetObjectFileCreateMemoryCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetObjectFileMutex ());
         ObjectFileInstances &instances = GetObjectFileInstances ();
         
         ObjectFileInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_memory_callback;
         }
     }
@@ -1028,7 +1017,7 @@
     {
     }
 
-    std::string name;
+    ConstString name;
     std::string description;
     ObjectContainerCreateInstance create_callback;
     ObjectFileGetModuleSpecifications get_module_specifications;
@@ -1052,7 +1041,7 @@
 }
 
 bool
-PluginManager::RegisterPlugin (const char *name,
+PluginManager::RegisterPlugin (const ConstString &name,
                                const char *description,
                                ObjectContainerCreateInstance create_callback,
                                ObjectFileGetModuleSpecifications get_module_specifications)
@@ -1060,7 +1049,7 @@
     if (create_callback)
     {
         ObjectContainerInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
@@ -1104,18 +1093,17 @@
 }
 
 ObjectContainerCreateInstance
-PluginManager::GetObjectContainerCreateCallbackForPluginName (const char *name)
+PluginManager::GetObjectContainerCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetObjectContainerMutex ());
         ObjectContainerInstances &instances = GetObjectContainerInstances ();
         
         ObjectContainerInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -1143,7 +1131,7 @@
     {
     }
 
-    std::string name;
+    ConstString name;
     std::string description;
     LogChannelCreateInstance create_callback;
 };
@@ -1169,7 +1157,7 @@
 bool
 PluginManager::RegisterPlugin
 (
-    const char *name,
+    const ConstString &name,
     const char *description,
     LogChannelCreateInstance create_callback
 )
@@ -1177,7 +1165,7 @@
     if (create_callback)
     {
         LogInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
@@ -1215,7 +1203,7 @@
     Mutex::Locker locker (GetLogMutex ());
     LogInstances &instances = GetLogInstances ();
     if (idx < instances.size())
-        return instances[idx].name.c_str();
+        return instances[idx].name.GetCString();
     return NULL;
 }
 
@@ -1231,18 +1219,17 @@
 }
 
 LogChannelCreateInstance
-PluginManager::GetLogChannelCreateCallbackForPluginName (const char *name)
+PluginManager::GetLogChannelCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetLogMutex ());
         LogInstances &instances = GetLogInstances ();
         
         LogInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -1261,7 +1248,7 @@
     {
     }
     
-    std::string name;
+    ConstString name;
     std::string description;
     PlatformCreateInstance create_callback;
     DebuggerInitializeCallback debugger_init_callback;
@@ -1285,7 +1272,7 @@
 
 
 bool
-PluginManager::RegisterPlugin (const char *name,
+PluginManager::RegisterPlugin (const ConstString &name,
                                const char *description,
                                PlatformCreateInstance create_callback,
                                DebuggerInitializeCallback debugger_init_callback)
@@ -1295,7 +1282,7 @@
         Mutex::Locker locker (GetPlatformInstancesMutex ());
         
         PlatformInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
@@ -1314,7 +1301,7 @@
     Mutex::Locker locker (GetPlatformInstancesMutex ());
     PlatformInstances &instances = GetPlatformInstances ();
     if (idx < instances.size())
-        return instances[idx].name.c_str();
+        return instances[idx].name.GetCString();
     return NULL;
 }
 
@@ -1360,18 +1347,17 @@
 }
 
 PlatformCreateInstance
-PluginManager::GetPlatformCreateCallbackForPluginName (const char *name)
+PluginManager::GetPlatformCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
         Mutex::Locker locker (GetPlatformInstancesMutex ());
         PlatformInstances &instances = GetPlatformInstances ();
-        llvm::StringRef name_sref(name);
 
         PlatformInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -1381,7 +1367,7 @@
 size_t
 PluginManager::AutoCompletePlatformName (const char *name, StringList &matches)
 {
-    if (name && name[0])
+    if (name)
     {
         Mutex::Locker locker (GetPlatformInstancesMutex ());
         PlatformInstances &instances = GetPlatformInstances ();
@@ -1390,7 +1376,7 @@
         PlatformInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            llvm::StringRef plugin_name (pos->name);
+            llvm::StringRef plugin_name (pos->name.GetCString());
             if (plugin_name.startswith(name_sref))
                 matches.AppendString (plugin_name.data());
         }
@@ -1408,7 +1394,7 @@
     {
     }
     
-    std::string name;
+    ConstString name;
     std::string description;
     ProcessCreateInstance create_callback;
 };
@@ -1433,7 +1419,7 @@
 bool
 PluginManager::RegisterPlugin
 (
- const char *name,
+ const ConstString &name,
  const char *description,
  ProcessCreateInstance create_callback
  )
@@ -1441,7 +1427,7 @@
     if (create_callback)
     {
         ProcessInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
@@ -1458,7 +1444,7 @@
     Mutex::Locker locker (GetProcessMutex ());
     ProcessInstances &instances = GetProcessInstances ();
     if (idx < instances.size())
-        return instances[idx].name.c_str();
+        return instances[idx].name.GetCString();
     return NULL;
 }
 
@@ -1505,18 +1491,17 @@
 
 
 ProcessCreateInstance
-PluginManager::GetProcessCreateCallbackForPluginName (const char *name)
+PluginManager::GetProcessCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetProcessMutex ());
         ProcessInstances &instances = GetProcessInstances ();
         
         ProcessInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -1534,7 +1519,7 @@
     {
     }
 
-    std::string name;
+    ConstString name;
     std::string description;
     SymbolFileCreateInstance create_callback;
 };
@@ -1559,7 +1544,7 @@
 bool
 PluginManager::RegisterPlugin
 (
-    const char *name,
+    const ConstString &name,
     const char *description,
     SymbolFileCreateInstance create_callback
 )
@@ -1567,7 +1552,7 @@
     if (create_callback)
     {
         SymbolFileInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
@@ -1610,18 +1595,17 @@
 }
 
 SymbolFileCreateInstance
-PluginManager::GetSymbolFileCreateCallbackForPluginName (const char *name)
+PluginManager::GetSymbolFileCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetSymbolFileMutex ());
         SymbolFileInstances &instances = GetSymbolFileInstances ();
         
         SymbolFileInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -1641,7 +1625,7 @@
     {
     }
 
-    std::string name;
+    ConstString name;
     std::string description;
     SymbolVendorCreateInstance create_callback;
 };
@@ -1665,7 +1649,7 @@
 bool
 PluginManager::RegisterPlugin
 (
-    const char *name,
+    const ConstString &name,
     const char *description,
     SymbolVendorCreateInstance create_callback
 )
@@ -1673,7 +1657,7 @@
     if (create_callback)
     {
         SymbolVendorInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
@@ -1717,18 +1701,17 @@
 
 
 SymbolVendorCreateInstance
-PluginManager::GetSymbolVendorCreateCallbackForPluginName (const char *name)
+PluginManager::GetSymbolVendorCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetSymbolVendorMutex ());
         SymbolVendorInstances &instances = GetSymbolVendorInstances ();
         
         SymbolVendorInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }
@@ -1747,7 +1730,7 @@
     {
     }
 
-    std::string name;
+    ConstString name;
     std::string description;
     UnwindAssemblyCreateInstance create_callback;
 };
@@ -1771,7 +1754,7 @@
 bool
 PluginManager::RegisterPlugin
 (
-    const char *name,
+    const ConstString &name,
     const char *description,
     UnwindAssemblyCreateInstance create_callback
 )
@@ -1779,7 +1762,7 @@
     if (create_callback)
     {
         UnwindAssemblyInstance instance;
-        assert (name && name[0]);
+        assert ((bool)name);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
@@ -1823,18 +1806,17 @@
 
 
 UnwindAssemblyCreateInstance
-PluginManager::GetUnwindAssemblyCreateCallbackForPluginName (const char *name)
+PluginManager::GetUnwindAssemblyCreateCallbackForPluginName (const ConstString &name)
 {
-    if (name && name[0])
+    if (name)
     {
-        llvm::StringRef name_sref(name);
         Mutex::Locker locker (GetUnwindAssemblyMutex ());
         UnwindAssemblyInstances &instances = GetUnwindAssemblyInstances ();
         
         UnwindAssemblyInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (name_sref.equals (pos->name))
+            if (name == pos->name)
                 return pos->create_callback;
         }
     }