summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
authorCaroline Tice <ctice@apple.com>2010-09-27 00:30:10 +0000
committerCaroline Tice <ctice@apple.com>2010-09-27 00:30:10 +0000
commit1559a46b3eae1f941a67937abfafaf7d12f5ec1c (patch)
treed1de2061dc9a9fd0dfb0ffd0f8c73a1baa036a02 /lldb/source
parentc8a4973389b8d6b75c06c02112873e823a82a27b (diff)
downloadbcm5719-llvm-1559a46b3eae1f941a67937abfafaf7d12f5ec1c.tar.gz
bcm5719-llvm-1559a46b3eae1f941a67937abfafaf7d12f5ec1c.zip
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. llvm-svn: 114808
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/API/SBDebugger.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectSettings.cpp24
-rw-r--r--lldb/source/Core/UserSettingsController.cpp32
-rw-r--r--lldb/source/Target/Process.cpp16
-rw-r--r--lldb/source/Target/Target.cpp21
-rw-r--r--lldb/source/Target/TargetList.cpp3
-rw-r--r--lldb/source/Target/Thread.cpp16
7 files changed, 86 insertions, 28 deletions
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 81658d5ab59..d29a9f76303 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 f74bb70ad4b..dd60fd67933 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 a42dab00db8..6df92490dc5 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<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 @@ 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<std::string, InstanceSettings *>::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<std::string, lldb::InstanceSettingsSP>::iterator pending_pos;
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index a12377792d0..646a8e8a807 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 f81d9e5ef00..bbc41be9f8c 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 a4adf3f32fb..6033a60cf86 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 11273b180e1..d4fbfdf3bfb 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
//--------------------------------------------------------------
OpenPOWER on IntegriCloud