11#include "llvm/ADT/StringRef.h"
24#define LLDB_OPTIONS_settings_set
25#include "CommandOptions.inc"
31 "Set the value of the specified debugger setting.") {
43 arg1.push_back(var_name_arg);
51 arg2.push_back(value_arg);
58 "\nWhen setting a dictionary or array variable, you can set multiple entries \
59at once by giving the values to the set command. For example:"
62(lldb) settings set target.run-args value1 value2 value3
63(lldb) settings set target.env-vars MYPATH=~/.:/usr/bin SOME_ENV_VAR=12345
65(lldb) settings show target.run-args
69(lldb) settings show target.env-vars
74 "Warning: The 'set' command re-sets the entire array or dictionary. If you \
75just want to add, remove or update individual values (or add something to \
76the end), use one of the other settings sub-commands: append, replace, \
77insert-before or insert-after.");
88 class CommandOptions :
public Options {
99 switch (short_option) {
110 llvm_unreachable(
"Unimplemented option");
123 return llvm::ArrayRef(g_settings_set_options);
137 const char *arg =
nullptr;
138 size_t setting_var_idx;
139 for (setting_var_idx = 0; setting_var_idx < argc; ++setting_var_idx) {
141 if (arg && arg[0] !=
'-')
161 const char *setting_var_name =
164 lldb::OptionValueSP value_sp(
174 Args cmd_args(command);
181 const size_t argc = cmd_args.GetArgumentCount();
184 result.
AppendError(
"'settings set' takes more arguments");
188 const char *var_name = cmd_args.GetArgumentAtIndex(0);
189 if ((var_name ==
nullptr) || (var_name[0] ==
'\0')) {
191 "'settings set' command requires a valid variable name");
208 llvm::StringRef var_value(command);
209 var_value = var_value.split(var_name).second.ltrim();
214 var_name, var_value);
216 if (
error.Success()) {
225 var_name, var_value);
247 "Show matching debugger settings and their current "
248 "values. Defaults to showing all settings.",
259 arg1.push_back(var_name_arg);
280 for (
const auto &arg : args) {
284 if (
error.Success()) {
300#define LLDB_OPTIONS_settings_write
301#include "CommandOptions.inc"
307 interpreter,
"settings export",
308 "Write matching debugger settings and their "
309 "current values to a file that can be read in with "
310 "\"settings read\". Defaults to writing all settings.",
321 arg1.push_back(var_name_arg);
342 switch (short_option) {
350 llvm_unreachable(
"Unimplemented option");
362 return llvm::ArrayRef(g_settings_write_options);
374 std::string path(file_spec.
GetPath());
382 lldb::eFilePermissionsFileDefault);
398 for (
const auto &arg : args) {
401 if (!
error.Success()) {
414#define LLDB_OPTIONS_settings_read
415#include "CommandOptions.inc"
421 interpreter,
"settings read",
422 "Read settings previously saved to a file with \"settings write\".",
440 switch (short_option) {
445 llvm_unreachable(
"Unimplemented option");
456 return llvm::ArrayRef(g_settings_read_options);
487 "List and describe matching debugger settings. "
488 "Defaults to all listing all settings.",
502 arg.push_back(var_name_arg);
503 arg.push_back(prefix_name_arg);
525 const bool dump_qualified_name =
true;
528 const char *property_path = arg.c_str();
536 dump_qualified_name);
557 "Remove a value from a setting, specified by array "
558 "index or dictionary key.") {
571 arg1.push_back(var_name_arg);
582 arg2.push_back(index_arg);
583 arg2.push_back(key_arg);
608 Args cmd_args(command);
616 result.
AppendError(
"'settings remove' takes an array or dictionary item, "
617 "or an array followed by one or more indexes, or a "
618 "dictionary followed by one or more key names to "
624 if ((var_name ==
nullptr) || (var_name[0] ==
'\0')) {
626 "'settings remove' command requires a valid variable name");
631 llvm::StringRef var_value(command);
632 var_value = var_value.split(var_name).second.trim();
651 "Replace the debugger setting value specified by "
652 "array index or dictionary key.") {
667 arg1.push_back(var_name_arg);
678 arg2.push_back(index_arg);
679 arg2.push_back(key_arg);
687 arg3.push_back(value_arg);
716 Args cmd_args(command);
718 if ((var_name ==
nullptr) || (var_name[0] ==
'\0')) {
719 result.
AppendError(
"'settings replace' command requires a valid variable "
720 "name; No value supplied");
725 llvm::StringRef var_value(command);
726 var_value = var_value.split(var_name).second.trim();
747 "Insert one or more values into an debugger array "
748 "setting immediately before the specified element "
763 arg1.push_back(var_name_arg);
771 arg2.push_back(index_arg);
779 arg3.push_back(value_arg);
808 Args cmd_args(command);
812 result.
AppendError(
"'settings insert-before' takes more arguments");
817 if ((var_name ==
nullptr) || (var_name[0] ==
'\0')) {
818 result.
AppendError(
"'settings insert-before' command requires a valid "
819 "variable name; No value supplied");
824 llvm::StringRef var_value(command);
825 var_value = var_value.split(var_name).second.trim();
844 "Insert one or more values into a debugger array "
845 "settings after the specified element index.") {
859 arg1.push_back(var_name_arg);
867 arg2.push_back(index_arg);
875 arg3.push_back(value_arg);
904 Args cmd_args(command);
908 result.
AppendError(
"'settings insert-after' takes more arguments");
913 if ((var_name ==
nullptr) || (var_name[0] ==
'\0')) {
914 result.
AppendError(
"'settings insert-after' command requires a valid "
915 "variable name; No value supplied");
920 llvm::StringRef var_value(command);
921 var_value = var_value.split(var_name).second.trim();
940 "Append one or more values to a debugger array, "
941 "dictionary, or string setting.") {
953 arg1.push_back(var_name_arg);
961 arg2.push_back(value_arg);
988 Args cmd_args(command);
992 result.
AppendError(
"'settings append' takes more arguments");
997 if ((var_name ==
nullptr) || (var_name[0] ==
'\0')) {
998 result.
AppendError(
"'settings append' command requires a valid variable "
999 "name; No value supplied");
1007 llvm::StringRef var_value(command);
1008 var_value = var_value.split(var_name).second.trim();
1022#define LLDB_OPTIONS_settings_clear
1023#include "CommandOptions.inc"
1029 interpreter,
"settings clear",
1030 "Clear a debugger setting array, dictionary, or string. "
1031 "If '-a' option is specified, it clears all settings.", nullptr) {
1041 arg.push_back(var_name_arg);
1070 switch (short_option) {
1075 llvm_unreachable(
"Unimplemented option");
1085 return llvm::ArrayRef(g_settings_clear_options);
1098 result.
AppendError(
"'settings clear --all' doesn't take any arguments");
1106 result.
AppendError(
"'settings clear' takes exactly one argument");
1111 if ((var_name ==
nullptr) || (var_name[0] ==
'\0')) {
1112 result.
AppendError(
"'settings clear' command requires a valid variable "
1113 "name; No value supplied");
1136 "Commands for managing LLDB settings.",
1137 "settings <subcommand> [<command-options>]") {
static llvm::raw_ostream & error(Stream &strm)
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
CommandObjectSettingsAppend(CommandInterpreter &interpreter)
~CommandObjectSettingsAppend() override=default
bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override
bool WantsCompletion() override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
void OptionParsingStarting(ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
~CommandOptions() override=default
bool DoExecute(Args &command, CommandReturnObject &result) override
Options * GetOptions() override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
~CommandObjectSettingsClear() override=default
CommandObjectSettingsClear(CommandInterpreter &interpreter)
~CommandObjectSettingsInsertAfter() override=default
CommandObjectSettingsInsertAfter(CommandInterpreter &interpreter)
bool WantsCompletion() override
bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
~CommandObjectSettingsInsertBefore() override=default
bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override
CommandObjectSettingsInsertBefore(CommandInterpreter &interpreter)
bool WantsCompletion() override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
CommandObjectSettingsList(CommandInterpreter &interpreter)
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
~CommandObjectSettingsList() override=default
bool DoExecute(Args &args, CommandReturnObject &result) override
~CommandOptions() override=default
void OptionParsingStarting(ExecutionContext *execution_context) override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
~CommandObjectSettingsRead() override=default
CommandObjectSettingsRead(CommandInterpreter &interpreter)
Options * GetOptions() override
bool DoExecute(Args &command, CommandReturnObject &result) override
bool WantsCompletion() override
CommandObjectSettingsRemove(CommandInterpreter &interpreter)
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
~CommandObjectSettingsRemove() override=default
bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override
bool WantsCompletion() override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override
CommandObjectSettingsReplace(CommandInterpreter &interpreter)
~CommandObjectSettingsReplace() override=default
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
void OptionParsingStarting(ExecutionContext *execution_context) override
~CommandOptions() override=default
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override
Options * GetOptions() override
CommandObjectSettingsSet(CommandInterpreter &interpreter)
~CommandObjectSettingsSet() override=default
bool WantsCompletion() override
CommandObjectSettingsShow(CommandInterpreter &interpreter)
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
bool DoExecute(Args &args, CommandReturnObject &result) override
~CommandObjectSettingsShow() override=default
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
~CommandOptions() override=default
void OptionParsingStarting(ExecutionContext *execution_context) override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
~CommandObjectSettingsWrite() override=default
bool DoExecute(Args &args, CommandReturnObject &result) override
CommandObjectSettingsWrite(CommandInterpreter &interpreter)
Options * GetOptions() override
A command line argument class.
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
const char * GetArgumentAtIndex(size_t idx) const
Gets the NULL terminated C string argument pointer for the argument at index idx.
static bool InvokeCommonCompletionCallbacks(CommandInterpreter &interpreter, uint32_t completion_mask, lldb_private::CompletionRequest &request, SearchFilter *searcher)
void SetPrintErrors(bool print_errors)
void SetEchoCommands(bool echo_commands)
void SetAddToHistory(bool add_to_history)
void SetStopOnError(bool stop_on_error)
void SetPrintResults(bool print_results)
void HandleCommandsFromFile(FileSpec &file, const ExecutionContext &context, const CommandInterpreterRunOptions &options, CommandReturnObject &result)
Execute a list of commands from a file.
~CommandObjectMultiwordSettings() override
CommandObjectMultiwordSettings(CommandInterpreter &interpreter)
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
std::vector< CommandArgumentData > CommandArgumentEntry
virtual void SetHelpLong(llvm::StringRef str)
ExecutionContext m_exe_ctx
std::vector< CommandArgumentEntry > m_arguments
CommandInterpreter & GetCommandInterpreter()
CommandInterpreter & m_interpreter
bool ParseOptions(Args &args, CommandReturnObject &result)
void void AppendError(llvm::StringRef in_string)
void SetStatus(lldb::ReturnStatus status)
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
Stream & GetOutputStream()
"lldb/Utility/ArgCompletionRequest.h"
const Args & GetParsedLine() const
size_t GetCursorIndex() const
Status SetPropertyValue(const ExecutionContext *exe_ctx, VarSetOperationType op, llvm::StringRef property_path, llvm::StringRef value) override
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
void Clear()
Clear the object's state.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
void Resolve(llvm::SmallVectorImpl< char > &path)
Resolve path to make it canonical.
static FileSystem & Instance()
bool IsValid() const override
IsValid.
A command line option parsing protocol class.
std::vector< Option > m_getopt_table
virtual void DumpAllDescriptions(CommandInterpreter &interpreter, Stream &strm) const
virtual void DumpAllPropertyValues(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask, bool is_json=false)
virtual lldb::OptionValuePropertiesSP GetValueProperties() const
size_t EOL()
Output and End of Line character to the stream.
A class that represents a running process on the host machine.
std::vector< OptionArgElement > OptionElementVector
@ eVarSetOperationReplace
@ eVarSetOperationInsertBefore
@ eVarSetOperationInsertAfter
@ eSettingsNameCompletion
@ eReturnStatusSuccessFinishResult
@ eReturnStatusSuccessFinishNoResult
@ eArgTypeSettingVariableName
Used to build individual command argument lists.
ArgumentRepetitionType arg_repetition
lldb::CommandArgumentType arg_type