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 =
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");
207 llvm::StringRef var_value(command);
208 var_value = var_value.split(var_name).second.ltrim();
213 var_name, var_value);
215 if (
error.Success()) {
224 var_name, var_value);
245 "Show matching debugger settings and their current "
246 "values. Defaults to showing all settings.",
258 for (
const auto &arg : args) {
262 if (
error.Success()) {
276#define LLDB_OPTIONS_settings_write
277#include "CommandOptions.inc"
283 interpreter,
"settings export",
284 "Write matching debugger settings and their "
285 "current values to a file that can be read in with "
286 "\"settings read\". Defaults to writing all settings.",
306 switch (short_option) {
314 llvm_unreachable(
"Unimplemented option");
326 return llvm::ArrayRef(g_settings_write_options);
338 std::string path(file_spec.
GetPath());
346 lldb::eFilePermissionsFileDefault);
362 for (
const auto &arg : args) {
365 if (!
error.Success()) {
376#define LLDB_OPTIONS_settings_read
377#include "CommandOptions.inc"
383 interpreter,
"settings read",
384 "Read settings previously saved to a file with \"settings write\".",
402 switch (short_option) {
407 llvm_unreachable(
"Unimplemented option");
418 return llvm::ArrayRef(g_settings_read_options);
448 "List and describe matching debugger settings. "
449 "Defaults to all listing all settings.",
463 arg.push_back(var_name_arg);
464 arg.push_back(prefix_name_arg);
486 const bool dump_qualified_name =
true;
489 const char *property_path = arg.c_str();
497 dump_qualified_name);
516 "Remove a value from a setting, specified by array "
517 "index or dictionary key.") {
530 arg1.push_back(var_name_arg);
541 arg2.push_back(index_arg);
542 arg2.push_back(key_arg);
567 Args cmd_args(command);
575 result.
AppendError(
"'settings remove' takes an array or dictionary item, "
576 "or an array followed by one or more indexes, or a "
577 "dictionary followed by one or more key names to "
583 if ((var_name ==
nullptr) || (var_name[0] ==
'\0')) {
585 "'settings remove' command requires a valid variable name");
590 llvm::StringRef var_value(command);
591 var_value = var_value.split(var_name).second.trim();
607 "Replace the debugger setting value specified by "
608 "array index or dictionary key.") {
623 arg1.push_back(var_name_arg);
634 arg2.push_back(index_arg);
635 arg2.push_back(key_arg);
643 arg3.push_back(value_arg);
672 Args cmd_args(command);
674 if ((var_name ==
nullptr) || (var_name[0] ==
'\0')) {
675 result.
AppendError(
"'settings replace' command requires a valid variable "
676 "name; No value supplied");
681 llvm::StringRef var_value(command);
682 var_value = var_value.split(var_name).second.trim();
700 "Insert one or more values into an debugger array "
701 "setting immediately before the specified element "
716 arg1.push_back(var_name_arg);
724 arg2.push_back(index_arg);
732 arg3.push_back(value_arg);
761 Args cmd_args(command);
765 result.
AppendError(
"'settings insert-before' takes more arguments");
770 if ((var_name ==
nullptr) || (var_name[0] ==
'\0')) {
771 result.
AppendError(
"'settings insert-before' command requires a valid "
772 "variable name; No value supplied");
777 llvm::StringRef var_value(command);
778 var_value = var_value.split(var_name).second.trim();
794 "Insert one or more values into a debugger array "
795 "settings after the specified element index.") {
809 arg1.push_back(var_name_arg);
817 arg2.push_back(index_arg);
825 arg3.push_back(value_arg);
854 Args cmd_args(command);
858 result.
AppendError(
"'settings insert-after' takes more arguments");
863 if ((var_name ==
nullptr) || (var_name[0] ==
'\0')) {
864 result.
AppendError(
"'settings insert-after' command requires a valid "
865 "variable name; No value supplied");
870 llvm::StringRef var_value(command);
871 var_value = var_value.split(var_name).second.trim();
887 "Append one or more values to a debugger array, "
888 "dictionary, or string setting.") {
900 arg1.push_back(var_name_arg);
908 arg2.push_back(value_arg);
935 Args cmd_args(command);
939 result.
AppendError(
"'settings append' takes more arguments");
944 if ((var_name ==
nullptr) || (var_name[0] ==
'\0')) {
945 result.
AppendError(
"'settings append' command requires a valid variable "
946 "name; No value supplied");
954 llvm::StringRef var_value(command);
955 var_value = var_value.split(var_name).second.trim();
966#define LLDB_OPTIONS_settings_clear
967#include "CommandOptions.inc"
973 interpreter,
"settings clear",
974 "Clear a debugger setting array, dictionary, or string. "
975 "If '-a' option is specified, it clears all settings.", nullptr) {
1002 switch (short_option) {
1007 llvm_unreachable(
"Unimplemented option");
1017 return llvm::ArrayRef(g_settings_clear_options);
1030 result.
AppendError(
"'settings clear --all' doesn't take any arguments");
1038 result.
AppendError(
"'settings clear' takes exactly one argument");
1043 if ((var_name ==
nullptr) || (var_name[0] ==
'\0')) {
1044 result.
AppendError(
"'settings clear' command requires a valid variable "
1045 "name; No value supplied");
1065 "Commands for managing LLDB settings.",
1066 "settings <subcommand> [<command-options>]") {
static llvm::raw_ostream & error(Stream &strm)
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
CommandObjectSettingsAppend(CommandInterpreter &interpreter)
~CommandObjectSettingsAppend() override=default
void 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
Options * GetOptions() override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
~CommandObjectSettingsClear() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectSettingsClear(CommandInterpreter &interpreter)
~CommandObjectSettingsInsertAfter() override=default
void DoExecute(llvm::StringRef command, CommandReturnObject &result) override
CommandObjectSettingsInsertAfter(CommandInterpreter &interpreter)
bool WantsCompletion() override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
~CommandObjectSettingsInsertBefore() override=default
CommandObjectSettingsInsertBefore(CommandInterpreter &interpreter)
bool WantsCompletion() override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
void DoExecute(llvm::StringRef command, CommandReturnObject &result) override
CommandObjectSettingsList(CommandInterpreter &interpreter)
void DoExecute(Args &args, CommandReturnObject &result) override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
~CommandObjectSettingsList() override=default
~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
void DoExecute(Args &command, CommandReturnObject &result) override
void DoExecute(llvm::StringRef command, CommandReturnObject &result) override
bool WantsCompletion() override
CommandObjectSettingsRemove(CommandInterpreter &interpreter)
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
~CommandObjectSettingsRemove() override=default
bool WantsCompletion() override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
void 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 default version handles argument definitions that have only one argument type,...
Options * GetOptions() override
CommandObjectSettingsSet(CommandInterpreter &interpreter)
~CommandObjectSettingsSet() override=default
bool WantsCompletion() override
void DoExecute(llvm::StringRef command, CommandReturnObject &result) override
void DoExecute(Args &args, CommandReturnObject &result) override
CommandObjectSettingsShow(CommandInterpreter &interpreter)
~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.
void DoExecute(Args &args, CommandReturnObject &result) override
~CommandObjectSettingsWrite() override=default
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)
void AddSimpleArgumentList(lldb::CommandArgumentType arg_type, ArgumentRepetitionType repetition_type=eArgRepeatPlain)
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
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
@ eReturnStatusSuccessFinishResult
@ eReturnStatusSuccessFinishNoResult
@ eArgTypeSettingVariableName
std::shared_ptr< lldb_private::OptionValue > OptionValueSP
Used to build individual command argument lists.
ArgumentRepetitionType arg_repetition
lldb::CommandArgumentType arg_type