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.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@114808 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/Process.cpp b/source/Target/Process.cpp
index a123777..646a8e8 100644
--- a/source/Target/Process.cpp
+++ b/source/Target/Process.cpp
@@ -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
 //--------------------------------------------------------------
diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp
index f81d9e5..bbc41be 100644
--- a/source/Target/Target.cpp
+++ b/source/Target/Target.cpp
@@ -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;
 
diff --git a/source/Target/TargetList.cpp b/source/Target/TargetList.cpp
index a4adf3f..6033a60 100644
--- a/source/Target/TargetList.cpp
+++ b/source/Target/TargetList.cpp
@@ -101,6 +101,9 @@
             target_sp->SetExecutableModule (exe_module_sp, get_dependent_files);
         }
     }
+
+    if (target_sp.get())
+        target_sp->UpdateInstanceName();
     
     if (target_sp.get())
     {
diff --git a/source/Target/Thread.cpp b/source/Target/Thread.cpp
index 11273b1..d4fbfdf 100644
--- a/source/Target/Thread.cpp
+++ b/source/Target/Thread.cpp
@@ -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
 //--------------------------------------------------------------