9#ifndef LLDB_INTERPRETER_COMMANDINTERPRETER_H
10#define LLDB_INTERPRETER_COMMANDINTERPRETER_H
32#include <unordered_map>
35class CommandInterpreter;
288 bool include_aliases =
false)
const;
338 bool leaf_is_command,
343 llvm::StringRef args_string = llvm::StringRef());
365 std::string &raw_input_string,
366 std::string &alias_result,
375 bool force_repeat_command =
false);
440 bool include_aliases,
450 llvm::StringRef help_text);
453 llvm::StringRef separator,
454 llvm::StringRef help_text,
size_t max_word_len);
463 llvm::StringRef separator, llvm::StringRef help_text,
464 uint32_t max_word_len);
476 bool Confirm(llvm::StringRef message,
bool default_answer);
495 const char *alias_name,
Args &cmd_args,
496 std::string &raw_input_string,
514 bool search_builtin_commands,
515 bool search_user_commands,
516 bool search_alias_commands,
517 bool search_user_mw_commands);
539 s.
Printf(
"*** Some of the displayed variables have more members than the "
540 "debugger will show by default. To show all of them, you can "
541 "either use the --show-all-children option to %s or raise the "
542 "limit by changing the target.max-children-count setting.\n",
548 s.
Printf(
"*** Some of the displayed variables have a greater depth of "
549 "members than the debugger will show by default. To increase "
550 "the limit, use the --depth option to %s, or raise the limit by "
551 "changing the target.max-children-depth setting.\n",
566 void *baton =
nullptr);
570 void *baton =
nullptr);
654 std::optional<std::string> output_file = std::nullopt);
681 std::string &line)
override;
684 static constexpr llvm::StringLiteral control_sequence(
"quit\n");
686 return control_sequence;
697 bool include_aliases =
true,
724 const Flags &io_handler_flags)
const;
A command line argument class.
An event broadcasting class.
CommandInterpreterRunOptions(LazyBool stop_on_continue, LazyBool stop_on_error, LazyBool stop_on_crash, LazyBool echo_commands, LazyBool echo_comments, LazyBool print_results, LazyBool print_errors, LazyBool add_to_history, LazyBool handle_repeats)
Construct a CommandInterpreterRunOptions object.
bool GetSpawnThread() const
static bool DefaultToNo(LazyBool flag)
void SetStopOnContinue(bool stop_on_continue)
void SetSilent(bool silent)
CommandInterpreterRunOptions()=default
void SetAllowRepeats(bool allow_repeats)
void SetSpawnThread(bool spawn_thread)
bool GetAllowRepeats() const
void SetAutoHandleEvents(bool auto_handle_events)
bool GetEchoCommentCommands() const
bool GetAutoHandleEvents() const
void SetPrintErrors(bool print_errors)
LazyBool m_add_to_history
bool GetStopOnCrash() const
void SetEchoCommands(bool echo_commands)
bool GetAddToHistory() const
void SetAddToHistory(bool add_to_history)
bool GetStopOnContinue() const
bool GetPrintResults() const
void SetStopOnError(bool stop_on_error)
bool GetStopOnError() const
void SetPrintResults(bool print_results)
bool GetEchoCommands() const
LazyBool m_echo_comment_commands
bool GetPrintErrors() const
void SetEchoCommentCommands(bool echo_comments)
LazyBool m_auto_handle_events
void SetStopOnCrash(bool stop_on_crash)
LazyBool m_stop_on_continue
static bool DefaultToYes(LazyBool flag)
bool IsResult(lldb::CommandInterpreterResult result)
lldb::CommandInterpreterResult GetResult() const
void SetResult(lldb::CommandInterpreterResult result)
friend CommandInterpreter
uint32_t GetNumErrors() const
void IncrementNumberOfErrors()
lldb::CommandInterpreterResult m_result
CommandInterpreterRunResult()=default
CommandUsageMap m_command_usages
bool m_skip_lldbinit_files
bool GetSaveTranscript() const
void SetReachedMaximumDepth()
bool EchoCommandNonInteractive(llvm::StringRef line, const Flags &io_handler_flags) const
void UpdatePrompt(llvm::StringRef prompt)
bool IOHandlerInterrupt(IOHandler &io_handler) override
lldb::IOHandlerSP m_command_io_handler_sp
void SetPromptOnQuit(bool enable)
void SourceInitFileHome(CommandReturnObject &result, bool is_repl)
We will first see if there is an application specific ".lldbinit" file whose name is "~/....
std::optional< std::string > GetAutoSuggestionForCommand(llvm::StringRef line)
Returns the auto-suggestion string that should be added to the given command line.
void IOHandlerInputComplete(IOHandler &io_handler, std::string &line) override
Called when a line or lines have been retrieved.
llvm::json::Value GetStatistics()
void LoadCommandDictionary()
std::stack< ExecutionContext > m_overriden_exe_contexts
bool GetStopCmdSourceOnError() const
void OutputFormattedHelpText(Stream &strm, llvm::StringRef prefix, llvm::StringRef help_text)
bool Confirm(llvm::StringRef message, bool default_answer)
bool UserMultiwordCommandExists(llvm::StringRef cmd) const
Determine whether a root-level user multiword command with this name exists.
static llvm::StringRef GetStaticBroadcasterClass()
void GetAliasHelp(const char *alias_name, StreamString &help_string)
void IncreaseCommandUsage(const CommandObject &cmd_obj)
CommandObject * GetAliasCommandObject(llvm::StringRef cmd, StringList *matches=nullptr, StringList *descriptions=nullptr) const
static const char * g_no_argument
void SetEchoCommands(bool enable)
bool RemoveAlias(llvm::StringRef alias_name)
void SetSaveSessionDirectory(llvm::StringRef path)
bool HasAliasOptions() const
void RemoveAllUserMultiword()
void SourceInitFile(FileSpec file, CommandReturnObject &result)
CommandAlias * AddAlias(llvm::StringRef alias_name, lldb::CommandObjectSP &command_obj_sp, llvm::StringRef args_string=llvm::StringRef())
int GetCommandNamesMatchingPartialString(const char *cmd_cstr, bool include_aliases, StringList &matches, StringList &descriptions)
void FindCommandsForApropos(llvm::StringRef word, StringList &commands_found, StringList &commands_help, bool search_builtin_commands, bool search_user_commands, bool search_alias_commands, bool search_user_mw_commands)
CommandObject * GetCommandObject(llvm::StringRef cmd, StringList *matches=nullptr, StringList *descriptions=nullptr) const
std::atomic< CommandHandlingState > m_command_state
Status PreprocessCommand(std::string &command)
CommandObject::CommandMap m_alias_dict
CommandObject * ResolveCommandImpl(std::string &command_line, CommandReturnObject &result)
CommandObject::CommandMap m_command_dict
ChildrenOmissionWarningStatus m_truncation_warning
Whether we truncated a value's list of children and whether the user has been told.
void SkipAppInitFiles(bool skip_app_init_files)
void SetOpenTranscriptInEditor(bool enable)
void HandleCompletion(CompletionRequest &request)
CommandInterpreterRunResult m_result
bool GetSpaceReplPrompts() const
void SkipLLDBInitFiles(bool skip_lldbinit_files)
ChildrenOmissionWarningStatus m_max_depth_warning
Whether we reached the maximum child nesting depth and whether the user has been told.
void ResolveCommand(const char *command_line, CommandReturnObject &result)
bool SetQuitExitCode(int exit_code)
Sets the exit code for the quit command.
CommandInterpreterRunResult RunCommandInterpreter(CommandInterpreterRunOptions &options)
bool HandleCommand(const char *command_line, LazyBool add_to_history, const ExecutionContext &override_context, CommandReturnObject &result)
bool DidProcessStopAbnormally() const
CommandObject::CommandMap m_user_dict
std::optional< int > m_quit_exit_code
ExecutionContext GetExecutionContext() const
const CommandObject::CommandMap & GetUserCommands() const
CommandObject * GetUserCommandObject(llvm::StringRef cmd, StringList *matches=nullptr, StringList *descriptions=nullptr) const
void SourceInitFileGlobal(CommandReturnObject &result)
@ eBroadcastBitAsynchronousOutputData
@ eBroadcastBitQuitCommandReceived
@ eBroadcastBitAsynchronousErrorData
@ eBroadcastBitResetPrompt
@ eBroadcastBitThreadShouldExit
bool GetAliasFullName(llvm::StringRef cmd, std::string &full_name) 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
bool WasInterrupted() const
void HandleCompletionMatches(CompletionRequest &request)
Status AddUserCommand(llvm::StringRef name, const lldb::CommandObjectSP &cmd_sp, bool can_replace)
llvm::StringMap< uint64_t > CommandUsageMap
Command usage statistics.
bool AddCommand(llvm::StringRef name, const lldb::CommandObjectSP &cmd_sp, bool can_replace)
void PrintCommandOutput(IOHandler &io_handler, llvm::StringRef str, bool is_stdout)
int m_iohandler_nesting_level
bool GetOpenTranscriptInEditor() const
bool AliasExists(llvm::StringRef cmd) const
Determine whether an alias command with this name exists.
bool GetExpandRegexAliases() const
int GetOptionArgumentPosition(const char *in_string)
Picks the number out of a string of the form "%NNN", otherwise return 0.
bool HasUserMultiwordCommands() const
void StartHandlingCommand()
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 GetBatchCommandMode()
bool GetPromptOnQuit() const
std::string m_repeat_command
const char * GetCommandPrefix()
bool SaveTranscript(CommandReturnObject &result, std::optional< std::string > output_file=std::nullopt)
Save the current debugger session transcript to a file on disk.
int GetQuitExitCode(bool &exited) const
Returns the exit code that the user has specified when running the 'quit' command.
~CommandInterpreter() override=default
lldb::PlatformSP GetPlatform(bool prefer_target_platform)
bool GetRequireCommandOverwrite() const
void RestoreExecutionContext()
void GetPythonCommandsFromIOHandler(const char *prompt, IOHandlerDelegate &delegate, void *baton=nullptr)
lldb::CommandObjectSP GetCommandSPExact(llvm::StringRef cmd, bool include_aliases=false) const
const CommandAlias * GetAlias(llvm::StringRef alias_name) const
void FinishHandlingCommand()
bool RemoveUser(llvm::StringRef alias_name)
void GetLLDBCommandsFromIOHandler(const char *prompt, IOHandlerDelegate &delegate, void *baton=nullptr)
lldb::CommandObjectSP GetCommandSP(llvm::StringRef cmd, bool include_aliases=true, bool exact=true, StringList *matches=nullptr, StringList *descriptions=nullptr) const
void OutputHelpText(Stream &stream, llvm::StringRef command_word, llvm::StringRef separator, llvm::StringRef help_text, uint32_t max_word_len)
CommandObject * GetCommandObjectForCommand(llvm::StringRef &command_line)
static const char * g_need_argument
bool m_skip_app_init_files
void SetSynchronous(bool value)
uint32_t m_command_source_depth
Status PreprocessToken(std::string &token)
bool RemoveUserMultiword(llvm::StringRef multiword_name)
bool GetSaveSessionOnQuit() const
FileSpec GetSaveSessionDirectory() const
ChildrenOmissionWarningStatus
Tristate boolean to manage children omission warnings.
@ eNoOmission
No children were omitted.
@ eWarnedOmission
Children omitted and notified.
@ eUnwarnedOmission
Children omitted, and not yet notified.
bool UserCommandExists(llvm::StringRef cmd) const
Determine whether a root-level user command with this name exists.
bool GetRepeatPreviousCommand() const
lldb::IOHandlerSP GetIOHandler(bool force_create=false, CommandInterpreterRunOptions *options=nullptr)
bool m_batch_command_mode
bool HasUserCommands() const
const CommandObject::CommandMap & GetUserMultiwordCommands() const
void BuildAliasCommandArgs(CommandObject *alias_cmd_obj, const char *alias_name, Args &cmd_args, std::string &raw_input_string, CommandReturnObject &result)
std::vector< uint32_t > m_command_source_flags
CommandHistory m_command_history
CommandObject * BuildAliasResult(llvm::StringRef alias_name, std::string &raw_input_string, std::string &alias_result, CommandReturnObject &result)
void OverrideExecutionContext(const ExecutionContext &override_context)
bool SetBatchCommandMode(bool value)
const CommandObject::CommandMap & GetCommands() const
const char * ProcessEmbeddedScriptCommands(const char *arg)
void AllowExitCodeOnQuit(bool allow)
Specify if the command interpreter should allow that the user can specify a custom exit code when cal...
CommandObject::CommandMap m_user_mw_dict
bool m_synchronous_execution
StreamString m_transcript_stream
Turn on settings interpreter.save-transcript for LLDB to populate this stream.
void HandleCommandsFromFile(FileSpec &file, const ExecutionContext &context, const CommandInterpreterRunOptions &options, CommandReturnObject &result)
Execute a list of commands from a file.
void SourceInitFileCwd(CommandReturnObject &result)
CommandHistory & GetCommandHistory()
void SetSaveSessionOnQuit(bool enable)
static const char * g_argument
void PrintWarningsIfNecessary(Stream &s, const std::string &cmd_name)
std::vector< FileSpec > m_command_source_dirs
A stack of directory paths.
llvm::StringRef IOHandlerGetControlSequence(char ch) override
void HandleCommands(const StringList &commands, const ExecutionContext &context, const CommandInterpreterRunOptions &options, CommandReturnObject &result)
Execute a list of commands in sequence.
void SetSaveTranscript(bool enable)
FileSpec GetCurrentSourceDir()
llvm::StringRef GetBroadcasterClass() const override
This needs to be filled in if you are going to register the broadcaster with the broadcaster manager ...
void SetEchoCommentCommands(bool enable)
StructuredData::Array m_transcript
Contains a list of handled commands and their details.
bool RemoveCommand(llvm::StringRef cmd, bool force=false)
Remove a command if it is removable (python or regex command).
const StructuredData::Array & GetTranscript() const
const CommandObject::CommandMap & GetAliases() const
bool GetEchoCommands() const
llvm::StringRef GetCommandName() const
std::map< std::string, lldb::CommandObjectSP, std::less<> > CommandMap
"lldb/Utility/ArgCompletionRequest.h"
A class to manage flag bits.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
A delegate class for use with IOHandler subclasses.
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.
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::IOHandler > IOHandlerSP
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
CommandInterpreterResult
The result from a command interpreter run.
@ eCommandInterpreterResultSuccess
Command interpreter finished successfully.
std::shared_ptr< lldb_private::Platform > PlatformSP