[Lldb-commits] [lldb] r129483 - in /lldb/trunk: include/lldb/ include/lldb/Core/ include/lldb/Interpreter/ include/lldb/Target/ source/Commands/ source/Core/ source/Interpreter/ source/Plugins/Platform/MacOSX/ source/Plugins/Platform/gdb-server/ source/Plugins/SymbolFile/DWARF/ source/Target/ tools/driver/

Greg Clayton gclayton at apple.com
Wed Apr 13 15:47:15 PDT 2011


Author: gclayton
Date: Wed Apr 13 17:47:15 2011
New Revision: 129483

URL: http://llvm.org/viewvc/llvm-project?rev=129483&view=rev
Log:
Added auto completion for architecture names and for platforms.

Modified the OptionGroupOptions to be able to specify only some of the options
that should be appended by using the usage_mask in the group defintions and
also provided a way to remap them to a new usage mask after the copy. This 
allows options to be re-used and also targetted for specific option groups.

Modfied the CommandArgumentType to have a new eArgTypePlatform enumeration.
Taught the option parser to be able to automatically use the appropriate
auto completion for a given options if nothing is explicitly specified
in the option definition. So you don't have to specify it in the option
definition tables.

Renamed the default host platform name to "host", and the default platform
hostname to be "localhost".

Modified the "file" and "platform select" commands to make sure all options
and args are good prior to creating a new platform. Also defer the computation
of the architecture in the file command until all options are parsed and the
platform has either not been specified or reset to a new value to avoid
computing the arch more than once.

Switch the PluginManager code over to using llvm::StringRef for string
comparisons and got rid of all the AccessorXXX functions in lieu of the newer
mutex + collection singleton accessors.



Modified:
    lldb/trunk/include/lldb/Core/ArchSpec.h
    lldb/trunk/include/lldb/Core/Log.h
    lldb/trunk/include/lldb/Core/PluginManager.h
    lldb/trunk/include/lldb/Interpreter/CommandCompletions.h
    lldb/trunk/include/lldb/Interpreter/Options.h
    lldb/trunk/include/lldb/Target/Platform.h
    lldb/trunk/include/lldb/lldb-enumerations.h
    lldb/trunk/include/lldb/lldb-private-types.h
    lldb/trunk/source/Commands/CommandCompletions.cpp
    lldb/trunk/source/Commands/CommandObjectFile.cpp
    lldb/trunk/source/Commands/CommandObjectFile.h
    lldb/trunk/source/Commands/CommandObjectLog.cpp
    lldb/trunk/source/Commands/CommandObjectPlatform.cpp
    lldb/trunk/source/Commands/CommandObjectPlatform.h
    lldb/trunk/source/Core/ArchSpec.cpp
    lldb/trunk/source/Core/Log.cpp
    lldb/trunk/source/Core/PluginManager.cpp
    lldb/trunk/source/Interpreter/CommandObject.cpp
    lldb/trunk/source/Interpreter/Options.cpp
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
    lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
    lldb/trunk/source/Target/Platform.cpp
    lldb/trunk/tools/driver/Driver.cpp

Modified: lldb/trunk/include/lldb/Core/ArchSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ArchSpec.h?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ArchSpec.h (original)
+++ lldb/trunk/include/lldb/Core/ArchSpec.h Wed Apr 13 17:47:15 2011
@@ -142,6 +142,10 @@
     const ArchSpec&
     operator= (const ArchSpec& rhs);
 
+    static uint32_t
+    AutoComplete (const char *name, 
+                  StringList &matches);
+
     //------------------------------------------------------------------
     /// Returns a static string representing the current architecture.
     ///

Modified: lldb/trunk/include/lldb/Core/Log.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Log.h?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Log.h (original)
+++ lldb/trunk/include/lldb/Core/Log.h Wed Apr 13 17:47:15 2011
@@ -105,6 +105,13 @@
 
     static void
     Terminate ();
+    
+    //------------------------------------------------------------------
+    // Auto completion
+    //------------------------------------------------------------------
+    static void
+    AutoCompleteChannelName (const char *channel_name, 
+                             StringList &matches);
 
     //------------------------------------------------------------------
     // Member functions
@@ -193,9 +200,6 @@
     virtual
     ~LogChannel ();
 
-    static const char *
-    GetPluginSuffix ();
-
     static lldb::LogChannelSP
     FindPlugin (const char *plugin_name);
 

Modified: lldb/trunk/include/lldb/Core/PluginManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/PluginManager.h?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/PluginManager.h (original)
+++ lldb/trunk/include/lldb/Core/PluginManager.h Wed Apr 13 17:47:15 2011
@@ -192,6 +192,9 @@
     static const char *
     GetPlatformPluginDescriptionAtIndex (uint32_t idx);
 
+    static uint32_t
+    AutoCompletePlatformName (const char *partial_name, 
+                              StringList &matches);
     //------------------------------------------------------------------
     // Process
     //------------------------------------------------------------------

Modified: lldb/trunk/include/lldb/Interpreter/CommandCompletions.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandCompletions.h?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandCompletions.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandCompletions.h Wed Apr 13 17:47:15 2011
@@ -38,16 +38,19 @@
                                        lldb_private::StringList &matches);  // The array of matches we return.
     typedef enum
     {
-        eNoCompletion            = 0,
-        eSourceFileCompletion    = (1 << 0),
-        eDiskFileCompletion      = (1 << 1),
-        eDiskDirectoryCompletion = (1 << 2),
-        eSymbolCompletion        = (1 << 3),
-        eModuleCompletion        = (1 << 4),
-        eSettingsNameCompletion  = (1 << 5),
-        eCustomCompletion        = (1 << 6)  // This item serves two purposes.  It is the last element in the enum,
-                                            // so you can add custom enums starting from here in your Option class.
-                                            // Also if you & in this bit the base code will not process the option.
+        eNoCompletion             = 0u,
+        eSourceFileCompletion     = (1u << 0),
+        eDiskFileCompletion       = (1u << 1),
+        eDiskDirectoryCompletion  = (1u << 2),
+        eSymbolCompletion         = (1u << 3),
+        eModuleCompletion         = (1u << 4),
+        eSettingsNameCompletion   = (1u << 5),
+        ePlatformPluginCompletion = (1u << 6),
+        eArchitectureCompletion   = (1u << 7),
+        // This item serves two purposes.  It is the last element in the enum,
+        // so you can add custom enums starting from here in your Option class.
+        // Also if you & in this bit the base code will not process the option.
+        eCustomCompletion         = (1u << 8)  
 
     } CommonCompletionTypes;
 
@@ -121,6 +124,25 @@
                    SearchFilter *searcher,
                    bool &word_complete,
                    lldb_private::StringList &matches);
+
+    static int
+    PlatformPluginNames (CommandInterpreter &interpreter,
+                         const char *partial_file_name,
+                         int match_start_point,
+                         int max_return_elements,
+                         SearchFilter *searcher,
+                         bool &word_complete,
+                         lldb_private::StringList &matches);
+
+    
+    static int
+    ArchitectureNames (CommandInterpreter &interpreter,
+                       const char *partial_file_name,
+                       int match_start_point,
+                       int max_return_elements,
+                       SearchFilter *searcher,
+                       bool &word_complete,
+                       lldb_private::StringList &matches);
     
     //----------------------------------------------------------------------
     // The Completer class is a convenient base class for building searchers

Modified: lldb/trunk/include/lldb/Interpreter/Options.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Options.h?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/Options.h (original)
+++ lldb/trunk/include/lldb/Interpreter/Options.h Wed Apr 13 17:47:15 2011
@@ -382,7 +382,7 @@
         OptionGroupOptions (CommandInterpreter &interpreter) :
             Options (interpreter),
             m_option_defs (),
-            m_option_groups (),
+            m_option_infos (),
             m_did_finalize (false)
         {
         }
@@ -392,11 +392,32 @@
         {
         }
         
+        //----------------------------------------------------------------------
+        /// Append options from a OptionGroup class.
+        ///
+        /// Append options from \a group that have a usage mask that has any bits
+        /// in "src_mask" set. After the option definition is copied into the
+        /// options definitions in this class, set the usage_mask to "dst_mask".
+        ///
+        /// @param[in] group
+        ///     A group of options to take option values from and copy their 
+        ///     definitions into this class.
+        ///
+        /// @param[in] src_mask
+        ///     When copying options from \a group, you might only want some of
+        ///     the options to be appended to this group. This mask allows you
+        ///     to control which options from \a group get added. It also allows
+        ///     you to specify the same options from \a group multiple times
+        ///     for different option sets.
+        ///
+        /// @param[in] dst_mask
+        ///     Set the usage mask for any copied options to \a dst_mask after
+        ///     copying the option definition.
+        //----------------------------------------------------------------------        
         void
-        Append (OptionGroup* group);
-
-        void
-        Append (OptionGroup* group, uint32_t usage_mask);        
+        Append (OptionGroup* group, 
+                uint32_t src_mask, 
+                uint32_t dst_mask);        
 
         void
         Finalize ();
@@ -417,10 +438,20 @@
             assert (m_did_finalize);
             return &m_option_defs[0];
         }
-        typedef std::vector<OptionGroup*> OptionGroupsType;
+        struct OptionInfo
+        {
+            OptionInfo (OptionGroup* g, uint32_t i) :
+                option_group (g),
+                option_index (i)
+            {
+            }
+            OptionGroup* option_group;  // The group that this option came from
+            uint32_t option_index;      // The original option index from the OptionGroup
+        };
+        typedef std::vector<OptionInfo> OptionInfos;
         
         std::vector<OptionDefinition> m_option_defs;
-        OptionGroupsType m_option_groups;
+        OptionInfos m_option_infos;
         bool m_did_finalize;
     };
     

Modified: lldb/trunk/include/lldb/Target/Platform.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Platform.h?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Platform.h (original)
+++ lldb/trunk/include/lldb/Target/Platform.h Wed Apr 13 17:47:15 2011
@@ -57,6 +57,9 @@
         static lldb::PlatformSP
         GetDefaultPlatform ();
 
+        static const char *
+        GetHostPlatformName ();
+
         static void
         SetDefaultPlatform (const lldb::PlatformSP &platform_sp);
 

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Wed Apr 13 17:47:15 2011
@@ -387,6 +387,7 @@
         eArgTypeValue,
         eArgTypeWidth,
         eArgTypeNone,
+        eArgTypePlatform,
         eArgTypeLastArg  // Always keep this entry as the last entry in this enumeration!!
     } CommandArgumentType;
 

Modified: lldb/trunk/include/lldb/lldb-private-types.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-types.h?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-private-types.h (original)
+++ lldb/trunk/include/lldb/lldb-private-types.h Wed Apr 13 17:47:15 2011
@@ -59,7 +59,7 @@
         char short_option;                       // Single character for this option.
         int option_has_arg;                      // no_argument, required_argument or optional_argument
         OptionEnumValueElement *enum_values;     // If non-NULL an array of enum values.
-        uint32_t completionType;                 // Cookie the option class can use to do define the argument completion.
+        uint32_t completion_type;                // Cookie the option class can use to do define the argument completion.
         lldb::CommandArgumentType argument_type; // Type of argument this option takes
         const char *  usage_text;                // Full text explaining what this options does and what (if any) argument to
                                                  // pass it.

Modified: lldb/trunk/source/Commands/CommandCompletions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandCompletions.cpp (original)
+++ lldb/trunk/source/Commands/CommandCompletions.cpp Wed Apr 13 17:47:15 2011
@@ -20,6 +20,7 @@
 // Project includes
 #include "lldb/Host/FileSpec.h"
 #include "lldb/Core/FileSpecList.h"
+#include "lldb/Core/PluginManager.h"
 #include "lldb/Interpreter/Args.h"
 #include "lldb/Interpreter/CommandCompletions.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
@@ -38,6 +39,8 @@
     {eSymbolCompletion,          CommandCompletions::Symbols},
     {eModuleCompletion,          CommandCompletions::Modules},
     {eSettingsNameCompletion,    CommandCompletions::SettingsNames},
+    {ePlatformPluginCompletion,  CommandCompletions::PlatformPluginNames},
+    {eArchitectureCompletion,    CommandCompletions::ArchitectureNames},
     {eNoCompletion,              NULL}      // This one has to be last in the list.
 };
 
@@ -413,6 +416,36 @@
     //return matches.GetSize();
 }
 
+
+int
+CommandCompletions::PlatformPluginNames (CommandInterpreter &interpreter,
+                                         const char *partial_name,
+                                         int match_start_point,
+                                         int max_return_elements,
+                                         SearchFilter *searcher,
+                                         bool &word_complete,
+                                         lldb_private::StringList &matches)
+{
+    const uint32_t num_matches = PluginManager::AutoCompletePlatformName(partial_name, matches);
+    word_complete = num_matches == 1;
+    return num_matches;
+}
+
+int
+CommandCompletions::ArchitectureNames (CommandInterpreter &interpreter,
+                                       const char *partial_name,
+                                       int match_start_point,
+                                       int max_return_elements,
+                                       SearchFilter *searcher,
+                                       bool &word_complete,
+                                       lldb_private::StringList &matches)
+{
+    const uint32_t num_matches = ArchSpec::AutoComplete (partial_name, matches);
+    word_complete = num_matches == 1;
+    return num_matches;
+}
+
+
 CommandCompletions::Completer::Completer 
 (
     CommandInterpreter &interpreter,

Modified: lldb/trunk/source/Commands/CommandObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFile.cpp?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFile.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFile.cpp Wed Apr 13 17:47:15 2011
@@ -26,7 +26,6 @@
 using namespace lldb_private;
 
 FileOptionGroup::FileOptionGroup() :
-    m_arch (),
     m_arch_str ()
 {
 }
@@ -53,6 +52,17 @@
     return g_file_option_table;
 }
 
+bool
+FileOptionGroup::GetArchitecture (Platform *platform, ArchSpec &arch)
+{
+    if (m_arch_str.empty())
+        arch.Clear();
+    else
+        arch.SetTriple(m_arch_str.c_str(), platform);
+    return arch.IsValid();
+}
+
+
 Error
 FileOptionGroup::SetOptionValue (CommandInterpreter &interpreter,
                                  uint32_t option_idx,
@@ -64,17 +74,7 @@
     switch (short_option)
     {
         case 'a':
-            {
-                // Save the arch value in case we specify a platform after specifying the arch
-                m_arch_str.assign (option_arg);
-                // Check to see if we already have a platform?
-                m_arch_platform_sp = interpreter.GetPlatform (false);
-                ArchSpec option_arch (option_arg, m_arch_platform_sp.get());
-                if (option_arch.IsValid())
-                    m_arch = option_arch;
-                else
-                    error.SetErrorStringWithFormat ("Invalid arch string '%s'.\n", option_arg);
-            }
+            m_arch_str.assign (option_arg);
             break;
 
         default:
@@ -88,26 +88,7 @@
 void
 FileOptionGroup::OptionParsingStarting (CommandInterpreter &interpreter)
 {
-    m_arch.Clear();
-}
-
-Error
-FileOptionGroup::OptionParsingFinished (CommandInterpreter &interpreter)
-{
-    Error error;
-    if (m_arch.IsValid())
-    {
-        PlatformSP curr_platform_sp (interpreter.GetPlatform (false));
-        if (curr_platform_sp.get() != m_arch_platform_sp.get())
-        {
-            ArchSpec option_arch (m_arch_str.c_str(), curr_platform_sp.get());
-            if (option_arch.IsValid())
-                m_arch = option_arch;
-            else
-                error.SetErrorStringWithFormat ("invalid arch '%s' for platform '%s'", m_arch_str.c_str(), curr_platform_sp->GetName());
-        }
-    }
-    return error;
+    m_arch_str.clear();
 }
 
 //-------------------------------------------------------------------------
@@ -136,8 +117,8 @@
     // Push the data for the first argument into the m_arguments vector.
     m_arguments.push_back (arg);
     
-    m_option_group.Append (&m_file_options);
-    m_option_group.Append (&m_platform_options);
+    m_option_group.Append (&m_file_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
+    m_option_group.Append (&m_platform_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
     m_option_group.Finalize();
 }
 
@@ -164,18 +145,46 @@
     if (argc == 1)
     {
         FileSpec file_spec (file_path, true);
+        
+        bool select = true;
+        PlatformSP platform_sp;
+        
+        Error error;
+        
+        if (!m_platform_options.platform_name.empty())
+        {
+            platform_sp = m_platform_options.CreatePlatformWithOptions(m_interpreter, select, error);
+            if (!platform_sp)
+            {
+                result.AppendError(error.AsCString());
+                result.SetStatus (eReturnStatusFailed);
+                return false;
+            }
+        }
+        ArchSpec file_arch;
+        
+        if (!m_file_options.m_arch_str.empty())
+        {        
+            if (!platform_sp)
+                platform_sp = m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform();
+            if (!m_file_options.GetArchitecture(platform_sp.get(), file_arch))
+            {
+                result.AppendErrorWithFormat("invalid architecture '%s'", m_file_options.m_arch_str.c_str());
+                result.SetStatus (eReturnStatusFailed);
+                return false;
+            }
+        }
 
         if (! file_spec.Exists() && !file_spec.ResolveExecutableLocation())
         {
             result.AppendErrorWithFormat ("File '%s' does not exist.\n", file_path);
             result.SetStatus (eReturnStatusFailed);
-            return result.Succeeded();
+            return false;
         }
 
         TargetSP target_sp;
-
         Debugger &debugger = m_interpreter.GetDebugger();
-        Error error = debugger.GetTargetList().CreateTarget (debugger, file_spec, m_file_options.m_arch, true, target_sp);
+        error = debugger.GetTargetList().CreateTarget (debugger, file_spec, file_arch, true, target_sp);
 
         if (target_sp)
         {

Modified: lldb/trunk/source/Commands/CommandObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFile.h?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFile.h (original)
+++ lldb/trunk/source/Commands/CommandObjectFile.h Wed Apr 13 17:47:15 2011
@@ -26,37 +26,35 @@
 // CommandObjectFile
 //-------------------------------------------------------------------------
 
-    class FileOptionGroup : public OptionGroup
-    {
-    public:
-        
-        FileOptionGroup ();
-        
-        virtual
-        ~FileOptionGroup ();
-
-        
-        virtual uint32_t
-        GetNumDefinitions ();
-        
-        virtual const OptionDefinition*
-        GetDefinitions ();
-        
-        virtual Error
-        SetOptionValue (CommandInterpreter &interpreter,
-                        uint32_t option_idx,
-                        const char *option_value);
-        
-        virtual void
-        OptionParsingStarting (CommandInterpreter &interpreter);
-        
-        virtual Error
-        OptionParsingFinished (CommandInterpreter &interpreter);
-        
-        ArchSpec m_arch;
-        lldb::PlatformSP m_arch_platform_sp; // The platform that was used to resolve m_arch
-        std::string m_arch_str; // Save the arch triple in case a platform is specified after the architecture
-    };
+class FileOptionGroup : public OptionGroup
+{
+public:
+    
+    FileOptionGroup ();
+    
+    virtual
+    ~FileOptionGroup ();
+
+    
+    virtual uint32_t
+    GetNumDefinitions ();
+    
+    virtual const OptionDefinition*
+    GetDefinitions ();
+    
+    virtual Error
+    SetOptionValue (CommandInterpreter &interpreter,
+                    uint32_t option_idx,
+                    const char *option_value);
+    
+    virtual void
+    OptionParsingStarting (CommandInterpreter &interpreter);
+    
+    bool
+    GetArchitecture (Platform *platform, ArchSpec &arch);
+
+    std::string m_arch_str; // Save the arch triple in case a platform is specified after the architecture
+};
 
 class CommandObjectFile : public CommandObject
 {

Modified: lldb/trunk/source/Commands/CommandObjectLog.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectLog.cpp?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectLog.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectLog.cpp Wed Apr 13 17:47:15 2011
@@ -42,16 +42,6 @@
 using namespace lldb_private;
 
 
-static LogChannelSP
-GetLogChannelPluginForChannel (const char *channel)
-{
-    std::string log_channel_plugin_name(channel);
-    log_channel_plugin_name += LogChannel::GetPluginSuffix();
-    LogChannelSP log_channel_sp (LogChannel::FindPlugin (log_channel_plugin_name.c_str()));
-    return log_channel_sp;
-}
-
-
 class CommandObjectLogEnable : public CommandObject
 {
 public:
@@ -99,6 +89,27 @@
         return &m_options;
     }
 
+//    int
+//    HandleArgumentCompletion (Args &input,
+//                              int &cursor_index,
+//                              int &cursor_char_position,
+//                              OptionElementVector &opt_element_vector,
+//                              int match_start_point,
+//                              int max_return_elements,
+//                              bool &word_complete,
+//                              StringList &matches)
+//    {
+//        std::string completion_str (input.GetArgumentAtIndex(cursor_index));
+//        completion_str.erase (cursor_char_position);
+//        
+//        if (cursor_index == 1)
+//        {
+//            //
+//            Log::AutoCompleteChannelName (completion_str.c_str(), matches);
+//        }
+//        return matches.GetSize();
+//    }
+//
     virtual bool
     Execute (Args& args,
              CommandReturnObject &result)
@@ -141,7 +152,7 @@
             }
             else
             {
-                LogChannelSP log_channel_sp (GetLogChannelPluginForChannel(channel.c_str()));
+                LogChannelSP log_channel_sp (LogChannel::FindPlugin (channel.c_str()));
                 if (log_channel_sp)
                 {
                     if (log_channel_sp->Enable (log_stream_sp, log_options, &result.GetErrorStream(), args))
@@ -314,7 +325,7 @@
             }
             else
             {
-                LogChannelSP log_channel_sp (GetLogChannelPluginForChannel(channel.c_str()));
+                LogChannelSP log_channel_sp (LogChannel::FindPlugin(channel.c_str()));
                 if (log_channel_sp)
                 {
                     log_channel_sp->Disable(args, &result.GetErrorStream());
@@ -388,7 +399,7 @@
                 }
                 else
                 {
-                    LogChannelSP log_channel_sp (GetLogChannelPluginForChannel(channel.c_str()));
+                    LogChannelSP log_channel_sp (LogChannel::FindPlugin(channel.c_str()));
                     if (log_channel_sp)
                     {
                         log_channel_sp->ListCategories(&result.GetOutputStream());

Modified: lldb/trunk/source/Commands/CommandObjectPlatform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.cpp?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectPlatform.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectPlatform.cpp Wed Apr 13 17:47:15 2011
@@ -29,44 +29,31 @@
 
 
 PlatformSP 
-PlatformOptionGroup::CreatePlatformWithOptions (CommandInterpreter &interpreter,
-                                                const char *platform_name, 
-                                                bool select, 
-                                                Error& error)
+PlatformOptionGroup::CreatePlatformWithOptions (CommandInterpreter &interpreter, bool select, Error& error)
 {
-    if (platform_name && platform_name[0])
+    PlatformSP platform_sp;
+    if (!platform_name.empty())
     {
-        if (platform_sp)
-        {
-            error.SetErrorString ("platform can't be set more than once in a command");
-            return PlatformSP();
-        }
-
-        platform_sp = Platform::Create (platform_name, error);
+        platform_sp = Platform::Create (platform_name.c_str(), error);
 
         if (platform_sp)
         {
-                interpreter.GetDebugger().GetPlatformList().Append (platform_sp, select);
-                if (os_version_major != UINT32_MAX)
-                {
-                    platform_sp->SetOSVersion (os_version_major,
-                                               os_version_minor,
-                                               os_version_update);
-                }
+            interpreter.GetDebugger().GetPlatformList().Append (platform_sp, select);
+            if (os_version_major != UINT32_MAX)
+            {
+                platform_sp->SetOSVersion (os_version_major,
+                                           os_version_minor,
+                                           os_version_update);
+            }
         }
     }
-    else
-    {
-        error.SetErrorString ("invalid platform name");
-        platform_sp.reset();
-    }
     return platform_sp;
 }
 
 void
 PlatformOptionGroup::OptionParsingStarting (CommandInterpreter &interpreter)
 {
-    platform_sp.reset();
+    platform_name.clear();
     os_version_major = UINT32_MAX;
     os_version_minor = UINT32_MAX;
     os_version_update = UINT32_MAX;
@@ -75,7 +62,7 @@
 static OptionDefinition
 g_option_table[] =
 {
-    { LLDB_OPT_SET_ALL, false, "platform"   , 'p', required_argument, NULL, 0, eArgTypeNone, "Specify name of the platform to use for this target, creating the platform if necessary."},
+    { LLDB_OPT_SET_ALL, false, "platform"   , 'p', required_argument, NULL, 0, eArgTypePlatform, "Specify name of the platform to use for this target, creating the platform if necessary."},
     { LLDB_OPT_SET_ALL, false, "sdk-version", 'v', required_argument, NULL, 0, eArgTypeNone, "Specify the initial SDK version to use prior to connecting." }
 };
 
@@ -112,19 +99,12 @@
     switch (short_option)
     {
     case 'p':
-        CreatePlatformWithOptions (interpreter, option_arg, true, error);
+        platform_name.assign (option_arg);
         break;
 
     case 'v':
         if (Args::StringToVersion (option_arg, os_version_major, os_version_minor, os_version_update) == option_arg)
-        {
             error.SetErrorStringWithFormat ("invalid version string '%s'", option_arg);
-        }
-        else
-        {
-            if (platform_sp)
-                platform_sp->SetOSVersion (os_version_major, os_version_minor, os_version_update);
-        }
         break;
         
     default:
@@ -149,7 +129,7 @@
         m_option_group (interpreter),
         m_platform_options (false) // Don't include the "--platform" option by passing false
     {
-        m_option_group.Append (&m_platform_options);
+        m_option_group.Append (&m_platform_options, LLDB_OPT_SET_ALL, 1);
         m_option_group.Finalize();
     }
 
@@ -161,16 +141,31 @@
     virtual bool
     Execute (Args& args, CommandReturnObject &result)
     {
-        Error error;
         if (args.GetArgumentCount() == 1)
         {
-            const bool select = true;
-            PlatformSP platform_sp (m_platform_options.CreatePlatformWithOptions (m_interpreter,
-                                                                                  args.GetArgumentAtIndex (0), 
-                                                                                  select, 
-                                                                                  error));
-            if (platform_sp)
-                platform_sp->GetStatus (result.GetOutputStream());
+            const char *platform_name = args.GetArgumentAtIndex (0);
+            if (platform_name && platform_name[0])
+            {
+                const bool select = true;
+                m_platform_options.platform_name.assign (platform_name);
+                Error error;
+                PlatformSP platform_sp (m_platform_options.CreatePlatformWithOptions (m_interpreter, select, error));
+                if (platform_sp)
+                {
+                    platform_sp->GetStatus (result.GetOutputStream());
+                    result.SetStatus (eReturnStatusSuccessFinishResult);
+                }
+                else
+                {
+                    result.AppendError(error.AsCString());
+                    result.SetStatus (eReturnStatusFailed);
+                }
+            }
+            else
+            {
+                result.AppendError ("invalid platform name");
+                result.SetStatus (eReturnStatusFailed);
+            }
         }
         else
         {

Modified: lldb/trunk/source/Commands/CommandObjectPlatform.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.h?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectPlatform.h (original)
+++ lldb/trunk/source/Commands/CommandObjectPlatform.h Wed Apr 13 17:47:15 2011
@@ -49,11 +49,11 @@
 public:
     
     PlatformOptionGroup (bool include_platform_option) :
-        m_include_platform_option (include_platform_option),
-        platform_sp (),
+        platform_name (),
         os_version_major (UINT32_MAX),
         os_version_minor (UINT32_MAX),
-        os_version_update (UINT32_MAX)
+        os_version_update (UINT32_MAX),
+        m_include_platform_option (include_platform_option)
     {
     }
     
@@ -74,17 +74,16 @@
                     const char *option_value);
     
     lldb::PlatformSP 
-    CreatePlatformWithOptions (CommandInterpreter &interpreter,
-                               const char *platform_name, 
-                               bool select, 
-                               Error& error);
+    CreatePlatformWithOptions (CommandInterpreter &interpreter, 
+                               bool select,
+                               Error &error);
 
     virtual void
     OptionParsingStarting (CommandInterpreter &interpreter);
         
     // Instance variables to hold the values for command options.
     
-    lldb::PlatformSP platform_sp;
+    std::string platform_name;
     uint32_t os_version_major;
     uint32_t os_version_minor;
     uint32_t os_version_update;

Modified: lldb/trunk/source/Core/ArchSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/source/Core/ArchSpec.cpp (original)
+++ lldb/trunk/source/Core/ArchSpec.cpp Wed Apr 13 17:47:15 2011
@@ -79,11 +79,11 @@
     { eByteOrderLittle, 4, 4, 4, llvm::Triple::sparc  , ArchSpec::eCore_sparc_generic   , "sparc"     },
     { eByteOrderLittle, 8, 4, 4, llvm::Triple::sparcv9, ArchSpec::eCore_sparc9_generic  , "sparcv9"   },
 
-    { eByteOrderLittle, 4, 1, 15, llvm::Triple::x86    , ArchSpec::eCore_x86_32_i386     , "i386"      },
-    { eByteOrderLittle, 4, 1, 15, llvm::Triple::x86    , ArchSpec::eCore_x86_32_i486     , "i486"      },
-    { eByteOrderLittle, 4, 1, 15, llvm::Triple::x86    , ArchSpec::eCore_x86_32_i486sx   , "i486sx"    },
+    { eByteOrderLittle, 4, 1, 15, llvm::Triple::x86    , ArchSpec::eCore_x86_32_i386    , "i386"      },
+    { eByteOrderLittle, 4, 1, 15, llvm::Triple::x86    , ArchSpec::eCore_x86_32_i486    , "i486"      },
+    { eByteOrderLittle, 4, 1, 15, llvm::Triple::x86    , ArchSpec::eCore_x86_32_i486sx  , "i486sx"    },
 
-    { eByteOrderLittle, 8, 1, 15, llvm::Triple::x86_64 , ArchSpec::eCore_x86_64_x86_64   , "x86_64"    }
+    { eByteOrderLittle, 8, 1, 15, llvm::Triple::x86_64 , ArchSpec::eCore_x86_64_x86_64  , "x86_64"    }
 };
 
 struct ArchDefinitionEntry
@@ -104,6 +104,28 @@
 };
 
 
+uint32_t
+ArchSpec::AutoComplete (const char *name, StringList &matches)
+{
+    uint32_t i;
+    if (name && name[0])
+    {
+        for (i = 0; i < ArchSpec::kNumCores; ++i)
+        {
+            if (NameMatches(g_core_definitions[i].name, eNameMatchStartsWith, name))
+                matches.AppendString (g_core_definitions[i].name);
+        }
+    }
+    else
+    {
+        for (i = 0; i < ArchSpec::kNumCores; ++i)
+            matches.AppendString (g_core_definitions[i].name);
+    }
+    return matches.GetSize();
+}
+
+
+
 #define CPU_ANY (UINT32_MAX)
 
 //===----------------------------------------------------------------------===//

Modified: lldb/trunk/source/Core/Log.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Log.cpp?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/source/Core/Log.cpp (original)
+++ lldb/trunk/source/Core/Log.cpp Wed Apr 13 17:47:15 2011
@@ -382,6 +382,27 @@
 }
 
 void
+Log::AutoCompleteChannelName (const char *channel_name, StringList &matches)
+{
+    LogChannelMap &map = GetChannelMap ();
+    LogChannelMapIter pos, end = map.end();
+    for (pos = map.begin(); pos != end; ++pos)
+    {
+        const char *pos_channel_name = pos->first.GetCString();
+        if (channel_name && channel_name[0])
+        {
+            if (NameMatches (channel_name, eNameMatchStartsWith, pos_channel_name))
+            {
+                matches.AppendString(pos_channel_name);
+            }
+        }
+        else
+            matches.AppendString(pos_channel_name);
+
+    }
+}
+
+void
 Log::DisableAllLogChannels (Stream *feedback_strm)
 {
     CallbackMap &callback_map = GetCallbackMap ();
@@ -499,10 +520,4 @@
 {
 }
 
-const char *
-LogChannel::GetPluginSuffix ()
-{
-    return ".log-channel";
-}
-
 

Modified: lldb/trunk/source/Core/PluginManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/source/Core/PluginManager.cpp (original)
+++ lldb/trunk/source/Core/PluginManager.cpp Wed Apr 13 17:47:15 2011
@@ -19,6 +19,8 @@
 #include "lldb/Host/Host.h"
 #include "lldb/Host/Mutex.h"
 
+#include "llvm/ADT/StringRef.h"
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -256,7 +258,7 @@
     {
         ABIInstance instance;
         assert (name && name[0]);
-        instance.name = name;
+        instance.name.assign (name);
         if (description && description[0])
             instance.description = description;
         instance.create_callback = create_callback;
@@ -293,7 +295,6 @@
 {
     Mutex::Locker locker (GetABIInstancesMutex ());
     ABIInstances &instances = GetABIInstances ();
-
     if (idx < instances.size())
         return instances[idx].create_callback;
     return NULL;
@@ -305,13 +306,13 @@
     if (name && name[0])
     {
         Mutex::Locker locker (GetABIInstancesMutex ());
-        std::string ss_name(name);
+        llvm::StringRef name_sref(name);
         ABIInstances &instances = GetABIInstances ();
 
         ABIInstances::iterator pos, end = instances.end();
         for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (pos->name == ss_name)
+            if (name_sref.equals (pos->name))
                 return pos->create_callback;
         }
     }
@@ -338,50 +339,19 @@
 
 typedef std::vector<DisassemblerInstance> DisassemblerInstances;
 
-static bool
-AccessDisassemblerInstances (PluginAction action, DisassemblerInstance &instance, uint32_t index)
+static Mutex &
+GetDisassemblerMutex ()
 {
-    static DisassemblerInstances g_plugin_instances;
-
-    switch (action)
-    {
-    case ePluginRegisterInstance:
-        if (instance.create_callback)
-        {
-            g_plugin_instances.push_back (instance);
-            return true;
-        }
-        break;
-
-    case ePluginUnregisterInstance:
-        if (instance.create_callback)
-        {
-            DisassemblerInstances::iterator pos, end = g_plugin_instances.end();
-            for (pos = g_plugin_instances.begin(); pos != end; ++ pos)
-            {
-                if (pos->create_callback == instance.create_callback)
-                {
-                    g_plugin_instances.erase(pos);
-                    return true;
-                }
-            }
-        }
-        break;
-
-    case ePluginGetInstanceAtIndex:
-        if (index < g_plugin_instances.size())
-        {
-            instance = g_plugin_instances[index];
-            return true;
-        }
-        break;
-
-    default:
-        break;
-    }
-    return false;
+    static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
+    return g_instances_mutex;
 }
 
+static DisassemblerInstances &
+GetDisassemblerInstances ()
+{
+    static DisassemblerInstances g_instances;
+    return g_instances;
+}
 
 bool
 PluginManager::RegisterPlugin
@@ -399,7 +369,9 @@
         if (description && description[0])
             instance.description = description;
         instance.create_callback = create_callback;
-        return AccessDisassemblerInstances (ePluginRegisterInstance, instance, 0);
+        Mutex::Locker locker (GetDisassemblerMutex ());
+        GetDisassemblerInstances ().push_back (instance);
+        return true;
     }
     return false;
 }
@@ -409,9 +381,18 @@
 {
     if (create_callback)
     {
-        DisassemblerInstance instance;
-        instance.create_callback = create_callback;
-        return AccessDisassemblerInstances (ePluginUnregisterInstance, instance, 0);
+        Mutex::Locker locker (GetDisassemblerMutex ());
+        DisassemblerInstances &instances = GetDisassemblerInstances ();
+        
+        DisassemblerInstances::iterator pos, end = instances.end();
+        for (pos = instances.begin(); pos != end; ++ pos)
+        {
+            if (pos->create_callback == create_callback)
+            {
+                instances.erase(pos);
+                return true;
+            }
+        }
     }
     return false;
 }
@@ -419,9 +400,10 @@
 DisassemblerCreateInstance
 PluginManager::GetDisassemblerCreateCallbackAtIndex (uint32_t idx)
 {
-    DisassemblerInstance instance;
-    if (AccessDisassemblerInstances (ePluginGetInstanceAtIndex, instance, idx))
-        return instance.create_callback;
+    Mutex::Locker locker (GetDisassemblerMutex ());
+    DisassemblerInstances &instances = GetDisassemblerInstances ();
+    if (idx < instances.size())
+        return instances[idx].create_callback;
     return NULL;
 }
 
@@ -430,12 +412,15 @@
 {
     if (name && name[0])
     {
-        DisassemblerInstance instance;
-        std::string ss_name(name);
-        for (uint32_t idx = 0; AccessDisassemblerInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx)
+        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 (instance.name == ss_name)
-                return instance.create_callback;
+            if (name_sref.equals (pos->name))
+                return pos->create_callback;
         }
     }
     return NULL;
@@ -462,48 +447,19 @@
 
 typedef std::vector<DynamicLoaderInstance> DynamicLoaderInstances;
 
-static bool
-AccessDynamicLoaderInstances (PluginAction action, DynamicLoaderInstance &instance, uint32_t index)
-{
-    static DynamicLoaderInstances g_plugin_instances;
-
-    switch (action)
-    {
-    case ePluginRegisterInstance:
-        if (instance.create_callback)
-        {
-            g_plugin_instances.push_back (instance);
-            return true;
-        }
-        break;
-
-    case ePluginUnregisterInstance:
-        if (instance.create_callback)
-        {
-            DynamicLoaderInstances::iterator pos, end = g_plugin_instances.end();
-            for (pos = g_plugin_instances.begin(); pos != end; ++ pos)
-            {
-                if (pos->create_callback == instance.create_callback)
-                {
-                    g_plugin_instances.erase(pos);
-                    return true;
-                }
-            }
-        }
-        break;
 
-    case ePluginGetInstanceAtIndex:
-        if (index < g_plugin_instances.size())
-        {
-            instance = g_plugin_instances[index];
-            return true;
-        }
-        break;
+static Mutex &
+GetDynamicLoaderMutex ()
+{
+    static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
+    return g_instances_mutex;
+}
 
-    default:
-        break;
-    }
-    return false;
+static DynamicLoaderInstances &
+GetDynamicLoaderInstances ()
+{
+    static DynamicLoaderInstances g_instances;
+    return g_instances;
 }
 
 
@@ -523,7 +479,8 @@
         if (description && description[0])
             instance.description = description;
         instance.create_callback = create_callback;
-        return AccessDynamicLoaderInstances (ePluginRegisterInstance, instance, 0);
+        Mutex::Locker locker (GetDynamicLoaderMutex ());
+        GetDynamicLoaderInstances ().push_back (instance);
     }
     return false;
 }
@@ -533,9 +490,18 @@
 {
     if (create_callback)
     {
-        DynamicLoaderInstance instance;
-        instance.create_callback = create_callback;
-        return AccessDynamicLoaderInstances (ePluginUnregisterInstance, instance, 0);
+        Mutex::Locker locker (GetDynamicLoaderMutex ());
+        DynamicLoaderInstances &instances = GetDynamicLoaderInstances ();
+        
+        DynamicLoaderInstances::iterator pos, end = instances.end();
+        for (pos = instances.begin(); pos != end; ++ pos)
+        {
+            if (pos->create_callback == create_callback)
+            {
+                instances.erase(pos);
+                return true;
+            }
+        }
     }
     return false;
 }
@@ -543,9 +509,10 @@
 DynamicLoaderCreateInstance
 PluginManager::GetDynamicLoaderCreateCallbackAtIndex (uint32_t idx)
 {
-    DynamicLoaderInstance instance;
-    if (AccessDynamicLoaderInstances (ePluginGetInstanceAtIndex, instance, idx))
-        return instance.create_callback;
+    Mutex::Locker locker (GetDynamicLoaderMutex ());
+    DynamicLoaderInstances &instances = GetDynamicLoaderInstances ();
+    if (idx < instances.size())
+        return instances[idx].create_callback;
     return NULL;
 }
 
@@ -554,12 +521,15 @@
 {
     if (name && name[0])
     {
-        DynamicLoaderInstance instance;
-        std::string ss_name(name);
-        for (uint32_t idx = 0; AccessDynamicLoaderInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx)
+        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 (instance.name == ss_name)
-                return instance.create_callback;
+            if (name_sref.equals (pos->name))
+                return pos->create_callback;
         }
     }
     return NULL;
@@ -584,48 +554,18 @@
 
 typedef std::vector<EmulateInstructionInstance> EmulateInstructionInstances;
 
-static bool
-AccessEmulateInstructionInstances (PluginAction action, EmulateInstructionInstance &instance, uint32_t index)
+static Mutex &
+GetEmulateInstructionMutex ()
 {
-    static EmulateInstructionInstances g_plugin_instances;
-    
-    switch (action)
-    {
-        case ePluginRegisterInstance:
-            if (instance.create_callback)
-            {
-                g_plugin_instances.push_back (instance);
-                return true;
-            }
-            break;
-            
-        case ePluginUnregisterInstance:
-            if (instance.create_callback)
-            {
-                EmulateInstructionInstances::iterator pos, end = g_plugin_instances.end();
-                for (pos = g_plugin_instances.begin(); pos != end; ++ pos)
-                {
-                    if (pos->create_callback == instance.create_callback)
-                    {
-                        g_plugin_instances.erase(pos);
-                        return true;
-                    }
-                }
-            }
-            break;
-            
-        case ePluginGetInstanceAtIndex:
-            if (index < g_plugin_instances.size())
-            {
-                instance = g_plugin_instances[index];
-                return true;
-            }
-            break;
-            
-        default:
-            break;
-    }
-    return false;
+    static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
+    return g_instances_mutex;
+}
+
+static EmulateInstructionInstances &
+GetEmulateInstructionInstances ()
+{
+    static EmulateInstructionInstances g_instances;
+    return g_instances;
 }
 
 
@@ -645,7 +585,8 @@
         if (description && description[0])
             instance.description = description;
         instance.create_callback = create_callback;
-        return AccessEmulateInstructionInstances (ePluginRegisterInstance, instance, 0);
+        Mutex::Locker locker (GetEmulateInstructionMutex ());
+        GetEmulateInstructionInstances ().push_back (instance);
     }
     return false;
 }
@@ -655,9 +596,18 @@
 {
     if (create_callback)
     {
-        EmulateInstructionInstance instance;
-        instance.create_callback = create_callback;
-        return AccessEmulateInstructionInstances (ePluginUnregisterInstance, instance, 0);
+        Mutex::Locker locker (GetEmulateInstructionMutex ());
+        EmulateInstructionInstances &instances = GetEmulateInstructionInstances ();
+        
+        EmulateInstructionInstances::iterator pos, end = instances.end();
+        for (pos = instances.begin(); pos != end; ++ pos)
+        {
+            if (pos->create_callback == create_callback)
+            {
+                instances.erase(pos);
+                return true;
+            }
+        }
     }
     return false;
 }
@@ -665,9 +615,10 @@
 EmulateInstructionCreateInstance
 PluginManager::GetEmulateInstructionCreateCallbackAtIndex (uint32_t idx)
 {
-    EmulateInstructionInstance instance;
-    if (AccessEmulateInstructionInstances (ePluginGetInstanceAtIndex, instance, idx))
-        return instance.create_callback;
+    Mutex::Locker locker (GetEmulateInstructionMutex ());
+    EmulateInstructionInstances &instances = GetEmulateInstructionInstances ();
+    if (idx < instances.size())
+        return instances[idx].create_callback;
     return NULL;
 }
 
@@ -676,12 +627,15 @@
 {
     if (name && name[0])
     {
-        EmulateInstructionInstance instance;
-        std::string ss_name(name);
-        for (uint32_t idx = 0; AccessEmulateInstructionInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx)
+        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 (instance.name == ss_name)
-                return instance.create_callback;
+            if (name_sref.equals (pos->name))
+                return pos->create_callback;
         }
     }
     return NULL;
@@ -707,50 +661,19 @@
 
 typedef std::vector<LanguageRuntimeInstance> LanguageRuntimeInstances;
 
-static bool
-AccessLanguageRuntimeInstances (PluginAction action, LanguageRuntimeInstance &instance, uint32_t index)
+static Mutex &
+GetLanguageRuntimeMutex ()
 {
-    static LanguageRuntimeInstances g_plugin_instances;
-
-    switch (action)
-    {
-        case ePluginRegisterInstance:
-            if (instance.create_callback)
-            {
-                g_plugin_instances.push_back (instance);
-                return true;
-            }
-            break;
-
-        case ePluginUnregisterInstance:
-            if (instance.create_callback)
-            {
-                LanguageRuntimeInstances::iterator pos, end = g_plugin_instances.end();
-                for (pos = g_plugin_instances.begin(); pos != end; ++ pos)
-                {
-                    if (pos->create_callback == instance.create_callback)
-                    {
-                        g_plugin_instances.erase(pos);
-                        return true;
-                    }
-                }
-            }
-            break;
-
-        case ePluginGetInstanceAtIndex:
-            if (index < g_plugin_instances.size())
-            {
-                instance = g_plugin_instances[index];
-                return true;
-            }
-            break;
-
-        default:
-            break;
-    }
-    return false;
+    static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
+    return g_instances_mutex;
 }
 
+static LanguageRuntimeInstances &
+GetLanguageRuntimeInstances ()
+{
+    static LanguageRuntimeInstances g_instances;
+    return g_instances;
+}
 
 bool
 PluginManager::RegisterPlugin
@@ -768,7 +691,8 @@
         if (description && description[0])
             instance.description = description;
         instance.create_callback = create_callback;
-        return AccessLanguageRuntimeInstances (ePluginRegisterInstance, instance, 0);
+        Mutex::Locker locker (GetLanguageRuntimeMutex ());
+        GetLanguageRuntimeInstances ().push_back (instance);
     }
     return false;
 }
@@ -778,9 +702,18 @@
 {
     if (create_callback)
     {
-        LanguageRuntimeInstance instance;
-        instance.create_callback = create_callback;
-        return AccessLanguageRuntimeInstances (ePluginUnregisterInstance, instance, 0);
+        Mutex::Locker locker (GetLanguageRuntimeMutex ());
+        LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances ();
+        
+        LanguageRuntimeInstances::iterator pos, end = instances.end();
+        for (pos = instances.begin(); pos != end; ++ pos)
+        {
+            if (pos->create_callback == create_callback)
+            {
+                instances.erase(pos);
+                return true;
+            }
+        }
     }
     return false;
 }
@@ -788,9 +721,10 @@
 LanguageRuntimeCreateInstance
 PluginManager::GetLanguageRuntimeCreateCallbackAtIndex (uint32_t idx)
 {
-    LanguageRuntimeInstance instance;
-    if (AccessLanguageRuntimeInstances (ePluginGetInstanceAtIndex, instance, idx))
-        return instance.create_callback;
+    Mutex::Locker locker (GetLanguageRuntimeMutex ());
+    LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances ();
+    if (idx < instances.size())
+        return instances[idx].create_callback;
     return NULL;
 }
 
@@ -799,12 +733,15 @@
 {
     if (name && name[0])
     {
-        LanguageRuntimeInstance instance;
-        std::string ss_name(name);
-        for (uint32_t idx = 0; AccessLanguageRuntimeInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx)
+        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 (instance.name == ss_name)
-                return instance.create_callback;
+            if (name_sref.equals (pos->name))
+                return pos->create_callback;
         }
     }
     return NULL;
@@ -828,48 +765,18 @@
 
 typedef std::vector<ObjectFileInstance> ObjectFileInstances;
 
-static bool
-AccessObjectFileInstances (PluginAction action, ObjectFileInstance &instance, uint32_t index)
+static Mutex &
+GetObjectFileMutex ()
 {
-    static ObjectFileInstances g_plugin_instances;
-
-    switch (action)
-    {
-    case ePluginRegisterInstance:
-        if (instance.create_callback)
-        {
-            g_plugin_instances.push_back (instance);
-            return true;
-        }
-        break;
-
-    case ePluginUnregisterInstance:
-        if (instance.create_callback)
-        {
-            ObjectFileInstances::iterator pos, end = g_plugin_instances.end();
-            for (pos = g_plugin_instances.begin(); pos != end; ++ pos)
-            {
-                if (pos->create_callback == instance.create_callback)
-                {
-                    g_plugin_instances.erase(pos);
-                    return true;
-                }
-            }
-        }
-        break;
-
-    case ePluginGetInstanceAtIndex:
-        if (index < g_plugin_instances.size())
-        {
-            instance = g_plugin_instances[index];
-            return true;
-        }
-        break;
+    static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
+    return g_instances_mutex;
+}
 
-    default:
-        break;
-    }
-    return false;
+static ObjectFileInstances &
+GetObjectFileInstances ()
+{
+    static ObjectFileInstances g_instances;
+    return g_instances;
 }
 
 
@@ -889,7 +796,8 @@
         if (description && description[0])
             instance.description = description;
         instance.create_callback = create_callback;
-        return AccessObjectFileInstances (ePluginRegisterInstance, instance, 0);
+        Mutex::Locker locker (GetObjectFileMutex ());
+        GetObjectFileInstances ().push_back (instance);
     }
     return false;
 }
@@ -899,9 +807,18 @@
 {
     if (create_callback)
     {
-        ObjectFileInstance instance;
-        instance.create_callback = create_callback;
-        return AccessObjectFileInstances (ePluginUnregisterInstance, instance, 0);
+        Mutex::Locker locker (GetObjectFileMutex ());
+        ObjectFileInstances &instances = GetObjectFileInstances ();
+        
+        ObjectFileInstances::iterator pos, end = instances.end();
+        for (pos = instances.begin(); pos != end; ++ pos)
+        {
+            if (pos->create_callback == create_callback)
+            {
+                instances.erase(pos);
+                return true;
+            }
+        }
     }
     return false;
 }
@@ -909,22 +826,27 @@
 ObjectFileCreateInstance
 PluginManager::GetObjectFileCreateCallbackAtIndex (uint32_t idx)
 {
-    ObjectFileInstance instance;
-    if (AccessObjectFileInstances (ePluginGetInstanceAtIndex, instance, idx))
-        return instance.create_callback;
+    Mutex::Locker locker (GetObjectFileMutex ());
+    ObjectFileInstances &instances = GetObjectFileInstances ();
+    if (idx < instances.size())
+        return instances[idx].create_callback;
     return NULL;
 }
+
 ObjectFileCreateInstance
 PluginManager::GetObjectFileCreateCallbackForPluginName (const char *name)
 {
     if (name && name[0])
     {
-        ObjectFileInstance instance;
-        std::string ss_name(name);
-        for (uint32_t idx = 0; AccessObjectFileInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx)
+        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 (instance.name == ss_name)
-                return instance.create_callback;
+            if (name_sref.equals (pos->name))
+                return pos->create_callback;
         }
     }
     return NULL;
@@ -950,50 +872,19 @@
 
 typedef std::vector<ObjectContainerInstance> ObjectContainerInstances;
 
-static bool
-AccessObjectContainerInstances (PluginAction action, ObjectContainerInstance &instance, uint32_t index)
+static Mutex &
+GetObjectContainerMutex ()
 {
-    static ObjectContainerInstances g_plugin_instances;
-
-    switch (action)
-    {
-    case ePluginRegisterInstance:
-        if (instance.create_callback)
-        {
-            g_plugin_instances.push_back (instance);
-            return true;
-        }
-        break;
-
-    case ePluginUnregisterInstance:
-        if (instance.create_callback)
-        {
-            ObjectContainerInstances::iterator pos, end = g_plugin_instances.end();
-            for (pos = g_plugin_instances.begin(); pos != end; ++ pos)
-            {
-                if (pos->create_callback == instance.create_callback)
-                {
-                    g_plugin_instances.erase(pos);
-                    return true;
-                }
-            }
-        }
-        break;
-
-    case ePluginGetInstanceAtIndex:
-        if (index < g_plugin_instances.size())
-        {
-            instance = g_plugin_instances[index];
-            return true;
-        }
-        break;
-
-    default:
-        break;
-    }
-    return false;
+    static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
+    return g_instances_mutex;
 }
 
+static ObjectContainerInstances &
+GetObjectContainerInstances ()
+{
+    static ObjectContainerInstances g_instances;
+    return g_instances;
+}
 
 bool
 PluginManager::RegisterPlugin
@@ -1011,7 +902,8 @@
         if (description && description[0])
             instance.description = description;
         instance.create_callback = create_callback;
-        return AccessObjectContainerInstances (ePluginRegisterInstance, instance, 0);
+        Mutex::Locker locker (GetObjectContainerMutex ());
+        GetObjectContainerInstances ().push_back (instance);
     }
     return false;
 }
@@ -1021,9 +913,18 @@
 {
     if (create_callback)
     {
-        ObjectContainerInstance instance;
-        instance.create_callback = create_callback;
-        return AccessObjectContainerInstances (ePluginUnregisterInstance, instance, 0);
+        Mutex::Locker locker (GetObjectContainerMutex ());
+        ObjectContainerInstances &instances = GetObjectContainerInstances ();
+        
+        ObjectContainerInstances::iterator pos, end = instances.end();
+        for (pos = instances.begin(); pos != end; ++ pos)
+        {
+            if (pos->create_callback == create_callback)
+            {
+                instances.erase(pos);
+                return true;
+            }
+        }
     }
     return false;
 }
@@ -1031,22 +932,27 @@
 ObjectContainerCreateInstance
 PluginManager::GetObjectContainerCreateCallbackAtIndex (uint32_t idx)
 {
-    ObjectContainerInstance instance;
-    if (AccessObjectContainerInstances (ePluginGetInstanceAtIndex, instance, idx))
-        return instance.create_callback;
+    Mutex::Locker locker (GetObjectContainerMutex ());
+    ObjectContainerInstances &instances = GetObjectContainerInstances ();
+    if (idx < instances.size())
+        return instances[idx].create_callback;
     return NULL;
 }
+
 ObjectContainerCreateInstance
 PluginManager::GetObjectContainerCreateCallbackForPluginName (const char *name)
 {
     if (name && name[0])
     {
-        ObjectContainerInstance instance;
-        std::string ss_name(name);
-        for (uint32_t idx = 0; AccessObjectContainerInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx)
+        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 (instance.name == ss_name)
-                return instance.create_callback;
+            if (name_sref.equals (pos->name))
+                return pos->create_callback;
         }
     }
     return NULL;
@@ -1054,9 +960,9 @@
 
 #pragma mark LogChannel
 
-struct LogChannelInstance
+struct LogInstance
 {
-    LogChannelInstance() :
+    LogInstance() :
         name(),
         description(),
         create_callback(NULL)
@@ -1068,53 +974,24 @@
     LogChannelCreateInstance create_callback;
 };
 
-typedef std::vector<LogChannelInstance> LogChannelInstances;
+typedef std::vector<LogInstance> LogInstances;
 
-static bool
-AccessLogChannelInstances (PluginAction action, LogChannelInstance &instance, uint32_t index)
+static Mutex &
+GetLogMutex ()
 {
-    static LogChannelInstances g_plugin_instances;
+    static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
+    return g_instances_mutex;
+}
 
-    switch (action)
-    {
-    case ePluginRegisterInstance:
-        if (instance.create_callback)
-        {
-            g_plugin_instances.push_back (instance);
-            return true;
-        }
-        break;
-
-    case ePluginUnregisterInstance:
-        if (instance.create_callback)
-        {
-            LogChannelInstances::iterator pos, end = g_plugin_instances.end();
-            for (pos = g_plugin_instances.begin(); pos != end; ++ pos)
-            {
-                if (pos->create_callback == instance.create_callback)
-                {
-                    g_plugin_instances.erase(pos);
-                    return true;
-                }
-            }
-        }
-        break;
-
-    case ePluginGetInstanceAtIndex:
-        if (index < g_plugin_instances.size())
-        {
-            instance = g_plugin_instances[index];
-            return true;
-        }
-        break;
-
-    default:
-        break;
-    }
-    return false;
+static LogInstances &
+GetLogInstances ()
+{
+    static LogInstances g_instances;
+    return g_instances;
 }
 
 
+
 bool
 PluginManager::RegisterPlugin
 (
@@ -1125,13 +1002,14 @@
 {
     if (create_callback)
     {
-        LogChannelInstance instance;
+        LogInstance instance;
         assert (name && name[0]);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
         instance.create_callback = create_callback;
-        return AccessLogChannelInstances (ePluginRegisterInstance, instance, 0);
+        Mutex::Locker locker (GetLogMutex ());
+        GetLogInstances ().push_back (instance);
     }
     return false;
 }
@@ -1141,9 +1019,18 @@
 {
     if (create_callback)
     {
-        LogChannelInstance instance;
-        instance.create_callback = create_callback;
-        return AccessLogChannelInstances (ePluginUnregisterInstance, instance, 0);
+        Mutex::Locker locker (GetLogMutex ());
+        LogInstances &instances = GetLogInstances ();
+        
+        LogInstances::iterator pos, end = instances.end();
+        for (pos = instances.begin(); pos != end; ++ pos)
+        {
+            if (pos->create_callback == create_callback)
+            {
+                instances.erase(pos);
+                return true;
+            }
+        }
     }
     return false;
 }
@@ -1151,9 +1038,10 @@
 const char *
 PluginManager::GetLogChannelCreateNameAtIndex (uint32_t idx)
 {
-    LogChannelInstance instance;
-    if (AccessLogChannelInstances (ePluginGetInstanceAtIndex, instance, idx))
-        return instance.name.c_str();
+    Mutex::Locker locker (GetLogMutex ());
+    LogInstances &instances = GetLogInstances ();
+    if (idx < instances.size())
+        return instances[idx].name.c_str();
     return NULL;
 }
 
@@ -1161,9 +1049,10 @@
 LogChannelCreateInstance
 PluginManager::GetLogChannelCreateCallbackAtIndex (uint32_t idx)
 {
-    LogChannelInstance instance;
-    if (AccessLogChannelInstances (ePluginGetInstanceAtIndex, instance, idx))
-        return instance.create_callback;
+    Mutex::Locker locker (GetLogMutex ());
+    LogInstances &instances = GetLogInstances ();
+    if (idx < instances.size())
+        return instances[idx].create_callback;
     return NULL;
 }
 
@@ -1172,12 +1061,15 @@
 {
     if (name && name[0])
     {
-        LogChannelInstance instance;
-        std::string ss_name(name);
-        for (uint32_t idx = 0; AccessLogChannelInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx)
+        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 (instance.name == ss_name)
-                return instance.create_callback;
+            if (name_sref.equals (pos->name))
+                return pos->create_callback;
         }
     }
     return NULL;
@@ -1215,6 +1107,7 @@
     return g_platform_instances;
 }
 
+
 bool
 PluginManager::RegisterPlugin (const char *name,
                                const char *description,
@@ -1240,9 +1133,9 @@
 PluginManager::GetPlatformPluginNameAtIndex (uint32_t idx)
 {
     Mutex::Locker locker (GetPlatformInstancesMutex ());
-    PlatformInstances &platform_instances = GetPlatformInstances ();
-    if (idx < platform_instances.size())
-        return platform_instances[idx].name.c_str();
+    PlatformInstances &instances = GetPlatformInstances ();
+    if (idx < instances.size())
+        return instances[idx].name.c_str();
     return NULL;
 }
 
@@ -1250,9 +1143,9 @@
 PluginManager::GetPlatformPluginDescriptionAtIndex (uint32_t idx)
 {
     Mutex::Locker locker (GetPlatformInstancesMutex ());
-    PlatformInstances &platform_instances = GetPlatformInstances ();
-    if (idx < platform_instances.size())
-        return platform_instances[idx].description.c_str();
+    PlatformInstances &instances = GetPlatformInstances ();
+    if (idx < instances.size())
+        return instances[idx].description.c_str();
     return NULL;
 }
 
@@ -1262,14 +1155,14 @@
     if (create_callback)
     {
         Mutex::Locker locker (GetPlatformInstancesMutex ());
-        PlatformInstances &platform_instances = GetPlatformInstances ();
+        PlatformInstances &instances = GetPlatformInstances ();
 
-        PlatformInstances::iterator pos, end = platform_instances.end();
-        for (pos = platform_instances.begin(); pos != end; ++ pos)
+        PlatformInstances::iterator pos, end = instances.end();
+        for (pos = instances.begin(); pos != end; ++ pos)
         {
             if (pos->create_callback == create_callback)
             {
-                platform_instances.erase(pos);
+                instances.erase(pos);
                 return true;
             }
         }
@@ -1281,9 +1174,9 @@
 PluginManager::GetPlatformCreateCallbackAtIndex (uint32_t idx)
 {
     Mutex::Locker locker (GetPlatformInstancesMutex ());
-    PlatformInstances &platform_instances = GetPlatformInstances ();
-    if (idx < platform_instances.size())
-        return platform_instances[idx].create_callback;
+    PlatformInstances &instances = GetPlatformInstances ();
+    if (idx < instances.size())
+        return instances[idx].create_callback;
     return NULL;
 }
 
@@ -1293,19 +1186,39 @@
     if (name && name[0])
     {
         Mutex::Locker locker (GetPlatformInstancesMutex ());
-        std::string ss_name(name);
-        PlatformInstances &platform_instances = GetPlatformInstances ();
+        PlatformInstances &instances = GetPlatformInstances ();
+        llvm::StringRef name_sref(name);
 
-        PlatformInstances::iterator pos, end = platform_instances.end();
-        for (pos = platform_instances.begin(); pos != end; ++ pos)
+        PlatformInstances::iterator pos, end = instances.end();
+        for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (pos->name == ss_name)
+            if (name_sref.equals (name))
                 return pos->create_callback;
         }
     }
     return NULL;
 }
 
+uint32_t
+PluginManager::AutoCompletePlatformName (const char *name, StringList &matches)
+{
+    if (name && name[0])
+    {
+        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)
+        {
+            const char *plugin_name = pos->name.c_str();
+            if (name_sref.startswith(plugin_name))
+                matches.AppendString (plugin_name);
+        }
+    }
+    return matches.GetSize();
+}
+
 #pragma mark Process
 
 struct ProcessInstance
@@ -1324,48 +1237,18 @@
 
 typedef std::vector<ProcessInstance> ProcessInstances;
 
-static bool
-AccessProcessInstances (PluginAction action, ProcessInstance &instance, uint32_t index)
+static Mutex &
+GetProcessMutex ()
 {
-    static ProcessInstances g_plugin_instances;
-    
-    switch (action)
-    {
-        case ePluginRegisterInstance:
-            if (instance.create_callback)
-            {
-                g_plugin_instances.push_back (instance);
-                return true;
-            }
-            break;
-            
-        case ePluginUnregisterInstance:
-            if (instance.create_callback)
-            {
-                ProcessInstances::iterator pos, end = g_plugin_instances.end();
-                for (pos = g_plugin_instances.begin(); pos != end; ++ pos)
-                {
-                    if (pos->create_callback == instance.create_callback)
-                    {
-                        g_plugin_instances.erase(pos);
-                        return true;
-                    }
-                }
-            }
-            break;
-            
-        case ePluginGetInstanceAtIndex:
-            if (index < g_plugin_instances.size())
-            {
-                instance = g_plugin_instances[index];
-                return true;
-            }
-            break;
-            
-        default:
-            break;
-    }
-    return false;
+    static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
+    return g_instances_mutex;
+}
+
+static ProcessInstances &
+GetProcessInstances ()
+{
+    static ProcessInstances g_instances;
+    return g_instances;
 }
 
 
@@ -1385,7 +1268,8 @@
         if (description && description[0])
             instance.description = description;
         instance.create_callback = create_callback;
-        return AccessProcessInstances (ePluginRegisterInstance, instance, 0);
+        Mutex::Locker locker (GetProcessMutex ());
+        GetProcessInstances ().push_back (instance);
     }
     return false;
 }
@@ -1393,18 +1277,20 @@
 const char *
 PluginManager::GetProcessPluginNameAtIndex (uint32_t idx)
 {
-    ProcessInstance instance;
-    if (AccessProcessInstances (ePluginGetInstanceAtIndex, instance, idx))
-        return instance.name.c_str();
+    Mutex::Locker locker (GetProcessMutex ());
+    ProcessInstances &instances = GetProcessInstances ();
+    if (idx < instances.size())
+        return instances[idx].name.c_str();
     return NULL;
 }
 
 const char *
 PluginManager::GetProcessPluginDescriptionAtIndex (uint32_t idx)
 {
-    ProcessInstance instance;
-    if (AccessProcessInstances (ePluginGetInstanceAtIndex, instance, idx))
-        return instance.description.c_str();
+    Mutex::Locker locker (GetProcessMutex ());
+    ProcessInstances &instances = GetProcessInstances ();
+    if (idx < instances.size())
+        return instances[idx].description.c_str();
     return NULL;
 }
 
@@ -1413,9 +1299,18 @@
 {
     if (create_callback)
     {
-        ProcessInstance instance;
-        instance.create_callback = create_callback;
-        return AccessProcessInstances (ePluginUnregisterInstance, instance, 0);
+        Mutex::Locker locker (GetProcessMutex ());
+        ProcessInstances &instances = GetProcessInstances ();
+        
+        ProcessInstances::iterator pos, end = instances.end();
+        for (pos = instances.begin(); pos != end; ++ pos)
+        {
+            if (pos->create_callback == create_callback)
+            {
+                instances.erase(pos);
+                return true;
+            }
+        }
     }
     return false;
 }
@@ -1423,23 +1318,28 @@
 ProcessCreateInstance
 PluginManager::GetProcessCreateCallbackAtIndex (uint32_t idx)
 {
-    ProcessInstance instance;
-    if (AccessProcessInstances (ePluginGetInstanceAtIndex, instance, idx))
-        return instance.create_callback;
+    Mutex::Locker locker (GetProcessMutex ());
+    ProcessInstances &instances = GetProcessInstances ();
+    if (idx < instances.size())
+        return instances[idx].create_callback;
     return NULL;
 }
 
+
 ProcessCreateInstance
 PluginManager::GetProcessCreateCallbackForPluginName (const char *name)
 {
     if (name && name[0])
     {
-        ProcessInstance instance;
-        std::string ss_name(name);
-        for (uint32_t idx = 0; AccessProcessInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx)
+        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 (instance.name == ss_name)
-                return instance.create_callback;
+            if (name_sref.equals (pos->name))
+                return pos->create_callback;
         }
     }
     return NULL;
@@ -1463,48 +1363,18 @@
 
 typedef std::vector<SymbolFileInstance> SymbolFileInstances;
 
-static bool
-AccessSymbolFileInstances (PluginAction action, SymbolFileInstance &instance, uint32_t index)
+static Mutex &
+GetSymbolFileMutex ()
 {
-    static SymbolFileInstances g_plugin_instances;
-
-    switch (action)
-    {
-    case ePluginRegisterInstance:
-        if (instance.create_callback)
-        {
-            g_plugin_instances.push_back (instance);
-            return true;
-        }
-        break;
-
-    case ePluginUnregisterInstance:
-        if (instance.create_callback)
-        {
-            SymbolFileInstances::iterator pos, end = g_plugin_instances.end();
-            for (pos = g_plugin_instances.begin(); pos != end; ++ pos)
-            {
-                if (pos->create_callback == instance.create_callback)
-                {
-                    g_plugin_instances.erase(pos);
-                    return true;
-                }
-            }
-        }
-        break;
-
-    case ePluginGetInstanceAtIndex:
-        if (index < g_plugin_instances.size())
-        {
-            instance = g_plugin_instances[index];
-            return true;
-        }
-        break;
+    static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
+    return g_instances_mutex;
+}
 
-    default:
-        break;
-    }
-    return false;
+static SymbolFileInstances &
+GetSymbolFileInstances ()
+{
+    static SymbolFileInstances g_instances;
+    return g_instances;
 }
 
 
@@ -1524,7 +1394,8 @@
         if (description && description[0])
             instance.description = description;
         instance.create_callback = create_callback;
-        return AccessSymbolFileInstances (ePluginRegisterInstance, instance, 0);
+        Mutex::Locker locker (GetSymbolFileMutex ());
+        GetSymbolFileInstances ().push_back (instance);
     }
     return false;
 }
@@ -1534,9 +1405,18 @@
 {
     if (create_callback)
     {
-        SymbolFileInstance instance;
-        instance.create_callback = create_callback;
-        return AccessSymbolFileInstances (ePluginUnregisterInstance, instance, 0);
+        Mutex::Locker locker (GetSymbolFileMutex ());
+        SymbolFileInstances &instances = GetSymbolFileInstances ();
+        
+        SymbolFileInstances::iterator pos, end = instances.end();
+        for (pos = instances.begin(); pos != end; ++ pos)
+        {
+            if (pos->create_callback == create_callback)
+            {
+                instances.erase(pos);
+                return true;
+            }
+        }
     }
     return false;
 }
@@ -1544,22 +1424,27 @@
 SymbolFileCreateInstance
 PluginManager::GetSymbolFileCreateCallbackAtIndex (uint32_t idx)
 {
-    SymbolFileInstance instance;
-    if (AccessSymbolFileInstances (ePluginGetInstanceAtIndex, instance, idx))
-        return instance.create_callback;
+    Mutex::Locker locker (GetSymbolFileMutex ());
+    SymbolFileInstances &instances = GetSymbolFileInstances ();
+    if (idx < instances.size())
+        return instances[idx].create_callback;
     return NULL;
 }
+
 SymbolFileCreateInstance
 PluginManager::GetSymbolFileCreateCallbackForPluginName (const char *name)
 {
     if (name && name[0])
     {
-        SymbolFileInstance instance;
-        std::string ss_name(name);
-        for (uint32_t idx = 0; AccessSymbolFileInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx)
+        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 (instance.name == ss_name)
-                return instance.create_callback;
+            if (name_sref.equals (pos->name))
+                return pos->create_callback;
         }
     }
     return NULL;
@@ -1585,48 +1470,18 @@
 
 typedef std::vector<SymbolVendorInstance> SymbolVendorInstances;
 
-static bool
-AccessSymbolVendorInstances (PluginAction action, SymbolVendorInstance &instance, uint32_t index)
+static Mutex &
+GetSymbolVendorMutex ()
 {
-    static SymbolVendorInstances g_plugin_instances;
-
-    switch (action)
-    {
-    case ePluginRegisterInstance:
-        if (instance.create_callback)
-        {
-            g_plugin_instances.push_back (instance);
-            return true;
-        }
-        break;
-
-    case ePluginUnregisterInstance:
-        if (instance.create_callback)
-        {
-            SymbolVendorInstances::iterator pos, end = g_plugin_instances.end();
-            for (pos = g_plugin_instances.begin(); pos != end; ++ pos)
-            {
-                if (pos->create_callback == instance.create_callback)
-                {
-                    g_plugin_instances.erase(pos);
-                    return true;
-                }
-            }
-        }
-        break;
-
-    case ePluginGetInstanceAtIndex:
-        if (index < g_plugin_instances.size())
-        {
-            instance = g_plugin_instances[index];
-            return true;
-        }
-        break;
+    static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
+    return g_instances_mutex;
+}
 
-    default:
-        break;
-    }
-    return false;
+static SymbolVendorInstances &
+GetSymbolVendorInstances ()
+{
+    static SymbolVendorInstances g_instances;
+    return g_instances;
 }
 
 bool
@@ -1645,7 +1500,8 @@
         if (description && description[0])
             instance.description = description;
         instance.create_callback = create_callback;
-        return AccessSymbolVendorInstances (ePluginRegisterInstance, instance, 0);
+        Mutex::Locker locker (GetSymbolVendorMutex ());
+        GetSymbolVendorInstances ().push_back (instance);
     }
     return false;
 }
@@ -1655,9 +1511,18 @@
 {
     if (create_callback)
     {
-        SymbolVendorInstance instance;
-        instance.create_callback = create_callback;
-        return AccessSymbolVendorInstances (ePluginUnregisterInstance, instance, 0);
+        Mutex::Locker locker (GetSymbolVendorMutex ());
+        SymbolVendorInstances &instances = GetSymbolVendorInstances ();
+        
+        SymbolVendorInstances::iterator pos, end = instances.end();
+        for (pos = instances.begin(); pos != end; ++ pos)
+        {
+            if (pos->create_callback == create_callback)
+            {
+                instances.erase(pos);
+                return true;
+            }
+        }
     }
     return false;
 }
@@ -1665,23 +1530,28 @@
 SymbolVendorCreateInstance
 PluginManager::GetSymbolVendorCreateCallbackAtIndex (uint32_t idx)
 {
-    SymbolVendorInstance instance;
-    if (AccessSymbolVendorInstances (ePluginGetInstanceAtIndex, instance, idx))
-        return instance.create_callback;
+    Mutex::Locker locker (GetSymbolVendorMutex ());
+    SymbolVendorInstances &instances = GetSymbolVendorInstances ();
+    if (idx < instances.size())
+        return instances[idx].create_callback;
     return NULL;
 }
 
+
 SymbolVendorCreateInstance
 PluginManager::GetSymbolVendorCreateCallbackForPluginName (const char *name)
 {
     if (name && name[0])
     {
-        SymbolVendorInstance instance;
-        std::string ss_name(name);
-        for (uint32_t idx = 0; AccessSymbolVendorInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx)
+        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 (instance.name == ss_name)
-                return instance.create_callback;
+            if (name_sref.equals (pos->name))
+                return pos->create_callback;
         }
     }
     return NULL;
@@ -1706,48 +1576,18 @@
 
 typedef std::vector<UnwindAssemblyProfilerInstance> UnwindAssemblyProfilerInstances;
 
-static bool
-AccessUnwindAssemblyProfilerInstances (PluginAction action, UnwindAssemblyProfilerInstance &instance, uint32_t index)
+static Mutex &
+GetUnwindAssemblyProfilerMutex ()
 {
-    static UnwindAssemblyProfilerInstances g_plugin_instances;
-
-    switch (action)
-    {
-    case ePluginRegisterInstance:
-        if (instance.create_callback)
-        {
-            g_plugin_instances.push_back (instance);
-            return true;
-        }
-        break;
-
-    case ePluginUnregisterInstance:
-        if (instance.create_callback)
-        {
-            UnwindAssemblyProfilerInstances::iterator pos, end = g_plugin_instances.end();
-            for (pos = g_plugin_instances.begin(); pos != end; ++ pos)
-            {
-                if (pos->create_callback == instance.create_callback)
-                {
-                    g_plugin_instances.erase(pos);
-                    return true;
-                }
-            }
-        }
-        break;
-
-    case ePluginGetInstanceAtIndex:
-        if (index < g_plugin_instances.size())
-        {
-            instance = g_plugin_instances[index];
-            return true;
-        }
-        break;
+    static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
+    return g_instances_mutex;
+}
 
-    default:
-        break;
-    }
-    return false;
+static UnwindAssemblyProfilerInstances &
+GetUnwindAssemblyProfilerInstances ()
+{
+    static UnwindAssemblyProfilerInstances g_instances;
+    return g_instances;
 }
 
 bool
@@ -1766,7 +1606,8 @@
         if (description && description[0])
             instance.description = description;
         instance.create_callback = create_callback;
-        return AccessUnwindAssemblyProfilerInstances (ePluginRegisterInstance, instance, 0);
+        Mutex::Locker locker (GetUnwindAssemblyProfilerMutex ());
+        GetUnwindAssemblyProfilerInstances ().push_back (instance);
     }
     return false;
 }
@@ -1776,9 +1617,18 @@
 {
     if (create_callback)
     {
-        UnwindAssemblyProfilerInstance instance;
-        instance.create_callback = create_callback;
-        return AccessUnwindAssemblyProfilerInstances (ePluginUnregisterInstance, instance, 0);
+        Mutex::Locker locker (GetUnwindAssemblyProfilerMutex ());
+        UnwindAssemblyProfilerInstances &instances = GetUnwindAssemblyProfilerInstances ();
+        
+        UnwindAssemblyProfilerInstances::iterator pos, end = instances.end();
+        for (pos = instances.begin(); pos != end; ++ pos)
+        {
+            if (pos->create_callback == create_callback)
+            {
+                instances.erase(pos);
+                return true;
+            }
+        }
     }
     return false;
 }
@@ -1786,23 +1636,28 @@
 UnwindAssemblyProfilerCreateInstance
 PluginManager::GetUnwindAssemblyProfilerCreateCallbackAtIndex (uint32_t idx)
 {
-    UnwindAssemblyProfilerInstance instance;
-    if (AccessUnwindAssemblyProfilerInstances (ePluginGetInstanceAtIndex, instance, idx))
-        return instance.create_callback;
+    Mutex::Locker locker (GetUnwindAssemblyProfilerMutex ());
+    UnwindAssemblyProfilerInstances &instances = GetUnwindAssemblyProfilerInstances ();
+    if (idx < instances.size())
+        return instances[idx].create_callback;
     return NULL;
 }
 
+
 UnwindAssemblyProfilerCreateInstance
 PluginManager::GetUnwindAssemblyProfilerCreateCallbackForPluginName (const char *name)
 {
     if (name && name[0])
     {
-        UnwindAssemblyProfilerInstance instance;
-        std::string ss_name(name);
-        for (uint32_t idx = 0; AccessUnwindAssemblyProfilerInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx)
+        llvm::StringRef name_sref(name);
+        Mutex::Locker locker (GetUnwindAssemblyProfilerMutex ());
+        UnwindAssemblyProfilerInstances &instances = GetUnwindAssemblyProfilerInstances ();
+        
+        UnwindAssemblyProfilerInstances::iterator pos, end = instances.end();
+        for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (instance.name == ss_name)
-                return instance.create_callback;
+            if (name_sref.equals (pos->name))
+                return pos->create_callback;
         }
     }
     return NULL;
@@ -1826,50 +1681,21 @@
 
 typedef std::vector<ArchDefaultUnwindPlanInstance> ArchDefaultUnwindPlanInstances;
 
-static bool
-AccessArchDefaultUnwindPlanInstances (PluginAction action, ArchDefaultUnwindPlanInstance &instance, uint32_t index)
+static Mutex &
+GetArchDefaultUnwindPlanMutex ()
 {
-    static ArchDefaultUnwindPlanInstances g_plugin_instances;
-
-    switch (action)
-    {
-    case ePluginRegisterInstance:
-        if (instance.create_callback)
-        {
-            g_plugin_instances.push_back (instance);
-            return true;
-        }
-        break;
-
-    case ePluginUnregisterInstance:
-        if (instance.create_callback)
-        {
-            ArchDefaultUnwindPlanInstances::iterator pos, end = g_plugin_instances.end();
-            for (pos = g_plugin_instances.begin(); pos != end; ++ pos)
-            {
-                if (pos->create_callback == instance.create_callback)
-                {
-                    g_plugin_instances.erase(pos);
-                    return true;
-                }
-            }
-        }
-        break;
-
-    case ePluginGetInstanceAtIndex:
-        if (index < g_plugin_instances.size())
-        {
-            instance = g_plugin_instances[index];
-            return true;
-        }
-        break;
+    static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
+    return g_instances_mutex;
+}
 
-    default:
-        break;
-    }
-    return false;
+static ArchDefaultUnwindPlanInstances &
+GetArchDefaultUnwindPlanInstances ()
+{
+    static ArchDefaultUnwindPlanInstances g_instances;
+    return g_instances;
 }
 
+
 bool
 PluginManager::RegisterPlugin
 (
@@ -1886,7 +1712,8 @@
         if (description && description[0])
             instance.description = description;
         instance.create_callback = create_callback;
-        return AccessArchDefaultUnwindPlanInstances (ePluginRegisterInstance, instance, 0);
+        Mutex::Locker locker (GetArchDefaultUnwindPlanMutex ());
+        GetArchDefaultUnwindPlanInstances ().push_back (instance);
     }
     return false;
 }
@@ -1896,9 +1723,18 @@
 {
     if (create_callback)
     {
-        ArchDefaultUnwindPlanInstance instance;
-        instance.create_callback = create_callback;
-        return AccessArchDefaultUnwindPlanInstances (ePluginUnregisterInstance, instance, 0);
+        Mutex::Locker locker (GetArchDefaultUnwindPlanMutex ());
+        ArchDefaultUnwindPlanInstances &instances = GetArchDefaultUnwindPlanInstances ();
+        
+        ArchDefaultUnwindPlanInstances::iterator pos, end = instances.end();
+        for (pos = instances.begin(); pos != end; ++ pos)
+        {
+            if (pos->create_callback == create_callback)
+            {
+                instances.erase(pos);
+                return true;
+            }
+        }
     }
     return false;
 }
@@ -1906,23 +1742,28 @@
 ArchDefaultUnwindPlanCreateInstance
 PluginManager::GetArchDefaultUnwindPlanCreateCallbackAtIndex (uint32_t idx)
 {
-    ArchDefaultUnwindPlanInstance instance;
-    if (AccessArchDefaultUnwindPlanInstances (ePluginGetInstanceAtIndex, instance, idx))
-        return instance.create_callback;
+    Mutex::Locker locker (GetArchDefaultUnwindPlanMutex ());
+    ArchDefaultUnwindPlanInstances &instances = GetArchDefaultUnwindPlanInstances ();
+    if (idx < instances.size())
+        return instances[idx].create_callback;
     return NULL;
 }
 
+
 ArchDefaultUnwindPlanCreateInstance
 PluginManager::GetArchDefaultUnwindPlanCreateCallbackForPluginName (const char *name)
 {
     if (name && name[0])
     {
-        ArchDefaultUnwindPlanInstance instance;
-        std::string ss_name(name);
-        for (uint32_t idx = 0; AccessArchDefaultUnwindPlanInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx)
+        llvm::StringRef name_sref(name);
+        Mutex::Locker locker (GetArchDefaultUnwindPlanMutex ());
+        ArchDefaultUnwindPlanInstances &instances = GetArchDefaultUnwindPlanInstances ();
+        
+        ArchDefaultUnwindPlanInstances::iterator pos, end = instances.end();
+        for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (instance.name == ss_name)
-                return instance.create_callback;
+            if (name_sref.equals (pos->name))
+                return pos->create_callback;
         }
     }
     return NULL;
@@ -1946,48 +1787,18 @@
 
 typedef std::vector<ArchVolatileRegsInstance> ArchVolatileRegsInstances;
 
-static bool
-AccessArchVolatileRegsInstances (PluginAction action, ArchVolatileRegsInstance &instance, uint32_t index)
+static Mutex &
+GetArchVolatileRegsMutex ()
 {
-    static ArchVolatileRegsInstances g_plugin_instances;
-
-    switch (action)
-    {
-    case ePluginRegisterInstance:
-        if (instance.create_callback)
-        {
-            g_plugin_instances.push_back (instance);
-            return true;
-        }
-        break;
-
-    case ePluginUnregisterInstance:
-        if (instance.create_callback)
-        {
-            ArchVolatileRegsInstances::iterator pos, end = g_plugin_instances.end();
-            for (pos = g_plugin_instances.begin(); pos != end; ++ pos)
-            {
-                if (pos->create_callback == instance.create_callback)
-                {
-                    g_plugin_instances.erase(pos);
-                    return true;
-                }
-            }
-        }
-        break;
-
-    case ePluginGetInstanceAtIndex:
-        if (index < g_plugin_instances.size())
-        {
-            instance = g_plugin_instances[index];
-            return true;
-        }
-        break;
+    static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
+    return g_instances_mutex;
+}
 
-    default:
-        break;
-    }
-    return false;
+static ArchVolatileRegsInstances &
+GetArchVolatileRegsInstances ()
+{
+    static ArchVolatileRegsInstances g_instances;
+    return g_instances;
 }
 
 bool
@@ -2006,7 +1817,8 @@
         if (description && description[0])
             instance.description = description;
         instance.create_callback = create_callback;
-        return AccessArchVolatileRegsInstances (ePluginRegisterInstance, instance, 0);
+        Mutex::Locker locker (GetArchVolatileRegsMutex ());
+        GetArchVolatileRegsInstances ().push_back (instance);
     }
     return false;
 }
@@ -2016,9 +1828,18 @@
 {
     if (create_callback)
     {
-        ArchVolatileRegsInstance instance;
-        instance.create_callback = create_callback;
-        return AccessArchVolatileRegsInstances (ePluginUnregisterInstance, instance, 0);
+        Mutex::Locker locker (GetArchVolatileRegsMutex ());
+        ArchVolatileRegsInstances &instances = GetArchVolatileRegsInstances ();
+        
+        ArchVolatileRegsInstances::iterator pos, end = instances.end();
+        for (pos = instances.begin(); pos != end; ++ pos)
+        {
+            if (pos->create_callback == create_callback)
+            {
+                instances.erase(pos);
+                return true;
+            }
+        }
     }
     return false;
 }
@@ -2026,9 +1847,10 @@
 ArchVolatileRegsCreateInstance
 PluginManager::GetArchVolatileRegsCreateCallbackAtIndex (uint32_t idx)
 {
-    ArchVolatileRegsInstance instance;
-    if (AccessArchVolatileRegsInstances (ePluginGetInstanceAtIndex, instance, idx))
-        return instance.create_callback;
+    Mutex::Locker locker (GetArchVolatileRegsMutex ());
+    ArchVolatileRegsInstances &instances = GetArchVolatileRegsInstances ();
+    if (idx < instances.size())
+        return instances[idx].create_callback;
     return NULL;
 }
 
@@ -2037,12 +1859,15 @@
 {
     if (name && name[0])
     {
-        ArchVolatileRegsInstance instance;
-        std::string ss_name(name);
-        for (uint32_t idx = 0; AccessArchVolatileRegsInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx)
+        llvm::StringRef name_sref(name);
+        Mutex::Locker locker (GetArchVolatileRegsMutex ());
+        ArchVolatileRegsInstances &instances = GetArchVolatileRegsInstances ();
+        
+        ArchVolatileRegsInstances::iterator pos, end = instances.end();
+        for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (instance.name == ss_name)
-                return instance.create_callback;
+            if (name_sref.equals (pos->name))
+                return pos->create_callback;
         }
     }
     return NULL;

Modified: lldb/trunk/source/Interpreter/CommandObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandObject.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandObject.cpp Wed Apr 13 17:47:15 2011
@@ -650,7 +650,7 @@
     { eArgTypeAddress, "address", CommandCompletions::eNoCompletion, NULL, "A valid address in the target program's execution space." },
     { eArgTypeAliasName, "alias-name", CommandCompletions::eNoCompletion, NULL, "The name of an abbreviation (alias) for a debugger command." },
     { eArgTypeAliasOptions, "options-for-aliased-command", CommandCompletions::eNoCompletion, NULL, "Command options to be used as part of an alias (abbreviation) definition.  (See 'help commands alias' for more information.)" },
-    { eArgTypeArchitecture, "arch", CommandCompletions::eNoCompletion, NULL, "The architecture name, e.g. i386 or x86_64." },
+    { eArgTypeArchitecture, "arch", CommandCompletions::eArchitectureCompletion, NULL, "The architecture name, e.g. i386 or x86_64." },
     { eArgTypeBoolean, "boolean", CommandCompletions::eNoCompletion, NULL, "A Boolean value: 'true' or 'false'" },
     { eArgTypeBreakpointID, "breakpt-id", CommandCompletions::eNoCompletion, BreakpointIDHelpTextCallback, NULL },
     { eArgTypeBreakpointIDRange, "breakpt-id-list", CommandCompletions::eNoCompletion, BreakpointIDRangeHelpTextCallback, NULL },
@@ -707,6 +707,7 @@
     { eArgTypeValue, "value", CommandCompletions::eNoCompletion, NULL, "A value could be anything, depending on where and how it is used." },
     { eArgTypeWidth, "width", CommandCompletions::eNoCompletion, NULL, "Help text goes here." },
     { eArgTypeNone, "none", CommandCompletions::eNoCompletion, NULL, "No help available for this." },
+    { eArgTypePlatform, "platform-name", CommandCompletions::ePlatformPluginCompletion, NULL, "The name of an installed platform plug-in . Type 'platform list' to see a complete list of installed platforms." }
 };
 
 const CommandObject::ArgumentTableEntry*

Modified: lldb/trunk/source/Interpreter/Options.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/Options.cpp (original)
+++ lldb/trunk/source/Interpreter/Options.cpp Wed Apr 13 17:47:15 2011
@@ -11,8 +11,9 @@
 
 // C Includes
 // C++ Includes
-#include <bitset>
 #include <algorithm>
+#include <bitset>
+#include <set>
 
 // Other libraries and framework includes
 // Project includes
@@ -853,7 +854,19 @@
     // for that shared library.
     // FIXME: Do we want to also have an "OptionType" so we don't have to match string names?
 
-    uint32_t completion_mask = opt_defs[opt_defs_index].completionType;
+    uint32_t completion_mask = opt_defs[opt_defs_index].completion_type;
+    
+    if (completion_mask == 0)
+    {
+        lldb::CommandArgumentType option_arg_type = opt_defs[opt_defs_index].argument_type;
+        if (option_arg_type != eArgTypeNone)
+        {
+            CommandObject::ArgumentTableEntry *arg_entry = CommandObject::FindArgumentDataByType (opt_defs[opt_defs_index].argument_type);
+            if (arg_entry)
+                completion_mask = arg_entry->completion_type;
+        }
+    }
+
     if (completion_mask & CommandCompletions::eSourceFileCompletion
         || completion_mask & CommandCompletions::eSymbolCompletion)
     {
@@ -893,28 +906,21 @@
 }
 
 
-
-
-void
-OptionGroupOptions::Append (OptionGroup* group)
-{
-    m_option_groups.push_back (group);
-    const OptionDefinition* group_option_defs = group->GetDefinitions ();
-    const uint32_t group_option_count = group->GetNumDefinitions();
-    for (uint32_t i=0; i<group_option_count; ++i)
-        m_option_defs.push_back (group_option_defs[i]);
-}
-
 void
-OptionGroupOptions::Append (OptionGroup* group, uint32_t usage_mask)
+OptionGroupOptions::Append (OptionGroup* group, 
+                            uint32_t src_mask, 
+                            uint32_t dst_mask)
 {
-    m_option_groups.push_back (group);
     const OptionDefinition* group_option_defs = group->GetDefinitions ();
     const uint32_t group_option_count = group->GetNumDefinitions();
     for (uint32_t i=0; i<group_option_count; ++i)
     {
-        m_option_defs.push_back (group_option_defs[i]);
-        m_option_defs.back().usage_mask = usage_mask;
+        if (group_option_defs[i].usage_mask & src_mask)
+        {
+            m_option_infos.push_back (OptionInfo (group, i));
+            m_option_defs.push_back (group_option_defs[i]);
+            m_option_defs.back().usage_mask = dst_mask;
+        }
     }
 }
 
@@ -933,38 +939,53 @@
     // After calling OptionGroupOptions::Append(...), you must finalize the groups
     // by calling OptionGroupOptions::Finlize()
     assert (m_did_finalize);
-
-    uint32_t curr_idx = 0;
-    OptionGroupsType::iterator pos, end = m_option_groups.end();
-    for (pos = m_option_groups.begin(); pos != end; ++pos)
-    {
-        const uint32_t num_group_definitions = (*pos)->GetNumDefinitions();
-        if (option_idx < curr_idx + num_group_definitions)
-            return (*pos)->SetOptionValue (m_interpreter, option_idx - curr_idx, option_value);
-        curr_idx += num_group_definitions;
-    }
+    assert (m_option_infos.size() + 1 == m_option_defs.size());
     Error error;
-    error.SetErrorString ("invalid option index"); // Shouldn't happen...
+    if (option_idx < m_option_infos.size())
+    {
+        error = m_option_infos[option_idx].option_group->SetOptionValue (m_interpreter, 
+                                                                         m_option_infos[option_idx].option_index,
+                                                                         option_value);
+        
+    }
+    else
+    {
+        error.SetErrorString ("invalid option index"); // Shouldn't happen...
+    }
     return error;
 }
 
 void
 OptionGroupOptions::OptionParsingStarting ()
 {
-    OptionGroupsType::iterator pos, end = m_option_groups.end();
-    for (pos = m_option_groups.begin(); pos != end; ++pos)
-        (*pos)->OptionParsingStarting (m_interpreter);
+    std::set<OptionGroup*> group_set;
+    OptionInfos::iterator pos, end = m_option_infos.end();
+    for (pos = m_option_infos.begin(); pos != end; ++pos)
+    {
+        OptionGroup* group = pos->option_group;
+        if (group_set.find(group) == group_set.end())
+        {
+            group->OptionParsingStarting (m_interpreter);
+            group_set.insert(group);
+        }
+    }
 }
 Error
 OptionGroupOptions::OptionParsingFinished ()
 {
+    std::set<OptionGroup*> group_set;
     Error error;
-    OptionGroupsType::iterator pos, end = m_option_groups.end();
-    for (pos = m_option_groups.begin(); pos != end; ++pos)
+    OptionInfos::iterator pos, end = m_option_infos.end();
+    for (pos = m_option_infos.begin(); pos != end; ++pos)
     {
-        error = (*pos)->OptionParsingFinished (m_interpreter);
-        if (error.Fail())
-            return error;
+        OptionGroup* group = pos->option_group;
+        if (group_set.find(group) == group_set.end())
+        {
+            error = group->OptionParsingFinished (m_interpreter);
+            group_set.insert(group);
+            if (error.Fail())
+                return error;
+        }
     }
     return error;
 }

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp Wed Apr 13 17:47:15 2011
@@ -80,7 +80,7 @@
 PlatformMacOSX::GetShortPluginNameStatic (bool is_host)
 {
     if (is_host)
-        return "local-macosx";
+        return Platform::GetHostPlatformName ();
     else
         return "remote-macosx";
 }

Modified: lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp Wed Apr 13 17:47:15 2011
@@ -312,7 +312,7 @@
                 break;
         }
     }
-    const uint32_t old_packet_timeout = m_gdb_client.SetPacketTimeout (3000); // TODO: lower this to 5 seconds prior to checkin!!!
+    const uint32_t old_packet_timeout = m_gdb_client.SetPacketTimeout (5);
     int arg_packet_err = m_gdb_client.SendArgumentsPacket (argv);
     m_gdb_client.SetPacketTimeout (old_packet_timeout);
     if (arg_packet_err == 0)

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp Wed Apr 13 17:47:15 2011
@@ -54,16 +54,9 @@
 const char *
 LogChannelDWARF::GetPluginNameStatic()
 {
-    static std::string g_plugin_name;
-    if (g_plugin_name.empty())
-    {
-        g_plugin_name = SymbolFileDWARF::GetPluginNameStatic();
-        g_plugin_name += LogChannel::GetPluginSuffix ();
-    }
-    return g_plugin_name.c_str();
+    return SymbolFileDWARF::GetPluginNameStatic();
 }
 
-
 const char *
 LogChannelDWARF::GetPluginDescriptionStatic()
 {

Modified: lldb/trunk/source/Target/Platform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/source/Target/Platform.cpp (original)
+++ lldb/trunk/source/Target/Platform.cpp Wed Apr 13 17:47:15 2011
@@ -46,6 +46,13 @@
     return g_remote_connected_platforms;
 }
 
+
+const char *
+Platform::GetHostPlatformName ()
+{
+    return "host";
+}
+
 //------------------------------------------------------------------
 /// Get the native host platform plug-in. 
 ///
@@ -319,11 +326,8 @@
 const char *
 Platform::GetHostname ()
 {
-    if (IsHost() && m_name.empty())
-    {
-        if (!Host::GetHostname(m_name))
-            return "localhost";
-    }
+    if (IsHost())
+        return "localhost";
 
     if (m_name.empty())        
         return NULL;

Modified: lldb/trunk/tools/driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=129483&r1=129482&r2=129483&view=diff
==============================================================================
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Wed Apr 13 17:47:15 2011
@@ -59,7 +59,7 @@
     const char * long_option;                // Full name for this option.
     char short_option;                       // Single character for this option.
     int option_has_arg;                      // no_argument, required_argument or optional_argument
-    uint32_t completionType;                 // Cookie the option class can use to do define the argument completion.
+    uint32_t completion_type;                // Cookie the option class can use to do define the argument completion.
     lldb::CommandArgumentType argument_type; // Type of argument this option takes
     const char *  usage_text;                // Full text explaining what this options does and what (if any) argument to
                                              // pass it.





More information about the lldb-commits mailing list