diff options
-rw-r--r-- | lldb/include/lldb/Interpreter/Args.h | 3 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectSettings.cpp | 40 | ||||
-rw-r--r-- | lldb/source/Core/UserSettingsController.cpp | 27 | ||||
-rw-r--r-- | lldb/source/Interpreter/Args.cpp | 22 |
4 files changed, 79 insertions, 13 deletions
diff --git a/lldb/include/lldb/Interpreter/Args.h b/lldb/include/lldb/Interpreter/Args.h index 3a62fdee42f..1f1b92b924a 100644 --- a/lldb/include/lldb/Interpreter/Args.h +++ b/lldb/include/lldb/Interpreter/Args.h @@ -122,6 +122,9 @@ public: bool GetCommandString (std::string &command); + bool + GetQuotedCommandString (std::string &command); + //------------------------------------------------------------------ /// Gets the number of arguments left in this command object. /// diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp index dc71b64a52b..9e80fc5360a 100644 --- a/lldb/source/Commands/CommandObjectSettings.cpp +++ b/lldb/source/Commands/CommandObjectSettings.cpp @@ -90,6 +90,29 @@ CommandObjectSettingsSet::CommandObjectSettingsSet (CommandInterpreter &interpre // Push the data for the first argument into the m_arguments vector. m_arguments.push_back (arg1); m_arguments.push_back (arg2); + + SetHelpLong ( +"When setting a dictionary or array variable, you can set multiple entries \n\ +at once by giving the values to the set command. For example: \n\ +\n\ +(lldb) settings set target.process.run-args value1 value2 value3 \n\ +(lldb) settings set target.process.env-vars [\"MYPATH\"]=~/.:/usr/bin [\"SOME_ENV_VAR\"]=12345 \n\ +\n\ +(lldb) settings show target.process.run-args \n\ + [0]: 'value1' \n\ + [1]: 'value2' \n\ + [3]: 'value3' \n\ +(lldb) settings show target.process.env-vars \n\ + 'MYPATH=~/.:/usr/bin'\n\ + 'SOME_ENV_VAR=12345' \n\ +\n\ +Note the special syntax for setting a dictionary element: [\"<key>\"]=<value> \n\ +\n\ +Warning: The 'set' command re-sets the entire array or dictionary. If you \n\ +just want to add, remove or update individual values (or add something to \n\ +the end), use one of the other settings sub-commands: append, replace, \n\ +insert-before or insert-after.\n"); + } CommandObjectSettingsSet::~CommandObjectSettingsSet() @@ -126,7 +149,7 @@ CommandObjectSettingsSet::Execute (Args& command, CommandReturnObject &result) const char *var_value; std::string value_string; - command.GetCommandString (value_string); + command.GetQuotedCommandString (value_string); var_value = value_string.c_str(); if (!m_options.m_reset @@ -342,14 +365,17 @@ CommandObjectSettingsShow::Execute (Args& command, if (value.GetSize() == 0) result.AppendMessageWithFormat ("%s%s = ''\n", variable_name, type_name); - else if (value.GetSize() == 1) + else if ((var_type != lldb::eSetVarTypeArray) && (var_type != lldb::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) { - result.AppendMessageWithFormat (" [%d]: '%s'\n", i, value.GetStringAtIndex (i)); + if (var_type == lldb::eSetVarTypeArray) + result.AppendMessageWithFormat (" [%d]: '%s'\n", i, value.GetStringAtIndex (i)); + else if (var_type == lldb::eSetVarTypeDictionary) + result.AppendMessageWithFormat (" '%s'\n", value.GetStringAtIndex (i)); } } result.SetStatus (eReturnStatusSuccessFinishNoResult); @@ -727,7 +753,7 @@ CommandObjectSettingsReplace::Execute ( Args& command, const char *var_value; std::string value_string; - command.GetCommandString (value_string); + command.GetQuotedCommandString (value_string); var_value = value_string.c_str(); if ((var_value == NULL) || (var_value[0] == '\0')) @@ -872,7 +898,7 @@ CommandObjectSettingsInsertBefore::Execute ( Args& const char *var_value; std::string value_string; - command.GetCommandString (value_string); + command.GetQuotedCommandString (value_string); var_value = value_string.c_str(); if ((var_value == NULL) || (var_value[0] == '\0')) @@ -1019,7 +1045,7 @@ CommandObjectSettingsInsertAfter::Execute ( Args& co const char *var_value; std::string value_string; - command.GetCommandString (value_string); + command.GetQuotedCommandString (value_string); var_value = value_string.c_str(); if ((var_value == NULL) || (var_value[0] == '\0')) @@ -1144,7 +1170,7 @@ CommandObjectSettingsAppend::Execute (Args& command, const char *var_value; std::string value_string; - command.GetCommandString (value_string); + command.GetQuotedCommandString (value_string); var_value = value_string.c_str(); if ((var_value == NULL) || (var_value[0] == '\0')) diff --git a/lldb/source/Core/UserSettingsController.cpp b/lldb/source/Core/UserSettingsController.cpp index 8b652a90cd0..fc8d1aab57f 100644 --- a/lldb/source/Core/UserSettingsController.cpp +++ b/lldb/source/Core/UserSettingsController.cpp @@ -780,18 +780,31 @@ UserSettingsController::GetAllDefaultSettingValues (StreamString &result_stream) m_default_settings->GetInstanceSettingsValue (entry, var_name, tmp_value, NULL); StreamString value_string; + bool multi_value = false; if (tmp_value.GetSize() == 1) value_string.Printf ("%s", tmp_value.GetStringAtIndex (0)); else { for (int j = 0; j < tmp_value.GetSize(); ++j) - value_string.Printf ("%s ", tmp_value.GetStringAtIndex (j)); + { + if (entry.var_type == lldb::eSetVarTypeArray) + value_string.Printf ("\n [%d]: '%s'", j, tmp_value.GetStringAtIndex (j)); + else if (entry.var_type == lldb::eSetVarTypeDictionary) + value_string.Printf ("\n '%s'", tmp_value.GetStringAtIndex (j)); + } + multi_value = true; } if (! parent_prefix.empty()) - result_stream.Printf ("%s.%s (%s) = '%s'\n", prefix, var_name.AsCString(), - UserSettingsController::GetTypeString (entry.var_type), value_string.GetData()); + { + if (multi_value) + result_stream.Printf ("%s.%s (%s):%s\n", prefix, var_name.AsCString(), + UserSettingsController::GetTypeString (entry.var_type), value_string.GetData()); + else + result_stream.Printf ("%s.%s (%s) = '%s'\n", prefix, var_name.AsCString(), + UserSettingsController::GetTypeString (entry.var_type), value_string.GetData()); + } } } @@ -1366,10 +1379,12 @@ UserSettingsController::GetAllVariableValues (CommandInterpreter &interpreter, value.GetStringAtIndex (0)); else { - description.Printf ("%s (%s) = '", full_var_name.GetData(), GetTypeString (entry.var_type)); + description.Printf ("%s (%s):\n", full_var_name.GetData(), GetTypeString (entry.var_type)); for (int j = 0; j < value.GetSize(); ++j) - description.Printf ("%s ", value.GetStringAtIndex (j)); - description.Printf ("'"); + if (entry.var_type == lldb::eSetVarTypeArray) + description.Printf (" [%d]: '%s'\n", j, value.GetStringAtIndex (j)); + else if (entry.var_type == lldb::eSetVarTypeDictionary) + description.Printf (" '%s'\n", value.GetStringAtIndex (j)); } result_stream.Printf ("%s\n", description.GetData()); diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp index b0e448ee9bd..e5264e593bd 100644 --- a/lldb/source/Interpreter/Args.cpp +++ b/lldb/source/Interpreter/Args.cpp @@ -93,6 +93,28 @@ Args::GetCommandString (std::string &command) return argc > 0; } +bool +Args::GetQuotedCommandString (std::string &command) +{ + command.clear (); + int argc = GetArgumentCount (); + for (int i = 0; i < argc; ++i) + { + if (i > 0) + command += ' '; + char quote_char = m_args_quote_char[i]; + if (quote_char != '\0') + { + command += quote_char; + command += m_argv[i]; + command += quote_char; + } + else + command += m_argv[i]; + } + return argc > 0; +} + void Args::SetCommandString (const char *command, size_t len) { |