Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- CommandObjectSettings.cpp -------------------------------*- C++ -*-===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "CommandObjectSettings.h" |
| 10 | |
Eugene Zelenko | 3f18ea0 | 2016-02-24 02:05:55 +0000 | [diff] [blame] | 11 | #include "llvm/ADT/StringRef.h" |
| 12 | |
Zachary Turner | 3eb2b44 | 2017-03-22 23:33:16 +0000 | [diff] [blame] | 13 | #include "lldb/Host/OptionParser.h" |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 14 | #include "lldb/Interpreter/CommandCompletions.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 15 | #include "lldb/Interpreter/CommandInterpreter.h" |
| 16 | #include "lldb/Interpreter/CommandReturnObject.h" |
Zachary Turner | 633a29c | 2015-03-04 01:58:01 +0000 | [diff] [blame] | 17 | #include "lldb/Interpreter/OptionValueProperties.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 18 | |
| 19 | using namespace lldb; |
| 20 | using namespace lldb_private; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 21 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 22 | // CommandObjectSettingsSet |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 23 | |
Tatyana Krasnukha | 8fe53c49 | 2018-09-26 18:50:19 +0000 | [diff] [blame] | 24 | static constexpr OptionDefinition g_settings_set_options[] = { |
Zachary Turner | 1f0f5b5 | 2016-09-22 20:22:55 +0000 | [diff] [blame] | 25 | // clang-format off |
Jonas Devlieghere | 9c6c201 | 2018-10-24 22:04:20 +0000 | [diff] [blame] | 26 | { LLDB_OPT_SET_2, false, "global", 'g', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Apply the new value to the global default value." }, |
| 27 | { LLDB_OPT_SET_2, false, "force", 'f', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Force an empty value to be accepted as the default." } |
Zachary Turner | 1f0f5b5 | 2016-09-22 20:22:55 +0000 | [diff] [blame] | 28 | // clang-format on |
| 29 | }; |
| 30 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 31 | class CommandObjectSettingsSet : public CommandObjectRaw { |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 32 | public: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 33 | CommandObjectSettingsSet(CommandInterpreter &interpreter) |
| 34 | : CommandObjectRaw(interpreter, "settings set", |
Zachary Turner | a449698 | 2016-10-05 21:14:38 +0000 | [diff] [blame] | 35 | "Set the value of the specified debugger setting."), |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 36 | m_options() { |
| 37 | CommandArgumentEntry arg1; |
| 38 | CommandArgumentEntry arg2; |
| 39 | CommandArgumentData var_name_arg; |
| 40 | CommandArgumentData value_arg; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 41 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 42 | // Define the first (and only) variant of this arg. |
| 43 | var_name_arg.arg_type = eArgTypeSettingVariableName; |
| 44 | var_name_arg.arg_repetition = eArgRepeatPlain; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 45 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 46 | // There is only one variant this argument could be; put it into the |
| 47 | // argument entry. |
| 48 | arg1.push_back(var_name_arg); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 49 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 50 | // Define the first (and only) variant of this arg. |
| 51 | value_arg.arg_type = eArgTypeValue; |
| 52 | value_arg.arg_repetition = eArgRepeatPlain; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 53 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 54 | // There is only one variant this argument could be; put it into the |
| 55 | // argument entry. |
| 56 | arg2.push_back(value_arg); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 57 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 58 | // Push the data for the first argument into the m_arguments vector. |
| 59 | m_arguments.push_back(arg1); |
| 60 | m_arguments.push_back(arg2); |
| 61 | |
| 62 | SetHelpLong( |
| 63 | "\nWhen setting a dictionary or array variable, you can set multiple entries \ |
| 64 | at once by giving the values to the set command. For example:" |
| 65 | R"( |
Kate Stone | ea671fb | 2015-07-14 05:48:36 +0000 | [diff] [blame] | 66 | |
| 67 | (lldb) settings set target.run-args value1 value2 value3 |
| 68 | (lldb) settings set target.env-vars MYPATH=~/.:/usr/bin SOME_ENV_VAR=12345 |
| 69 | |
| 70 | (lldb) settings show target.run-args |
| 71 | [0]: 'value1' |
| 72 | [1]: 'value2' |
| 73 | [3]: 'value3' |
| 74 | (lldb) settings show target.env-vars |
| 75 | 'MYPATH=~/.:/usr/bin' |
| 76 | 'SOME_ENV_VAR=12345' |
| 77 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 78 | )" |
| 79 | "Warning: The 'set' command re-sets the entire array or dictionary. If you \ |
Kate Stone | ea671fb | 2015-07-14 05:48:36 +0000 | [diff] [blame] | 80 | just want to add, remove or update individual values (or add something to \ |
| 81 | the end), use one of the other settings sub-commands: append, replace, \ |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 82 | insert-before or insert-after."); |
| 83 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 84 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 85 | ~CommandObjectSettingsSet() override = default; |
| 86 | |
| 87 | // Overrides base class's behavior where WantsCompletion = |
| 88 | // !WantsRawCommandString. |
| 89 | bool WantsCompletion() override { return true; } |
| 90 | |
| 91 | Options *GetOptions() override { return &m_options; } |
| 92 | |
| 93 | class CommandOptions : public Options { |
| 94 | public: |
| 95 | CommandOptions() : Options(), m_global(false) {} |
| 96 | |
| 97 | ~CommandOptions() override = default; |
| 98 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 99 | Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, |
| 100 | ExecutionContext *execution_context) override { |
| 101 | Status error; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 102 | const int short_option = m_getopt_table[option_idx].val; |
| 103 | |
| 104 | switch (short_option) { |
Jonas Devlieghere | 9c6c201 | 2018-10-24 22:04:20 +0000 | [diff] [blame] | 105 | case 'f': |
| 106 | m_force = true; |
| 107 | break; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 108 | case 'g': |
| 109 | m_global = true; |
| 110 | break; |
| 111 | default: |
| 112 | error.SetErrorStringWithFormat("unrecognized options '%c'", |
| 113 | short_option); |
| 114 | break; |
| 115 | } |
| 116 | |
| 117 | return error; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 118 | } |
| 119 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 120 | void OptionParsingStarting(ExecutionContext *execution_context) override { |
| 121 | m_global = false; |
Jonas Devlieghere | 9c6c201 | 2018-10-24 22:04:20 +0000 | [diff] [blame] | 122 | m_force = false; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 123 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 124 | |
Zachary Turner | 1f0f5b5 | 2016-09-22 20:22:55 +0000 | [diff] [blame] | 125 | llvm::ArrayRef<OptionDefinition> GetDefinitions() override { |
Zachary Turner | 7060243 | 2016-09-22 21:06:13 +0000 | [diff] [blame] | 126 | return llvm::makeArrayRef(g_settings_set_options); |
Zachary Turner | 1f0f5b5 | 2016-09-22 20:22:55 +0000 | [diff] [blame] | 127 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 128 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 129 | // Instance variables to hold the values for command options. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 130 | bool m_global; |
Jonas Devlieghere | 9c6c201 | 2018-10-24 22:04:20 +0000 | [diff] [blame] | 131 | bool m_force; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 132 | }; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 133 | |
Raphael Isemann | 2443bbd | 2018-07-02 21:29:56 +0000 | [diff] [blame] | 134 | int HandleArgumentCompletion( |
| 135 | CompletionRequest &request, |
| 136 | OptionElementVector &opt_element_vector) override { |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 137 | |
Raphael Isemann | 2443bbd | 2018-07-02 21:29:56 +0000 | [diff] [blame] | 138 | const size_t argc = request.GetParsedLine().GetArgumentCount(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 139 | const char *arg = nullptr; |
| 140 | int setting_var_idx; |
Pavel Labath | 5f56fca | 2018-03-09 10:39:40 +0000 | [diff] [blame] | 141 | for (setting_var_idx = 0; setting_var_idx < static_cast<int>(argc); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 142 | ++setting_var_idx) { |
Raphael Isemann | 2443bbd | 2018-07-02 21:29:56 +0000 | [diff] [blame] | 143 | arg = request.GetParsedLine().GetArgumentAtIndex(setting_var_idx); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 144 | if (arg && arg[0] != '-') |
| 145 | break; // We found our setting variable name index |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 146 | } |
Raphael Isemann | 2443bbd | 2018-07-02 21:29:56 +0000 | [diff] [blame] | 147 | if (request.GetCursorIndex() == setting_var_idx) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 148 | // Attempting to complete setting variable name |
| 149 | CommandCompletions::InvokeCommonCompletionCallbacks( |
| 150 | GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, |
Raphael Isemann | a2e76c0 | 2018-07-13 18:28:14 +0000 | [diff] [blame] | 151 | request, nullptr); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 152 | } else { |
Raphael Isemann | 2443bbd | 2018-07-02 21:29:56 +0000 | [diff] [blame] | 153 | arg = |
| 154 | request.GetParsedLine().GetArgumentAtIndex(request.GetCursorIndex()); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 155 | |
| 156 | if (arg) { |
| 157 | if (arg[0] == '-') { |
| 158 | // Complete option name |
| 159 | } else { |
| 160 | // Complete setting value |
| 161 | const char *setting_var_name = |
Raphael Isemann | 2443bbd | 2018-07-02 21:29:56 +0000 | [diff] [blame] | 162 | request.GetParsedLine().GetArgumentAtIndex(setting_var_idx); |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 163 | Status error; |
Jonas Devlieghere | 5717986 | 2019-04-27 06:19:42 +0000 | [diff] [blame] | 164 | lldb::OptionValueSP value_sp(GetDebugger().GetPropertyValue( |
| 165 | &m_exe_ctx, setting_var_name, false, error)); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 166 | if (value_sp) { |
Raphael Isemann | a2e76c0 | 2018-07-13 18:28:14 +0000 | [diff] [blame] | 167 | value_sp->AutoComplete(m_interpreter, request); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 168 | } |
| 169 | } |
| 170 | } |
| 171 | } |
Raphael Isemann | 1a6d7ab | 2018-07-27 18:42:46 +0000 | [diff] [blame] | 172 | return request.GetNumberOfMatches(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 173 | } |
| 174 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 175 | protected: |
Raphael Isemann | 4d51a90 | 2018-07-12 22:28:52 +0000 | [diff] [blame] | 176 | bool DoExecute(llvm::StringRef command, |
| 177 | CommandReturnObject &result) override { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 178 | Args cmd_args(command); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 179 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 180 | // Process possible options. |
| 181 | if (!ParseOptions(cmd_args, result)) |
| 182 | return false; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 183 | |
Jonas Devlieghere | 9c6c201 | 2018-10-24 22:04:20 +0000 | [diff] [blame] | 184 | const size_t min_argc = m_options.m_force ? 1 : 2; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 185 | const size_t argc = cmd_args.GetArgumentCount(); |
Jonas Devlieghere | 9c6c201 | 2018-10-24 22:04:20 +0000 | [diff] [blame] | 186 | |
| 187 | if ((argc < min_argc) && (!m_options.m_global)) { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 188 | result.AppendError("'settings set' takes more arguments"); |
| 189 | result.SetStatus(eReturnStatusFailed); |
| 190 | return false; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 191 | } |
Eugene Zelenko | 3f18ea0 | 2016-02-24 02:05:55 +0000 | [diff] [blame] | 192 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 193 | const char *var_name = cmd_args.GetArgumentAtIndex(0); |
| 194 | if ((var_name == nullptr) || (var_name[0] == '\0')) { |
| 195 | result.AppendError( |
| 196 | "'settings set' command requires a valid variable name"); |
| 197 | result.SetStatus(eReturnStatusFailed); |
| 198 | return false; |
| 199 | } |
| 200 | |
Jonas Devlieghere | 9c6c201 | 2018-10-24 22:04:20 +0000 | [diff] [blame] | 201 | // A missing value corresponds to clearing the setting when "force" is |
| 202 | // specified. |
| 203 | if (argc == 1 && m_options.m_force) { |
Jonas Devlieghere | 5717986 | 2019-04-27 06:19:42 +0000 | [diff] [blame] | 204 | Status error(GetDebugger().SetPropertyValue( |
Jonas Devlieghere | 9c6c201 | 2018-10-24 22:04:20 +0000 | [diff] [blame] | 205 | &m_exe_ctx, eVarSetOperationClear, var_name, llvm::StringRef())); |
| 206 | if (error.Fail()) { |
| 207 | result.AppendError(error.AsCString()); |
| 208 | result.SetStatus(eReturnStatusFailed); |
| 209 | return false; |
| 210 | } |
| 211 | return result.Succeeded(); |
| 212 | } |
| 213 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 214 | // Split the raw command into var_name and value pair. |
| 215 | llvm::StringRef raw_str(command); |
| 216 | std::string var_value_string = raw_str.split(var_name).second.str(); |
| 217 | const char *var_value_cstr = |
| 218 | Args::StripSpaces(var_value_string, true, false, false); |
| 219 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 220 | Status error; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 221 | if (m_options.m_global) { |
Jonas Devlieghere | 5717986 | 2019-04-27 06:19:42 +0000 | [diff] [blame] | 222 | error = GetDebugger().SetPropertyValue(nullptr, eVarSetOperationAssign, |
| 223 | var_name, var_value_cstr); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | if (error.Success()) { |
| 227 | // FIXME this is the same issue as the one in commands script import |
| 228 | // we could be setting target.load-script-from-symbol-file which would |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 229 | // cause Python scripts to be loaded, which could run LLDB commands (e.g. |
| 230 | // settings set target.process.python-os-plugin-path) and cause a crash |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 231 | // if we did not clear the command's exe_ctx first |
| 232 | ExecutionContext exe_ctx(m_exe_ctx); |
| 233 | m_exe_ctx.Clear(); |
Jonas Devlieghere | 5717986 | 2019-04-27 06:19:42 +0000 | [diff] [blame] | 234 | error = GetDebugger().SetPropertyValue(&exe_ctx, eVarSetOperationAssign, |
| 235 | var_name, var_value_cstr); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | if (error.Fail()) { |
| 239 | result.AppendError(error.AsCString()); |
| 240 | result.SetStatus(eReturnStatusFailed); |
| 241 | return false; |
| 242 | } else { |
| 243 | result.SetStatus(eReturnStatusSuccessFinishResult); |
| 244 | } |
| 245 | |
| 246 | return result.Succeeded(); |
| 247 | } |
| 248 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 249 | private: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 250 | CommandOptions m_options; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 251 | }; |
| 252 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 253 | // CommandObjectSettingsShow -- Show current values |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 254 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 255 | class CommandObjectSettingsShow : public CommandObjectParsed { |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 256 | public: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 257 | CommandObjectSettingsShow(CommandInterpreter &interpreter) |
| 258 | : CommandObjectParsed(interpreter, "settings show", |
| 259 | "Show matching debugger settings and their current " |
| 260 | "values. Defaults to showing all settings.", |
| 261 | nullptr) { |
| 262 | CommandArgumentEntry arg1; |
| 263 | CommandArgumentData var_name_arg; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 264 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 265 | // Define the first (and only) variant of this arg. |
| 266 | var_name_arg.arg_type = eArgTypeSettingVariableName; |
| 267 | var_name_arg.arg_repetition = eArgRepeatOptional; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 268 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 269 | // There is only one variant this argument could be; put it into the |
| 270 | // argument entry. |
| 271 | arg1.push_back(var_name_arg); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 272 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 273 | // Push the data for the first argument into the m_arguments vector. |
| 274 | m_arguments.push_back(arg1); |
| 275 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 276 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 277 | ~CommandObjectSettingsShow() override = default; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 278 | |
Raphael Isemann | 2443bbd | 2018-07-02 21:29:56 +0000 | [diff] [blame] | 279 | int HandleArgumentCompletion( |
| 280 | CompletionRequest &request, |
| 281 | OptionElementVector &opt_element_vector) override { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 282 | CommandCompletions::InvokeCommonCompletionCallbacks( |
| 283 | GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, |
Raphael Isemann | a2e76c0 | 2018-07-13 18:28:14 +0000 | [diff] [blame] | 284 | request, nullptr); |
Raphael Isemann | 1a6d7ab | 2018-07-27 18:42:46 +0000 | [diff] [blame] | 285 | return request.GetNumberOfMatches(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 286 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 287 | |
| 288 | protected: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 289 | bool DoExecute(Args &args, CommandReturnObject &result) override { |
| 290 | result.SetStatus(eReturnStatusSuccessFinishResult); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 291 | |
Zachary Turner | 97d2c40 | 2016-10-05 23:40:23 +0000 | [diff] [blame] | 292 | if (!args.empty()) { |
Zachary Turner | d6a2475 | 2016-11-22 17:10:15 +0000 | [diff] [blame] | 293 | for (const auto &arg : args) { |
Jonas Devlieghere | 5717986 | 2019-04-27 06:19:42 +0000 | [diff] [blame] | 294 | Status error(GetDebugger().DumpPropertyValue( |
Zachary Turner | d6a2475 | 2016-11-22 17:10:15 +0000 | [diff] [blame] | 295 | &m_exe_ctx, result.GetOutputStream(), arg.ref, |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 296 | OptionValue::eDumpGroupValue)); |
| 297 | if (error.Success()) { |
| 298 | result.GetOutputStream().EOL(); |
| 299 | } else { |
| 300 | result.AppendError(error.AsCString()); |
| 301 | result.SetStatus(eReturnStatusFailed); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 302 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 303 | } |
| 304 | } else { |
Jonas Devlieghere | 5717986 | 2019-04-27 06:19:42 +0000 | [diff] [blame] | 305 | GetDebugger().DumpAllPropertyValues(&m_exe_ctx, result.GetOutputStream(), |
| 306 | OptionValue::eDumpGroupValue); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 307 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 308 | |
| 309 | return result.Succeeded(); |
| 310 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 311 | }; |
| 312 | |
Jonas Devlieghere | b76e25a | 2018-10-26 00:00:17 +0000 | [diff] [blame] | 313 | // CommandObjectSettingsWrite -- Write settings to file |
Jonas Devlieghere | b76e25a | 2018-10-26 00:00:17 +0000 | [diff] [blame] | 314 | |
| 315 | static constexpr OptionDefinition g_settings_write_options[] = { |
| 316 | // clang-format off |
| 317 | { LLDB_OPT_SET_ALL, true, "file", 'f', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eDiskFileCompletion, eArgTypeFilename, "The file into which to write the settings." }, |
| 318 | { LLDB_OPT_SET_ALL, false, "append",'a', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Append to saved settings file if it exists."}, |
| 319 | // clang-format on |
| 320 | }; |
| 321 | |
| 322 | class CommandObjectSettingsWrite : public CommandObjectParsed { |
| 323 | public: |
| 324 | CommandObjectSettingsWrite(CommandInterpreter &interpreter) |
| 325 | : CommandObjectParsed( |
| 326 | interpreter, "settings export", |
| 327 | "Write matching debugger settings and their " |
| 328 | "current values to a file that can be read in with " |
| 329 | "\"settings read\". Defaults to writing all settings.", |
| 330 | nullptr), |
| 331 | m_options() { |
| 332 | CommandArgumentEntry arg1; |
| 333 | CommandArgumentData var_name_arg; |
| 334 | |
| 335 | // Define the first (and only) variant of this arg. |
| 336 | var_name_arg.arg_type = eArgTypeSettingVariableName; |
| 337 | var_name_arg.arg_repetition = eArgRepeatOptional; |
| 338 | |
| 339 | // There is only one variant this argument could be; put it into the |
| 340 | // argument entry. |
| 341 | arg1.push_back(var_name_arg); |
| 342 | |
| 343 | // Push the data for the first argument into the m_arguments vector. |
| 344 | m_arguments.push_back(arg1); |
| 345 | } |
| 346 | |
| 347 | ~CommandObjectSettingsWrite() override = default; |
| 348 | |
| 349 | Options *GetOptions() override { return &m_options; } |
| 350 | |
| 351 | class CommandOptions : public Options { |
| 352 | public: |
| 353 | CommandOptions() : Options() {} |
| 354 | |
| 355 | ~CommandOptions() override = default; |
| 356 | |
| 357 | Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, |
| 358 | ExecutionContext *execution_context) override { |
| 359 | Status error; |
| 360 | const int short_option = m_getopt_table[option_idx].val; |
| 361 | |
| 362 | switch (short_option) { |
| 363 | case 'f': |
| 364 | m_filename.assign(option_arg); |
| 365 | break; |
| 366 | case 'a': |
| 367 | m_append = true; |
| 368 | break; |
| 369 | default: |
| 370 | error.SetErrorStringWithFormat("unrecognized option '%c'", |
| 371 | short_option); |
| 372 | break; |
| 373 | } |
| 374 | |
| 375 | return error; |
| 376 | } |
| 377 | |
| 378 | void OptionParsingStarting(ExecutionContext *execution_context) override { |
| 379 | m_filename.clear(); |
| 380 | m_append = false; |
| 381 | } |
| 382 | |
| 383 | llvm::ArrayRef<OptionDefinition> GetDefinitions() override { |
| 384 | return llvm::makeArrayRef(g_settings_write_options); |
| 385 | } |
| 386 | |
| 387 | // Instance variables to hold the values for command options. |
| 388 | std::string m_filename; |
| 389 | bool m_append = false; |
| 390 | }; |
| 391 | |
| 392 | protected: |
| 393 | bool DoExecute(Args &args, CommandReturnObject &result) override { |
Jonas Devlieghere | 8f3be7a | 2018-11-01 21:05:36 +0000 | [diff] [blame] | 394 | FileSpec file_spec(m_options.m_filename); |
| 395 | FileSystem::Instance().Resolve(file_spec); |
| 396 | std::string path(file_spec.GetPath()); |
Jonas Devlieghere | b76e25a | 2018-10-26 00:00:17 +0000 | [diff] [blame] | 397 | uint32_t options = File::OpenOptions::eOpenOptionWrite | |
| 398 | File::OpenOptions::eOpenOptionCanCreate; |
| 399 | if (m_options.m_append) |
| 400 | options |= File::OpenOptions::eOpenOptionAppend; |
| 401 | else |
| 402 | options |= File::OpenOptions::eOpenOptionTruncate; |
| 403 | |
| 404 | StreamFile out_file(path.c_str(), options, |
| 405 | lldb::eFilePermissionsFileDefault); |
| 406 | |
| 407 | if (!out_file.GetFile().IsValid()) { |
| 408 | result.AppendErrorWithFormat("%s: unable to write to file", path.c_str()); |
| 409 | result.SetStatus(eReturnStatusFailed); |
| 410 | return false; |
| 411 | } |
| 412 | |
| 413 | // Exporting should not be context sensitive. |
| 414 | ExecutionContext clean_ctx; |
| 415 | |
| 416 | if (args.empty()) { |
Jonas Devlieghere | 5717986 | 2019-04-27 06:19:42 +0000 | [diff] [blame] | 417 | GetDebugger().DumpAllPropertyValues(&clean_ctx, out_file, |
| 418 | OptionValue::eDumpGroupExport); |
Jonas Devlieghere | b76e25a | 2018-10-26 00:00:17 +0000 | [diff] [blame] | 419 | return result.Succeeded(); |
| 420 | } |
| 421 | |
| 422 | for (const auto &arg : args) { |
Jonas Devlieghere | 5717986 | 2019-04-27 06:19:42 +0000 | [diff] [blame] | 423 | Status error(GetDebugger().DumpPropertyValue( |
Jonas Devlieghere | b76e25a | 2018-10-26 00:00:17 +0000 | [diff] [blame] | 424 | &clean_ctx, out_file, arg.ref, OptionValue::eDumpGroupExport)); |
| 425 | if (!error.Success()) { |
| 426 | result.AppendError(error.AsCString()); |
| 427 | result.SetStatus(eReturnStatusFailed); |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | return result.Succeeded(); |
| 432 | } |
| 433 | |
| 434 | private: |
| 435 | CommandOptions m_options; |
| 436 | }; |
| 437 | |
Jonas Devlieghere | b76e25a | 2018-10-26 00:00:17 +0000 | [diff] [blame] | 438 | // CommandObjectSettingsRead -- Read settings from file |
Jonas Devlieghere | b76e25a | 2018-10-26 00:00:17 +0000 | [diff] [blame] | 439 | |
| 440 | static constexpr OptionDefinition g_settings_read_options[] = { |
| 441 | // clang-format off |
| 442 | {LLDB_OPT_SET_ALL, true, "file",'f', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eDiskFileCompletion, eArgTypeFilename, "The file from which to read the breakpoints." }, |
| 443 | // clang-format on |
| 444 | }; |
| 445 | |
| 446 | class CommandObjectSettingsRead : public CommandObjectParsed { |
| 447 | public: |
| 448 | CommandObjectSettingsRead(CommandInterpreter &interpreter) |
| 449 | : CommandObjectParsed( |
| 450 | interpreter, "settings read", |
| 451 | "Read settings previously saved to a file with \"settings write\".", |
| 452 | nullptr), |
| 453 | m_options() {} |
| 454 | |
| 455 | ~CommandObjectSettingsRead() override = default; |
| 456 | |
| 457 | Options *GetOptions() override { return &m_options; } |
| 458 | |
| 459 | class CommandOptions : public Options { |
| 460 | public: |
| 461 | CommandOptions() : Options() {} |
| 462 | |
| 463 | ~CommandOptions() override = default; |
| 464 | |
| 465 | Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, |
| 466 | ExecutionContext *execution_context) override { |
| 467 | Status error; |
| 468 | const int short_option = m_getopt_table[option_idx].val; |
| 469 | |
| 470 | switch (short_option) { |
| 471 | case 'f': |
| 472 | m_filename.assign(option_arg); |
| 473 | break; |
| 474 | default: |
| 475 | error.SetErrorStringWithFormat("unrecognized option '%c'", |
| 476 | short_option); |
| 477 | break; |
| 478 | } |
| 479 | |
| 480 | return error; |
| 481 | } |
| 482 | |
| 483 | void OptionParsingStarting(ExecutionContext *execution_context) override { |
| 484 | m_filename.clear(); |
| 485 | } |
| 486 | |
| 487 | llvm::ArrayRef<OptionDefinition> GetDefinitions() override { |
| 488 | return llvm::makeArrayRef(g_settings_read_options); |
| 489 | } |
| 490 | |
| 491 | // Instance variables to hold the values for command options. |
| 492 | std::string m_filename; |
| 493 | }; |
| 494 | |
| 495 | protected: |
| 496 | bool DoExecute(Args &command, CommandReturnObject &result) override { |
Jonas Devlieghere | 8f3be7a | 2018-11-01 21:05:36 +0000 | [diff] [blame] | 497 | FileSpec file(m_options.m_filename); |
| 498 | FileSystem::Instance().Resolve(file); |
Jonas Devlieghere | b76e25a | 2018-10-26 00:00:17 +0000 | [diff] [blame] | 499 | ExecutionContext clean_ctx; |
| 500 | CommandInterpreterRunOptions options; |
| 501 | options.SetAddToHistory(false); |
| 502 | options.SetEchoCommands(false); |
| 503 | options.SetPrintResults(true); |
Jonas Devlieghere | c0b48ab | 2019-05-08 01:23:47 +0000 | [diff] [blame] | 504 | options.SetPrintErrors(true); |
Jonas Devlieghere | b76e25a | 2018-10-26 00:00:17 +0000 | [diff] [blame] | 505 | options.SetStopOnError(false); |
| 506 | m_interpreter.HandleCommandsFromFile(file, &clean_ctx, options, result); |
| 507 | return result.Succeeded(); |
| 508 | } |
| 509 | |
| 510 | private: |
| 511 | CommandOptions m_options; |
| 512 | }; |
| 513 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 514 | // CommandObjectSettingsList -- List settable variables |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 515 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 516 | class CommandObjectSettingsList : public CommandObjectParsed { |
Kate Stone | 7428a18 | 2016-07-14 22:03:10 +0000 | [diff] [blame] | 517 | public: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 518 | CommandObjectSettingsList(CommandInterpreter &interpreter) |
| 519 | : CommandObjectParsed(interpreter, "settings list", |
| 520 | "List and describe matching debugger settings. " |
| 521 | "Defaults to all listing all settings.", |
| 522 | nullptr) { |
| 523 | CommandArgumentEntry arg; |
| 524 | CommandArgumentData var_name_arg; |
| 525 | CommandArgumentData prefix_name_arg; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 526 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 527 | // Define the first variant of this arg. |
| 528 | var_name_arg.arg_type = eArgTypeSettingVariableName; |
| 529 | var_name_arg.arg_repetition = eArgRepeatOptional; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 530 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 531 | // Define the second variant of this arg. |
| 532 | prefix_name_arg.arg_type = eArgTypeSettingPrefix; |
| 533 | prefix_name_arg.arg_repetition = eArgRepeatOptional; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 534 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 535 | arg.push_back(var_name_arg); |
| 536 | arg.push_back(prefix_name_arg); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 537 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 538 | // Push the data for the first argument into the m_arguments vector. |
| 539 | m_arguments.push_back(arg); |
| 540 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 541 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 542 | ~CommandObjectSettingsList() override = default; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 543 | |
Raphael Isemann | 2443bbd | 2018-07-02 21:29:56 +0000 | [diff] [blame] | 544 | int HandleArgumentCompletion( |
| 545 | CompletionRequest &request, |
| 546 | OptionElementVector &opt_element_vector) override { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 547 | CommandCompletions::InvokeCommonCompletionCallbacks( |
| 548 | GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, |
Raphael Isemann | a2e76c0 | 2018-07-13 18:28:14 +0000 | [diff] [blame] | 549 | request, nullptr); |
Raphael Isemann | 1a6d7ab | 2018-07-27 18:42:46 +0000 | [diff] [blame] | 550 | return request.GetNumberOfMatches(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 551 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 552 | |
| 553 | protected: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 554 | bool DoExecute(Args &args, CommandReturnObject &result) override { |
| 555 | result.SetStatus(eReturnStatusSuccessFinishResult); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 556 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 557 | const bool will_modify = false; |
| 558 | const size_t argc = args.GetArgumentCount(); |
| 559 | if (argc > 0) { |
| 560 | const bool dump_qualified_name = true; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 561 | |
Zachary Turner | 97d2c40 | 2016-10-05 23:40:23 +0000 | [diff] [blame] | 562 | // TODO: Convert to StringRef based enumeration. Requires converting |
| 563 | // GetPropertyAtPath first. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 564 | for (size_t i = 0; i < argc; ++i) { |
| 565 | const char *property_path = args.GetArgumentAtIndex(i); |
Greg Clayton | 67cc063 | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 566 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 567 | const Property *property = |
Jonas Devlieghere | 5717986 | 2019-04-27 06:19:42 +0000 | [diff] [blame] | 568 | GetDebugger().GetValueProperties()->GetPropertyAtPath( |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 569 | &m_exe_ctx, will_modify, property_path); |
| 570 | |
| 571 | if (property) { |
| 572 | property->DumpDescription(m_interpreter, result.GetOutputStream(), 0, |
| 573 | dump_qualified_name); |
| 574 | } else { |
| 575 | result.AppendErrorWithFormat("invalid property path '%s'", |
| 576 | property_path); |
| 577 | result.SetStatus(eReturnStatusFailed); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 578 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 579 | } |
| 580 | } else { |
Jonas Devlieghere | 5717986 | 2019-04-27 06:19:42 +0000 | [diff] [blame] | 581 | GetDebugger().DumpAllDescriptions(m_interpreter, |
| 582 | result.GetOutputStream()); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 583 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 584 | |
| 585 | return result.Succeeded(); |
| 586 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 587 | }; |
| 588 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 589 | // CommandObjectSettingsRemove |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 590 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 591 | class CommandObjectSettingsRemove : public CommandObjectRaw { |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 592 | public: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 593 | CommandObjectSettingsRemove(CommandInterpreter &interpreter) |
| 594 | : CommandObjectRaw(interpreter, "settings remove", |
| 595 | "Remove a value from a setting, specified by array " |
Zachary Turner | a449698 | 2016-10-05 21:14:38 +0000 | [diff] [blame] | 596 | "index or dictionary key.") { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 597 | CommandArgumentEntry arg1; |
| 598 | CommandArgumentEntry arg2; |
| 599 | CommandArgumentData var_name_arg; |
| 600 | CommandArgumentData index_arg; |
| 601 | CommandArgumentData key_arg; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 602 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 603 | // Define the first (and only) variant of this arg. |
| 604 | var_name_arg.arg_type = eArgTypeSettingVariableName; |
| 605 | var_name_arg.arg_repetition = eArgRepeatPlain; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 606 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 607 | // There is only one variant this argument could be; put it into the |
| 608 | // argument entry. |
| 609 | arg1.push_back(var_name_arg); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 610 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 611 | // Define the first variant of this arg. |
| 612 | index_arg.arg_type = eArgTypeSettingIndex; |
| 613 | index_arg.arg_repetition = eArgRepeatPlain; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 614 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 615 | // Define the second variant of this arg. |
| 616 | key_arg.arg_type = eArgTypeSettingKey; |
| 617 | key_arg.arg_repetition = eArgRepeatPlain; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 618 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 619 | // Push both variants into this arg |
| 620 | arg2.push_back(index_arg); |
| 621 | arg2.push_back(key_arg); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 622 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 623 | // Push the data for the first argument into the m_arguments vector. |
| 624 | m_arguments.push_back(arg1); |
| 625 | m_arguments.push_back(arg2); |
| 626 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 627 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 628 | ~CommandObjectSettingsRemove() override = default; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 629 | |
Raphael Isemann | 2443bbd | 2018-07-02 21:29:56 +0000 | [diff] [blame] | 630 | int HandleArgumentCompletion( |
| 631 | CompletionRequest &request, |
| 632 | OptionElementVector &opt_element_vector) override { |
Raphael Isemann | 2443bbd | 2018-07-02 21:29:56 +0000 | [diff] [blame] | 633 | if (request.GetCursorIndex() < 2) |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 634 | CommandCompletions::InvokeCommonCompletionCallbacks( |
| 635 | GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, |
Raphael Isemann | a2e76c0 | 2018-07-13 18:28:14 +0000 | [diff] [blame] | 636 | request, nullptr); |
Raphael Isemann | 1a6d7ab | 2018-07-27 18:42:46 +0000 | [diff] [blame] | 637 | return request.GetNumberOfMatches(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 638 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 639 | |
| 640 | protected: |
Raphael Isemann | 4d51a90 | 2018-07-12 22:28:52 +0000 | [diff] [blame] | 641 | bool DoExecute(llvm::StringRef command, |
| 642 | CommandReturnObject &result) override { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 643 | result.SetStatus(eReturnStatusSuccessFinishNoResult); |
| 644 | |
| 645 | Args cmd_args(command); |
| 646 | |
| 647 | // Process possible options. |
| 648 | if (!ParseOptions(cmd_args, result)) |
| 649 | return false; |
| 650 | |
| 651 | const size_t argc = cmd_args.GetArgumentCount(); |
| 652 | if (argc == 0) { |
| 653 | result.AppendError("'settings set' takes an array or dictionary item, or " |
| 654 | "an array followed by one or more indexes, or a " |
| 655 | "dictionary followed by one or more key names to " |
| 656 | "remove"); |
| 657 | result.SetStatus(eReturnStatusFailed); |
| 658 | return false; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 659 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 660 | |
| 661 | const char *var_name = cmd_args.GetArgumentAtIndex(0); |
| 662 | if ((var_name == nullptr) || (var_name[0] == '\0')) { |
| 663 | result.AppendError( |
| 664 | "'settings set' command requires a valid variable name"); |
| 665 | result.SetStatus(eReturnStatusFailed); |
| 666 | return false; |
| 667 | } |
| 668 | |
| 669 | // Split the raw command into var_name and value pair. |
| 670 | llvm::StringRef raw_str(command); |
| 671 | std::string var_value_string = raw_str.split(var_name).second.str(); |
| 672 | const char *var_value_cstr = |
| 673 | Args::StripSpaces(var_value_string, true, true, false); |
| 674 | |
Jonas Devlieghere | 5717986 | 2019-04-27 06:19:42 +0000 | [diff] [blame] | 675 | Status error(GetDebugger().SetPropertyValue( |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 676 | &m_exe_ctx, eVarSetOperationRemove, var_name, var_value_cstr)); |
| 677 | if (error.Fail()) { |
| 678 | result.AppendError(error.AsCString()); |
| 679 | result.SetStatus(eReturnStatusFailed); |
| 680 | return false; |
| 681 | } |
| 682 | |
| 683 | return result.Succeeded(); |
| 684 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 685 | }; |
| 686 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 687 | // CommandObjectSettingsReplace |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 688 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 689 | class CommandObjectSettingsReplace : public CommandObjectRaw { |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 690 | public: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 691 | CommandObjectSettingsReplace(CommandInterpreter &interpreter) |
| 692 | : CommandObjectRaw(interpreter, "settings replace", |
| 693 | "Replace the debugger setting value specified by " |
Zachary Turner | a449698 | 2016-10-05 21:14:38 +0000 | [diff] [blame] | 694 | "array index or dictionary key.") { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 695 | CommandArgumentEntry arg1; |
| 696 | CommandArgumentEntry arg2; |
| 697 | CommandArgumentEntry arg3; |
| 698 | CommandArgumentData var_name_arg; |
| 699 | CommandArgumentData index_arg; |
| 700 | CommandArgumentData key_arg; |
| 701 | CommandArgumentData value_arg; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 702 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 703 | // Define the first (and only) variant of this arg. |
| 704 | var_name_arg.arg_type = eArgTypeSettingVariableName; |
| 705 | var_name_arg.arg_repetition = eArgRepeatPlain; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 706 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 707 | // There is only one variant this argument could be; put it into the |
| 708 | // argument entry. |
| 709 | arg1.push_back(var_name_arg); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 710 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 711 | // Define the first (variant of this arg. |
| 712 | index_arg.arg_type = eArgTypeSettingIndex; |
| 713 | index_arg.arg_repetition = eArgRepeatPlain; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 714 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 715 | // Define the second (variant of this arg. |
| 716 | key_arg.arg_type = eArgTypeSettingKey; |
| 717 | key_arg.arg_repetition = eArgRepeatPlain; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 718 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 719 | // Put both variants into this arg |
| 720 | arg2.push_back(index_arg); |
| 721 | arg2.push_back(key_arg); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 722 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 723 | // Define the first (and only) variant of this arg. |
| 724 | value_arg.arg_type = eArgTypeValue; |
| 725 | value_arg.arg_repetition = eArgRepeatPlain; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 726 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 727 | // There is only one variant this argument could be; put it into the |
| 728 | // argument entry. |
| 729 | arg3.push_back(value_arg); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 730 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 731 | // Push the data for the first argument into the m_arguments vector. |
| 732 | m_arguments.push_back(arg1); |
| 733 | m_arguments.push_back(arg2); |
| 734 | m_arguments.push_back(arg3); |
| 735 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 736 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 737 | ~CommandObjectSettingsReplace() override = default; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 738 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 739 | // Overrides base class's behavior where WantsCompletion = |
| 740 | // !WantsRawCommandString. |
| 741 | bool WantsCompletion() override { return true; } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 742 | |
Raphael Isemann | 2443bbd | 2018-07-02 21:29:56 +0000 | [diff] [blame] | 743 | int HandleArgumentCompletion( |
| 744 | CompletionRequest &request, |
| 745 | OptionElementVector &opt_element_vector) override { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 746 | // Attempting to complete variable name |
Raphael Isemann | 2443bbd | 2018-07-02 21:29:56 +0000 | [diff] [blame] | 747 | if (request.GetCursorIndex() < 2) |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 748 | CommandCompletions::InvokeCommonCompletionCallbacks( |
| 749 | GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, |
Raphael Isemann | a2e76c0 | 2018-07-13 18:28:14 +0000 | [diff] [blame] | 750 | request, nullptr); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 751 | |
Raphael Isemann | 1a6d7ab | 2018-07-27 18:42:46 +0000 | [diff] [blame] | 752 | return request.GetNumberOfMatches(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 753 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 754 | |
| 755 | protected: |
Raphael Isemann | 4d51a90 | 2018-07-12 22:28:52 +0000 | [diff] [blame] | 756 | bool DoExecute(llvm::StringRef command, |
| 757 | CommandReturnObject &result) override { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 758 | result.SetStatus(eReturnStatusSuccessFinishNoResult); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 759 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 760 | Args cmd_args(command); |
| 761 | const char *var_name = cmd_args.GetArgumentAtIndex(0); |
| 762 | if ((var_name == nullptr) || (var_name[0] == '\0')) { |
| 763 | result.AppendError("'settings replace' command requires a valid variable " |
| 764 | "name; No value supplied"); |
| 765 | result.SetStatus(eReturnStatusFailed); |
| 766 | return false; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 767 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 768 | |
| 769 | // Split the raw command into var_name, index_value, and value triple. |
| 770 | llvm::StringRef raw_str(command); |
| 771 | std::string var_value_string = raw_str.split(var_name).second.str(); |
| 772 | const char *var_value_cstr = |
| 773 | Args::StripSpaces(var_value_string, true, true, false); |
| 774 | |
Jonas Devlieghere | 5717986 | 2019-04-27 06:19:42 +0000 | [diff] [blame] | 775 | Status error(GetDebugger().SetPropertyValue( |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 776 | &m_exe_ctx, eVarSetOperationReplace, var_name, var_value_cstr)); |
| 777 | if (error.Fail()) { |
| 778 | result.AppendError(error.AsCString()); |
| 779 | result.SetStatus(eReturnStatusFailed); |
| 780 | return false; |
| 781 | } else { |
| 782 | result.SetStatus(eReturnStatusSuccessFinishNoResult); |
| 783 | } |
| 784 | |
| 785 | return result.Succeeded(); |
| 786 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 787 | }; |
| 788 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 789 | // CommandObjectSettingsInsertBefore |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 790 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 791 | class CommandObjectSettingsInsertBefore : public CommandObjectRaw { |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 792 | public: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 793 | CommandObjectSettingsInsertBefore(CommandInterpreter &interpreter) |
| 794 | : CommandObjectRaw(interpreter, "settings insert-before", |
| 795 | "Insert one or more values into an debugger array " |
| 796 | "setting immediately before the specified element " |
Zachary Turner | a449698 | 2016-10-05 21:14:38 +0000 | [diff] [blame] | 797 | "index.") { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 798 | CommandArgumentEntry arg1; |
| 799 | CommandArgumentEntry arg2; |
| 800 | CommandArgumentEntry arg3; |
| 801 | CommandArgumentData var_name_arg; |
| 802 | CommandArgumentData index_arg; |
| 803 | CommandArgumentData value_arg; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 804 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 805 | // Define the first (and only) variant of this arg. |
| 806 | var_name_arg.arg_type = eArgTypeSettingVariableName; |
| 807 | var_name_arg.arg_repetition = eArgRepeatPlain; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 808 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 809 | // There is only one variant this argument could be; put it into the |
| 810 | // argument entry. |
| 811 | arg1.push_back(var_name_arg); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 812 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 813 | // Define the first (variant of this arg. |
| 814 | index_arg.arg_type = eArgTypeSettingIndex; |
| 815 | index_arg.arg_repetition = eArgRepeatPlain; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 816 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 817 | // There is only one variant this argument could be; put it into the |
| 818 | // argument entry. |
| 819 | arg2.push_back(index_arg); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 820 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 821 | // Define the first (and only) variant of this arg. |
| 822 | value_arg.arg_type = eArgTypeValue; |
| 823 | value_arg.arg_repetition = eArgRepeatPlain; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 824 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 825 | // There is only one variant this argument could be; put it into the |
| 826 | // argument entry. |
| 827 | arg3.push_back(value_arg); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 828 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 829 | // Push the data for the first argument into the m_arguments vector. |
| 830 | m_arguments.push_back(arg1); |
| 831 | m_arguments.push_back(arg2); |
| 832 | m_arguments.push_back(arg3); |
| 833 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 834 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 835 | ~CommandObjectSettingsInsertBefore() override = default; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 836 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 837 | // Overrides base class's behavior where WantsCompletion = |
| 838 | // !WantsRawCommandString. |
| 839 | bool WantsCompletion() override { return true; } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 840 | |
Raphael Isemann | 2443bbd | 2018-07-02 21:29:56 +0000 | [diff] [blame] | 841 | int HandleArgumentCompletion( |
| 842 | CompletionRequest &request, |
| 843 | OptionElementVector &opt_element_vector) override { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 844 | // Attempting to complete variable name |
Raphael Isemann | 2443bbd | 2018-07-02 21:29:56 +0000 | [diff] [blame] | 845 | if (request.GetCursorIndex() < 2) |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 846 | CommandCompletions::InvokeCommonCompletionCallbacks( |
| 847 | GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, |
Raphael Isemann | a2e76c0 | 2018-07-13 18:28:14 +0000 | [diff] [blame] | 848 | request, nullptr); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 849 | |
Raphael Isemann | 1a6d7ab | 2018-07-27 18:42:46 +0000 | [diff] [blame] | 850 | return request.GetNumberOfMatches(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 851 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 852 | |
| 853 | protected: |
Raphael Isemann | 4d51a90 | 2018-07-12 22:28:52 +0000 | [diff] [blame] | 854 | bool DoExecute(llvm::StringRef command, |
| 855 | CommandReturnObject &result) override { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 856 | result.SetStatus(eReturnStatusSuccessFinishNoResult); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 857 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 858 | Args cmd_args(command); |
| 859 | const size_t argc = cmd_args.GetArgumentCount(); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 860 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 861 | if (argc < 3) { |
| 862 | result.AppendError("'settings insert-before' takes more arguments"); |
| 863 | result.SetStatus(eReturnStatusFailed); |
| 864 | return false; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 865 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 866 | |
| 867 | const char *var_name = cmd_args.GetArgumentAtIndex(0); |
| 868 | if ((var_name == nullptr) || (var_name[0] == '\0')) { |
| 869 | result.AppendError("'settings insert-before' command requires a valid " |
| 870 | "variable name; No value supplied"); |
| 871 | result.SetStatus(eReturnStatusFailed); |
| 872 | return false; |
| 873 | } |
| 874 | |
| 875 | // Split the raw command into var_name, index_value, and value triple. |
| 876 | llvm::StringRef raw_str(command); |
| 877 | std::string var_value_string = raw_str.split(var_name).second.str(); |
| 878 | const char *var_value_cstr = |
| 879 | Args::StripSpaces(var_value_string, true, true, false); |
| 880 | |
Jonas Devlieghere | 5717986 | 2019-04-27 06:19:42 +0000 | [diff] [blame] | 881 | Status error(GetDebugger().SetPropertyValue( |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 882 | &m_exe_ctx, eVarSetOperationInsertBefore, var_name, var_value_cstr)); |
| 883 | if (error.Fail()) { |
| 884 | result.AppendError(error.AsCString()); |
| 885 | result.SetStatus(eReturnStatusFailed); |
| 886 | return false; |
| 887 | } |
| 888 | |
| 889 | return result.Succeeded(); |
| 890 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 891 | }; |
| 892 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 893 | // CommandObjectSettingInsertAfter |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 894 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 895 | class CommandObjectSettingsInsertAfter : public CommandObjectRaw { |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 896 | public: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 897 | CommandObjectSettingsInsertAfter(CommandInterpreter &interpreter) |
| 898 | : CommandObjectRaw(interpreter, "settings insert-after", |
| 899 | "Insert one or more values into a debugger array " |
Zachary Turner | a449698 | 2016-10-05 21:14:38 +0000 | [diff] [blame] | 900 | "settings after the specified element index.") { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 901 | CommandArgumentEntry arg1; |
| 902 | CommandArgumentEntry arg2; |
| 903 | CommandArgumentEntry arg3; |
| 904 | CommandArgumentData var_name_arg; |
| 905 | CommandArgumentData index_arg; |
| 906 | CommandArgumentData value_arg; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 907 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 908 | // Define the first (and only) variant of this arg. |
| 909 | var_name_arg.arg_type = eArgTypeSettingVariableName; |
| 910 | var_name_arg.arg_repetition = eArgRepeatPlain; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 911 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 912 | // There is only one variant this argument could be; put it into the |
| 913 | // argument entry. |
| 914 | arg1.push_back(var_name_arg); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 915 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 916 | // Define the first (variant of this arg. |
| 917 | index_arg.arg_type = eArgTypeSettingIndex; |
| 918 | index_arg.arg_repetition = eArgRepeatPlain; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 919 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 920 | // There is only one variant this argument could be; put it into the |
| 921 | // argument entry. |
| 922 | arg2.push_back(index_arg); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 923 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 924 | // Define the first (and only) variant of this arg. |
| 925 | value_arg.arg_type = eArgTypeValue; |
| 926 | value_arg.arg_repetition = eArgRepeatPlain; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 927 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 928 | // There is only one variant this argument could be; put it into the |
| 929 | // argument entry. |
| 930 | arg3.push_back(value_arg); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 931 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 932 | // Push the data for the first argument into the m_arguments vector. |
| 933 | m_arguments.push_back(arg1); |
| 934 | m_arguments.push_back(arg2); |
| 935 | m_arguments.push_back(arg3); |
| 936 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 937 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 938 | ~CommandObjectSettingsInsertAfter() override = default; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 939 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 940 | // Overrides base class's behavior where WantsCompletion = |
| 941 | // !WantsRawCommandString. |
| 942 | bool WantsCompletion() override { return true; } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 943 | |
Raphael Isemann | 2443bbd | 2018-07-02 21:29:56 +0000 | [diff] [blame] | 944 | int HandleArgumentCompletion( |
| 945 | CompletionRequest &request, |
| 946 | OptionElementVector &opt_element_vector) override { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 947 | // Attempting to complete variable name |
Raphael Isemann | 2443bbd | 2018-07-02 21:29:56 +0000 | [diff] [blame] | 948 | if (request.GetCursorIndex() < 2) |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 949 | CommandCompletions::InvokeCommonCompletionCallbacks( |
| 950 | GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, |
Raphael Isemann | a2e76c0 | 2018-07-13 18:28:14 +0000 | [diff] [blame] | 951 | request, nullptr); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 952 | |
Raphael Isemann | 1a6d7ab | 2018-07-27 18:42:46 +0000 | [diff] [blame] | 953 | return request.GetNumberOfMatches(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 954 | } |
| 955 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 956 | protected: |
Raphael Isemann | 4d51a90 | 2018-07-12 22:28:52 +0000 | [diff] [blame] | 957 | bool DoExecute(llvm::StringRef command, |
| 958 | CommandReturnObject &result) override { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 959 | result.SetStatus(eReturnStatusSuccessFinishNoResult); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 960 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 961 | Args cmd_args(command); |
| 962 | const size_t argc = cmd_args.GetArgumentCount(); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 963 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 964 | if (argc < 3) { |
| 965 | result.AppendError("'settings insert-after' takes more arguments"); |
| 966 | result.SetStatus(eReturnStatusFailed); |
| 967 | return false; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 968 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 969 | |
| 970 | const char *var_name = cmd_args.GetArgumentAtIndex(0); |
| 971 | if ((var_name == nullptr) || (var_name[0] == '\0')) { |
| 972 | result.AppendError("'settings insert-after' command requires a valid " |
| 973 | "variable name; No value supplied"); |
| 974 | result.SetStatus(eReturnStatusFailed); |
| 975 | return false; |
| 976 | } |
| 977 | |
| 978 | // Split the raw command into var_name, index_value, and value triple. |
| 979 | llvm::StringRef raw_str(command); |
| 980 | std::string var_value_string = raw_str.split(var_name).second.str(); |
| 981 | const char *var_value_cstr = |
| 982 | Args::StripSpaces(var_value_string, true, true, false); |
| 983 | |
Jonas Devlieghere | 5717986 | 2019-04-27 06:19:42 +0000 | [diff] [blame] | 984 | Status error(GetDebugger().SetPropertyValue( |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 985 | &m_exe_ctx, eVarSetOperationInsertAfter, var_name, var_value_cstr)); |
| 986 | if (error.Fail()) { |
| 987 | result.AppendError(error.AsCString()); |
| 988 | result.SetStatus(eReturnStatusFailed); |
| 989 | return false; |
| 990 | } |
| 991 | |
| 992 | return result.Succeeded(); |
| 993 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 994 | }; |
| 995 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 996 | // CommandObjectSettingsAppend |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 997 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 998 | class CommandObjectSettingsAppend : public CommandObjectRaw { |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 999 | public: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1000 | CommandObjectSettingsAppend(CommandInterpreter &interpreter) |
| 1001 | : CommandObjectRaw(interpreter, "settings append", |
| 1002 | "Append one or more values to a debugger array, " |
Zachary Turner | a449698 | 2016-10-05 21:14:38 +0000 | [diff] [blame] | 1003 | "dictionary, or string setting.") { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1004 | CommandArgumentEntry arg1; |
| 1005 | CommandArgumentEntry arg2; |
| 1006 | CommandArgumentData var_name_arg; |
| 1007 | CommandArgumentData value_arg; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1008 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1009 | // Define the first (and only) variant of this arg. |
| 1010 | var_name_arg.arg_type = eArgTypeSettingVariableName; |
| 1011 | var_name_arg.arg_repetition = eArgRepeatPlain; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1012 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1013 | // There is only one variant this argument could be; put it into the |
| 1014 | // argument entry. |
| 1015 | arg1.push_back(var_name_arg); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1016 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1017 | // Define the first (and only) variant of this arg. |
| 1018 | value_arg.arg_type = eArgTypeValue; |
| 1019 | value_arg.arg_repetition = eArgRepeatPlain; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1020 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1021 | // There is only one variant this argument could be; put it into the |
| 1022 | // argument entry. |
| 1023 | arg2.push_back(value_arg); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1024 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1025 | // Push the data for the first argument into the m_arguments vector. |
| 1026 | m_arguments.push_back(arg1); |
| 1027 | m_arguments.push_back(arg2); |
| 1028 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1029 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1030 | ~CommandObjectSettingsAppend() override = default; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1031 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1032 | // Overrides base class's behavior where WantsCompletion = |
| 1033 | // !WantsRawCommandString. |
| 1034 | bool WantsCompletion() override { return true; } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1035 | |
Raphael Isemann | 2443bbd | 2018-07-02 21:29:56 +0000 | [diff] [blame] | 1036 | int HandleArgumentCompletion( |
| 1037 | CompletionRequest &request, |
| 1038 | OptionElementVector &opt_element_vector) override { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1039 | // Attempting to complete variable name |
Raphael Isemann | 2443bbd | 2018-07-02 21:29:56 +0000 | [diff] [blame] | 1040 | if (request.GetCursorIndex() < 2) |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1041 | CommandCompletions::InvokeCommonCompletionCallbacks( |
| 1042 | GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, |
Raphael Isemann | a2e76c0 | 2018-07-13 18:28:14 +0000 | [diff] [blame] | 1043 | request, nullptr); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1044 | |
Raphael Isemann | 1a6d7ab | 2018-07-27 18:42:46 +0000 | [diff] [blame] | 1045 | return request.GetNumberOfMatches(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1046 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1047 | |
| 1048 | protected: |
Raphael Isemann | 4d51a90 | 2018-07-12 22:28:52 +0000 | [diff] [blame] | 1049 | bool DoExecute(llvm::StringRef command, |
| 1050 | CommandReturnObject &result) override { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1051 | result.SetStatus(eReturnStatusSuccessFinishNoResult); |
| 1052 | Args cmd_args(command); |
| 1053 | const size_t argc = cmd_args.GetArgumentCount(); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1054 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1055 | if (argc < 2) { |
| 1056 | result.AppendError("'settings append' takes more arguments"); |
| 1057 | result.SetStatus(eReturnStatusFailed); |
| 1058 | return false; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1059 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1060 | |
| 1061 | const char *var_name = cmd_args.GetArgumentAtIndex(0); |
| 1062 | if ((var_name == nullptr) || (var_name[0] == '\0')) { |
| 1063 | result.AppendError("'settings append' command requires a valid variable " |
| 1064 | "name; No value supplied"); |
| 1065 | result.SetStatus(eReturnStatusFailed); |
| 1066 | return false; |
| 1067 | } |
| 1068 | |
Adrian Prantl | 0509724 | 2018-04-30 16:49:04 +0000 | [diff] [blame] | 1069 | // Do not perform cmd_args.Shift() since StringRef is manipulating the raw |
| 1070 | // character string later on. |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1071 | |
| 1072 | // Split the raw command into var_name and value pair. |
| 1073 | llvm::StringRef raw_str(command); |
| 1074 | std::string var_value_string = raw_str.split(var_name).second.str(); |
| 1075 | const char *var_value_cstr = |
| 1076 | Args::StripSpaces(var_value_string, true, true, false); |
| 1077 | |
Jonas Devlieghere | 5717986 | 2019-04-27 06:19:42 +0000 | [diff] [blame] | 1078 | Status error(GetDebugger().SetPropertyValue( |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1079 | &m_exe_ctx, eVarSetOperationAppend, var_name, var_value_cstr)); |
| 1080 | if (error.Fail()) { |
| 1081 | result.AppendError(error.AsCString()); |
| 1082 | result.SetStatus(eReturnStatusFailed); |
| 1083 | return false; |
| 1084 | } |
| 1085 | |
| 1086 | return result.Succeeded(); |
| 1087 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1088 | }; |
| 1089 | |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1090 | // CommandObjectSettingsClear |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1091 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1092 | class CommandObjectSettingsClear : public CommandObjectParsed { |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1093 | public: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1094 | CommandObjectSettingsClear(CommandInterpreter &interpreter) |
| 1095 | : CommandObjectParsed( |
| 1096 | interpreter, "settings clear", |
| 1097 | "Clear a debugger setting array, dictionary, or string.", nullptr) { |
| 1098 | CommandArgumentEntry arg; |
| 1099 | CommandArgumentData var_name_arg; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1100 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1101 | // Define the first (and only) variant of this arg. |
| 1102 | var_name_arg.arg_type = eArgTypeSettingVariableName; |
| 1103 | var_name_arg.arg_repetition = eArgRepeatPlain; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1104 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1105 | // There is only one variant this argument could be; put it into the |
| 1106 | // argument entry. |
| 1107 | arg.push_back(var_name_arg); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1108 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1109 | // Push the data for the first argument into the m_arguments vector. |
| 1110 | m_arguments.push_back(arg); |
| 1111 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1112 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1113 | ~CommandObjectSettingsClear() override = default; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1114 | |
Raphael Isemann | 2443bbd | 2018-07-02 21:29:56 +0000 | [diff] [blame] | 1115 | int HandleArgumentCompletion( |
| 1116 | CompletionRequest &request, |
| 1117 | OptionElementVector &opt_element_vector) override { |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1118 | // Attempting to complete variable name |
Raphael Isemann | 2443bbd | 2018-07-02 21:29:56 +0000 | [diff] [blame] | 1119 | if (request.GetCursorIndex() < 2) |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1120 | CommandCompletions::InvokeCommonCompletionCallbacks( |
| 1121 | GetCommandInterpreter(), CommandCompletions::eSettingsNameCompletion, |
Raphael Isemann | a2e76c0 | 2018-07-13 18:28:14 +0000 | [diff] [blame] | 1122 | request, nullptr); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1123 | |
Raphael Isemann | 1a6d7ab | 2018-07-27 18:42:46 +0000 | [diff] [blame] | 1124 | return request.GetNumberOfMatches(); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1125 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1126 | |
| 1127 | protected: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1128 | bool DoExecute(Args &command, CommandReturnObject &result) override { |
| 1129 | result.SetStatus(eReturnStatusSuccessFinishNoResult); |
| 1130 | const size_t argc = command.GetArgumentCount(); |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1131 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1132 | if (argc != 1) { |
| 1133 | result.AppendError("'settings clear' takes exactly one argument"); |
| 1134 | result.SetStatus(eReturnStatusFailed); |
| 1135 | return false; |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1136 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1137 | |
| 1138 | const char *var_name = command.GetArgumentAtIndex(0); |
| 1139 | if ((var_name == nullptr) || (var_name[0] == '\0')) { |
| 1140 | result.AppendError("'settings clear' command requires a valid variable " |
| 1141 | "name; No value supplied"); |
| 1142 | result.SetStatus(eReturnStatusFailed); |
| 1143 | return false; |
| 1144 | } |
| 1145 | |
Jonas Devlieghere | 5717986 | 2019-04-27 06:19:42 +0000 | [diff] [blame] | 1146 | Status error(GetDebugger().SetPropertyValue( |
Zachary Turner | 31d97a5 | 2016-11-17 18:08:12 +0000 | [diff] [blame] | 1147 | &m_exe_ctx, eVarSetOperationClear, var_name, llvm::StringRef())); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1148 | if (error.Fail()) { |
| 1149 | result.AppendError(error.AsCString()); |
| 1150 | result.SetStatus(eReturnStatusFailed); |
| 1151 | return false; |
| 1152 | } |
| 1153 | |
| 1154 | return result.Succeeded(); |
| 1155 | } |
Jim Ingham | 5a98841 | 2012-06-08 21:56:10 +0000 | [diff] [blame] | 1156 | }; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1157 | |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 1158 | // CommandObjectMultiwordSettings |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1159 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 1160 | CommandObjectMultiwordSettings::CommandObjectMultiwordSettings( |
| 1161 | CommandInterpreter &interpreter) |
| 1162 | : CommandObjectMultiword(interpreter, "settings", |
| 1163 | "Commands for managing LLDB settings.", |
| 1164 | "settings <subcommand> [<command-options>]") { |
| 1165 | LoadSubCommand("set", |
| 1166 | CommandObjectSP(new CommandObjectSettingsSet(interpreter))); |
| 1167 | LoadSubCommand("show", |
| 1168 | CommandObjectSP(new CommandObjectSettingsShow(interpreter))); |
| 1169 | LoadSubCommand("list", |
| 1170 | CommandObjectSP(new CommandObjectSettingsList(interpreter))); |
| 1171 | LoadSubCommand("remove", |
| 1172 | CommandObjectSP(new CommandObjectSettingsRemove(interpreter))); |
| 1173 | LoadSubCommand("replace", CommandObjectSP( |
| 1174 | new CommandObjectSettingsReplace(interpreter))); |
| 1175 | LoadSubCommand( |
| 1176 | "insert-before", |
| 1177 | CommandObjectSP(new CommandObjectSettingsInsertBefore(interpreter))); |
| 1178 | LoadSubCommand( |
| 1179 | "insert-after", |
| 1180 | CommandObjectSP(new CommandObjectSettingsInsertAfter(interpreter))); |
| 1181 | LoadSubCommand("append", |
| 1182 | CommandObjectSP(new CommandObjectSettingsAppend(interpreter))); |
| 1183 | LoadSubCommand("clear", |
| 1184 | CommandObjectSP(new CommandObjectSettingsClear(interpreter))); |
Jonas Devlieghere | b76e25a | 2018-10-26 00:00:17 +0000 | [diff] [blame] | 1185 | LoadSubCommand("write", |
| 1186 | CommandObjectSP(new CommandObjectSettingsWrite(interpreter))); |
| 1187 | LoadSubCommand("read", |
| 1188 | CommandObjectSP(new CommandObjectSettingsRead(interpreter))); |
Caroline Tice | 3df9a8d | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 1189 | } |
| 1190 | |
Eugene Zelenko | 3f18ea0 | 2016-02-24 02:05:55 +0000 | [diff] [blame] | 1191 | CommandObjectMultiwordSettings::~CommandObjectMultiwordSettings() = default; |