27#include "llvm/ADT/StringRef.h"
36#define LLDB_OPTIONS_source
37#include "CommandOptions.inc"
43 interpreter,
"command source",
44 "Read and execute LLDB commands from the file <filename>.",
52 uint32_t index)
override {
53 return std::string(
"");
72 switch (short_option) {
90 llvm_unreachable(
"Unimplemented option");
104 return llvm::ArrayRef(g_source_options);
118 "'%s' takes exactly one executable filename argument.",
124 if (
m_options.m_cmd_relative_to_command_file) {
127 result.
AppendError(
"command source -C can only be specified "
128 "from a command file");
134 FileSpec cmd_file(command[0].ref());
138 result.
AppendError(
"command source -C can only be used "
139 "with a relative path.");
150 if (
m_options.m_stop_on_error.OptionWasSet() ||
152 m_options.m_stop_on_continue.OptionWasSet()) {
153 if (
m_options.m_stop_on_continue.OptionWasSet())
155 m_options.m_stop_on_continue.GetCurrentValue());
157 if (
m_options.m_stop_on_error.OptionWasSet())
161 if (
m_options.m_silent_run.GetCurrentValue()) {
171 m_interpreter.HandleCommandsFromFile(cmd_file, options, result);
177#pragma mark CommandObjectCommandsAlias
180#define LLDB_OPTIONS_alias
181#include "CommandOptions.inc"
184 "Enter your Python command(s). Type 'DONE' to end.\n"
185 "You must define a Python function with this signature:\n"
186 "def my_command_impl(debugger, args, exe_ctx, result, internal_dict):\n";
197 return llvm::ArrayRef(g_alias_options);
204 const int short_option =
GetDefinitions()[option_idx].short_option;
205 std::string option_str(option_value);
207 switch (short_option) {
209 m_help.SetCurrentValue(option_str);
219 llvm_unreachable(
"Unimplemented option");
242 interpreter,
"command alias",
243 "Define a custom command in terms of an existing command.") {
248 "'alias' allows the user to create a short-cut or abbreviation for long \
249commands, multi-word commands, and commands that take particular options. \
250Below are some simple examples of how one might use the 'alias' command:"
253(lldb) command alias sc script
255 Creates the abbreviation 'sc' for the 'script' command.
257(lldb) command alias bp breakpoint
260 " Creates the abbreviation 'bp' for the 'breakpoint' command. Since \
261breakpoint commands are two-word commands, the user would still need to \
262enter the second word after 'bp', e.g. 'bp enable' or 'bp delete'."
265(lldb) command alias bpl breakpoint list
267 Creates the abbreviation 'bpl' for the two-word command 'breakpoint list'.
270 "An alias can include some options for the command, with the values either \
271filled in at the time the alias is created, or specified as positional \
272arguments, to be filled in when the alias is invoked. The following example \
273shows how to create aliases with options:"
276(lldb) command alias bfl breakpoint set -f %1 -l %2
279 " Creates the abbreviation 'bfl' (for break-file-line), with the -f and -l \
280options already part of the alias. So if the user wants to set a breakpoint \
281by file and line without explicitly having to use the -f and -l options, the \
282user can now use 'bfl' instead. The '%1' and '%2' are positional placeholders \
283for the actual arguments that will be passed when the alias command is used. \
284The number in the placeholder refers to the position/order the actual value \
285occupies when the alias is used. All the occurrences of '%1' in the alias \
286will be replaced with the first argument, all the occurrences of '%2' in the \
287alias will be replaced with the second argument, and so on. This also allows \
288actual arguments to be used multiple times within an alias (see 'process \
289launch' example below)."
293 "Note: the positional arguments must substitute as whole words in the resultant \
294command, so you can't at present do something like this to append the file extension \
298(lldb) command alias bcppfl breakpoint set -f %1.cpp -l %2
301 "For more complex aliasing, use the \"command regex\" command instead. In the \
302'bfl' case above, the actual file value will be filled in with the first argument \
303following 'bfl' and the actual line number value will be filled in with the second \
304argument. The user would use this alias as follows:"
307(lldb) command alias bfl breakpoint set -f %1 -l %2
308(lldb) bfl my-file.c 137
310This would be the same as if the user had entered 'breakpoint set -f my-file.c -l 137'.
314(lldb) command alias pltty process launch -s -o %1 -e %1
315(lldb) pltty /dev/tty0
317 Interpreted as 'process launch -s -o /dev/tty0 -e /dev/tty0'
320 "If the user always wanted to pass the same value to a particular option, the \
321alias could be defined with that value directly in the alias as a constant, \
322rather than using a positional placeholder:"
325(lldb) command alias bl3 breakpoint set -f %1 -l 3
327 Always sets a breakpoint on line 3 of whatever file is indicated.
331 "If the alias abbreviation or the full alias command collides with another \
332existing command, the command resolver will prefer to use the alias over any \
333other command as far as there is only one alias command match.");
348 arg1.push_back(alias_arg);
356 arg2.push_back(cmd_arg);
364 arg3.push_back(options_arg);
375 void DoExecute(llvm::StringRef raw_command_line,
377 if (raw_command_line.empty()) {
378 result.
AppendError(
"'command alias' requires at least two arguments");
385 OptionsWithRaw args_with_suffix(raw_command_line);
387 if (args_with_suffix.HasArgs())
392 llvm::StringRef raw_command_string = args_with_suffix.GetRawPart();
393 Args args(raw_command_string);
395 if (args.GetArgumentCount() < 2) {
396 result.
AppendError(
"'command alias' requires at least two arguments");
402 auto alias_command = args[0].ref();
403 if (alias_command.starts_with(
"-")) {
404 result.
AppendError(
"aliases starting with a dash are not supported");
405 if (alias_command ==
"--help" || alias_command ==
"--long-help") {
406 result.
AppendWarning(
"if trying to pass options to 'command alias' add "
407 "a -- at the end of the options");
414 size_t pos = raw_command_string.find(alias_command);
416 raw_command_string = raw_command_string.substr(alias_command.size());
417 pos = raw_command_string.find_first_not_of(
' ');
418 if ((pos != std::string::npos) && (pos > 0))
419 raw_command_string = raw_command_string.substr(pos);
421 result.
AppendError(
"error parsing command string. No alias created");
428 "'%s' is a permanent debugger command and cannot be redefined.",
433 if (
m_interpreter.UserMultiwordCommandExists(alias_command)) {
435 "'%s' is a user container command and cannot be overwritten.\n"
436 "Delete it first with 'command container delete'",
444 llvm::StringRef original_raw_command_string = raw_command_string;
446 m_interpreter.GetCommandObjectForCommand(raw_command_string);
450 "'%s' does not begin with a valid command."
451 " No alias created.",
452 original_raw_command_string.str().c_str());
465 llvm::StringRef raw_command_string,
467 CommandReturnObject &result) {
471 std::make_shared<OptionArgVector>();
473 const bool include_aliases =
true;
481 cmd_obj_sp = cmd_obj.shared_from_this();
486 "overwriting existing definition for '{0}'", alias_command);
489 alias_command, cmd_obj_sp, raw_command_string)) {
496 result.
AppendError(
"Unable to create requested alias.\n");
505 result.
AppendError(
"'command alias' requires at least two arguments");
510 const std::string alias_command(std::string(args[0].ref()));
511 const std::string actual_command(std::string(args[1].ref()));
521 "'%s' is a permanent debugger command and cannot be redefined.",
522 alias_command.c_str());
526 if (
m_interpreter.UserMultiwordCommandExists(alias_command)) {
528 "'%s' is user container command and cannot be overwritten.\n"
529 "Delete it first with 'command container delete'",
530 alias_command.c_str());
537 bool use_subcommand =
false;
538 if (!command_obj_sp) {
540 actual_command.c_str());
546 std::make_shared<OptionArgVector>();
549 auto sub_command = args[0].ref();
550 assert(!sub_command.empty());
552 if (!subcommand_obj_sp) {
554 "'%s' is not a valid sub-command of '%s'. "
555 "Unable to create alias.",
556 args[0].c_str(), actual_command.c_str());
560 sub_cmd_obj = subcommand_obj_sp.get();
561 use_subcommand =
true;
563 cmd_obj = sub_cmd_obj;
568 std::string args_string;
582 "overwriting existing definition for '{0}'", alias_command);
586 alias_command, use_subcommand ? subcommand_obj_sp : command_obj_sp,
594 result.
AppendError(
"Unable to create requested alias.\n");
602#pragma mark CommandObjectCommandsUnalias
609 interpreter,
"command unalias",
610 "Delete one or more custom commands defined by 'command alias'.",
630 CommandObject::CommandMap::iterator pos;
634 result.
AppendError(
"must call 'unalias' with a valid alias");
638 auto command_name = args[0].ref();
642 "'%s' is not a known command.\nTry 'help' to see a "
643 "current list of commands.",
651 "'%s' is not an alias, it is a debugger command which can be "
652 "removed using the 'command delete' command.",
656 "'%s' is a permanent debugger command and cannot be removed.",
665 "Error occurred while attempting to unalias '%s'.",
677#pragma mark CommandObjectCommandsDelete
684 interpreter,
"command delete",
685 "Delete one or more custom commands defined by 'command regex'.",
699 if (ent.second->IsRemovable())
706 CommandObject::CommandMap::iterator pos;
710 "defined regular expression command names",
715 auto command_name = args[0].ref();
718 const bool generate_upropos =
true;
719 const bool generate_type_lookup =
false;
721 &error_msg_stream, command_name, llvm::StringRef(), llvm::StringRef(),
722 generate_upropos, generate_type_lookup);
729 "'%s' is a permanent debugger command and cannot be removed.",
740#define LLDB_OPTIONS_regex
741#include "CommandOptions.inc"
743#pragma mark CommandObjectCommandsAddRegex
750 interpreter,
"command regex",
751 "Define a custom command in terms of "
752 "existing commands by matching "
753 "regular expressions.",
754 "command regex <cmd-name> [s/<regex>/<subst>/ ...]"),
760 "This command allows the user to create powerful regular expression commands \
761with substitutions. The regular expressions and substitutions are specified \
762using the regular expression substitution format of:"
768 "<regex> is a regular expression that can use parenthesis to capture regular \
769expression input and substitute the captured matches in the output using %1 \
770for the first match, %2 for the second, and so on."
774 "The regular expressions can all be specified on the command line if more than \
775one argument is provided. If just the command name is provided on the command \
776line, then the regular expressions and substitutions can be entered on separate \
777lines, followed by an empty line to terminate the command definition."
783 "The following example will define a regular expression command named 'f' that \
784will call 'finish' if there are no arguments, or 'frame select <frame-idx>' if \
785a number follows 'f':"
788 (lldb) command regex f s/^$/finish/ 's/([0-9]+)/frame select %1/')");
801 "Enter one or more sed substitution commands in "
802 "the form: 's/<regex>/<subst>/'.\nTerminate the "
803 "substitution list with an empty line.\n");
809 std::string &data)
override {
814 bool check_only =
false;
815 for (
const std::string &line : lines) {
826 m_interpreter.AddCommand(cmd_sp->GetCommandName(), cmd_sp,
true);
831 void DoExecute(Args &command, CommandReturnObject &result)
override {
834 result.
AppendError(
"usage: 'command regex <command-name> "
835 "[s/<regex1>/<subst1>/ s/<regex2>/<subst2>/ ...]'\n");
840 auto name = command[0].ref();
848 const bool multiple_lines =
true;
850 debugger, IOHandler::Type::Other,
852 llvm::StringRef(
"> "),
854 multiple_lines, color_prompt,
863 for (
auto &entry : command.
entries().drop_front()) {
864 bool check_only =
false;
870 if (
error.Success()) {
884 return Status::FromErrorStringWithFormat(
885 "invalid regular expression command object for: '%.*s'",
886 (
int)regex_sed.size(), regex_sed.data());
890 size_t regex_sed_size = regex_sed.size();
892 if (regex_sed_size <= 1) {
893 return Status::FromErrorStringWithFormat(
894 "regular expression substitution string is too short: '%.*s'",
895 (
int)regex_sed.size(), regex_sed.data());
899 if (regex_sed[0] !=
's') {
900 return Status::FromErrorStringWithFormat(
901 "regular expression substitution string "
902 "doesn't start with 's': '%.*s'",
903 (
int)regex_sed.size(), regex_sed.data());
906 const size_t first_separator_char_pos = 1;
909 const char separator_char = regex_sed[first_separator_char_pos];
910 const size_t second_separator_char_pos =
911 regex_sed.find(separator_char, first_separator_char_pos + 1);
913 if (second_separator_char_pos == std::string::npos) {
914 return Status::FromErrorStringWithFormat(
915 "missing second '%c' separator char after '%.*s' in '%.*s'",
917 (
int)(regex_sed.size() - first_separator_char_pos - 1),
918 regex_sed.data() + (first_separator_char_pos + 1),
919 (
int)regex_sed.size(), regex_sed.data());
923 const size_t third_separator_char_pos =
924 regex_sed.find(separator_char, second_separator_char_pos + 1);
926 if (third_separator_char_pos == std::string::npos) {
927 return Status::FromErrorStringWithFormat(
928 "missing third '%c' separator char after '%.*s' in '%.*s'",
930 (
int)(regex_sed.size() - second_separator_char_pos - 1),
931 regex_sed.data() + (second_separator_char_pos + 1),
932 (
int)regex_sed.size(), regex_sed.data());
936 if (third_separator_char_pos != regex_sed_size - 1) {
938 if (regex_sed.find_first_not_of(
"\t\n\v\f\r ",
939 third_separator_char_pos + 1) !=
941 return Status::FromErrorStringWithFormat(
942 "extra data found after the '%.*s' regular expression substitution "
944 (
int)third_separator_char_pos + 1, regex_sed.data(),
945 (
int)(regex_sed.size() - third_separator_char_pos - 1),
946 regex_sed.data() + (third_separator_char_pos + 1));
949 }
else if (first_separator_char_pos + 1 == second_separator_char_pos) {
950 return Status::FromErrorStringWithFormat(
951 "<regex> can't be empty in 's%c<regex>%c<subst>%c' string: '%.*s'",
952 separator_char, separator_char, separator_char, (
int)regex_sed.size(),
955 }
else if (second_separator_char_pos + 1 == third_separator_char_pos) {
956 return Status::FromErrorStringWithFormat(
957 "<subst> can't be empty in 's%c<regex>%c<subst>%c' string: '%.*s'",
958 separator_char, separator_char, separator_char, (
int)regex_sed.size(),
964 std::string regex(std::string(regex_sed.substr(
965 first_separator_char_pos + 1,
966 second_separator_char_pos - first_separator_char_pos - 1)));
967 std::string subst(std::string(regex_sed.substr(
968 second_separator_char_pos + 1,
969 third_separator_char_pos - second_separator_char_pos - 1)));
979 m_interpreter.AddCommand(cmd_sp->GetCommandName(), cmd_sp,
true);
994 ExecutionContext *execution_context)
override {
998 switch (short_option) {
1000 m_help.assign(std::string(option_arg));
1003 m_syntax.assign(std::string(option_arg));
1006 llvm_unreachable(
"Unimplemented option");
1018 return llvm::ArrayRef(g_regex_options);
1040 std::string funct, std::string help,
1049 stream.
Printf(
"For more information run 'help %s'", name.c_str());
1070 std::string docstring;
1073 if (!docstring.empty())
1134 stream.
Printf(
"For more information run 'help %s'", name.c_str());
1137 GetFlags().Set(scripter->GetFlagsForCommandObject(cmd_obj_sp));
1156 uint32_t index)
override {
1159 return std::nullopt;
1170 std::string docstring;
1173 if (!docstring.empty())
1187 std::string docstring;
1190 if (!docstring.empty())
1257 "No script interpreter for SetOptionValue.");
1262 "SetOptionValue called with empty cmd_obj.");
1267 "SetOptionValue called before options definitions "
1274 const char * long_option =
1277 execution_context, long_option, option_arg);
1280 "Error setting option: {0} to {1}", long_option, option_arg);
1300 size_t counter, uint32_t &usage_mask) {
1316 obj_sp->GetAsUnsignedInteger();
1319 uint32_t value = uint_val->
GetValue();
1322 "0 is not a valid group for option {0}", counter);
1324 usage_mask = (1 << (value - 1));
1331 "required field is not a array for option {0}", counter);
1335 auto groups_accumulator
1336 = [counter, &usage_mask, &
error]
1340 uint32_t value = int_val->
GetValue();
1343 "0 is not a valid group for element {0}", counter);
1346 usage_mask |= (1 << (value - 1));
1352 "Group element not an int or array of integers for element {0}",
1356 size_t num_range_elem = arr_val->
GetSize();
1357 if (num_range_elem != 2) {
1359 "Subranges of a group not a start and a stop for element {0}",
1366 "Start element of a subrange of a "
1367 "group not unsigned int for element {0}",
1371 uint32_t start = int_val->
GetValue();
1375 "End element of a subrange of a group"
1376 " not unsigned int for element {0}",
1380 uint32_t end = int_val->
GetValue();
1381 if (start == 0 || end == 0 || start > end) {
1383 "Invalid subrange of a group: {0} - "
1384 "{1} for element {2}",
1385 start, end, counter);
1388 for (uint32_t i = start; i <= end; i++) {
1389 usage_mask |= (1 << (i - 1));
1393 array_val->
ForEach(groups_accumulator);
1409 size_t short_opt_counter = 0;
1411 auto add_element = [
this, &
error, &counter, &short_opt_counter]
1416 "Value in options dictionary is not a dictionary");
1448 "'required' field is not a boolean "
1461 llvm::StringRef short_str = obj_sp->GetStringValue();
1462 if (short_str.empty()) {
1464 "short_option field empty for "
1468 }
else if (short_str.size() != 1) {
1470 "short_option field has extra "
1471 "characters for option {0}",
1475 short_option = (int) short_str[0];
1479 short_option = short_opt_counter++;
1484 if (long_option.empty()) {
1486 "empty long_option for option {0}", counter);
1490 option_def.
long_option = ((*(inserted.first)).data());
1496 = obj_sp->GetAsUnsignedInteger();
1499 "Value type must be an unsigned "
1503 uint64_t val_type = uint_val->
GetValue();
1507 "CommandArgumentType bounds",
1524 "Completion type must be an "
1525 "unsigned integer for option {0}",
1529 uint64_t completion_type = uint_val->
GetValue();
1532 "Completion type for option {0} "
1533 "beyond the CompletionType bounds",
1545 "required usage missing from option "
1550 llvm::StringRef usage_stref;
1551 usage_stref = obj_sp->GetStringValue();
1552 if (usage_stref.empty()) {
1554 "empty usage text for option {0}", counter);
1567 "enum values must be an array for "
1572 size_t num_elem = array->
GetSize();
1573 size_t enum_ctr = 0;
1574 m_enum_storage[counter] = std::vector<EnumValueStorage>(num_elem);
1575 std::vector<EnumValueStorage> &curr_elem =
m_enum_storage[counter];
1581 auto add_enum = [&enum_ctr, &curr_elem, counter, &
error]
1586 "Enum values for option {0} not "
1591 size_t num_enum_elements = enum_arr->
GetSize();
1592 if (num_enum_elements != 2) {
1594 "Wrong number of elements: {0} "
1595 "for enum {1} in option {2}",
1596 num_enum_elements, enum_ctr, counter);
1601 llvm::StringRef val_stref = obj_sp->GetStringValue();
1602 std::string value_cstr_str = val_stref.str().c_str();
1608 "No usage for enum {0} in option "
1613 llvm::StringRef usage_stref = obj_sp->GetStringValue();
1614 std::string usage_cstr_str = usage_stref.str().c_str();
1616 usage_cstr_str, enum_ctr);
1623 if (!
error.Success())
1627 for (
auto &elem : curr_elem)
1653 for (
auto option_elem : option_vec) {
1654 int cur_defs_index = option_elem.opt_defs_index;
1660 bool option_has_arg = opt_defs[cur_defs_index].option_has_arg;
1661 llvm::StringRef cur_arg_value;
1662 if (option_has_arg) {
1663 int cur_arg_pos = option_elem.opt_arg_pos;
1681 assert(completion_dict_sp &&
"Must have valid completion dict");
1683 llvm::StringRef completion;
1685 if (completion_dict_sp->GetValueForKeyAsString(
"no-completion",
1689 if (completion_dict_sp->GetValueForKeyAsString(
"completion",
1691 llvm::StringRef mode_str;
1693 if (completion_dict_sp->GetValueForKeyAsString(
"mode", mode_str)) {
1694 if (mode_str ==
"complete")
1696 else if (mode_str ==
"partial")
1709 if (completion_dict_sp->GetValueForKeyAsArray(
"values", completions)) {
1710 completion_dict_sp->GetValueForKeyAsArray(
"descriptions", descriptions);
1711 size_t num_completions = completions->
GetSize();
1712 for (
size_t idx = 0; idx < num_completions; idx++) {
1730 int opt_element_index,
1743 size_t defs_index = option_vec[opt_element_index].opt_defs_index;
1744 llvm::StringRef option_name = defs[defs_index].long_option;
1745 bool is_enum = defs[defs_index].enum_values.size() != 0;
1746 if (option_name.empty())
1752 completion_dict_sp =
1756 if (!completion_dict_sp) {
1758 opt_element_index, interpreter);
1768 element.string_value =
"value not set";
1769 element.usage =
"usage not set";
1774 size_t in_value) :
value(std::move(in_str_val)),
usage(std::move(in_usage)) {
1827 interpreter, name, cmd_obj_sp, synch));
1835 if (opt_error.
Fail())
1838 if (arg_error.
Fail())
1840 opt_error.
Fail() ?
", also " :
"",
1871 if (options_object_sp) {
1876 = options_object_sp->GetAsDictionary();
1892 if (args_object_sp) {
1907 size_t elem_counter = 0;
1908 auto args_adder = [
this, counter, &elem_counter, &this_entry]
1914 uint32_t arg_opt_set_association;
1916 auto report_error = [
this, elem_counter,
1917 counter](
const char *err_txt) ->
bool {
1919 "Element {0} of arguments "
1920 "list element {1}: %s.",
1921 elem_counter, counter, err_txt);
1927 report_error(
"is not a dictionary.");
1935 = obj_sp->GetAsUnsignedInteger();
1937 report_error(
"value type must be an unsigned integer");
1940 uint64_t arg_type_int = uint_val->
GetValue();
1942 report_error(
"value type beyond ArgumentRepetitionType bounds");
1949 std::optional<ArgumentRepetitionType> repeat;
1951 llvm::StringRef repeat_str = obj_sp->GetStringValue();
1952 if (repeat_str.empty()) {
1953 report_error(
"repeat value is empty");
1958 report_error(
"invalid repeat value");
1961 arg_repetition = *repeat;
1967 counter, arg_opt_set_association);
1968 this_entry.emplace_back(arg_type, arg_repetition,
1969 arg_opt_set_association);
1977 "{0} is not an array",
1981 args_array->
ForEach(args_adder);
1984 if (this_entry.empty()) {
1996 args_array->
ForEach(arg_array_adder);
2040 : llvm::ArrayRef<OptionDefinition>();
2042 std::unordered_set<size_t> option_slots;
2043 for (
const auto &elem : option_vec) {
2044 if (elem.opt_defs_index == -1)
2046 option_slots.insert(elem.opt_pos);
2047 if (defs[elem.opt_defs_index].option_has_arg)
2048 option_slots.insert(elem.opt_arg_pos);
2051 std::vector<llvm::StringRef> args_vec;
2055 size_t args_elem_pos = cursor_idx;
2057 for (
size_t idx = 0; idx < num_args; idx++) {
2058 if (option_slots.count(idx) == 0)
2059 args_vec.push_back(args[idx].ref());
2060 else if (idx < cursor_idx)
2067 if (!completion_dict_sp) {
2072 m_options.ProcessCompletionDict(request, completion_dict_sp);
2080 uint32_t index)
override {
2083 return std::nullopt;
2094 std::string docstring;
2097 if (!docstring.empty())
2111 std::string docstring;
2114 if (!docstring.empty())
2161std::unordered_set<std::string>
2165#define LLDB_OPTIONS_script_import
2166#include "CommandOptions.inc"
2172 "Import a scripting module in LLDB.", nullptr) {
2192 switch (short_option) {
2203 llvm_unreachable(
"Unimplemented option");
2214 return llvm::ArrayRef(g_script_import_options);
2221 if (command.
empty()) {
2222 result.
AppendError(
"command script import needs one or more arguments");
2227 if (
m_options.relative_to_command_file) {
2230 result.
AppendError(
"command script import -c can only be specified "
2231 "from a command file");
2236 for (
auto &entry : command.
entries()) {
2253 entry.c_str(), options,
error,
nullptr,
2266#define LLDB_OPTIONS_script_add
2267#include "CommandOptions.inc"
2274 "Add a scripted function as an LLDB command.",
2275 "Add a scripted function as an lldb command. "
2276 "If you provide a single argument, the command "
2277 "will be added at the root level of the command "
2278 "hierarchy. If there are more arguments they "
2279 "must be a path to a user-added container "
2280 "command, and the last element will be the new "
2294 opt_element_vector);
2309 switch (short_option) {
2311 if (!option_arg.empty())
2315 if (!option_arg.empty())
2319 if (!option_arg.empty())
2332 if (!
error.Success())
2334 "unrecognized value for synchronicity '%s'",
2335 option_arg.str().c_str());
2343 if (!
error.Success())
2345 "unrecognized value for command completion type '%s'",
2346 option_arg.str().c_str());
2350 llvm_unreachable(
"Unimplemented option");
2367 return llvm::ArrayRef(g_script_add_options);
2393 std::string &data)
override {
2401 std::string funct_name_str;
2403 if (funct_name_str.empty()) {
2406 "error: unable to obtain a function name, didn't "
2407 "add python command.\n");
2420 "error: unable to add selected command: '%s'",
2424 llvm::Error llvm_error =
m_container->LoadUserSubcommand(
2429 "error: unable to add selected command: '%s'",
2430 llvm::toString(std::move(llvm_error)).c_str());
2437 "error: unable to create function, didn't add python command\n");
2442 "error: empty function, didn't add python command\n");
2447 "error: script interpreter missing, didn't add python command\n");
2455 result.
AppendError(
"only scripting language supported for scripted "
2456 "commands is currently Python");
2461 result.
AppendError(
"'command script add' requires at least one argument");
2479 command,
true, path_error);
2481 if (path_error.
Fail()) {
2492 m_cmd_name = std::string(command[num_args - 1].ref());
2508 new_cmd_sp = std::make_shared<CommandObjectPythonFunction>(
2514 result.
AppendError(
"cannot find ScriptInterpreter");
2532 new_cmd_sp = std::make_shared<CommandObjectScriptingObjectRaw>(
2542 if (add_error.
Fail())
2546 llvm::Error llvm_error =
2550 "cannot add command: %s",
2551 llvm::toString(std::move(llvm_error)).c_str());
2571 "List defined top-level scripted commands.",
2589 "Delete all scripted commands.", nullptr) {}
2607 interpreter,
"command script delete",
2608 "Delete a scripted command by specifying the path to the command.",
2625 llvm::StringRef root_cmd = command[0].ref();
2628 if (root_cmd.empty()) {
2635 "but no user defined commands found");
2642 command[0].c_str());
2645 if (!cmd_sp->IsUserCommand()) {
2647 command[0].c_str());
2650 if (cmd_sp->GetAsMultiwordCommand() && num_args == 1) {
2652 "Delete with \"command container delete\"",
2653 command[0].c_str());
2677 command[0].c_str());
2680 const char *leaf_cmd = command[num_args - 1].c_str();
2681 llvm::Error llvm_error =
2686 "could not delete command '%s': %s", leaf_cmd,
2687 llvm::toString(std::move(llvm_error)).c_str());
2693 out_stream <<
"Deleted command:";
2694 for (
size_t idx = 0; idx < num_args; idx++) {
2696 out_stream << command[idx].c_str();
2703#pragma mark CommandObjectMultiwordCommandsScript
2711 interpreter,
"command script",
2712 "Commands for managing custom "
2713 "commands implemented by "
2714 "interpreter scripts.",
2715 "command script <subcommand> [<subcommand-options>]") {
2734#pragma mark CommandObjectCommandContainer
2735#define LLDB_OPTIONS_container_add
2736#include "CommandOptions.inc"
2742 interpreter,
"command container add",
2743 "Add a container command to lldb. Adding to built-"
2744 "in container commands is not allowed.",
2745 "command container add [[path1]...] container-name") {
2772 switch (short_option) {
2774 if (!option_arg.empty())
2781 if (!option_arg.empty())
2785 llvm_unreachable(
"Unimplemented option");
2798 return llvm::ArrayRef(g_container_add_options);
2810 if (num_args == 0) {
2815 if (num_args == 1) {
2821 cmd_sp->GetAsMultiwordCommand()->SetRemovable(
true);
2823 cmd_name, cmd_sp,
m_options.m_overwrite);
2824 if (add_error.
Fail()) {
2849 llvm::Error llvm_error =
2853 llvm::toString(std::move(llvm_error)).c_str());
2864#define LLDB_OPTIONS_multiword_delete
2865#include "CommandOptions.inc"
2870 interpreter,
"command container delete",
2871 "Delete a container command previously added to "
2873 "command container delete [[path1] ...] container-cmd") {
2890 if (num_args == 0) {
2895 if (num_args == 1) {
2907 if (!cmd_sp->IsUserCommand()) {
2909 "container command %s is not a user command", cmd_name);
2912 if (!cmd_sp->GetAsMultiwordCommand()) {
2940 llvm::Error llvm_error =
2944 llvm::toString(std::move(llvm_error)).c_str());
2955 interpreter,
"command container",
2956 "Commands for adding container commands to lldb. "
2957 "Container commands are containers for other commands. You can "
2958 "add nested container commands by specifying a command path, "
2959 "but you can't add commands into the built-in command hierarchy.",
2960 "command container <subcommand> [<subcommand-options>]") {
2971#pragma mark CommandObjectMultiwordCommands
2978 "Commands for managing custom LLDB commands.",
2979 "command <subcommand> [<subcommand-options>]") {
static const char * g_python_command_instructions
static llvm::raw_ostream & error(Stream &strm)
static bool LoadScriptingModule(const FileSpec &scripting_fspec, ScriptInterpreter &script_interpreter, Target &target, Status &error)
CommandObjectCommandContainer(CommandInterpreter &interpreter)
~CommandObjectCommandContainer() override=default
llvm::StringRef GetSyntax()
~CommandOptions() override=default
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
llvm::StringRef GetHelp()
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
void OptionParsingStarting(ExecutionContext *execution_context) override
std::unique_ptr< CommandObjectRegexCommand > m_regex_cmd_up
void IOHandlerInputComplete(IOHandler &io_handler, std::string &data) override
Called when a line or lines have been retrieved.
~CommandObjectCommandsAddRegex() override=default
CommandObjectCommandsAddRegex(CommandInterpreter &interpreter)
Options * GetOptions() override
Status AppendRegexSubstitution(const llvm::StringRef ®ex_sed, bool check_only)
void DoExecute(Args &command, CommandReturnObject &result) override
void IOHandlerActivated(IOHandler &io_handler, bool interactive) override
void AddRegexCommandToInterpreter()
~CommandOptions() override=default
OptionValueString m_long_help
void OptionParsingStarting(ExecutionContext *execution_context) override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
bool HandleAliasingNormalCommand(Args &args, CommandReturnObject &result)
OptionGroupOptions m_option_group
CommandOptions m_command_options
void DoExecute(llvm::StringRef raw_command_line, CommandReturnObject &result) override
~CommandObjectCommandsAlias() override=default
Options * GetOptions() override
bool HandleAliasingRawCommand(llvm::StringRef alias_command, llvm::StringRef raw_command_string, CommandObject &cmd_obj, CommandReturnObject &result)
CommandObjectCommandsAlias(CommandInterpreter &interpreter)
~CommandOptions() override=default
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
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.
~CommandObjectCommandsContainerAdd() override=default
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
Options * GetOptions() override
CommandObjectCommandsContainerAdd(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectCommandsContainerDelete(CommandInterpreter &interpreter)
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
~CommandObjectCommandsContainerDelete() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectCommandsDelete(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,...
~CommandObjectCommandsDelete() override=default
LazyBool m_overwrite_lazy
~CommandOptions() override=default
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
CompletionType m_completion_type
ScriptedCommandSynchronicity m_synchronicity
void OptionParsingStarting(ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
void IOHandlerActivated(IOHandler &io_handler, bool interactive) override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectCommandsScriptAdd() override=default
void IOHandlerInputComplete(IOHandler &io_handler, std::string &data) override
Called when a line or lines have been retrieved.
CompletionType m_completion_type
ScriptedCommandSynchronicity m_synchronicity
Options * GetOptions() override
CommandObjectMultiword * m_container
CommandObjectCommandsScriptAdd(CommandInterpreter &interpreter)
CommandObjectCommandsScriptClear(CommandInterpreter &interpreter)
~CommandObjectCommandsScriptClear() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectCommandsScriptDelete() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectCommandsScriptDelete(CommandInterpreter &interpreter)
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
void OptionParsingStarting(ExecutionContext *execution_context) override
bool relative_to_command_file
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
~CommandOptions() override=default
CommandObjectCommandsScriptImport(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
Options * GetOptions() override
~CommandObjectCommandsScriptImport() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectCommandsScriptList() override=default
CommandObjectCommandsScriptList(CommandInterpreter &interpreter)
OptionValueBoolean m_cmd_relative_to_command_file
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
OptionValueBoolean m_stop_on_error
~CommandOptions() override=default
void OptionParsingStarting(ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
OptionValueBoolean m_stop_on_continue
OptionValueBoolean m_silent_run
std::optional< std::string > GetRepeatCommand(Args ¤t_command_args, uint32_t index) override
Get the command that appropriate for a "repeat" of the current command.
CommandObjectCommandsSource(CommandInterpreter &interpreter)
Options * GetOptions() override
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectCommandsSource() override=default
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
void DoExecute(Args &args, CommandReturnObject &result) override
CommandObjectCommandsUnalias(CommandInterpreter &interpreter)
~CommandObjectCommandsUnalias() override=default
~CommandObjectMultiwordCommandsScript() override=default
CommandObjectMultiwordCommandsScript(CommandInterpreter &interpreter)
std::string m_function_name
void DoExecute(llvm::StringRef raw_command_line, CommandReturnObject &result) override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
bool IsRemovable() const override
ScriptedCommandSynchronicity GetSynchronicity()
bool WantsCompletion() override
CommandObjectPythonFunction(CommandInterpreter &interpreter, std::string name, std::string funct, std::string help, ScriptedCommandSynchronicity synch, CompletionType completion_type)
ScriptedCommandSynchronicity m_synchro
llvm::StringRef GetHelpLong() override
const std::string & GetFunctionName()
CompletionType m_completion_type
~CommandObjectPythonFunction() override=default
StructuredData::GenericSP m_cmd_obj_sp
static Status ParseUsageMaskFromArray(StructuredData::ObjectSP obj_sp, size_t counter, uint32_t &usage_mask)
std::vector< std::string > m_usage_container
CommandInterpreter & m_interpreter
std::unique_ptr< OptionDefinition > m_options_definition_up
void OptionParsingStarting(ExecutionContext *execution_context) override
~CommandOptions() override=default
void HandleOptionArgumentCompletion(lldb_private::CompletionRequest &request, OptionElementVector &option_vec, int opt_element_index, CommandInterpreter &interpreter) override
Handles the generic bits of figuring out whether we are in an option, and if so completing it.
static std::unordered_set< std::string > g_string_storer
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
CommandOptions(CommandInterpreter &interpreter, StructuredData::GenericSP cmd_obj_sp)
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
std::vector< std::vector< OptionEnumValueElement > > m_enum_vector
void ProcessCompletionDict(CompletionRequest &request, StructuredData::DictionarySP &completion_dict_sp)
std::vector< std::vector< EnumValueStorage > > m_enum_storage
void PrepareOptionsForCompletion(CompletionRequest &request, OptionElementVector &option_vec, ExecutionContext *exe_ctx)
Status SetOptionsFromArray(StructuredData::Dictionary &options)
llvm::StringRef GetHelpLong() override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &option_vec) override
The default version handles argument definitions that have only one argument type,...
bool IsRemovable() const override
CommandObjectScriptingObjectParsed(CommandInterpreter &interpreter, std::string name, StructuredData::GenericSP cmd_obj_sp, ScriptedCommandSynchronicity synch)
void DoExecute(Args &args, CommandReturnObject &result) override
Options * GetOptions() override
llvm::StringRef GetHelp() override
std::optional< std::string > GetRepeatCommand(Args &args, uint32_t index) override
Get the command that appropriate for a "repeat" of the current command.
~CommandObjectScriptingObjectParsed() override=default
void PrepareOptionsForCompletion(CompletionRequest &request, OptionElementVector &option_vec)
bool m_fetched_help_short
bool WantsCompletion() override
ScriptedCommandSynchronicity m_synchro
StructuredData::GenericSP m_cmd_obj_sp
ScriptedCommandSynchronicity GetSynchronicity()
static CommandObjectSP Create(CommandInterpreter &interpreter, std::string name, StructuredData::GenericSP cmd_obj_sp, ScriptedCommandSynchronicity synch, CommandReturnObject &result)
CompletionType m_completion_type
bool WantsCompletion() override
llvm::StringRef GetHelp() override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
StructuredData::GenericSP m_cmd_obj_sp
std::optional< std::string > GetRepeatCommand(Args &args, uint32_t index) override
Get the command that appropriate for a "repeat" of the current command.
llvm::StringRef GetHelpLong() override
ScriptedCommandSynchronicity m_synchro
~CommandObjectScriptingObjectRaw() override=default
bool m_fetched_help_short
bool IsRemovable() const override
CommandObjectScriptingObjectRaw(CommandInterpreter &interpreter, std::string name, StructuredData::GenericSP cmd_obj_sp, ScriptedCommandSynchronicity synch, CompletionType completion_type)
ScriptedCommandSynchronicity GetSynchronicity()
void DoExecute(llvm::StringRef raw_command_line, CommandReturnObject &result) override
A command line argument class.
void Shift()
Shifts the first argument C string value of the array off the argument array.
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
llvm::ArrayRef< ArgEntry > entries() const
const char * GetArgumentAtIndex(size_t idx) const
Gets the NULL terminated C string argument pointer for the argument at index idx.
bool GetCommandString(std::string &command) const
static bool InvokeCommonCompletionCallbacks(CommandInterpreter &interpreter, uint32_t completion_mask, lldb_private::CompletionRequest &request, SearchFilter *searcher)
static void CompleteModifiableCmdPathArgs(CommandInterpreter &interpreter, CompletionRequest &request, OptionElementVector &opt_element_vector)
This completer works for commands whose only arguments are a command path.
void SetStopOnContinue(bool stop_on_continue)
void SetSilent(bool silent)
void SetPrintErrors(bool print_errors)
void SetEchoCommands(bool echo_commands)
void SetStopOnError(bool stop_on_error)
void SetPrintResults(bool print_results)
void SetEchoCommentCommands(bool echo_comments)
@ eCommandTypesUserDef
scripted commands
ExecutionContext GetExecutionContext() const
CommandObjectMultiword * VerifyUserMultiwordCmdPath(Args &path, bool leaf_is_command, Status &result)
Look up the command pointed to by path encoded in the arguments of the incoming command object.
Status AddUserCommand(llvm::StringRef name, const lldb::CommandObjectSP &cmd_sp, bool can_replace)
bool GetRequireCommandOverwrite() const
lldb::CommandObjectSP GetCommandSPExact(llvm::StringRef cmd, bool include_aliases=false) const
bool RemoveUserMultiword(llvm::StringRef multiword_name)
FileSpec GetCurrentSourceDir()
static void GenerateAdditionalHelpAvenuesMessage(Stream *s, llvm::StringRef command, llvm::StringRef prefix, llvm::StringRef subcommand, bool include_upropos=true, bool include_type_lookup=true)
~CommandObjectMultiwordCommands() override
CommandObjectMultiwordCommands(CommandInterpreter &interpreter)
llvm::Error LoadUserSubcommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj, bool can_replace) override
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
llvm::Error RemoveUserSubcommand(llvm::StringRef cmd_name, bool multiword_okay)
CommandObjectMultiword(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
friend class CommandInterpreter
CommandObjectParsed(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
CommandObjectRaw(CommandInterpreter &interpreter, llvm::StringRef name, llvm::StringRef help="", llvm::StringRef syntax="", uint32_t flags=0)
std::vector< CommandArgumentData > CommandArgumentEntry
virtual void SetHelpLong(llvm::StringRef str)
virtual bool WantsRawCommandString()=0
void AddSimpleArgumentList(lldb::CommandArgumentType arg_type, ArgumentRepetitionType repetition_type=eArgRepeatPlain)
bool ParseOptionsAndNotify(Args &args, CommandReturnObject &result, OptionGroupOptions &group_options, ExecutionContext &exe_ctx)
virtual llvm::StringRef GetHelpLong()
llvm::StringRef GetCommandName() const
static std::optional< ArgumentRepetitionType > ArgRepetitionFromString(llvm::StringRef string)
virtual bool IsMultiwordObject()
ExecutionContext m_exe_ctx
std::vector< CommandArgumentEntry > m_arguments
CommandInterpreter & GetCommandInterpreter()
CommandInterpreter & m_interpreter
CommandObject(CommandInterpreter &interpreter, llvm::StringRef name, llvm::StringRef help="", llvm::StringRef syntax="", uint32_t flags=0)
Flags & GetFlags()
The flags accessor.
virtual void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector)
The default version handles argument definitions that have only one argument type,...
virtual bool IsRemovable() const
virtual llvm::StringRef GetHelp()
virtual void SetHelp(llvm::StringRef str)
virtual lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd, StringList *matches=nullptr)
void AppendError(llvm::StringRef in_string)
llvm::StringRef GetOutputString() const
void AppendWarningWithFormatv(const char *format, Args &&...args)
void SetStatus(lldb::ReturnStatus status)
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
lldb::ReturnStatus GetStatus() const
void AppendWarning(llvm::StringRef in_string)
void AppendErrorWithFormatv(const char *format, Args &&...args)
Stream & GetOutputStream()
"lldb/Utility/ArgCompletionRequest.h"
void AddCompletion(llvm::StringRef completion, llvm::StringRef description="", CompletionMode mode=CompletionMode::Normal)
Adds a possible completion string.
const Args & GetParsedLine() const
size_t GetCursorCharPos() const
void TryCompleteCurrentArg(llvm::StringRef completion, llvm::StringRef description="")
Adds a possible completion string if the completion would complete the current argument.
size_t GetCursorIndex() const
CommandInterpreter & GetCommandInterpreter()
void RunIOHandlerAsync(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler=true)
Run the given IO handler and return immediately.
lldb::StreamUP GetAsyncOutputStream()
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, std::optional< lldb::ScriptLanguage > language={})
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
bool IsRelative() const
Returns true if the filespec represents a relative path.
void MakeAbsolute(const FileSpec &dir)
Make the FileSpec absolute by treating it relative to dir.
static FileSystem & Instance()
void Resolve(llvm::SmallVectorImpl< char > &path, bool force_make_absolute=false)
Resolve path to make it canonical.
ValueType Set(ValueType mask)
Set one or more flags by logical OR'ing mask with the current flags.
IOHandlerDelegateMultiline(llvm::StringRef end_line, Completion completion=Completion::None)
A delegate class for use with IOHandler subclasses.
lldb::LockableStreamFileSP GetErrorStreamFileSP()
lldb::LockableStreamFileSP GetOutputStreamFileSP()
LoadScriptOptions & SetInitSession(bool b)
LoadScriptOptions & SetSilent(bool b)
A command line option parsing protocol class.
virtual void HandleOptionArgumentCompletion(lldb_private::CompletionRequest &request, OptionElementVector &opt_element_vector, int opt_element_index, CommandInterpreter &interpreter)
Handles the generic bits of figuring out whether we are in an option, and if so completing it.
virtual Status OptionParsingFinished(ExecutionContext *execution_context)
virtual llvm::ArrayRef< OptionDefinition > GetDefinitions()
std::vector< Option > m_getopt_table
virtual bool SetOptionValueForCommandObject(StructuredData::GenericSP cmd_obj_sp, ExecutionContext *exe_ctx, llvm::StringRef long_option, llvm::StringRef value)
virtual StructuredData::GenericSP CreateScriptCommandObject(const char *class_name)
virtual bool RunScriptBasedCommand(const char *impl_function, llvm::StringRef args, ScriptedCommandSynchronicity synchronicity, lldb_private::CommandReturnObject &cmd_retobj, Status &error, const lldb_private::ExecutionContext &exe_ctx)
virtual bool GenerateScriptAliasFunction(StringList &input, std::string &output)
virtual StructuredData::DictionarySP HandleOptionArgumentCompletionForScriptedCommand(StructuredData::GenericSP impl_obj_sp, llvm::StringRef &long_name, size_t char_in_arg)
virtual std::optional< std::string > GetRepeatCommandForScriptedCommand(StructuredData::GenericSP impl_obj_sp, Args &args)
virtual bool GetDocumentationForItem(const char *item, std::string &dest)
virtual bool RunScriptBasedParsedCommand(StructuredData::GenericSP impl_obj_sp, Args &args, ScriptedCommandSynchronicity synchronicity, lldb_private::CommandReturnObject &cmd_retobj, Status &error, const lldb_private::ExecutionContext &exe_ctx)
virtual StructuredData::ObjectSP GetOptionsForCommandObject(StructuredData::GenericSP cmd_obj_sp)
virtual StructuredData::ObjectSP GetArgumentsForCommandObject(StructuredData::GenericSP cmd_obj_sp)
virtual void OptionParsingStartedForCommandObject(StructuredData::GenericSP cmd_obj_sp)
virtual bool GetLongHelpForCommandObject(StructuredData::GenericSP cmd_obj_sp, std::string &dest)
virtual uint32_t GetFlagsForCommandObject(StructuredData::GenericSP cmd_obj_sp)
virtual bool GetShortHelpForCommandObject(StructuredData::GenericSP cmd_obj_sp, std::string &dest)
virtual StructuredData::DictionarySP HandleArgumentCompletionForScriptedCommand(StructuredData::GenericSP impl_obj_sp, std::vector< llvm::StringRef > &args, size_t args_pos, size_t char_in_arg)
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
static Status FromErrorString(const char *str)
bool Fail() const
Test for error condition.
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
size_t SplitIntoLines(const std::string &lines)
ObjectSP GetItemAtIndex(size_t idx) const
bool ForEach(std::function< bool(Object *object)> const &foreach_callback) const
std::optional< llvm::StringRef > GetItemAtIndexAsString(size_t idx) const
ObjectSP GetValueForKey(llvm::StringRef key) const
void ForEach(std::function< bool(llvm::StringRef key, Object *object)> const &callback) const
Dictionary * GetAsDictionary()
std::shared_ptr< Generic > GenericSP
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Object > ObjectSP
Integer< uint64_t > UnsignedInteger
A class that represents a running process on the host machine.
std::vector< OptionArgElement > OptionElementVector
std::shared_ptr< OptionArgVector > OptionArgVectorSP
@ Partial
The current token has been partially completed.
@ Normal
The current token has been completed.
ScriptedCommandSynchronicity
@ eScriptedCommandSynchronicitySynchronous
std::shared_ptr< lldb_private::IOHandler > IOHandlerSP
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
@ eReturnStatusSuccessFinishResult
@ eReturnStatusSuccessFinishNoResult
std::shared_ptr< lldb_private::LockableStreamFile > LockableStreamFileSP
OptionEnumValueElement element
EnumValueStorage(const EnumValueStorage &in)
EnumValueStorage & operator=(const EnumValueStorage &in)
void SetElement(size_t in_value)
EnumValueStorage(std::string in_str_val, std::string in_usage, size_t in_value)
Used to build individual command argument lists.
ArgumentRepetitionType arg_repetition
lldb::CommandArgumentType arg_type
static int64_t ToOptionEnum(llvm::StringRef s, const OptionEnumValues &enum_values, int32_t fail_value, Status &error)
OptionValidator * validator
If non-NULL, option is valid iff |validator->IsValid()|, otherwise always valid.
const char * long_option
Full name for this option.
const char * usage_text
Full text explaining what this options does and what (if any) argument to pass it.
bool required
This option is required (in the current usage level).
uint32_t completion_type
The kind of completion for this option.
int option_has_arg
no_argument, required_argument or optional_argument
uint32_t usage_mask
Used to mark options that can be used together.
lldb::CommandArgumentType argument_type
Type of argument this option takes.
OptionEnumValues enum_values
If not empty, an array of enum values.
int short_option
Single character for this option.