[Lldb-commits] [lldb] r113370 - in /lldb/trunk: include/lldb/Core/Debugger.h include/lldb/Core/UserSettingsController.h include/lldb/Target/Process.h include/lldb/Target/Thread.h source/Core/Debugger.cpp source/Core/UserSettingsController.cpp source/Target/Process.cpp source/Target/Thread.cpp

Caroline Tice ctice at apple.com
Wed Sep 8 10:48:55 PDT 2010


Author: ctice
Date: Wed Sep  8 12:48:55 2010
New Revision: 113370

URL: http://llvm.org/viewvc/llvm-project?rev=113370&view=rev
Log:
Make sure creating a pending instance doesn't also trigger creating a live instance; also make sure creating a
pending instance uses the specified instance name rather than creating a new one; add brackets to instance names
when searching for and removing pending instances.


Modified:
    lldb/trunk/include/lldb/Core/Debugger.h
    lldb/trunk/include/lldb/Core/UserSettingsController.h
    lldb/trunk/include/lldb/Target/Process.h
    lldb/trunk/include/lldb/Target/Thread.h
    lldb/trunk/source/Core/Debugger.cpp
    lldb/trunk/source/Core/UserSettingsController.cpp
    lldb/trunk/source/Target/Process.cpp
    lldb/trunk/source/Target/Thread.cpp

Modified: lldb/trunk/include/lldb/Core/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=113370&r1=113369&r2=113370&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Wed Sep  8 12:48:55 2010
@@ -40,7 +40,7 @@
 {
 public:
     
-    DebuggerInstanceSettings (UserSettingsController &owner, const char *name = NULL);
+    DebuggerInstanceSettings (UserSettingsController &owner, bool live_instance = true, const char *name = NULL);
 
     DebuggerInstanceSettings (const DebuggerInstanceSettings &rhs);
 
@@ -124,7 +124,7 @@
     protected:
 
         lldb::InstanceSettingsSP
-        CreateNewInstanceSettings ();
+        CreateNewInstanceSettings (const char *instance_name);
 
         bool
         ValidTermWidthValue (const char *value, Error err);

Modified: lldb/trunk/include/lldb/Core/UserSettingsController.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UserSettingsController.h?rev=113370&r1=113369&r2=113370&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/UserSettingsController.h (original)
+++ lldb/trunk/include/lldb/Core/UserSettingsController.h Wed Sep  8 12:48:55 2010
@@ -61,7 +61,7 @@
     // Pure virtual functions, which all sub-classes must implement.
 
     virtual lldb::InstanceSettingsSP
-    CreateNewInstanceSettings () = 0;
+    CreateNewInstanceSettings (const char *instance_name) = 0;
   
     virtual void
     UpdateGlobalVariable (const ConstString &var_name,
@@ -334,7 +334,7 @@
 {
 public:
 
-    InstanceSettings (UserSettingsController &owner, const char *instance_name);
+    InstanceSettings (UserSettingsController &owner, const char *instance_name, bool live_instance = true);
 
     InstanceSettings (const InstanceSettings &rhs);
 

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=113370&r1=113369&r2=113370&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Wed Sep  8 12:48:55 2010
@@ -41,7 +41,7 @@
 {
 public:
 
-    ProcessInstanceSettings (UserSettingsController &owner, const char *name = NULL);
+    ProcessInstanceSettings (UserSettingsController &owner, bool live_instance = true, const char *name = NULL);
   
     ProcessInstanceSettings (const ProcessInstanceSettings &rhs);
 
@@ -251,7 +251,7 @@
     protected:
 
         lldb::InstanceSettingsSP
-        CreateNewInstanceSettings ();
+        CreateNewInstanceSettings (const char *instance_name);
 
         static lldb::OptionEnumValueElement g_plugins[];
 

Modified: lldb/trunk/include/lldb/Target/Thread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=113370&r1=113369&r2=113370&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Thread.h (original)
+++ lldb/trunk/include/lldb/Target/Thread.h Wed Sep  8 12:48:55 2010
@@ -29,7 +29,7 @@
 {
 public:
 
-    ThreadInstanceSettings (UserSettingsController &owner, const char *name = NULL);
+    ThreadInstanceSettings (UserSettingsController &owner, bool live_instance = true, const char *name = NULL);
   
     ThreadInstanceSettings (const ThreadInstanceSettings &rhs);
 
@@ -112,7 +112,7 @@
     protected:
 
         lldb::InstanceSettingsSP
-        CreateNewInstanceSettings ();
+        CreateNewInstanceSettings (const char *instance_name);
 
     private:
 

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=113370&r1=113369&r2=113370&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Wed Sep  8 12:48:55 2010
@@ -565,7 +565,8 @@
     UserSettingsController ("", lldb::UserSettingsControllerSP()),
     m_term_width (80)
 {
-    m_default_settings.reset (new DebuggerInstanceSettings (*this, InstanceSettings::GetDefaultName().AsCString()));
+    m_default_settings.reset (new DebuggerInstanceSettings (*this, false, 
+                                                            InstanceSettings::GetDefaultName().AsCString()));
 }
 
 Debugger::DebuggerSettingsController::~DebuggerSettingsController ()
@@ -574,9 +575,10 @@
 
 
 lldb::InstanceSettingsSP
-Debugger::DebuggerSettingsController::CreateNewInstanceSettings ()
+Debugger::DebuggerSettingsController::CreateNewInstanceSettings (const char *instance_name)
 {
-    DebuggerInstanceSettings *new_settings = new DebuggerInstanceSettings (*(Debugger::GetSettingsController().get()));
+    DebuggerInstanceSettings *new_settings = new DebuggerInstanceSettings (*(Debugger::GetSettingsController().get()),
+                                                                           false, instance_name);
     lldb::InstanceSettingsSP new_settings_sp (new_settings);
     return new_settings_sp;
 }
@@ -626,12 +628,13 @@
 //  class DebuggerInstanceSettings
 //--------------------------------------------------
 
-DebuggerInstanceSettings::DebuggerInstanceSettings (UserSettingsController &owner, const char *name) :
-    InstanceSettings (owner, (name == NULL ? CreateInstanceName ().AsCString() : name)),
+DebuggerInstanceSettings::DebuggerInstanceSettings (UserSettingsController &owner, bool live_instance,
+                                                    const char *name) :
+    InstanceSettings (owner, (name == NULL ? CreateInstanceName ().AsCString() : name), live_instance),
     m_prompt (),
     m_script_lang ()
 {
-    if (name == NULL)
+    if (name == NULL && live_instance)
     {
         const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name);
         CopyInstanceSettings (pending_settings, false);

Modified: lldb/trunk/source/Core/UserSettingsController.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=113370&r1=113369&r2=113370&view=diff
==============================================================================
--- lldb/trunk/source/Core/UserSettingsController.cpp (original)
+++ lldb/trunk/source/Core/UserSettingsController.cpp Wed Sep  8 12:48:55 2010
@@ -47,10 +47,10 @@
     if (parent)
     parent->RegisterChild (controller_sp);
 
-	controller_sp->CreateSettingsVector (global_settings, true);
-	controller_sp->CreateSettingsVector (instance_settings, false);
+    controller_sp->CreateSettingsVector (global_settings, true);
+    controller_sp->CreateSettingsVector (instance_settings, false);
 
-	controller_sp->InitializeGlobalVariables ();
+    controller_sp->InitializeGlobalVariables ();
     controller_sp->CreateDefaultInstanceSettings ();
 
     return true;
@@ -565,8 +565,17 @@
 void
 UserSettingsController::RemovePendingSettings (const ConstString &instance_name)
 {
+    StreamString tmp_name;
+
+    // Add surrounding brackets to instance name if not already present.
+
+    if (instance_name.AsCString()[0] != '[')
+        tmp_name.Printf ("[%s]", instance_name.AsCString());
+    else
+        tmp_name.Printf ("%s", instance_name.AsCString());
+
+    std::string instance_name_str (tmp_name.GetData());
     std::map<std::string, lldb::InstanceSettingsSP>::iterator pos;
-    std::string instance_name_str (instance_name.AsCString());
     Mutex::Locker locker (m_pending_settings_mutex);
 
     m_pending_settings.erase (instance_name_str);
@@ -576,7 +585,16 @@
 UserSettingsController::FindPendingSettings (const ConstString &instance_name)
 {
     std::map<std::string, lldb::InstanceSettingsSP>::iterator pos;
-    std::string instance_name_str (instance_name.AsCString());
+    StreamString tmp_name;
+
+    // Add surrounding brackets to instance name if not already present.
+
+    if (instance_name.AsCString()[0] != '[')
+        tmp_name.Printf ("[%s]", instance_name.AsCString());
+    else
+        tmp_name.Printf ("%s", instance_name.AsCString());
+
+    std::string instance_name_str (tmp_name.GetData());  // Need std::string for std::map look-up
 
     {   // Scope for mutex.
         Mutex::Locker locker (m_pending_settings_mutex);
@@ -655,9 +673,7 @@
       }
     else
       {
-        lldb::InstanceSettingsSP default_settings_sp =  
-                                                   m_pending_settings[InstanceSettings::GetDefaultName().AsCString()];
-        lldb::InstanceSettingsSP new_settings_sp = CreateNewInstanceSettings ();
+        lldb::InstanceSettingsSP new_settings_sp = CreateNewInstanceSettings (instance_name.AsCString());
         CopyDefaultSettings (new_settings_sp, instance_name, true);
         m_pending_settings[name_str] = new_settings_sp;
         return new_settings_sp;
@@ -1861,11 +1877,12 @@
 // class InstanceSettings
 //----------------------------------------------------------------------
 
-InstanceSettings::InstanceSettings (UserSettingsController &owner, const char *instance_name) :
+InstanceSettings::InstanceSettings (UserSettingsController &owner, const char *instance_name, bool live_instance) :
     m_owner (owner),
     m_instance_name (instance_name)
 {
-    if (m_instance_name != InstanceSettings::GetDefaultName())
+    if ((m_instance_name != InstanceSettings::GetDefaultName())
+        && live_instance)
         m_owner.RegisterInstanceSettings (this);
 }
 

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=113370&r1=113369&r2=113370&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Wed Sep  8 12:48:55 2010
@@ -1951,7 +1951,8 @@
 Process::ProcessSettingsController::ProcessSettingsController () :
     UserSettingsController ("process", Debugger::GetSettingsController())
 {
-    m_default_settings.reset (new ProcessInstanceSettings (*this, InstanceSettings::GetDefaultName().AsCString()));
+    m_default_settings.reset (new ProcessInstanceSettings (*this, false,
+                                                           InstanceSettings::GetDefaultName().AsCString()));
 }
 
 Process::ProcessSettingsController::~ProcessSettingsController ()
@@ -1959,9 +1960,10 @@
 }
 
 lldb::InstanceSettingsSP
-Process::ProcessSettingsController::CreateNewInstanceSettings ()
+Process::ProcessSettingsController::CreateNewInstanceSettings (const char *instance_name)
 {
-    ProcessInstanceSettings *new_settings = new ProcessInstanceSettings (*(Process::GetSettingsController().get()));
+    ProcessInstanceSettings *new_settings = new ProcessInstanceSettings (*(Process::GetSettingsController().get()),
+                                                                         false, instance_name);
     lldb::InstanceSettingsSP new_settings_sp (new_settings);
     return new_settings_sp;
 }
@@ -1970,8 +1972,9 @@
 // class ProcessInstanceSettings
 //--------------------------------------------------------------
 
-ProcessInstanceSettings::ProcessInstanceSettings (UserSettingsController &owner, const char *name) :
-    InstanceSettings (owner, (name == NULL ? CreateInstanceName().AsCString() : name)), 
+ProcessInstanceSettings::ProcessInstanceSettings (UserSettingsController &owner, bool live_instance, 
+                                                  const char *name) :
+  InstanceSettings (owner, (name == NULL ? CreateInstanceName().AsCString() : name), live_instance), 
     m_run_args (),
     m_env_vars (),
     m_input_path (),
@@ -1980,7 +1983,7 @@
     m_plugin (),
     m_disable_aslr (true)
 {
-    if (m_instance_name != InstanceSettings::GetDefaultName())
+    if (m_instance_name != InstanceSettings::GetDefaultName() && live_instance)
     {
         const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name);
         CopyInstanceSettings (pending_settings,false);

Modified: lldb/trunk/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=113370&r1=113369&r2=113370&view=diff
==============================================================================
--- lldb/trunk/source/Target/Thread.cpp (original)
+++ lldb/trunk/source/Target/Thread.cpp Wed Sep  8 12:48:55 2010
@@ -945,7 +945,8 @@
 Thread::ThreadSettingsController::ThreadSettingsController () :
     UserSettingsController ("thread", Process::GetSettingsController())
 {
-    m_default_settings.reset (new ThreadInstanceSettings (*this, InstanceSettings::GetDefaultName().AsCString()));
+    m_default_settings.reset (new ThreadInstanceSettings (*this, false, 
+                                                          InstanceSettings::GetDefaultName().AsCString()));
 }
 
 Thread::ThreadSettingsController::~ThreadSettingsController ()
@@ -953,9 +954,10 @@
 }
 
 lldb::InstanceSettingsSP
-Thread::ThreadSettingsController::CreateNewInstanceSettings ()
+Thread::ThreadSettingsController::CreateNewInstanceSettings (const char *instance_name)
 {
-    ThreadInstanceSettings *new_settings = new ThreadInstanceSettings (*(Thread::GetSettingsController().get()));
+    ThreadInstanceSettings *new_settings = new ThreadInstanceSettings (*(Thread::GetSettingsController().get()),
+                                                                       false, instance_name);
     lldb::InstanceSettingsSP new_settings_sp (new_settings);
     return new_settings_sp;
 }
@@ -964,13 +966,13 @@
 // class ThreadInstanceSettings
 //--------------------------------------------------------------
 
-ThreadInstanceSettings::ThreadInstanceSettings (UserSettingsController &owner, const char *name) :
-    InstanceSettings (owner, (name == NULL ? CreateInstanceName().AsCString() : name)), 
+ThreadInstanceSettings::ThreadInstanceSettings (UserSettingsController &owner, bool live_instance, const char *name) :
+    InstanceSettings (owner, (name == NULL ? CreateInstanceName().AsCString() : name), live_instance), 
     m_avoid_regexp_ap ()
 {
     // FIXME: This seems like generic code, why was it duplicated (with the slight difference that
     // DebuggerInstanceSettings checks name, not m_instance_name below) in Process & Debugger?
-    if (m_instance_name != InstanceSettings::GetDefaultName())
+    if (m_instance_name != InstanceSettings::GetDefaultName() && live_instance)
     {
         const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name);
         CopyInstanceSettings (pending_settings,false);





More information about the lldb-commits mailing list