diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index 438ed587a651..3f97ec1d9eaf 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -365,6 +365,9 @@ public: static lldb::UserSettingsControllerSP GetSettingsController (bool finish = false); + void + UpdateInstanceName (); + //------------------------------------------------------------------ /// Construct with a shared pointer to a target, and the Process listener. //------------------------------------------------------------------ diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 74ebeaed4ea3..8e76ecb01877 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -132,6 +132,9 @@ public: static void SetDefaultArchitecture (ArchSpec new_arch); + void + UpdateInstanceName (); + //------------------------------------------------------------------ /// Broadcaster event bits definitions. //------------------------------------------------------------------ diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h index 3aad792236aa..8be1851641a4 100644 --- a/lldb/include/lldb/Target/Thread.h +++ b/lldb/include/lldb/Target/Thread.h @@ -159,6 +159,9 @@ public: lldb::DataBufferSP m_data_sp; }; + void + UpdateInstanceName (); + static lldb::UserSettingsControllerSP GetSettingsController (bool finish = false); diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 81658d5ab597..d29a9f76303f 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -581,7 +581,7 @@ SBDebugger::SetInternalVariable (const char *var_name, const char *value, const { 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); diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp index f74bb70ad4be..dd60fd679335 100644 --- a/lldb/source/Commands/CommandObjectSettings.cpp +++ b/lldb/source/Commands/CommandObjectSettings.cpp @@ -194,7 +194,7 @@ CommandObjectSettingsSet::HandleArgumentCompletion (Args &input, CommandObjectSettingsSet::CommandOptions::CommandOptions () : Options (), - m_override (false), + m_override (true), m_reset (false) { } @@ -206,7 +206,7 @@ CommandObjectSettingsSet::CommandOptions::~CommandOptions () 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 @@ CommandObjectSettingsSet::CommandOptions::SetOptionValue (int option_idx, const switch (short_option) { - case 'o': - m_override = true; + case 'n': + m_override = false; break; case 'r': m_reset = true; @@ -243,7 +243,7 @@ CommandObjectSettingsSet::CommandOptions::ResetOptionValues () { Options::ResetOptionValues (); - m_override = false; + m_override = true; m_reset = false; } @@ -510,7 +510,7 @@ CommandObjectSettingsRemove::Execute ( Args& command, 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 @@ CommandObjectSettingsReplace::Execute ( Args& command, 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 @@ CommandObjectSettingsInsertBefore::Execute ( Args& 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 @@ CommandObjectSettingsInsertAfter::Execute ( Args& co 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 @@ CommandObjectSettingsAppend::~CommandObjectSettingsAppend () } bool -CommandObjectSettingsAppend::Execute ( Args& command, - CommandReturnObject &result) +CommandObjectSettingsAppend::Execute (Args& command, + CommandReturnObject &result) { UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); @@ -954,7 +954,7 @@ CommandObjectSettingsAppend::Execute ( Args& command, Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationAppend, - false, + true, m_interpreter.GetDebugger().GetInstanceName().AsCString()); if (err.Fail ()) { diff --git a/lldb/source/Core/UserSettingsController.cpp b/lldb/source/Core/UserSettingsController.cpp index a42dab00db8e..6df92490dc55 100644 --- a/lldb/source/Core/UserSettingsController.cpp +++ b/lldb/source/Core/UserSettingsController.cpp @@ -347,14 +347,14 @@ UserSettingsController::SetVariable (const char *full_dot_name, OverrideAllInstances (const_var_name, value, op, index_value, err); // Update all pending records as well. - std::map::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::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 @@ UserSettingsController::RenameInstanceSettings (const char *old_name, const char // 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::iterator pos; @@ -2185,7 +2191,7 @@ UserSettingsController::RenameInstanceSettings (const char *old_name, const char 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::iterator pending_pos; diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index a12377792d0b..646a8e8a807d 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -87,6 +87,8 @@ Process::Process(Target &target, Listener &listener) : 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 @@ Process::GetSettingsController (bool finish) 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/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index f81d9e5ef00f..bbc41be9f8c1 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -425,6 +425,8 @@ Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files) m_scratch_ast_context_ap.reset (new ClangASTContext(target_triple.GetCString())); } } + + UpdateInstanceName(); } @@ -792,6 +794,21 @@ Target::SetDefaultArchitecture (ArchSpec new_arch) 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 @@ TargetInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry, 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/lldb/source/Target/TargetList.cpp b/lldb/source/Target/TargetList.cpp index a4adf3f32fb7..6033a60cf86d 100644 --- a/lldb/source/Target/TargetList.cpp +++ b/lldb/source/Target/TargetList.cpp @@ -101,6 +101,9 @@ TargetList::CreateTarget target_sp->SetExecutableModule (exe_module_sp, get_dependent_files); } } + + if (target_sp.get()) + target_sp->UpdateInstanceName(); if (target_sp.get()) { diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index 11273b180e10..d4fbfdf3bfb4 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -62,6 +62,7 @@ Thread::Thread (Process &process, lldb::tid_t tid) : log->Printf ("%p Thread::Thread(tid = 0x%4.4x)", this, GetID()); QueueFundamentalPlan(true); + UpdateInstanceName(); } @@ -938,6 +939,21 @@ Thread::GetSettingsController (bool finish) 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 //--------------------------------------------------------------