[Lldb-commits] [lldb] r113474 - in /lldb/trunk: include/lldb/Core/ include/lldb/Interpreter/ source/API/ source/Commands/ source/Core/ source/Interpreter/

Caroline Tice ctice at apple.com
Wed Sep 8 23:25:08 PDT 2010


Author: ctice
Date: Thu Sep  9 01:25:08 2010
New Revision: 113474

URL: http://llvm.org/viewvc/llvm-project?rev=113474&view=rev
Log:
Make all debugger-level user settable variables into instance variables.
Make get/set variable at the debugger level always set the particular debugger's instance variables rather than
the default variables.



Modified:
    lldb/trunk/include/lldb/Core/Debugger.h
    lldb/trunk/include/lldb/Core/UserSettingsController.h
    lldb/trunk/include/lldb/Interpreter/CommandObject.h
    lldb/trunk/include/lldb/Interpreter/Options.h
    lldb/trunk/source/API/SBDebugger.cpp
    lldb/trunk/source/Commands/CommandObjectHelp.cpp
    lldb/trunk/source/Commands/CommandObjectImage.cpp
    lldb/trunk/source/Commands/CommandObjectProcess.cpp
    lldb/trunk/source/Commands/CommandObjectSettings.cpp
    lldb/trunk/source/Commands/CommandObjectSyntax.cpp
    lldb/trunk/source/Core/Debugger.cpp
    lldb/trunk/source/Core/UserSettingsController.cpp
    lldb/trunk/source/Interpreter/CommandInterpreter.cpp
    lldb/trunk/source/Interpreter/CommandObject.cpp
    lldb/trunk/source/Interpreter/Options.cpp

Modified: lldb/trunk/include/lldb/Core/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=113474&r1=113473&r2=113474&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Thu Sep  9 01:25:08 2010
@@ -74,6 +74,9 @@
     bool
     BroadcastPromptChange (const ConstString &instance_name, const char *new_prompt);
 
+    bool
+    ValidTermWidthValue (const char *value, Error err);
+
     const ConstString
     CreateInstanceName ();
 
@@ -83,8 +86,12 @@
     static const ConstString &
     ScriptLangVarName ();
   
+    static const ConstString &
+    TermWidthVarName ();
+  
 private:
 
+    int m_term_width;
     std::string m_prompt;
     lldb::ScriptLanguage m_script_lang;
 };
@@ -126,13 +133,9 @@
         lldb::InstanceSettingsSP
         CreateNewInstanceSettings (const char *instance_name);
 
-        bool
-        ValidTermWidthValue (const char *value, Error err);
-
     private:
 
         // Class-wide settings.
-        int m_term_width;
 
         DISALLOW_COPY_AND_ASSIGN (DebuggerSettingsController);
     };

Modified: lldb/trunk/include/lldb/Core/UserSettingsController.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UserSettingsController.h?rev=113474&r1=113473&r2=113474&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/UserSettingsController.h (original)
+++ lldb/trunk/include/lldb/Core/UserSettingsController.h Thu Sep  9 01:25:08 2010
@@ -82,11 +82,13 @@
                  const char *value, 
                  const lldb::VarSetOperationType op,
                  const bool override,
+                 const char *debugger_instance_name,
                  const char *index_value = NULL);
 
     StringList
     GetVariable (const char *full_dot_name, 
-                 lldb::SettableVariableType &var_type);
+                 lldb::SettableVariableType &var_type,
+                 const char *debugger_instance_name);
 
     const lldb::UserSettingsControllerSP &
     GetParent ();

Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=113474&r1=113473&r2=113474&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Thu Sep  9 01:25:08 2010
@@ -233,7 +233,7 @@
     }
     
     bool
-    HelpTextContainsWord (const char *search_word);
+    HelpTextContainsWord (const char *search_word, CommandInterpreter &interpreter);
 
     //------------------------------------------------------------------
     /// The flags accessor.

Modified: lldb/trunk/include/lldb/Interpreter/Options.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Options.h?rev=113474&r1=113473&r2=113474&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/Options.h (original)
+++ lldb/trunk/include/lldb/Interpreter/Options.h Thu Sep  9 01:25:08 2010
@@ -159,6 +159,7 @@
     void
     GenerateOptionUsage (Stream &strm,
                          CommandObject *cmd,
+                         const char *debugger_instance_name,
                          const char *program_name = NULL);
 
     // The following two pure virtual functions must be defined by every class that inherits from

Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=113474&r1=113473&r2=113474&view=diff
==============================================================================
--- lldb/trunk/source/API/SBDebugger.cpp (original)
+++ lldb/trunk/source/API/SBDebugger.cpp Thu Sep  9 01:25:08 2010
@@ -569,8 +569,16 @@
 SBDebugger::SetInternalVariable (const char *var_name, const char *value)
 {
     lldb::UserSettingsControllerSP root_settings_controller = lldb_private::Debugger::GetSettingsController();
+    
+    const char *debugger_instance_name;
 
-    Error err = root_settings_controller->SetVariable (var_name, value, lldb::eVarSetOperationAssign, false);
+    if (m_opaque_sp)
+        debugger_instance_name = m_opaque_sp->GetInstanceName().AsCString();
+    else
+        debugger_instance_name = "";
+
+    Error err = root_settings_controller->SetVariable (var_name, value, lldb::eVarSetOperationAssign, false,
+                                                       debugger_instance_name);
     SBError sb_error;
     sb_error.SetError (err);
 
@@ -581,10 +589,17 @@
 SBDebugger::GetInternalVariableValue (const char *var_name)
 {
     SBStringList ret_value;
+    lldb::SettableVariableType var_type;
+    const char *debugger_instance_name;
+
     lldb::UserSettingsControllerSP root_settings_controller = lldb_private::Debugger::GetSettingsController();
 
-    lldb::SettableVariableType var_type;
-    StringList value = root_settings_controller->GetVariable (var_name, var_type);
+    if (m_opaque_sp)
+        debugger_instance_name = m_opaque_sp->GetInstanceName().AsCString();
+    else
+        debugger_instance_name = "";
+
+    StringList value = root_settings_controller->GetVariable (var_name, var_type, debugger_instance_name);
     for (unsigned i = 0; i != value.GetSize(); ++i)
         ret_value.AppendString (value.GetStringAtIndex(i));
 

Modified: lldb/trunk/source/Commands/CommandObjectHelp.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectHelp.cpp?rev=113474&r1=113473&r2=113474&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectHelp.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectHelp.cpp Thu Sep  9 01:25:08 2010
@@ -96,7 +96,8 @@
                 {
                     interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1);
                     output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax());
-                    sub_cmd_obj->GetOptions()->GenerateOptionUsage (output_strm, sub_cmd_obj);
+                    sub_cmd_obj->GetOptions()->GenerateOptionUsage (output_strm, sub_cmd_obj,
+                                                                    interpreter.GetDebugger().GetInstanceName().AsCString());
                     const char *long_help = sub_cmd_obj->GetHelpLong();
                     if ((long_help != NULL)
                         && (strlen (long_help) > 0))

Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=113474&r1=113473&r2=113474&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectImage.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectImage.cpp Thu Sep  9 01:25:08 2010
@@ -1424,7 +1424,7 @@
             break;
 
         default:
-            m_options.GenerateOptionUsage (result.GetErrorStream(), this);
+            m_options.GenerateOptionUsage (result.GetErrorStream(), this, interpreter.GetDebugger().GetInstanceName().AsCString());
             syntax_error = true;
             break;
         }

Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=113474&r1=113473&r2=113474&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Thu Sep  9 01:25:08 2010
@@ -162,6 +162,7 @@
         process = target->CreateProcess (interpreter.GetDebugger().GetListener(), plugin_name).get();
 
         const char *process_name = process->GetInstanceName().AsCString();
+        const char *debugger_instance_name = interpreter.GetDebugger().GetInstanceName().AsCString();
         StreamString run_args_var_name;
         StreamString env_vars_var_name;
         StreamString disable_aslr_var_name;
@@ -170,7 +171,8 @@
         Args *run_args = NULL;
         run_args_var_name.Printf ("process.[%s].run-args", process_name);
         StringList run_args_value = Debugger::GetSettingsController()->GetVariable (run_args_var_name.GetData(), 
-                                                                                    var_type);
+                                                                                    var_type, debugger_instance_name);
+
         if (run_args_value.GetSize() > 0)
         {
             run_args = new Args;
@@ -181,7 +183,8 @@
         Args *environment = NULL;
         env_vars_var_name.Printf ("process.[%s].env-vars", process_name);
         StringList env_vars_value = Debugger::GetSettingsController()->GetVariable (env_vars_var_name.GetData(), 
-                                                                                    var_type);
+                                                                                    var_type, debugger_instance_name);
+
         if (env_vars_value.GetSize() > 0)
         {
             environment = new Args;
@@ -192,7 +195,9 @@
         uint32_t launch_flags = eLaunchFlagNone;
         disable_aslr_var_name.Printf ("process.[%s].disable-aslr", process_name);
         StringList disable_aslr_value = Debugger::GetSettingsController()->GetVariable(disable_aslr_var_name.GetData(),
-                                                                                       var_type);
+                                                                                       var_type, 
+                                                                                       debugger_instance_name);
+
         if (disable_aslr_value.GetSize() > 0)
         {
             if (strcmp (disable_aslr_value.GetStringAtIndex(0), "true") == 0)
@@ -214,7 +219,9 @@
             // launch-args was not empty; use that, AND re-set run-args to contains launch-args values.
             std::string new_run_args;
             launch_args.GetCommandString (new_run_args);
-            Debugger::GetSettingsController()->SetVariable (run_args_var_name.GetData(), new_run_args.c_str(), lldb::eVarSetOperationAssign, false);
+            Debugger::GetSettingsController()->SetVariable (run_args_var_name.GetData(), new_run_args.c_str(), 
+                                                            lldb::eVarSetOperationAssign, false,
+                                                            interpreter.GetDebugger().GetInstanceName().AsCString());
         }
 
 

Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=113474&r1=113473&r2=113474&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Thu Sep  9 01:25:08 2010
@@ -117,7 +117,8 @@
     else
     {
       Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationAssign, 
-                                              m_options.m_override);
+                                              m_options.m_override, 
+                                              interpreter.GetDebugger().GetInstanceName().AsCString());
         if (err.Fail ())
         {
             result.AppendError (err.AsCString());
@@ -284,7 +285,8 @@
         // The user requested to see the value of a particular variable.
         lldb::SettableVariableType var_type;
         const char *variable_name = command.GetArgumentAtIndex (0);
-        StringList value = root_settings->GetVariable (variable_name, var_type);
+        StringList value = root_settings->GetVariable (variable_name, var_type, 
+                                                       interpreter.GetDebugger().GetInstanceName().AsCString());
         
         if (value.GetSize() == 0)
         {
@@ -456,7 +458,8 @@
     index_value_string = index_value;
 
     Error err = root_settings->SetVariable (var_name_string.c_str(), NULL, lldb::eVarSetOperationRemove,  
-                                            false, index_value_string.c_str());
+                                            false, interpreter.GetDebugger().GetInstanceName().AsCString(),
+                                            index_value_string.c_str());
     if (err.Fail ())
     {
         result.AppendError (err.AsCString());
@@ -565,7 +568,8 @@
     else
     {
         Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationReplace, 
-                                                false, index_value_string.c_str());
+                                                false, interpreter.GetDebugger().GetInstanceName().AsCString(),
+                                                index_value_string.c_str());
         if (err.Fail ())
         {
             result.AppendError (err.AsCString());
@@ -676,7 +680,8 @@
     else
     {
         Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationInsertBefore,
-                                                false, index_value_string.c_str());
+                                                false, interpreter.GetDebugger().GetInstanceName().AsCString(),
+                                                index_value_string.c_str());
         if (err.Fail ())
         {
             result.AppendError (err.AsCString());
@@ -788,7 +793,8 @@
     else
     {
         Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationInsertAfter,
-                                                false, index_value_string.c_str());
+                                                false, interpreter.GetDebugger().GetInstanceName().AsCString(), 
+                                                index_value_string.c_str());
         if (err.Fail ())
         {
             result.AppendError (err.AsCString());
@@ -888,7 +894,7 @@
     else
     {
         Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationAppend, 
-                                                false);
+                                                false, interpreter.GetDebugger().GetInstanceName().AsCString());
         if (err.Fail ())
         {
             result.AppendError (err.AsCString());
@@ -969,7 +975,8 @@
         return false;
     }
 
-    Error err = root_settings->SetVariable (var_name, NULL, lldb::eVarSetOperationClear, false);
+    Error err = root_settings->SetVariable (var_name, NULL, lldb::eVarSetOperationClear, false, 
+                                            interpreter.GetDebugger().GetInstanceName().AsCString());
 
     if (err.Fail ())
     {

Modified: lldb/trunk/source/Commands/CommandObjectSyntax.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSyntax.cpp?rev=113474&r1=113473&r2=113474&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSyntax.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectSyntax.cpp Thu Sep  9 01:25:08 2010
@@ -76,7 +76,6 @@
             if (cmd_obj->GetOptions() != NULL)
             {
                 output_strm.Printf ("\nSyntax: %s\n", cmd_obj->GetSyntax());
-                //cmd_obj->GetOptions()->GenerateOptionUsage (output_strm, cmd_obj);
                 output_strm.Printf ("(Try 'help %s' for more information on command options syntax.)\n",
                                     cmd_obj->GetCommandName());
                 result.SetStatus (eReturnStatusSuccessFinishNoResult);

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=113474&r1=113473&r2=113474&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Thu Sep  9 01:25:08 2010
@@ -562,8 +562,7 @@
 //--------------------------------------------------
 
 Debugger::DebuggerSettingsController::DebuggerSettingsController () :
-    UserSettingsController ("", lldb::UserSettingsControllerSP()),
-    m_term_width (80)
+    UserSettingsController ("", lldb::UserSettingsControllerSP())
 {
     m_default_settings.reset (new DebuggerInstanceSettings (*this, false, 
                                                             InstanceSettings::GetDefaultName().AsCString()));
@@ -584,7 +583,7 @@
 }
 
 bool
-Debugger::DebuggerSettingsController::ValidTermWidthValue (const char *value, Error err)
+Debugger::DebuggerInstanceSettings::ValidTermWidthValue (const char *value, Error err)
 {
     bool valid = true;
 
@@ -604,7 +603,7 @@
             if (! isdigit (value[i]))
             {
                 valid = false;
-                err.SetErrorStringWithFormat ("'%s' is not a valid representation of an integer.\n", value);
+                err.SetErrorStringWithFormat ("'%s' is not a valid representation of an unsigned integer.\n", value);
             }
     }
 
@@ -680,7 +679,7 @@
 {
     if (var_name == PromptVarName())
     {
-      UserSettingsController::UpdateStringVariable (op, m_prompt, value, err);
+        UserSettingsController::UpdateStringVariable (op, m_prompt, value, err);
         if (!pending)
         {
             // 'instance_name' is actually (probably) in the form '[<instance_name>]';  if so, we need to
@@ -701,6 +700,13 @@
         m_script_lang = Args::StringToScriptLanguage (value, eScriptLanguageDefault,
                                                       &success);
     }
+    else if (var_name == TermWidthVarName())
+    {
+        if (ValidTermWidthValue (value, err))
+        {
+            m_term_width = atoi (value);
+        }
+    }
 }
 
 void
@@ -711,15 +717,7 @@
                                                             lldb::VarSetOperationType op,
                                                             Error &err)
 {
-    static ConstString term_width_name ("term-width");
-    
-    if (var_name == term_width_name)
-    {
-        if (ValidTermWidthValue (value, err))
-        {
-            m_term_width = atoi (value);
-        }
-    }
+    // There should not be any global variables at the Debugger level.
 }
 
 void
@@ -736,6 +734,12 @@
     {
         value.AppendString (ScriptInterpreter::LanguageToString (m_script_lang).c_str());
     }
+    else if (var_name == TermWidthVarName())
+    {
+        StreamString width_str;
+        width_str.Printf ("%d", m_term_width);
+        value.AppendString (width_str.GetData());
+    }
 }
 
 void
@@ -769,14 +773,7 @@
 Debugger::DebuggerSettingsController::GetGlobalSettingsValue (const ConstString &var_name,
                                                               StringList &value)
 {
-    static ConstString term_width_name ("term-width");
-  
-    if (var_name == term_width_name)
-    {
-        StreamString width_str;
-        width_str.Printf ("%d", m_term_width);
-        value.AppendString (width_str.GetData());
-    }
+    // There should not be any global variables at the Debugger level.
 }
 
 bool
@@ -845,6 +842,14 @@
     return script_lang_var_name;
 }
 
+const ConstString &
+DebuggerInstanceSettings::TermWidthVarName ()
+{
+    static ConstString term_width_var_name ("term-width");
+
+    return term_width_var_name;
+}
+
 //--------------------------------------------------
 // DebuggerSettingsController Variable Tables
 //--------------------------------------------------
@@ -854,7 +859,8 @@
 Debugger::DebuggerSettingsController::global_settings_table[] =
 {
   //{ "var-name",    var-type,      "default", enum-table, init'd, hidden, "help-text"},
-    { "term-width" , eSetVarTypeInt, "80"    , NULL,       false , false , "The maximum number of columns to use for displaying text." },
+  // The Debugger level global table should always be empty; all Debugger settable variables should be instance
+  // variables.
     {  NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL }
 };
 
@@ -864,6 +870,7 @@
 Debugger::DebuggerSettingsController::instance_settings_table[] =
 {
   //{ "var-name",     var-type ,        "default", enum-table, init'd, hidden, "help-text"},
+    { "term-width" , eSetVarTypeInt, "80"    , NULL,       false , false , "The maximum number of columns to use for displaying text." },
     { "script-lang" , eSetVarTypeString, "python", NULL,       false,  false,  "The script language to be used for evaluating user-written scripts." },
     { "prompt"      , eSetVarTypeString, "(lldb)", NULL,       false,  false,  "The debugger command line prompt displayed for the user." },
     {  NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL }

Modified: lldb/trunk/source/Core/UserSettingsController.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=113474&r1=113473&r2=113474&view=diff
==============================================================================
--- lldb/trunk/source/Core/UserSettingsController.cpp (original)
+++ lldb/trunk/source/Core/UserSettingsController.cpp Thu Sep  9 01:25:08 2010
@@ -84,7 +84,7 @@
                     full_name.Printf ("%s.%s", prefix, entry.var_name);
                 else
                     full_name.Printf ("%s", entry.var_name);
-                SetVariable (full_name.GetData(), entry.default_value, lldb::eVarSetOperationAssign, false);
+                SetVariable (full_name.GetData(), entry.default_value, lldb::eVarSetOperationAssign, false, "");
             }
             else if ((entry.var_type == lldb::eSetVarTypeEnum)
                      && (entry.enum_values != NULL))
@@ -95,7 +95,7 @@
                 else
                     full_name.Printf ("%s", entry.var_name);
                 SetVariable (full_name.GetData(), entry.enum_values[0].string_value, lldb::eVarSetOperationAssign,
-                             false);
+                             false, "");
             }
         }
         global_initialized = true;
@@ -215,6 +215,7 @@
                                      const char *value, 
                                      const lldb::VarSetOperationType op,
                                      const bool override,
+                                     const char *debugger_instance_name,
                                      const char *index_value)
 {
     Error err;
@@ -298,8 +299,28 @@
                             value = entry->enum_values[0].string_value;
                     }
 
-                    m_default_settings->UpdateInstanceSettingsVariable (const_var_name, index_value, value, 
-                                                                        default_name, *entry, op, err, true);
+                    if ((m_settings.level_name.GetLength() > 0)
+                        || strlen (debugger_instance_name) == 0)
+                      {
+                        // Set the default settings
+                        m_default_settings->UpdateInstanceSettingsVariable (const_var_name, index_value, value, 
+                                                                            default_name, *entry, op, err, true);
+                      }
+                    else
+                      {
+                        // We're at the Debugger level; find the correct debugger instance and set those settings
+                        StreamString tmp_name;
+                        if (debugger_instance_name[0] != '[')
+                            tmp_name.Printf ("[%s]", debugger_instance_name);
+                        else
+                            tmp_name.Printf ("%s", debugger_instance_name);
+                        ConstString dbg_name (tmp_name.GetData());
+                        InstanceSettings *dbg_settings = FindSettingsForInstance (dbg_name);
+                        if (dbg_settings)
+                            dbg_settings->UpdateInstanceSettingsVariable (const_var_name, index_value, value, dbg_name,
+                                                                          *entry, op, err, false);
+                      }
+
                     if (override)
                     {
                         OverrideAllInstances (const_var_name, value, op, index_value, err);
@@ -428,7 +449,8 @@
                                 new_name += '.';
                             new_name += names.GetArgumentAtIndex (j);
                         }
-                        return child->SetVariable (new_name.c_str(), value, op, override, index_value);
+                        return child->SetVariable (new_name.c_str(), value, op, override, debugger_instance_name,
+                                                   index_value);
                     }
                 }
                 if (!found)
@@ -450,7 +472,8 @@
 }
 
 StringList
-UserSettingsController::GetVariable (const char *full_dot_name, lldb::SettableVariableType &var_type)
+UserSettingsController::GetVariable (const char *full_dot_name, lldb::SettableVariableType &var_type, 
+                                     const char *debugger_instance_name)
 {
     Args names = UserSettingsController::BreakNameIntoPieces (full_dot_name);
     ConstString const_var_name;
@@ -496,7 +519,7 @@
                         new_name += '.';
                     new_name += names.GetArgumentAtIndex (j);
                 }
-                return child->GetVariable (new_name.c_str(), var_type);
+                return child->GetVariable (new_name.c_str(), var_type, debugger_instance_name);
             }
         }
 
@@ -530,8 +553,24 @@
                     }
                     else 
                     {
-                        // No valid instance name; assume they want the default settings.
-                        m_default_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value);
+                        if (m_settings.level_name.GetLength() > 0)
+                        {
+                            // No valid instance name; assume they want the default settings.
+                            m_default_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value);
+                        }
+                        else
+                        {
+                            // We're at the Debugger level;  use the debugger's instance settings.
+                            StreamString tmp_name;
+                            if (debugger_instance_name[0] != '[')
+                                tmp_name.Printf ("[%s]", debugger_instance_name);
+                            else
+                                tmp_name.Printf ("%s", debugger_instance_name);
+                            ConstString dbg_name (debugger_instance_name);
+                            InstanceSettings *dbg_settings = FindSettingsForInstance (dbg_name);
+                            if (dbg_settings)
+                                dbg_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value);
+                        }
                     }
                 }
             }
@@ -555,7 +594,21 @@
         else if (instance_entry)
         {
             var_type = instance_entry->var_type;
-            m_default_settings->GetInstanceSettingsValue  (*instance_entry, const_var_name, value);
+            if (m_settings.level_name.GetLength() > 0)
+                m_default_settings->GetInstanceSettingsValue  (*instance_entry, const_var_name, value);
+            else
+            {
+                // We're at the Debugger level;  use the debugger's instance settings.
+                StreamString tmp_name;
+                if (debugger_instance_name[0] != '[')
+                    tmp_name.Printf ("[%s]", debugger_instance_name);
+                else
+                    tmp_name.Printf ("%s", debugger_instance_name);
+                ConstString dbg_name (tmp_name.GetData());
+                InstanceSettings *dbg_settings = FindSettingsForInstance (dbg_name);
+                if (dbg_settings)
+                    dbg_settings->GetInstanceSettingsValue (*instance_entry, const_var_name, value);
+            }
         }
     }
 
@@ -1081,7 +1134,8 @@
             full_var_name.Printf ("%s.%s", current_prefix.c_str(), entry.var_name);
         else
             full_var_name.Printf ("%s", entry.var_name);
-        StringList value = root->GetVariable (full_var_name.GetData(), var_type);
+        StringList value = root->GetVariable (full_var_name.GetData(), var_type, 
+                                              interpreter.GetDebugger().GetInstanceName().AsCString());
         description.Clear();
         if (value.GetSize() == 1)   
             description.Printf ("%s (%s) = '%s'", full_var_name.GetData(), GetTypeString (entry.var_type),
@@ -1099,7 +1153,8 @@
 
     root->GetAllInstanceVariableValues (interpreter, result_stream);
     root->GetAllPendingSettingValues (result_stream);
-    root->GetAllDefaultSettingValues (result_stream);
+    if (root->GetLevelName().GetLength() > 0)               // Don't bother with default values for Debugger level.
+         root->GetAllDefaultSettingValues (result_stream);
 
 
     // Now, recurse across all children.

Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=113474&r1=113473&r2=113474&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Thu Sep  9 01:25:08 2010
@@ -64,7 +64,9 @@
     std::string lang_name = ScriptInterpreter::LanguageToString (script_language);
     StreamString var_name;
     var_name.Printf ("[%s].script-lang", dbg_name);
-    debugger.GetSettingsController()->SetVariable (var_name.GetData(), lang_name.c_str(), lldb::eVarSetOperationAssign, false);
+    debugger.GetSettingsController()->SetVariable (var_name.GetData(), lang_name.c_str(), 
+                                                   lldb::eVarSetOperationAssign, false, 
+                                                   m_debugger.GetInstanceName().AsCString());
 }
 
 void
@@ -140,7 +142,8 @@
     const char *dbg_name = GetDebugger().GetInstanceName().AsCString();
     StreamString var_name;
     var_name.Printf ("[%s].script-lang", dbg_name);
-    value = Debugger::GetSettingsController()->GetVariable (var_name.GetData(), var_type);
+    value = Debugger::GetSettingsController()->GetVariable (var_name.GetData(), var_type, 
+                                                            m_debugger.GetInstanceName().AsCString());
     bool success;
     script_language = Args::StringToScriptLanguage (value.GetStringAtIndex(0), lldb::eScriptLanguageDefault, &success);
     
@@ -777,7 +780,7 @@
     const char *instance_name = GetDebugger().GetInstanceName().AsCString();
     StreamString var_name;
     var_name.Printf ("[%s].prompt", instance_name);
-    return Debugger::GetSettingsController()->GetVariable (var_name.GetData(), var_type).GetStringAtIndex(0);
+    return Debugger::GetSettingsController()->GetVariable (var_name.GetData(), var_type, instance_name).GetStringAtIndex(0);
 }
 
 void
@@ -786,7 +789,8 @@
     const char *instance_name = GetDebugger().GetInstanceName().AsCString();
     StreamString name_str;
     name_str.Printf ("[%s].prompt", instance_name);
-    Debugger::GetSettingsController()->SetVariable (name_str.GetData(), new_prompt, lldb::eVarSetOperationAssign, false);
+    Debugger::GetSettingsController()->SetVariable (name_str.GetData(), new_prompt, lldb::eVarSetOperationAssign, 
+                                                    false, m_debugger.GetInstanceName().AsCString());
 }
 
 void
@@ -1037,7 +1041,8 @@
 {
     lldb::SettableVariableType var_type;
     const char *width_value = 
-                            Debugger::GetSettingsController()->GetVariable ("term-width", var_type).GetStringAtIndex(0);
+      Debugger::GetSettingsController()->GetVariable ("term-width", var_type,
+                                                      m_debugger.GetInstanceName().AsCString()).GetStringAtIndex(0);
     int max_columns = atoi (width_value);
     // Sanity check max_columns, to cope with emacs shell mode with TERM=dumb
     // (0 rows; 0 columns;).
@@ -1128,7 +1133,7 @@
           
           complete_command_name.Printf ("%s %s", prefix, command_name);
 
-          if (sub_cmd_obj->HelpTextContainsWord (search_word))
+          if (sub_cmd_obj->HelpTextContainsWord (search_word, *this))
           {
               commands_found.AppendString (complete_command_name.GetData());
               commands_help.AppendString (sub_cmd_obj->GetHelp());
@@ -1152,7 +1157,7 @@
         const char *command_name = pos->first.c_str();
         CommandObject *cmd_obj = pos->second.get();
 
-        if (cmd_obj->HelpTextContainsWord (search_word))
+        if (cmd_obj->HelpTextContainsWord (search_word, *this))
         {
             commands_found.AppendString (command_name);
             commands_help.AppendString (cmd_obj->GetHelp());

Modified: lldb/trunk/source/Interpreter/CommandObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=113474&r1=113473&r2=113474&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandObject.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandObject.cpp Thu Sep  9 01:25:08 2010
@@ -177,7 +177,8 @@
             else
             {
                 // No error string, output the usage information into result
-                options->GenerateOptionUsage (result.GetErrorStream(), this);
+                options->GenerateOptionUsage (result.GetErrorStream(), this,
+                                              interpreter.GetDebugger().GetInstanceName().AsCString());
             }
             // Set the return status to failed (this was an error).
             result.SetStatus (eReturnStatusFailed);
@@ -396,7 +397,7 @@
 }
 
 bool
-CommandObject::HelpTextContainsWord (const char *search_word)
+CommandObject::HelpTextContainsWord (const char *search_word, CommandInterpreter &interpreter)
 {
     const char *short_help;
     const char *long_help;
@@ -421,7 +422,7 @@
         && GetOptions() != NULL)
     {
         StreamString usage_help;
-        GetOptions()->GenerateOptionUsage (usage_help, this);
+        GetOptions()->GenerateOptionUsage (usage_help, this, interpreter.GetDebugger().GetInstanceName().AsCString());
         if (usage_help.GetSize() > 0)
         {
             const char *usage_text = usage_help.GetData();

Modified: lldb/trunk/source/Interpreter/Options.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=113474&r1=113473&r2=113474&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/Options.cpp (original)
+++ lldb/trunk/source/Interpreter/Options.cpp Thu Sep  9 01:25:08 2010
@@ -362,11 +362,13 @@
 (
     Stream &strm,
     CommandObject *cmd,
+    const char *debugger_instance_name,
     const char *program_name)
 {
     lldb::SettableVariableType var_type;
     const char *screen_width_str = 
-                            Debugger::GetSettingsController()->GetVariable ("term-width", var_type).GetStringAtIndex(0);
+      Debugger::GetSettingsController()->GetVariable ("term-width", var_type,
+                                                      debugger_instance_name).GetStringAtIndex(0);
     uint32_t screen_width = atoi (screen_width_str);
     if (screen_width == 0)
         screen_width = 80;





More information about the lldb-commits mailing list