aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectSettings.cpp
diff options
context:
space:
mode:
authorCaroline Tice <ctice@apple.com>2010-12-10 00:26:54 +0000
committerCaroline Tice <ctice@apple.com>2010-12-10 00:26:54 +0000
commit2d5289d621c29073b1bf09c1d8cfcb4c0dc811a9 (patch)
tree62e1bc99943577b9111ba7fdac7f4d1665675a11 /lldb/source/Commands/CommandObjectSettings.cpp
parent957373fc8455a1d0ec34028b6e2a9cfe8a1d4bd0 (diff)
downloadllvm-2d5289d621c29073b1bf09c1d8cfcb4c0dc811a9.zip
llvm-2d5289d621c29073b1bf09c1d8cfcb4c0dc811a9.tar.gz
llvm-2d5289d621c29073b1bf09c1d8cfcb4c0dc811a9.tar.bz2
Various fixes mostly relating to the User Settings stuff:
- Added new utility function to Arg, GetQuotedCommandString, which re-assembles the args into a string, replacing quotes that were originally there. - Modified user settings stuff to always show individual elements when printing out arrays and dictionaries. - Added more extensive help to 'settings set', explaining more about dictionaries and arrays (including current dictionary syntax). - Fixed bug in user settings where quotes were being stripped and lost, so that sometimes array or dictionary elements that ought to have been a single element were being split up. llvm-svn: 121438
Diffstat (limited to 'lldb/source/Commands/CommandObjectSettings.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectSettings.cpp40
1 files changed, 33 insertions, 7 deletions
diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp
index dc71b64..9e80fc5 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'))