General cleanup on the UserSettingsController stuff. There were 5 different

places that were dumping values for the settings. Centralized all of the
value dumping into a single place. When dumping values that aren't strings
we no longer surround the value with single quotes. When dumping values that
are strings, surround the string value with double quotes. When dumping array
values, assume they are always string values, and don't put quotes around
dictionary values.

llvm-svn: 129826
This commit is contained in:
Greg Clayton 2011-04-19 22:32:36 +00:00
parent 742668144e
commit 4c20717a8f
7 changed files with 427 additions and 434 deletions

View File

@ -135,41 +135,53 @@ public:
static void static void
FindAllSettingsDescriptions (CommandInterpreter &interpreter, FindAllSettingsDescriptions (CommandInterpreter &interpreter,
lldb::UserSettingsControllerSP root, const lldb::UserSettingsControllerSP& usc_sp,
std::string &current_prefix, const const char *current_prefix,
Stream &result_stream, Stream &result_stream,
Error &err); Error &err);
static void static void
FindSettingsDescriptions (CommandInterpreter &interpreter, FindSettingsDescriptions (CommandInterpreter &interpreter,
lldb::UserSettingsControllerSP root, const lldb::UserSettingsControllerSP& usc_sp,
std::string &current_prefix, const char *current_prefix,
const char *search_name, const char *search_name,
Stream &result_stream, Stream &result_stream,
Error &err); Error &err);
static void static void
SearchAllSettingsDescriptions (CommandInterpreter &interpreter, SearchAllSettingsDescriptions (CommandInterpreter &interpreter,
lldb::UserSettingsControllerSP root, const lldb::UserSettingsControllerSP& usc_sp,
std::string &current_prefix, const char *current_prefix,
const char *search_word, const char *search_word,
Stream &result_stream); Stream &result_stream);
static void static void
GetAllVariableValues (CommandInterpreter &interpreter, GetAllVariableValues (CommandInterpreter &interpreter,
lldb::UserSettingsControllerSP root, const lldb::UserSettingsControllerSP& usc_sp,
std::string &current_prefix, const char *current_prefix,
Stream &result_stream, Stream &result_stream,
Error &err); Error &err);
static bool
DumpValue (CommandInterpreter &interpreter,
const lldb::UserSettingsControllerSP& usc_sp,
const char *variable_dot_name,
Stream &strm);
static bool
DumpValue (const char *variable_dot_name,
SettableVariableType var_type,
const StringList &variable_value,
Stream &strm);
static int static int
CompleteSettingsNames (lldb::UserSettingsControllerSP root_settings, CompleteSettingsNames (const lldb::UserSettingsControllerSP& usc_sp,
Args &partial_setting_name_pieces, Args &partial_setting_name_pieces,
bool &word_complete, bool &word_complete,
StringList &matches); StringList &matches);
static int static int
CompleteSettingsValue (lldb::UserSettingsControllerSP root_settings, CompleteSettingsValue (const lldb::UserSettingsControllerSP& usc_sp,
const char *full_dot_name, const char *full_dot_name,
const char *partial_value, const char *partial_value,
bool &word_complete, bool &word_complete,
@ -341,10 +353,12 @@ protected:
private: private:
UserSettingDefinition m_settings; UserSettingDefinition m_settings;
typedef std::map<std::string,InstanceSettings*> InstanceSettingsMap;
std::vector<lldb::UserSettingsControllerSP> m_children; std::vector<lldb::UserSettingsControllerSP> m_children;
std::map <std::string, lldb::InstanceSettingsSP> m_pending_settings; std::map <std::string, lldb::InstanceSettingsSP> m_pending_settings;
std::map <std::string, InstanceSettings *> m_live_settings; // live settings should never be NULL (hence 'live') InstanceSettingsMap m_live_settings; // live settings should never be NULL (hence 'live')
mutable Mutex m_children_mutex; mutable Mutex m_children_mutex;
mutable Mutex m_pending_settings_mutex; mutable Mutex m_pending_settings_mutex;
mutable Mutex m_live_settings_mutex; mutable Mutex m_live_settings_mutex;

View File

@ -99,9 +99,12 @@ CommandObjectApropos::Execute
StreamString settings_search_results; StreamString settings_search_results;
lldb::UserSettingsControllerSP root = Debugger::GetSettingsController (); lldb::UserSettingsControllerSP root = Debugger::GetSettingsController ();
std::string settings_prefix = root->GetLevelName().AsCString(); const char *settings_prefix = root->GetLevelName().GetCString();
UserSettingsController::SearchAllSettingsDescriptions (m_interpreter, root, settings_prefix, search_word, UserSettingsController::SearchAllSettingsDescriptions (m_interpreter,
root,
settings_prefix,
search_word,
settings_search_results); settings_search_results);
if (settings_search_results.GetSize() > 0) if (settings_search_results.GetSize() > 0)

View File

@ -30,27 +30,15 @@ CommandObjectMultiwordSettings::CommandObjectMultiwordSettings (CommandInterpret
"A set of commands for manipulating internal settable debugger variables.", "A set of commands for manipulating internal settable debugger variables.",
"settings <command> [<command-options>]") "settings <command> [<command-options>]")
{ {
bool status; LoadSubCommand ("set", CommandObjectSP (new CommandObjectSettingsSet (interpreter)));
LoadSubCommand ("show", CommandObjectSP (new CommandObjectSettingsShow (interpreter)));
CommandObjectSP set_command_object (new CommandObjectSettingsSet (interpreter)); LoadSubCommand ("list", CommandObjectSP (new CommandObjectSettingsList (interpreter)));
CommandObjectSP show_command_object (new CommandObjectSettingsShow (interpreter)); LoadSubCommand ("remove", CommandObjectSP (new CommandObjectSettingsRemove (interpreter)));
CommandObjectSP list_command_object (new CommandObjectSettingsList (interpreter)); LoadSubCommand ("replace", CommandObjectSP (new CommandObjectSettingsReplace (interpreter)));
CommandObjectSP remove_command_object (new CommandObjectSettingsRemove (interpreter)); LoadSubCommand ("insert-before", CommandObjectSP (new CommandObjectSettingsInsertBefore (interpreter)));
CommandObjectSP replace_command_object (new CommandObjectSettingsReplace (interpreter)); LoadSubCommand ("insert-after", CommandObjectSP (new CommandObjectSettingsInsertAfter (interpreter)));
CommandObjectSP insert_before_command_object (new CommandObjectSettingsInsertBefore (interpreter)); LoadSubCommand ("append", CommandObjectSP (new CommandObjectSettingsAppend (interpreter)));
CommandObjectSP insert_after_command_object (new CommandObjectSettingsInsertAfter(interpreter)); LoadSubCommand ("clear", CommandObjectSP (new CommandObjectSettingsClear (interpreter)));
CommandObjectSP append_command_object (new CommandObjectSettingsAppend(interpreter));
CommandObjectSP clear_command_object (new CommandObjectSettingsClear(interpreter));
status = LoadSubCommand ("set", set_command_object);
status = LoadSubCommand ("show", show_command_object);
status = LoadSubCommand ("list", list_command_object);
status = LoadSubCommand ("remove", remove_command_object);
status = LoadSubCommand ("replace", replace_command_object);
status = LoadSubCommand ("insert-before", insert_before_command_object);
status = LoadSubCommand ("insert-after", insert_after_command_object);
status = LoadSubCommand ("append", append_command_object);
status = LoadSubCommand ("clear", clear_command_object);
} }
CommandObjectMultiwordSettings::~CommandObjectMultiwordSettings () CommandObjectMultiwordSettings::~CommandObjectMultiwordSettings ()
@ -123,7 +111,7 @@ CommandObjectSettingsSet::~CommandObjectSettingsSet()
bool bool
CommandObjectSettingsSet::Execute (Args& command, CommandReturnObject &result) CommandObjectSettingsSet::Execute (Args& command, CommandReturnObject &result)
{ {
UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
const int argc = command.GetArgumentCount (); const int argc = command.GetArgumentCount ();
@ -161,11 +149,11 @@ CommandObjectSettingsSet::Execute (Args& command, CommandReturnObject &result)
} }
else else
{ {
Error err = root_settings->SetVariable (var_name_string.c_str(), Error err = usc_sp->SetVariable (var_name_string.c_str(),
var_value, var_value,
eVarSetOperationAssign, eVarSetOperationAssign,
m_options.m_override, m_options.m_override,
m_interpreter.GetDebugger().GetInstanceName().AsCString()); m_interpreter.GetDebugger().GetInstanceName().AsCString());
if (err.Fail ()) if (err.Fail ())
{ {
result.AppendError (err.AsCString()); result.AppendError (err.AsCString());
@ -209,11 +197,11 @@ CommandObjectSettingsSet::HandleArgumentCompletion (Args &input,
&& completion_str.compare (matches.GetStringAtIndex(0)) == 0)) && completion_str.compare (matches.GetStringAtIndex(0)) == 0))
{ {
matches.Clear(); matches.Clear();
UserSettingsControllerSP root_settings = Debugger::GetSettingsController(); UserSettingsControllerSP usc_sp = Debugger::GetSettingsController();
if (cursor_index == 1) if (cursor_index == 1)
{ {
// The user is at the end of the variable name, which is complete and valid. // The user is at the end of the variable name, which is complete and valid.
UserSettingsController::CompleteSettingsValue (root_settings, UserSettingsController::CompleteSettingsValue (usc_sp,
input.GetArgumentAtIndex (1), // variable name input.GetArgumentAtIndex (1), // variable name
NULL, // empty value string NULL, // empty value string
word_complete, word_complete,
@ -222,7 +210,7 @@ CommandObjectSettingsSet::HandleArgumentCompletion (Args &input,
else else
{ {
// The user is partly into the variable value. // The user is partly into the variable value.
UserSettingsController::CompleteSettingsValue (root_settings, UserSettingsController::CompleteSettingsValue (usc_sp,
input.GetArgumentAtIndex (1), // variable name input.GetArgumentAtIndex (1), // variable name
completion_str.c_str(), // partial value string completion_str.c_str(), // partial value string
word_complete, word_complete,
@ -328,11 +316,10 @@ CommandObjectSettingsShow::~CommandObjectSettingsShow()
bool bool
CommandObjectSettingsShow::Execute (Args& command, CommandObjectSettingsShow::Execute (Args& command, CommandReturnObject &result)
CommandReturnObject &result)
{ {
UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
std::string current_prefix = root_settings->GetLevelName().AsCString(); const char *current_prefix = usc_sp->GetLevelName().GetCString();
Error err; Error err;
@ -341,48 +328,27 @@ CommandObjectSettingsShow::Execute (Args& command,
// The user requested to see the value of a particular variable. // The user requested to see the value of a particular variable.
SettableVariableType var_type; SettableVariableType var_type;
const char *variable_name = command.GetArgumentAtIndex (0); const char *variable_name = command.GetArgumentAtIndex (0);
StringList value = root_settings->GetVariable (variable_name, var_type, StringList value = usc_sp->GetVariable (variable_name,
m_interpreter.GetDebugger().GetInstanceName().AsCString(), var_type,
err); m_interpreter.GetDebugger().GetInstanceName().AsCString(),
err);
if (err.Fail ()) if (err.Fail ())
{ {
result.AppendError (err.AsCString()); result.AppendError (err.AsCString());
result.SetStatus (eReturnStatusFailed); result.SetStatus (eReturnStatusFailed);
} }
else else
{ {
StreamString tmp_str; UserSettingsController::DumpValue(m_interpreter, usc_sp, variable_name, result.GetOutputStream());
char *type_name = (char *) ""; result.SetStatus (eReturnStatusSuccessFinishResult);
if (var_type != eSetVarTypeNone)
{
tmp_str.Printf (" (%s)", UserSettingsController::GetTypeString (var_type));
type_name = (char *) tmp_str.GetData();
}
if (value.GetSize() == 0)
result.AppendMessageWithFormat ("%s%s = ''\n", variable_name, type_name);
else if ((var_type != eSetVarTypeArray) && (var_type != eSetVarTypeDictionary))
result.AppendMessageWithFormat ("%s%s = '%s'\n", variable_name, type_name, value.GetStringAtIndex (0));
else
{
result.AppendMessageWithFormat ("%s%s:\n", variable_name, type_name);
for (unsigned i = 0, e = value.GetSize(); i != e; ++i)
{
if (var_type == eSetVarTypeArray)
result.AppendMessageWithFormat (" [%d]: '%s'\n", i, value.GetStringAtIndex (i));
else if (var_type == eSetVarTypeDictionary)
result.AppendMessageWithFormat (" '%s'\n", value.GetStringAtIndex (i));
}
}
result.SetStatus (eReturnStatusSuccessFinishNoResult);
} }
} }
else else
{ {
UserSettingsController::GetAllVariableValues (m_interpreter, UserSettingsController::GetAllVariableValues (m_interpreter,
root_settings, usc_sp,
current_prefix, current_prefix,
result.GetOutputStream(), result.GetOutputStream(),
err); err);
@ -459,18 +425,17 @@ CommandObjectSettingsList::~CommandObjectSettingsList()
bool bool
CommandObjectSettingsList::Execute ( Args& command, CommandObjectSettingsList::Execute (Args& command, CommandReturnObject &result)
CommandReturnObject &result)
{ {
UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
std::string current_prefix = root_settings->GetLevelName().AsCString(); const char *current_prefix = usc_sp->GetLevelName().GetCString();
Error err; Error err;
if (command.GetArgumentCount() == 0) if (command.GetArgumentCount() == 0)
{ {
UserSettingsController::FindAllSettingsDescriptions (m_interpreter, UserSettingsController::FindAllSettingsDescriptions (m_interpreter,
root_settings, usc_sp,
current_prefix, current_prefix,
result.GetOutputStream(), result.GetOutputStream(),
err); err);
@ -479,7 +444,7 @@ CommandObjectSettingsList::Execute ( Args& command,
{ {
const char *search_name = command.GetArgumentAtIndex (0); const char *search_name = command.GetArgumentAtIndex (0);
UserSettingsController::FindSettingsDescriptions (m_interpreter, UserSettingsController::FindSettingsDescriptions (m_interpreter,
root_settings, usc_sp,
current_prefix, current_prefix,
search_name, search_name,
result.GetOutputStream(), result.GetOutputStream(),
@ -574,10 +539,9 @@ CommandObjectSettingsRemove::~CommandObjectSettingsRemove ()
} }
bool bool
CommandObjectSettingsRemove::Execute ( Args& command, CommandObjectSettingsRemove::Execute (Args& command, CommandReturnObject &result)
CommandReturnObject &result)
{ {
UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
const int argc = command.GetArgumentCount (); const int argc = command.GetArgumentCount ();
@ -611,12 +575,12 @@ CommandObjectSettingsRemove::Execute ( Args& command,
index_value_string = index_value; index_value_string = index_value;
Error err = root_settings->SetVariable (var_name_string.c_str(), Error err = usc_sp->SetVariable (var_name_string.c_str(),
NULL, NULL,
eVarSetOperationRemove, eVarSetOperationRemove,
true, true,
m_interpreter.GetDebugger().GetInstanceName().AsCString(), m_interpreter.GetDebugger().GetInstanceName().AsCString(),
index_value_string.c_str()); index_value_string.c_str());
if (err.Fail ()) if (err.Fail ())
{ {
result.AppendError (err.AsCString()); result.AppendError (err.AsCString());
@ -710,10 +674,9 @@ CommandObjectSettingsReplace::~CommandObjectSettingsReplace ()
} }
bool bool
CommandObjectSettingsReplace::Execute ( Args& command, CommandObjectSettingsReplace::Execute (Args& command, CommandReturnObject &result)
CommandReturnObject &result)
{ {
UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
const int argc = command.GetArgumentCount (); const int argc = command.GetArgumentCount ();
@ -761,12 +724,12 @@ CommandObjectSettingsReplace::Execute ( Args& command,
} }
else else
{ {
Error err = root_settings->SetVariable (var_name_string.c_str(), Error err = usc_sp->SetVariable (var_name_string.c_str(),
var_value, var_value,
eVarSetOperationReplace, eVarSetOperationReplace,
true, true,
m_interpreter.GetDebugger().GetInstanceName().AsCString(), m_interpreter.GetDebugger().GetInstanceName().AsCString(),
index_value_string.c_str()); index_value_string.c_str());
if (err.Fail ()) if (err.Fail ())
{ {
result.AppendError (err.AsCString()); result.AppendError (err.AsCString());
@ -855,10 +818,9 @@ CommandObjectSettingsInsertBefore::~CommandObjectSettingsInsertBefore ()
} }
bool bool
CommandObjectSettingsInsertBefore::Execute ( Args& command, CommandObjectSettingsInsertBefore::Execute (Args& command, CommandReturnObject &result)
CommandReturnObject &result)
{ {
UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
const int argc = command.GetArgumentCount (); const int argc = command.GetArgumentCount ();
@ -907,12 +869,12 @@ CommandObjectSettingsInsertBefore::Execute ( Args&
} }
else else
{ {
Error err = root_settings->SetVariable (var_name_string.c_str(), Error err = usc_sp->SetVariable (var_name_string.c_str(),
var_value, var_value,
eVarSetOperationInsertBefore, eVarSetOperationInsertBefore,
true, true,
m_interpreter.GetDebugger().GetInstanceName().AsCString(), m_interpreter.GetDebugger().GetInstanceName().AsCString(),
index_value_string.c_str()); index_value_string.c_str());
if (err.Fail ()) if (err.Fail ())
{ {
result.AppendError (err.AsCString()); result.AppendError (err.AsCString());
@ -1002,10 +964,9 @@ CommandObjectSettingsInsertAfter::~CommandObjectSettingsInsertAfter ()
} }
bool bool
CommandObjectSettingsInsertAfter::Execute ( Args& command, CommandObjectSettingsInsertAfter::Execute (Args& command, CommandReturnObject &result)
CommandReturnObject &result)
{ {
UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
const int argc = command.GetArgumentCount (); const int argc = command.GetArgumentCount ();
@ -1054,12 +1015,12 @@ CommandObjectSettingsInsertAfter::Execute ( Args& co
} }
else else
{ {
Error err = root_settings->SetVariable (var_name_string.c_str(), Error err = usc_sp->SetVariable (var_name_string.c_str(),
var_value, var_value,
eVarSetOperationInsertAfter, eVarSetOperationInsertAfter,
true, true,
m_interpreter.GetDebugger().GetInstanceName().AsCString(), m_interpreter.GetDebugger().GetInstanceName().AsCString(),
index_value_string.c_str()); index_value_string.c_str());
if (err.Fail ()) if (err.Fail ())
{ {
result.AppendError (err.AsCString()); result.AppendError (err.AsCString());
@ -1139,10 +1100,9 @@ CommandObjectSettingsAppend::~CommandObjectSettingsAppend ()
} }
bool bool
CommandObjectSettingsAppend::Execute (Args& command, CommandObjectSettingsAppend::Execute (Args& command, CommandReturnObject &result)
CommandReturnObject &result)
{ {
UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
const int argc = command.GetArgumentCount (); const int argc = command.GetArgumentCount ();
@ -1179,11 +1139,11 @@ CommandObjectSettingsAppend::Execute (Args& command,
} }
else else
{ {
Error err = root_settings->SetVariable (var_name_string.c_str(), Error err = usc_sp->SetVariable (var_name_string.c_str(),
var_value, var_value,
eVarSetOperationAppend, eVarSetOperationAppend,
true, true,
m_interpreter.GetDebugger().GetInstanceName().AsCString()); m_interpreter.GetDebugger().GetInstanceName().AsCString());
if (err.Fail ()) if (err.Fail ())
{ {
result.AppendError (err.AsCString()); result.AppendError (err.AsCString());
@ -1253,10 +1213,9 @@ CommandObjectSettingsClear::~CommandObjectSettingsClear ()
} }
bool bool
CommandObjectSettingsClear::Execute ( Args& command, CommandObjectSettingsClear::Execute (Args& command, CommandReturnObject &result)
CommandReturnObject &result)
{ {
UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
const int argc = command.GetArgumentCount (); const int argc = command.GetArgumentCount ();
@ -1275,11 +1234,11 @@ CommandObjectSettingsClear::Execute ( Args& command,
return false; return false;
} }
Error err = root_settings->SetVariable (var_name, Error err = usc_sp->SetVariable (var_name,
NULL, NULL,
eVarSetOperationClear, eVarSetOperationClear,
false, false,
m_interpreter.GetDebugger().GetInstanceName().AsCString()); m_interpreter.GetDebugger().GetInstanceName().AsCString());
if (err.Fail ()) if (err.Fail ())
{ {

File diff suppressed because it is too large Load Diff

View File

@ -1289,9 +1289,6 @@ Target::SettingsController::CreateInstanceSettings (const char *instance_name)
#define TSC_DEFAULT_ARCH "default-arch" #define TSC_DEFAULT_ARCH "default-arch"
#define TSC_EXPR_PREFIX "expr-prefix" #define TSC_EXPR_PREFIX "expr-prefix"
#define TSC_EXEC_LEVEL "execution-level"
#define TSC_EXEC_MODE "execution-mode"
#define TSC_EXEC_OS_TYPE "execution-os-type"
#define TSC_PREFER_DYNAMIC "prefer-dynamic-value" #define TSC_PREFER_DYNAMIC "prefer-dynamic-value"
@ -1310,27 +1307,6 @@ GetSettingNameForExpressionPrefix ()
return g_const_string; return g_const_string;
} }
static const ConstString &
GetSettingNameForExecutionLevel ()
{
static ConstString g_const_string (TSC_EXEC_LEVEL);
return g_const_string;
}
static const ConstString &
GetSettingNameForExecutionMode ()
{
static ConstString g_const_string (TSC_EXEC_MODE);
return g_const_string;
}
static const ConstString &
GetSettingNameForExecutionOSType ()
{
static ConstString g_const_string (TSC_EXEC_OS_TYPE);
return g_const_string;
}
static const ConstString & static const ConstString &
GetSettingNameForPreferDynamicValue () GetSettingNameForPreferDynamicValue ()
{ {

View File

@ -38,12 +38,12 @@ class AbbreviationsTestCase(TestBase):
patterns = ["Executing commands in '.*change_prompt.lldb'"]) patterns = ["Executing commands in '.*change_prompt.lldb'"])
self.expect("settings show prompt", self.expect("settings show prompt",
startstr = "prompt (string) = '[old-oak]'") startstr = 'prompt (string) = "[old-oak]"')
self.runCmd("settings set -r prompt") self.runCmd("settings set -r prompt")
self.expect("settings show prompt", self.expect("settings show prompt",
startstr = "prompt (string) = '(lldb) '") startstr = 'prompt (string) = "(lldb) "')
self.expect("lo li", self.expect("lo li",
@ -51,11 +51,11 @@ class AbbreviationsTestCase(TestBase):
self.runCmd("se se prompt Sycamore> ") self.runCmd("se se prompt Sycamore> ")
self.expect("se sh prompt", self.expect("se sh prompt",
startstr = "prompt (string) = 'Sycamore>'") startstr = 'prompt (string) = "Sycamore>"')
self.runCmd("se se -r prompt") self.runCmd("se se -r prompt")
self.expect("set sh prompt", self.expect("set sh prompt",
startstr = "prompt (string) = '(lldb) '") startstr = 'prompt (string) = "(lldb) "')
self.runCmd (r'''sc print "\n\n\tHello!\n"''') self.runCmd (r'''sc print "\n\n\tHello!\n"''')

View File

@ -35,11 +35,11 @@ class SettingsCommandTestCase(TestBase):
# Immediately test the setting. # Immediately test the setting.
self.expect("settings show prompt", SETTING_MSG("prompt"), self.expect("settings show prompt", SETTING_MSG("prompt"),
startstr = "prompt (string) = 'lldb2'") startstr = 'prompt (string) = "lldb2"')
# The overall display should also reflect the new setting. # The overall display should also reflect the new setting.
self.expect("settings show", SETTING_MSG("prompt"), self.expect("settings show", SETTING_MSG("prompt"),
substrs = ["prompt (string) = 'lldb2'"]) substrs = ['prompt (string) = "lldb2"'])
# Use '-r' option to reset to the original default prompt. # Use '-r' option to reset to the original default prompt.
self.runCmd("settings set -r prompt") self.runCmd("settings set -r prompt")
@ -51,11 +51,11 @@ class SettingsCommandTestCase(TestBase):
# Immediately test the setting. # Immediately test the setting.
self.expect("settings show term-width", SETTING_MSG("term-width"), self.expect("settings show term-width", SETTING_MSG("term-width"),
startstr = "term-width (int) = '70'") startstr = "term-width (int) = 70")
# The overall display should also reflect the new setting. # The overall display should also reflect the new setting.
self.expect("settings show", SETTING_MSG("term-width"), self.expect("settings show", SETTING_MSG("term-width"),
substrs = ["term-width (int) = '70'"]) substrs = ["term-width (int) = 70"])
def test_set_auto_confirm(self): def test_set_auto_confirm(self):
"""Test that after 'set auto-confirm true', manual confirmation should not kick in.""" """Test that after 'set auto-confirm true', manual confirmation should not kick in."""
@ -68,7 +68,7 @@ class SettingsCommandTestCase(TestBase):
# Immediately test the setting. # Immediately test the setting.
self.expect("settings show auto-confirm", SETTING_MSG("auto-confirm"), self.expect("settings show auto-confirm", SETTING_MSG("auto-confirm"),
startstr = "auto-confirm (boolean) = 'true'") startstr = "auto-confirm (boolean) = true")
# Now 'breakpoint delete' should just work fine without confirmation # Now 'breakpoint delete' should just work fine without confirmation
# prompt from the command interpreter. # prompt from the command interpreter.
@ -79,7 +79,7 @@ class SettingsCommandTestCase(TestBase):
# Restore the original setting of auto-confirm. # Restore the original setting of auto-confirm.
self.runCmd("settings set -r auto-confirm") self.runCmd("settings set -r auto-confirm")
self.expect("settings show auto-confirm", SETTING_MSG("auto-confirm"), self.expect("settings show auto-confirm", SETTING_MSG("auto-confirm"),
startstr = "auto-confirm (boolean) = 'false'") startstr = "auto-confirm (boolean) = false")
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
def test_run_args_and_env_vars_with_dsym(self): def test_run_args_and_env_vars_with_dsym(self):
@ -127,7 +127,7 @@ class SettingsCommandTestCase(TestBase):
# By default, inherit-env is 'true'. # By default, inherit-env is 'true'.
self.expect('settings show target.process.inherit-env', "Default inherit-env is 'true'", self.expect('settings show target.process.inherit-env', "Default inherit-env is 'true'",
startstr = "target.process.inherit-env (boolean) = 'true'") startstr = "target.process.inherit-env (boolean) = true")
# Set some host environment variables now. # Set some host environment variables now.
os.environ["MY_HOST_ENV_VAR1"] = "VAR1" os.environ["MY_HOST_ENV_VAR1"] = "VAR1"
@ -167,11 +167,11 @@ class SettingsCommandTestCase(TestBase):
self.expect("settings show target.process.error-path", self.expect("settings show target.process.error-path",
SETTING_MSG("target.process.error-path"), SETTING_MSG("target.process.error-path"),
startstr = "target.process.error-path (string) = 'stderr.txt'") startstr = 'target.process.error-path (string) = "stderr.txt"')
self.expect("settings show target.process.output-path", self.expect("settings show target.process.output-path",
SETTING_MSG("target.process.output-path"), SETTING_MSG("target.process.output-path"),
startstr = "target.process.output-path (string) = 'stdout.txt'") startstr = 'target.process.output-path (string) = "stdout.txt"')
self.runCmd("run", RUN_SUCCEEDED) self.runCmd("run", RUN_SUCCEEDED)
@ -201,31 +201,31 @@ class SettingsCommandTestCase(TestBase):
self.runCmd ("settings set -r target.process.env-vars") self.runCmd ("settings set -r target.process.env-vars")
self.runCmd ("settings set target.process.env-vars [\"MY_VAR\"]=some-value") self.runCmd ("settings set target.process.env-vars [\"MY_VAR\"]=some-value")
self.expect ("settings show target.process.env-vars", self.expect ("settings show target.process.env-vars",
substrs = [ "'MY_VAR=some-value'" ]) substrs = [ "MY_VAR=some-value" ])
self.runCmd ("settings set -r target.process.env-vars") self.runCmd ("settings set -r target.process.env-vars")
def test_print_array_setting(self): def test_print_array_setting(self):
self.runCmd ("settings set -r target.process.run-args") self.runCmd ("settings set -r target.process.run-args")
self.runCmd ("settings set target.process.run-args gobbledy-gook") self.runCmd ("settings set target.process.run-args gobbledy-gook")
self.expect ("settings show target.process.run-args", self.expect ("settings show target.process.run-args",
substrs = [ "[0]: 'gobbledy-gook'" ]) substrs = [ '[0]: "gobbledy-gook"' ])
self.runCmd ("settings set -r target.process.run-args") self.runCmd ("settings set -r target.process.run-args")
def test_settings_with_quotes (self): def test_settings_with_quotes (self):
self.runCmd ("settings set -r target.process.run-args") self.runCmd ("settings set -r target.process.run-args")
self.runCmd ("settings set target.process.run-args a b c") self.runCmd ("settings set target.process.run-args a b c")
self.expect ("settings show target.process.run-args", self.expect ("settings show target.process.run-args",
substrs = [ "[0]: 'a'", substrs = [ '[0]: "a"',
"[1]: 'b'", '[1]: "b"',
"[2]: 'c'" ]) '[2]: "c"' ])
self.runCmd ("settings set target.process.run-args 'a b c'") self.runCmd ("settings set target.process.run-args 'a b c'")
self.expect ("settings show target.process.run-args", self.expect ("settings show target.process.run-args",
substrs = [ "[0]: 'a b c'" ]) substrs = [ '[0]: "a b c"' ])
self.runCmd ("settings set -r target.process.run-args") self.runCmd ("settings set -r target.process.run-args")
self.runCmd ("settings set -r target.process.env-vars") self.runCmd ("settings set -r target.process.env-vars")
self.runCmd ("settings set target.process.env-vars [\"MY_FILE\"]='this is a file name with spaces.txt'") self.runCmd ('settings set target.process.env-vars ["MY_FILE"]="this is a file name with spaces.txt"')
self.expect ("settings show target.process.env-vars", self.expect ("settings show target.process.env-vars",
substrs = [ "'MY_FILE=this is a file name with spaces.txt'" ]) substrs = [ 'MY_FILE=this is a file name with spaces.txt' ])
self.runCmd ("settings set -r target.process.env-vars") self.runCmd ("settings set -r target.process.env-vars")
@ -238,18 +238,18 @@ class SettingsCommandTestCase(TestBase):
"thread-format (string) = ", "thread-format (string) = ",
"use-external-editor (boolean) = ", "use-external-editor (boolean) = ",
"auto-confirm (boolean) = ", "auto-confirm (boolean) = ",
"target.default-arch (string):", "target.default-arch (string) =",
"target.expr-prefix (string) = ", "target.expr-prefix (string) = ",
"target.process.run-args (array):", "target.process.run-args (array) =",
"target.process.env-vars (dictionary):", "target.process.env-vars (dictionary) =",
"target.process.inherit-env (boolean) = ", "target.process.inherit-env (boolean) = ",
"target.process.input-path (string) = ", "target.process.input-path (string) = ",
"target.process.output-path (string) = ", "target.process.output-path (string) = ",
"target.process.error-path (string) = ", "target.process.error-path (string) = ",
"target.process.plugin (enum):", "target.process.plugin (enum) =",
"target.process.disable-aslr (boolean) = ", "target.process.disable-aslr (boolean) = ",
"target.process.disable-stdio (boolean) = ", "target.process.disable-stdio (boolean) = ",
"target.process.thread.step-avoid-regexp (string):", "target.process.thread.step-avoid-regexp (string) =",
"target.process.thread.trace-thread (boolean) =" ]) "target.process.thread.trace-thread (boolean) =" ])