26#include "llvm/ADT/StringRef.h"
34#define LLDB_OPTIONS_source
35#include "CommandOptions.inc"
41 interpreter,
"command source",
42 "Read and execute LLDB commands from the file <filename>.",
53 arg.push_back(file_arg);
62 uint32_t index)
override {
63 return std::string(
"");
89 switch (short_option) {
107 llvm_unreachable(
"Unimplemented option");
121 return llvm::ArrayRef(g_source_options);
135 "'%s' takes exactly one executable filename argument.\n",
144 result.
AppendError(
"command source -C can only be specified "
145 "from a command file");
151 FileSpec cmd_file(command[0].ref());
155 result.
AppendError(
"command source -C can only be used "
156 "with a relative path.");
195#pragma mark CommandObjectCommandsAlias
198#define LLDB_OPTIONS_alias
199#include "CommandOptions.inc"
202 "Enter your Python command(s). Type 'DONE' to end.\n"
203 "You must define a Python function with this signature:\n"
204 "def my_command_impl(debugger, args, exe_ctx, result, internal_dict):\n";
215 return llvm::ArrayRef(g_alias_options);
222 const int short_option =
GetDefinitions()[option_idx].short_option;
223 std::string option_str(option_value);
225 switch (short_option) {
237 llvm_unreachable(
"Unimplemented option");
260 interpreter,
"command alias",
261 "Define a custom command in terms of an existing command.") {
266 "'alias' allows the user to create a short-cut or abbreviation for long \
267commands, multi-word commands, and commands that take particular options. \
268Below are some simple examples of how one might use the 'alias' command:"
271(lldb) command alias sc script
273 Creates the abbreviation 'sc' for the 'script' command.
275(lldb) command alias bp breakpoint
278 " Creates the abbreviation 'bp' for the 'breakpoint' command. Since \
279breakpoint commands are two-word commands, the user would still need to \
280enter the second word after 'bp', e.g. 'bp enable' or 'bp delete'."
283(lldb) command alias bpl breakpoint list
285 Creates the abbreviation 'bpl' for the two-word command 'breakpoint list'.
288 "An alias can include some options for the command, with the values either \
289filled in at the time the alias is created, or specified as positional \
290arguments, to be filled in when the alias is invoked. The following example \
291shows how to create aliases with options:"
294(lldb) command alias bfl breakpoint set -f %1 -l %2
297 " Creates the abbreviation 'bfl' (for break-file-line), with the -f and -l \
298options already part of the alias. So if the user wants to set a breakpoint \
299by file and line without explicitly having to use the -f and -l options, the \
300user can now use 'bfl' instead. The '%1' and '%2' are positional placeholders \
301for the actual arguments that will be passed when the alias command is used. \
302The number in the placeholder refers to the position/order the actual value \
303occupies when the alias is used. All the occurrences of '%1' in the alias \
304will be replaced with the first argument, all the occurrences of '%2' in the \
305alias will be replaced with the second argument, and so on. This also allows \
306actual arguments to be used multiple times within an alias (see 'process \
307launch' example below)."
311 "Note: the positional arguments must substitute as whole words in the resultant \
312command, so you can't at present do something like this to append the file extension \
316(lldb) command alias bcppfl breakpoint set -f %1.cpp -l %2
319 "For more complex aliasing, use the \"command regex\" command instead. In the \
320'bfl' case above, the actual file value will be filled in with the first argument \
321following 'bfl' and the actual line number value will be filled in with the second \
322argument. The user would use this alias as follows:"
325(lldb) command alias bfl breakpoint set -f %1 -l %2
326(lldb) bfl my-file.c 137
328This would be the same as if the user had entered 'breakpoint set -f my-file.c -l 137'.
332(lldb) command alias pltty process launch -s -o %1 -e %1
333(lldb) pltty /dev/tty0
335 Interpreted as 'process launch -s -o /dev/tty0 -e /dev/tty0'
338 "If the user always wanted to pass the same value to a particular option, the \
339alias could be defined with that value directly in the alias as a constant, \
340rather than using a positional placeholder:"
343(lldb) command alias bl3 breakpoint set -f %1 -l 3
345 Always sets a breakpoint on line 3 of whatever file is indicated.)");
360 arg1.push_back(alias_arg);
368 arg2.push_back(cmd_arg);
376 arg3.push_back(options_arg);
387 bool DoExecute(llvm::StringRef raw_command_line,
389 if (raw_command_line.empty()) {
390 result.
AppendError(
"'command alias' requires at least two arguments");
399 if (args_with_suffix.HasArgs())
404 llvm::StringRef raw_command_string = args_with_suffix.GetRawPart();
405 Args args(raw_command_string);
407 if (args.GetArgumentCount() < 2) {
408 result.
AppendError(
"'command alias' requires at least two arguments");
414 auto alias_command = args[0].ref();
415 if (alias_command.startswith(
"-")) {
416 result.
AppendError(
"aliases starting with a dash are not supported");
417 if (alias_command ==
"--help" || alias_command ==
"--long-help") {
418 result.
AppendWarning(
"if trying to pass options to 'command alias' add "
419 "a -- at the end of the options");
426 size_t pos = raw_command_string.find(alias_command);
428 raw_command_string = raw_command_string.substr(alias_command.size());
429 pos = raw_command_string.find_first_not_of(
' ');
430 if ((pos != std::string::npos) && (pos > 0))
431 raw_command_string = raw_command_string.substr(pos);
433 result.
AppendError(
"Error parsing command string. No alias created.");
440 "'%s' is a permanent debugger command and cannot be redefined.\n",
447 "'%s' is a user container command and cannot be overwritten.\n"
448 "Delete it first with 'command container delete'\n",
456 llvm::StringRef original_raw_command_string = raw_command_string;
462 "'%s' does not begin with a valid command."
463 " No alias created.",
464 original_raw_command_string.str().c_str());
479 llvm::StringRef raw_command_string,
487 const bool include_aliases =
true;
495 cmd_obj_sp = cmd_obj.shared_from_this();
500 "Overwriting existing definition for '%s'.\n",
501 alias_command.str().c_str());
504 alias_command, cmd_obj_sp, raw_command_string)) {
511 result.
AppendError(
"Unable to create requested alias.\n");
520 result.
AppendError(
"'command alias' requires at least two arguments");
525 const std::string alias_command(std::string(args[0].ref()));
526 const std::string actual_command(std::string(args[1].ref()));
536 "'%s' is a permanent debugger command and cannot be redefined.\n",
537 alias_command.c_str());
543 "'%s' is user container command and cannot be overwritten.\n"
544 "Delete it first with 'command container delete'",
545 alias_command.c_str());
552 bool use_subcommand =
false;
553 if (!command_obj_sp) {
555 actual_command.c_str());
564 auto sub_command = args[0].ref();
565 assert(!sub_command.empty());
567 if (!subcommand_obj_sp) {
569 "'%s' is not a valid sub-command of '%s'. "
570 "Unable to create alias.\n",
571 args[0].c_str(), actual_command.c_str());
575 sub_cmd_obj = subcommand_obj_sp.get();
576 use_subcommand =
true;
578 cmd_obj = sub_cmd_obj;
583 std::string args_string;
597 "Overwriting existing definition for '%s'.\n", alias_command.c_str());
601 alias_command, use_subcommand ? subcommand_obj_sp : command_obj_sp,
609 result.
AppendError(
"Unable to create requested alias.\n");
617#pragma mark CommandObjectCommandsUnalias
624 interpreter,
"command unalias",
625 "Delete one or more custom commands defined by 'command alias'.",
636 arg.push_back(alias_arg);
657 CommandObject::CommandMap::iterator pos;
661 result.
AppendError(
"must call 'unalias' with a valid alias");
665 auto command_name = args[0].ref();
669 "'%s' is not a known command.\nTry 'help' to see a "
670 "current list of commands.\n",
678 "'%s' is not an alias, it is a debugger command which can be "
679 "removed using the 'command delete' command.\n",
683 "'%s' is a permanent debugger command and cannot be removed.\n",
692 "Error occurred while attempting to unalias '%s'.\n",
705#pragma mark CommandObjectCommandsDelete
712 interpreter,
"command delete",
713 "Delete one or more custom commands defined by 'command regex'.",
724 arg.push_back(alias_arg);
739 if (ent.second->IsRemovable())
746 CommandObject::CommandMap::iterator pos;
750 "defined regular expression command names",
755 auto command_name = args[0].ref();
758 const bool generate_upropos =
true;
759 const bool generate_type_lookup =
false;
761 &error_msg_stream, command_name, llvm::StringRef(), llvm::StringRef(),
762 generate_upropos, generate_type_lookup);
769 "'%s' is a permanent debugger command and cannot be removed.\n",
781#define LLDB_OPTIONS_regex
782#include "CommandOptions.inc"
784#pragma mark CommandObjectCommandsAddRegex
791 interpreter,
"command regex",
792 "Define a custom command in terms of "
793 "existing commands by matching "
794 "regular expressions.",
795 "command regex <cmd-name> [s/<regex>/<subst>/ ...]"),
801 "This command allows the user to create powerful regular expression commands \
802with substitutions. The regular expressions and substitutions are specified \
803using the regular expression substitution format of:"
809 "<regex> is a regular expression that can use parenthesis to capture regular \
810expression input and substitute the captured matches in the output using %1 \
811for the first match, %2 for the second, and so on."
815 "The regular expressions can all be specified on the command line if more than \
816one argument is provided. If just the command name is provided on the command \
817line, then the regular expressions and substitutions can be entered on separate \
818lines, followed by an empty line to terminate the command definition."
824 "The following example will define a regular expression command named 'f' that \
825will call 'finish' if there are no arguments, or 'frame select <frame-idx>' if \
826a number follows 'f':"
829 (lldb) command regex f s/^$/finish/ 's/([0-9]+)/frame select %1/')");
839 if (output_sp && interactive) {
840 output_sp->PutCString(
"Enter one or more sed substitution commands in "
841 "the form: 's/<regex>/<subst>/'.\nTerminate the "
842 "substitution list with an empty line.\n");
848 std::string &data)
override {
853 bool check_only =
false;
854 for (
const std::string &line : lines) {
859 out_stream->Printf(
"error: %s\n",
error.AsCString());
874 result.
AppendError(
"usage: 'command regex <command-name> "
875 "[s/<regex1>/<subst1>/ s/<regex2>/<subst2>/ ...]'\n");
880 auto name = command[0].ref();
888 const bool multiple_lines =
true;
890 debugger, IOHandler::Type::Other,
892 llvm::StringRef(
"> "),
894 multiple_lines, color_prompt,
903 for (
auto &entry : command.
entries().drop_front()) {
904 bool check_only =
false;
910 if (
error.Success()) {
926 error.SetErrorStringWithFormat(
927 "invalid regular expression command object for: '%.*s'",
928 (
int)regex_sed.size(), regex_sed.data());
932 size_t regex_sed_size = regex_sed.size();
934 if (regex_sed_size <= 1) {
935 error.SetErrorStringWithFormat(
936 "regular expression substitution string is too short: '%.*s'",
937 (
int)regex_sed.size(), regex_sed.data());
941 if (regex_sed[0] !=
's') {
942 error.SetErrorStringWithFormat(
"regular expression substitution string "
943 "doesn't start with 's': '%.*s'",
944 (
int)regex_sed.size(), regex_sed.data());
947 const size_t first_separator_char_pos = 1;
950 const char separator_char = regex_sed[first_separator_char_pos];
951 const size_t second_separator_char_pos =
952 regex_sed.find(separator_char, first_separator_char_pos + 1);
954 if (second_separator_char_pos == std::string::npos) {
955 error.SetErrorStringWithFormat(
956 "missing second '%c' separator char after '%.*s' in '%.*s'",
958 (
int)(regex_sed.size() - first_separator_char_pos - 1),
959 regex_sed.data() + (first_separator_char_pos + 1),
960 (
int)regex_sed.size(), regex_sed.data());
964 const size_t third_separator_char_pos =
965 regex_sed.find(separator_char, second_separator_char_pos + 1);
967 if (third_separator_char_pos == std::string::npos) {
968 error.SetErrorStringWithFormat(
969 "missing third '%c' separator char after '%.*s' in '%.*s'",
971 (
int)(regex_sed.size() - second_separator_char_pos - 1),
972 regex_sed.data() + (second_separator_char_pos + 1),
973 (
int)regex_sed.size(), regex_sed.data());
977 if (third_separator_char_pos != regex_sed_size - 1) {
979 if (regex_sed.find_first_not_of(
"\t\n\v\f\r ",
980 third_separator_char_pos + 1) !=
982 error.SetErrorStringWithFormat(
983 "extra data found after the '%.*s' regular expression substitution "
985 (
int)third_separator_char_pos + 1, regex_sed.data(),
986 (
int)(regex_sed.size() - third_separator_char_pos - 1),
987 regex_sed.data() + (third_separator_char_pos + 1));
990 }
else if (first_separator_char_pos + 1 == second_separator_char_pos) {
991 error.SetErrorStringWithFormat(
992 "<regex> can't be empty in 's%c<regex>%c<subst>%c' string: '%.*s'",
993 separator_char, separator_char, separator_char, (
int)regex_sed.size(),
996 }
else if (second_separator_char_pos + 1 == third_separator_char_pos) {
997 error.SetErrorStringWithFormat(
998 "<subst> can't be empty in 's%c<regex>%c<subst>%c' string: '%.*s'",
999 separator_char, separator_char, separator_char, (
int)regex_sed.size(),
1005 std::string regex(std::string(regex_sed.substr(
1006 first_separator_char_pos + 1,
1007 second_separator_char_pos - first_separator_char_pos - 1)));
1008 std::string subst(std::string(regex_sed.substr(
1009 second_separator_char_pos + 1,
1010 third_separator_char_pos - second_separator_char_pos - 1)));
1028 class CommandOptions :
public Options {
1039 switch (short_option) {
1041 m_help.assign(std::string(option_arg));
1044 m_syntax.assign(std::string(option_arg));
1047 llvm_unreachable(
"Unimplemented option");
1059 return llvm::ArrayRef(g_regex_options);
1081 std::string funct, std::string help,
1090 stream.
Printf(
"For more information run 'help %s'", name.c_str());
1105 return CommandObjectRaw::GetHelpLong();
1109 return CommandObjectRaw::GetHelpLong();
1111 std::string docstring;
1114 if (!docstring.empty())
1116 return CommandObjectRaw::GetHelpLong();
1172 stream.
Printf(
"For more information run 'help %s'", name.c_str());
1175 GetFlags().
Set(scripter->GetFlagsForCommandObject(cmd_obj_sp));
1195 return CommandObjectRaw::GetHelp();
1198 return CommandObjectRaw::GetHelp();
1199 std::string docstring;
1202 if (!docstring.empty())
1205 return CommandObjectRaw::GetHelp();
1210 return CommandObjectRaw::GetHelpLong();
1214 return CommandObjectRaw::GetHelpLong();
1216 std::string docstring;
1219 if (!docstring.empty())
1221 return CommandObjectRaw::GetHelpLong();
1259#define LLDB_OPTIONS_script_import
1260#include "CommandOptions.inc"
1266 "Import a scripting module in LLDB.", nullptr) {
1276 arg1.push_back(cmd_arg);
1305 switch (short_option) {
1316 llvm_unreachable(
"Unimplemented option");
1327 return llvm::ArrayRef(g_script_import_options);
1334 if (command.
empty()) {
1335 result.
AppendError(
"command script import needs one or more arguments");
1343 result.
AppendError(
"command script import -c can only be specified "
1344 "from a command file");
1349 for (
auto &entry : command.
entries()) {
1365 if (
GetDebugger().GetScriptInterpreter()->LoadScriptingModule(
1366 entry.c_str(), options,
error,
nullptr,
1381#define LLDB_OPTIONS_script_add
1382#include "CommandOptions.inc"
1389 "Add a scripted function as an LLDB command.",
1390 "Add a scripted function as an lldb command. "
1391 "If you provide a single argument, the command "
1392 "will be added at the root level of the command "
1393 "hierarchy. If there are more arguments they "
1394 "must be a path to a user-added container "
1395 "command, and the last element will be the new "
1408 arg1.push_back(cmd_arg);
1422 opt_element_vector);
1437 switch (short_option) {
1439 if (!option_arg.empty())
1443 if (!option_arg.empty())
1447 if (!option_arg.empty())
1457 if (!
error.Success())
1458 error.SetErrorStringWithFormat(
1459 "unrecognized value for synchronicity '%s'",
1460 option_arg.str().c_str());
1468 if (!
error.Success())
1469 error.SetErrorStringWithFormat(
1470 "unrecognized value for command completion type '%s'",
1471 option_arg.str().c_str());
1475 llvm_unreachable(
"Unimplemented option");
1491 return llvm::ArrayRef(g_script_add_options);
1507 if (output_sp && interactive) {
1514 std::string &data)
override {
1522 std::string funct_name_str;
1524 if (funct_name_str.empty()) {
1525 error_sp->Printf(
"error: unable to obtain a function name, didn't "
1526 "add python command.\n");
1538 error_sp->Printf(
"error: unable to add selected command: '%s'",
1546 error_sp->Printf(
"error: unable to add selected command: '%s'",
1547 llvm::toString(std::move(llvm_error)).c_str());
1554 "error: unable to create function, didn't add python command\n");
1558 error_sp->Printf(
"error: empty function, didn't add python command\n");
1563 "error: script interpreter missing, didn't add python command\n");
1572 result.
AppendError(
"only scripting language supported for scripted "
1573 "commands is currently Python");
1578 result.
AppendError(
"'command script add' requires at least one argument");
1596 command,
true, path_error);
1598 if (path_error.
Fail()) {
1609 m_cmd_name = std::string(command[num_args - 1].ref());
1631 result.
AppendError(
"cannot find ScriptInterpreter");
1653 if (add_error.
Fail())
1657 llvm::Error llvm_error =
1661 llvm::toString(std::move(llvm_error)).c_str());
1682 "List defined top-level scripted commands.",
1702 "Delete all scripted commands.", nullptr) {}
1722 interpreter,
"command script delete",
1723 "Delete a scripted command by specifying the path to the command.",
1735 arg1.push_back(cmd_arg);
1753 llvm::StringRef root_cmd = command[0].ref();
1756 if (root_cmd.empty()) {
1763 "but no user defined commands found");
1770 command[0].c_str());
1773 if (!cmd_sp->IsUserCommand()) {
1775 command[0].c_str());
1778 if (cmd_sp->GetAsMultiwordCommand() && num_args == 1) {
1780 "Delete with \"command container delete\"",
1781 command[0].c_str());
1805 command[0].c_str());
1808 const char *leaf_cmd = command[num_args - 1].c_str();
1814 llvm::toString(std::move(llvm_error)).c_str());
1820 out_stream <<
"Deleted command:";
1821 for (
size_t idx = 0; idx < num_args; idx++) {
1823 out_stream << command[idx].c_str();
1831#pragma mark CommandObjectMultiwordCommandsScript
1839 interpreter,
"command script",
1840 "Commands for managing custom "
1841 "commands implemented by "
1842 "interpreter scripts.",
1843 "command script <subcommand> [<subcommand-options>]") {
1862#pragma mark CommandObjectCommandContainer
1863#define LLDB_OPTIONS_container_add
1864#include "CommandOptions.inc"
1870 interpreter,
"command container add",
1871 "Add a container command to lldb. Adding to built-"
1872 "in container commands is not allowed.",
1873 "command container add [[path1]...] container-name") {
1884 arg1.push_back(cmd_arg);
1913 switch (short_option) {
1915 if (!option_arg.empty())
1922 if (!option_arg.empty())
1926 llvm_unreachable(
"Unimplemented option");
1939 return llvm::ArrayRef(g_container_add_options);
1951 if (num_args == 0) {
1956 if (num_args == 1) {
1962 cmd_sp->GetAsMultiwordCommand()->SetRemovable(
true);
1965 if (add_error.
Fail()) {
1990 llvm::Error llvm_error =
1994 llvm::toString(std::move(llvm_error)).c_str());
2006#define LLDB_OPTIONS_multiword_delete
2007#include "CommandOptions.inc"
2012 interpreter,
"command container delete",
2013 "Delete a container command previously added to "
2015 "command container delete [[path1] ...] container-cmd") {
2026 arg1.push_back(cmd_arg);
2045 if (num_args == 0) {
2050 if (num_args == 1) {
2062 if (!cmd_sp->IsUserCommand()) {
2064 "container command %s is not a user command", cmd_name);
2067 if (!cmd_sp->GetAsMultiwordCommand()) {
2095 llvm::Error llvm_error =
2099 llvm::toString(std::move(llvm_error)).c_str());
2111 interpreter,
"command container",
2112 "Commands for adding container commands to lldb. "
2113 "Container commands are containers for other commands. You can "
2114 "add nested container commands by specifying a command path, "
2115 "but you can't add commands into the built-in command hierarchy.",
2116 "command container <subcommand> [<subcommand-options>]") {
2127#pragma mark CommandObjectMultiwordCommands
2134 "Commands for managing custom LLDB commands.",
2135 "command <subcommand> [<subcommand-options>]") {
static const char * g_python_command_instructions
static llvm::raw_ostream & error(Stream &strm)
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
bool DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectCommandsAddRegex(CommandInterpreter &interpreter)
Options * GetOptions() override
Status AppendRegexSubstitution(const llvm::StringRef ®ex_sed, bool check_only)
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
bool 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 input array contains a parsed version of the line.
Options * GetOptions() override
bool DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectCommandsContainerAdd(CommandInterpreter &interpreter)
CommandObjectCommandsContainerDelete(CommandInterpreter &interpreter)
bool DoExecute(Args &command, CommandReturnObject &result) override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
~CommandObjectCommandsContainerDelete() override=default
CommandObjectCommandsDelete(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
~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
bool DoExecute(Args &command, CommandReturnObject &result) override
void IOHandlerActivated(IOHandler &io_handler, bool interactive) override
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
~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
bool DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectCommandsScriptDelete() override=default
bool DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectCommandsScriptDelete(CommandInterpreter &interpreter)
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
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
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
bool DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectCommandsScriptImport(CommandInterpreter &interpreter)
Options * GetOptions() override
~CommandObjectCommandsScriptImport() override=default
~CommandObjectCommandsScriptList() override=default
bool DoExecute(Args &command, CommandReturnObject &result) override
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
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
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.
bool DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectCommandsSource(CommandInterpreter &interpreter)
Options * GetOptions() override
~CommandObjectCommandsSource() override=default
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
CommandObjectCommandsUnalias(CommandInterpreter &interpreter)
~CommandObjectCommandsUnalias() override=default
bool DoExecute(Args &args, CommandReturnObject &result) override
~CommandObjectMultiwordCommandsScript() override=default
CommandObjectMultiwordCommandsScript(CommandInterpreter &interpreter)
std::string m_function_name
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
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
bool DoExecute(llvm::StringRef raw_command_line, CommandReturnObject &result) override
llvm::StringRef GetHelpLong() override
const std::string & GetFunctionName()
CompletionType m_completion_type
~CommandObjectPythonFunction() override=default
bool m_fetched_help_short
llvm::StringRef GetHelp() override
bool IsRemovable() const override
llvm::StringRef GetHelpLong() override
bool DoExecute(llvm::StringRef raw_command_line, CommandReturnObject &result) override
~CommandObjectScriptingObject() override=default
CommandObjectScriptingObject(CommandInterpreter &interpreter, std::string name, StructuredData::GenericSP cmd_obj_sp, ScriptedCommandSynchronicity synch, CompletionType completion_type)
StructuredData::GenericSP m_cmd_obj_sp
bool WantsCompletion() override
CompletionType m_completion_type
ScriptedCommandSynchronicity m_synchro
ScriptedCommandSynchronicity GetSynchronicity()
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
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)
bool UserMultiwordCommandExists(llvm::StringRef cmd) const
Determine whether a root-level user multiword command with this name exists.
bool RemoveAlias(llvm::StringRef alias_name)
CommandAlias * AddAlias(llvm::StringRef alias_name, lldb::CommandObjectSP &command_obj_sp, llvm::StringRef args_string=llvm::StringRef())
CommandObject * GetCommandObject(llvm::StringRef cmd, StringList *matches=nullptr, StringList *descriptions=nullptr) const
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.
bool GetEchoCommentCommands() const
Status AddUserCommand(llvm::StringRef name, const lldb::CommandObjectSP &cmd_sp, bool can_replace)
bool AddCommand(llvm::StringRef name, const lldb::CommandObjectSP &cmd_sp, bool can_replace)
bool AliasExists(llvm::StringRef cmd) const
Determine whether an alias command with this name exists.
bool HasUserMultiwordCommands() const
void GetHelp(CommandReturnObject &result, uint32_t types=eCommandTypesAllThem)
bool CommandExists(llvm::StringRef cmd) const
Determine whether a root level, built-in command with this name exists.
bool GetRequireCommandOverwrite() const
void GetPythonCommandsFromIOHandler(const char *prompt, IOHandlerDelegate &delegate, void *baton=nullptr)
lldb::CommandObjectSP GetCommandSPExact(llvm::StringRef cmd, bool include_aliases=false) const
bool RemoveUser(llvm::StringRef alias_name)
CommandObject * GetCommandObjectForCommand(llvm::StringRef &command_line)
bool RemoveUserMultiword(llvm::StringRef multiword_name)
bool UserCommandExists(llvm::StringRef cmd) const
Determine whether a root-level user command with this name exists.
bool HasUserCommands() const
const CommandObject::CommandMap & GetCommands() const
void HandleCommandsFromFile(FileSpec &file, const ExecutionContext &context, const CommandInterpreterRunOptions &options, CommandReturnObject &result)
Execute a list of commands from a file.
FileSpec GetCurrentSourceDir()
bool RemoveCommand(llvm::StringRef cmd, bool force=false)
Remove a command if it is removable (python or regex command).
const CommandObject::CommandMap & GetAliases() const
bool GetEchoCommands() const
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)
std::vector< CommandArgumentData > CommandArgumentEntry
virtual void SetHelpLong(llvm::StringRef str)
virtual bool WantsRawCommandString()=0
bool ParseOptionsAndNotify(Args &args, CommandReturnObject &result, OptionGroupOptions &group_options, ExecutionContext &exe_ctx)
llvm::StringRef GetCommandName() const
virtual bool IsMultiwordObject()
ExecutionContext m_exe_ctx
std::vector< CommandArgumentEntry > m_arguments
CommandInterpreter & GetCommandInterpreter()
CommandInterpreter & m_interpreter
Flags & GetFlags()
The flags accessor.
virtual bool IsRemovable() const
virtual void SetHelp(llvm::StringRef str)
virtual lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd, StringList *matches=nullptr)
void AppendErrorWithFormatv(const char *format, Args &&... args)
void void AppendError(llvm::StringRef in_string)
void AppendWarningWithFormat(const char *format,...) __attribute__((format(printf
llvm::StringRef GetOutputData()
void SetStatus(lldb::ReturnStatus status)
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
lldb::ReturnStatus GetStatus() const
void void AppendWarning(llvm::StringRef in_string)
Stream & GetOutputStream()
"lldb/Utility/ArgCompletionRequest.h"
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
A class to manage flag bits.
lldb::StreamSP GetAsyncOutputStream()
CommandInterpreter & GetCommandInterpreter()
void RunIOHandlerAsync(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler=true)
Run the given IO handler and return immediately.
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, std::optional< lldb::ScriptLanguage > language={})
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
void Clear()
Clear the object's state.
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.
void Resolve(llvm::SmallVectorImpl< char > &path)
Resolve path to make it canonical.
static FileSystem & Instance()
ValueType Set(ValueType mask)
Set one or more flags by logical OR'ing mask with the current flags.
A delegate class for use with IOHandler subclasses.
lldb::StreamFileSP GetErrorStreamFileSP()
lldb::StreamFileSP GetOutputStreamFileSP()
LoadScriptOptions & SetInitSession(bool b)
LoadScriptOptions & SetSilent(bool b)
void Append(OptionGroup *group)
Append options from a OptionGroup class.
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
bool GetCurrentValue() const
const char * GetCurrentValue() const
Status SetCurrentValue(llvm::StringRef value)
bool OptionWasSet() const
A pair of an option list with a 'raw' string as a suffix.
A command line option parsing protocol class.
void NotifyOptionParsingStarting(ExecutionContext *execution_context)
std::vector< Option > m_getopt_table
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 bool GetDocumentationForItem(const char *item, std::string &dest)
virtual bool GetLongHelpForCommandObject(StructuredData::GenericSP cmd_obj_sp, std::string &dest)
virtual bool GetShortHelpForCommandObject(StructuredData::GenericSP cmd_obj_sp, std::string &dest)
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.
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 SplitIntoLines(const std::string &lines)
std::shared_ptr< Generic > GenericSP
A class that represents a running process on the host machine.
std::vector< OptionArgElement > OptionElementVector
std::shared_ptr< OptionArgVector > OptionArgVectorSP
ScriptedCommandSynchronicity
@ eScriptedCommandSynchronicitySynchronous
std::vector< std::tuple< std::string, int, std::string > > OptionArgVector
std::shared_ptr< lldb_private::IOHandler > IOHandlerSP
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
std::shared_ptr< lldb_private::Stream > StreamSP
@ eReturnStatusSuccessFinishResult
@ eReturnStatusSuccessFinishNoResult
std::shared_ptr< lldb_private::StreamFile > StreamFileSP
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)
OptionEnumValues enum_values
If not empty, an array of enum values.