[Lldb-commits] [lldb] r124836 - in /lldb/trunk: include/lldb/Core/UserSettingsController.h source/Commands/CommandObjectApropos.cpp source/Core/UserSettingsController.cpp

Caroline Tice ctice at apple.com
Thu Feb 3 16:16:49 PST 2011


Author: ctice
Date: Thu Feb  3 18:16:49 2011
New Revision: 124836

URL: http://llvm.org/viewvc/llvm-project?rev=124836&view=rev
Log:
Modify 'apropos' command to search settings variable descriptions as well.


Modified:
    lldb/trunk/include/lldb/Core/UserSettingsController.h
    lldb/trunk/source/Commands/CommandObjectApropos.cpp
    lldb/trunk/source/Core/UserSettingsController.cpp

Modified: lldb/trunk/include/lldb/Core/UserSettingsController.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UserSettingsController.h?rev=124836&r1=124835&r2=124836&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/UserSettingsController.h (original)
+++ lldb/trunk/include/lldb/Core/UserSettingsController.h Thu Feb  3 18:16:49 2011
@@ -147,6 +147,13 @@
                               const char *search_name,
                               StreamString &result_stream,
                               Error &err);
+    
+    static void
+    SearchAllSettingsDescriptions (CommandInterpreter &interpreter,
+                                   lldb::UserSettingsControllerSP root,
+                                   std::string &current_prefix,
+                                   const char *search_word,
+                                   StreamString &result_stream);
 
     static void
     GetAllVariableValues (CommandInterpreter &interpreter,

Modified: lldb/trunk/source/Commands/CommandObjectApropos.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectApropos.cpp?rev=124836&r1=124835&r2=124836&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectApropos.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectApropos.cpp Thu Feb  3 18:16:49 2011
@@ -95,6 +95,21 @@
                                                            max_len);
                 
             }
+            
+            
+            StreamString settings_search_results;
+            lldb::UserSettingsControllerSP root = Debugger::GetSettingsController ();
+            std::string settings_prefix = root->GetLevelName().AsCString();
+             
+            UserSettingsController::SearchAllSettingsDescriptions (m_interpreter, root, settings_prefix, search_word,
+                                                                   settings_search_results);
+            
+            if (settings_search_results.GetSize() > 0)
+            {
+                result.AppendMessageWithFormat ("\nThe following settings variables may relate to '%s': \n\n", search_word);
+                result.AppendMessageWithFormat ("%s", settings_search_results.GetData());
+            }
+            
             result.SetStatus (eReturnStatusSuccessFinishNoResult);
         }
         else

Modified: lldb/trunk/source/Core/UserSettingsController.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=124836&r1=124835&r2=124836&view=diff
==============================================================================
--- lldb/trunk/source/Core/UserSettingsController.cpp (original)
+++ lldb/trunk/source/Core/UserSettingsController.cpp Thu Feb  3 18:16:49 2011
@@ -1353,6 +1353,75 @@
 }
 
 void
+UserSettingsController::SearchAllSettingsDescriptions (CommandInterpreter &interpreter,
+                                                       lldb::UserSettingsControllerSP root,
+                                                       std::string &current_prefix,
+                                                       const char *search_word,
+                                                       StreamString &result_stream)
+{
+    if ((search_word == NULL) || (strlen (search_word) == 0))
+        return;
+    
+    int num_entries = root->m_settings.global_settings.size();
+
+    if (num_entries > 0)
+    {
+        for (int i = 0; i < num_entries; ++i)
+        {
+            SettingEntry &entry = root->m_settings.global_settings[i];
+            if (strcasestr (entry.description, search_word) != NULL)
+            {
+                StreamString var_name;
+                if (current_prefix.size() > 0)
+                    var_name.Printf ("%s.%s", current_prefix.c_str(), entry.var_name);
+                else
+                    var_name.Printf ("%s", entry.var_name);
+                interpreter.OutputFormattedHelpText (result_stream, var_name.GetData(), "--", entry.description,
+                                                     var_name.GetSize());
+            }
+        }
+    }
+    
+    num_entries = root->m_settings.instance_settings.size();
+    if (num_entries > 0)
+    {
+        for (int i = 0; i < num_entries; ++i)
+        {
+            SettingEntry &entry = root->m_settings.instance_settings[i];
+            if (strcasestr (entry.description, search_word) != NULL)
+            {
+                StreamString var_name;
+                if (current_prefix.size() > 0)
+                    var_name.Printf ("%s.%s", current_prefix.c_str(), entry.var_name);
+                else
+                    var_name.Printf ("%s", entry.var_name);
+                interpreter.OutputFormattedHelpText (result_stream, var_name.GetData(), "--", entry.description,
+                                                     var_name.GetSize());
+            }
+        }
+    }
+    
+    int num_children = root->GetNumChildren ();
+    for (int i = 0; i < num_children; ++i)
+    {
+        lldb::UserSettingsControllerSP child = root->GetChildAtIndex (i);
+        
+        if (child)
+        {
+            ConstString child_prefix = child->GetLevelName();
+            StreamString new_prefix;
+            if (! current_prefix.empty())
+                new_prefix.Printf ("%s.%s", current_prefix.c_str(), child_prefix.AsCString());
+            else
+                new_prefix.Printf ("%s", child_prefix.AsCString());
+            std::string new_prefix_str = new_prefix.GetData();
+            UserSettingsController::SearchAllSettingsDescriptions (interpreter, child, new_prefix_str, search_word,
+                                                                   result_stream);
+        }
+    }
+}
+
+void
 UserSettingsController::GetAllVariableValues (CommandInterpreter &interpreter,
                                               lldb::UserSettingsControllerSP root,
                                               std::string &current_prefix,





More information about the lldb-commits mailing list