[Lldb-commits] [lldb] r114808 - in /lldb/trunk: include/lldb/Target/Process.h include/lldb/Target/Target.h include/lldb/Target/Thread.h source/API/SBDebugger.cpp source/Commands/CommandObjectSettings.cpp source/Core/UserSettingsController.cpp source/Target/Process.cpp source/Target/Target.cpp source/Target/TargetList.cpp source/Target/Thread.cpp

Caroline Tice ctice at apple.com
Sun Sep 26 17:30:11 PDT 2010


Author: ctice
Date: Sun Sep 26 19:30:10 2010
New Revision: 114808

URL: http://llvm.org/viewvc/llvm-project?rev=114808&view=rev
Log:

Create more useful instance names for target, process and thread instances.

Change default 'set' behavior so that all instance settings for the specified variable will be
updated, unless the "-n" ("--no_override") command options is specified.


Modified:
    lldb/trunk/include/lldb/Target/Process.h
    lldb/trunk/include/lldb/Target/Target.h
    lldb/trunk/include/lldb/Target/Thread.h
    lldb/trunk/source/API/SBDebugger.cpp
    lldb/trunk/source/Commands/CommandObjectSettings.cpp
    lldb/trunk/source/Core/UserSettingsController.cpp
    lldb/trunk/source/Target/Process.cpp
    lldb/trunk/source/Target/Target.cpp
    lldb/trunk/source/Target/TargetList.cpp
    lldb/trunk/source/Target/Thread.cpp

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=114808&r1=114807&r2=114808&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Sun Sep 26 19:30:10 2010
@@ -365,6 +365,9 @@
     static lldb::UserSettingsControllerSP
     GetSettingsController (bool finish = false);
 
+    void
+    UpdateInstanceName ();
+
     //------------------------------------------------------------------
     /// Construct with a shared pointer to a target, and the Process listener.
     //------------------------------------------------------------------

Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=114808&r1=114807&r2=114808&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Sun Sep 26 19:30:10 2010
@@ -132,6 +132,9 @@
     static void
     SetDefaultArchitecture (ArchSpec new_arch);
 
+    void
+    UpdateInstanceName ();
+
     //------------------------------------------------------------------
     /// Broadcaster event bits definitions.
     //------------------------------------------------------------------

Modified: lldb/trunk/include/lldb/Target/Thread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=114808&r1=114807&r2=114808&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Thread.h (original)
+++ lldb/trunk/include/lldb/Target/Thread.h Sun Sep 26 19:30:10 2010
@@ -159,6 +159,9 @@
         lldb::DataBufferSP m_data_sp;
     };
 
+    void
+    UpdateInstanceName ();
+
     static lldb::UserSettingsControllerSP
     GetSettingsController (bool finish = false);
 

Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=114808&r1=114807&r2=114808&view=diff
==============================================================================
--- lldb/trunk/source/API/SBDebugger.cpp (original)
+++ lldb/trunk/source/API/SBDebugger.cpp Sun Sep 26 19:30:10 2010
@@ -581,7 +581,7 @@
 {
     lldb::UserSettingsControllerSP root_settings_controller = lldb_private::Debugger::GetSettingsController();
 
-    Error err = root_settings_controller->SetVariable (var_name, value, lldb::eVarSetOperationAssign, false,
+    Error err = root_settings_controller->SetVariable (var_name, value, lldb::eVarSetOperationAssign, true,
                                                        debugger_instance_name);
     SBError sb_error;
     sb_error.SetError (err);

Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=114808&r1=114807&r2=114808&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Sun Sep 26 19:30:10 2010
@@ -194,7 +194,7 @@
 
 CommandObjectSettingsSet::CommandOptions::CommandOptions () :
     Options (),
-    m_override (false),
+    m_override (true),
     m_reset (false)
 {
 }
@@ -206,7 +206,7 @@
 lldb::OptionDefinition
 CommandObjectSettingsSet::CommandOptions::g_option_table[] =
 {
-    { LLDB_OPT_SET_1, false, "override", 'o', no_argument, NULL, NULL, NULL, "Causes already existing instances and pending settings to use this new value.  This option only makes sense when setting default values." },
+    { LLDB_OPT_SET_1, false, "no_override", 'n', no_argument, NULL, NULL, NULL, "Prevents already existing instances and pending settings from being assigned this new value.  Using this option means that only the default or specified instance setting values will be updated." },
     { LLDB_OPT_SET_2, false, "reset", 'r', no_argument,   NULL, NULL, NULL, "Causes value to be reset to the original default for this variable.  No value needs to be specified when this option is used." },
 };
 
@@ -224,8 +224,8 @@
 
     switch (short_option)
     {
-        case 'o':
-            m_override = true;
+        case 'n':
+            m_override = false;
             break;
         case 'r':
             m_reset = true;
@@ -243,7 +243,7 @@
 {
     Options::ResetOptionValues ();
     
-    m_override = false;
+    m_override = true;
     m_reset = false;
 }
 
@@ -510,7 +510,7 @@
     Error err = root_settings->SetVariable (var_name_string.c_str(), 
                                             NULL, 
                                             lldb::eVarSetOperationRemove,  
-                                            false, 
+                                            true, 
                                             m_interpreter.GetDebugger().GetInstanceName().AsCString(),
                                             index_value_string.c_str());
     if (err.Fail ())
@@ -622,7 +622,7 @@
         Error err = root_settings->SetVariable (var_name_string.c_str(), 
                                                 var_value, 
                                                 lldb::eVarSetOperationReplace, 
-                                                false, 
+                                                true, 
                                                 m_interpreter.GetDebugger().GetInstanceName().AsCString(),
                                                 index_value_string.c_str());
         if (err.Fail ())
@@ -736,7 +736,7 @@
         Error err = root_settings->SetVariable (var_name_string.c_str(), 
                                                 var_value, 
                                                 lldb::eVarSetOperationInsertBefore,
-                                                false, 
+                                                true, 
                                                 m_interpreter.GetDebugger().GetInstanceName().AsCString(),
                                                 index_value_string.c_str());
         if (err.Fail ())
@@ -851,7 +851,7 @@
         Error err = root_settings->SetVariable (var_name_string.c_str(), 
                                                 var_value, 
                                                 lldb::eVarSetOperationInsertAfter,
-                                                false, 
+                                                true, 
                                                 m_interpreter.GetDebugger().GetInstanceName().AsCString(), 
                                                 index_value_string.c_str());
         if (err.Fail ())
@@ -911,8 +911,8 @@
 }
 
 bool
-CommandObjectSettingsAppend::Execute (                        Args& command,
-                                     CommandReturnObject &result)
+CommandObjectSettingsAppend::Execute (Args& command,
+                                      CommandReturnObject &result)
 {
     UserSettingsControllerSP root_settings = Debugger::GetSettingsController ();
 
@@ -954,7 +954,7 @@
         Error err = root_settings->SetVariable (var_name_string.c_str(), 
                                                 var_value, 
                                                 lldb::eVarSetOperationAppend, 
-                                                false, 
+                                                true, 
                                                 m_interpreter.GetDebugger().GetInstanceName().AsCString());
         if (err.Fail ())
         {

Modified: lldb/trunk/source/Core/UserSettingsController.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=114808&r1=114807&r2=114808&view=diff
==============================================================================
--- lldb/trunk/source/Core/UserSettingsController.cpp (original)
+++ lldb/trunk/source/Core/UserSettingsController.cpp Sun Sep 26 19:30:10 2010
@@ -347,14 +347,14 @@
                         OverrideAllInstances (const_var_name, value, op, index_value, err);
 
                         // Update all pending records as well.
-                        std::map<std::string, lldb::InstanceSettingsSP>::iterator pos, end = m_pending_settings.end();
-                        for (pos = m_pending_settings.begin(); pos != end; end++)
-                        {
-                            const ConstString instance_name (pos->first.c_str());
-                            lldb::InstanceSettingsSP setting_sp = pos->second;
-                            setting_sp->UpdateInstanceSettingsVariable (const_var_name, index_value, value, 
-                                                                        instance_name, *entry, op, err, true);
-                        }
+//                        std::map<std::string, lldb::InstanceSettingsSP>::iterator pos, end = m_pending_settings.end();
+//                        for (pos = m_pending_settings.begin(); pos != end; end++)
+//                        {
+//                            const ConstString instance_name (pos->first.c_str());
+//                            lldb::InstanceSettingsSP setting_sp = pos->second;
+//                            setting_sp->UpdateInstanceSettingsVariable (const_var_name, index_value, value, 
+//                                                                        instance_name, *entry, op, err, true);
+//                        }
                     }
                 }
             }
@@ -2164,18 +2164,24 @@
     // list, then this is not a setting that can be renamed.
 
     if ((old_name_key[0] != '[') || (old_name_key[old_name_key.size() -1] != ']'))
-      {
+    {
         StreamString tmp_str;
         tmp_str.Printf ("[%s]", old_name);
           old_name_key = tmp_str.GetData();
-      }
+    }
 
     if ((new_name_key[0] != '[') || (new_name_key[new_name_key.size() -1] != ']'))
-      {
+    {
         StreamString tmp_str;
         tmp_str.Printf ("[%s]", new_name);
         new_name_key = tmp_str.GetData();
-      }
+    }
+
+    if (old_name_key.compare (new_name_key) == 0) 
+        return;
+
+    size_t len = new_name_key.length();
+    std::string stripped_new_name = new_name_key.substr (1, len-2);  // new name without the '[ ]'
 
     std::map<std::string, InstanceSettings *>::iterator pos;
 
@@ -2185,7 +2191,7 @@
         InstanceSettings *live_settings = pos->second;
 
         // Rename the settings.
-        live_settings->ChangeInstanceName (new_name_key);
+        live_settings->ChangeInstanceName (stripped_new_name);
 
         // Now see if there are any pending settings for the new name; if so, copy them into live_settings.
         std::map<std::string,  lldb::InstanceSettingsSP>::iterator pending_pos;

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=114808&r1=114807&r2=114808&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Sun Sep 26 19:30:10 2010
@@ -87,6 +87,8 @@
     m_objc_object_printer(*this),
     m_persistent_vars()
 {
+    UpdateInstanceName();
+
     Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT);
     if (log)
         log->Printf ("%p Process::Process()", this);
@@ -1884,6 +1886,20 @@
     return g_settings_controller;
 }
 
+void
+Process::UpdateInstanceName ()
+{
+    ModuleSP module_sp = GetTarget().GetExecutableModule();
+    if (module_sp)
+    {
+        StreamString sstr;
+        sstr.Printf ("%s", module_sp->GetFileSpec().GetFilename().AsCString());
+                    
+	Process::GetSettingsController()->RenameInstanceSettings (GetInstanceName().AsCString(),
+                                                                  sstr.GetData());
+    }
+}
+
 //--------------------------------------------------------------
 // class Process::SettingsController
 //--------------------------------------------------------------

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=114808&r1=114807&r2=114808&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Sun Sep 26 19:30:10 2010
@@ -425,6 +425,8 @@
             m_scratch_ast_context_ap.reset (new ClangASTContext(target_triple.GetCString()));
         }
     }
+
+    UpdateInstanceName();
 }
 
 
@@ -792,6 +794,21 @@
                                                        lldb::eVarSetOperationAssign, false, "[]");
 }
 
+void
+Target::UpdateInstanceName ()
+{
+    StreamString sstr;
+    
+    ModuleSP module_sp = GetExecutableModule();
+    if (module_sp)
+    {
+        sstr.Printf ("%s_%s", module_sp->GetFileSpec().GetFilename().AsCString(), 
+                     module_sp->GetArchitecture().AsCString());
+	Target::GetSettingsController()->RenameInstanceSettings (GetInstanceName().AsCString(),
+								 sstr.GetData());
+    }
+}
+
 //--------------------------------------------------------------
 // class Target::SettingsController
 //--------------------------------------------------------------
@@ -948,9 +965,9 @@
 const ConstString
 TargetInstanceSettings::CreateInstanceName ()
 {
-    static int instance_count = 1;
     StreamString sstr;
-
+    static int instance_count = 1;
+    
     sstr.Printf ("target_%d", instance_count);
     ++instance_count;
 

Modified: lldb/trunk/source/Target/TargetList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/TargetList.cpp?rev=114808&r1=114807&r2=114808&view=diff
==============================================================================
--- lldb/trunk/source/Target/TargetList.cpp (original)
+++ lldb/trunk/source/Target/TargetList.cpp Sun Sep 26 19:30:10 2010
@@ -101,6 +101,9 @@
             target_sp->SetExecutableModule (exe_module_sp, get_dependent_files);
         }
     }
+
+    if (target_sp.get())
+        target_sp->UpdateInstanceName();
     
     if (target_sp.get())
     {

Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=114808&r1=114807&r2=114808&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Sun Sep 26 19:30:10 2010
@@ -62,6 +62,7 @@
         log->Printf ("%p Thread::Thread(tid = 0x%4.4x)", this, GetID());
 
     QueueFundamentalPlan(true);
+    UpdateInstanceName();
 }
 
 
@@ -938,6 +939,21 @@
     return g_settings_controller;
 }
 
+void
+Thread::UpdateInstanceName ()
+{
+    StreamString sstr;
+    const char *name = GetName();
+
+    if (name && name[0] != '\0')
+        sstr.Printf ("%s", name);
+    else if ((GetIndexID() != 0) || (GetID() != 0))
+        sstr.Printf ("0x%4.4x", GetIndexID(), GetID());
+
+    if (sstr.GetSize() > 0)
+	Thread::GetSettingsController()->RenameInstanceSettings (GetInstanceName().AsCString(), sstr.GetData());
+}
+
 //--------------------------------------------------------------
 // class Thread::ThreadSettingsController
 //--------------------------------------------------------------





More information about the lldb-commits mailing list