diff options
Diffstat (limited to 'include/lldb/Interpreter/CommandInterpreter.h')
| -rw-r--r-- | include/lldb/Interpreter/CommandInterpreter.h | 85 |
1 files changed, 54 insertions, 31 deletions
diff --git a/include/lldb/Interpreter/CommandInterpreter.h b/include/lldb/Interpreter/CommandInterpreter.h index 78f505c24754..558246037ad0 100644 --- a/include/lldb/Interpreter/CommandInterpreter.h +++ b/include/lldb/Interpreter/CommandInterpreter.h @@ -10,80 +10,81 @@ #ifndef liblldb_CommandInterpreter_h_ #define liblldb_CommandInterpreter_h_ -// C Includes -// C++ Includes -#include <mutex> -// Other libraries and framework includes -// Project includes -#include "lldb/Core/Broadcaster.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/Event.h" #include "lldb/Core/IOHandler.h" #include "lldb/Interpreter/CommandAlias.h" #include "lldb/Interpreter/CommandHistory.h" #include "lldb/Interpreter/CommandObject.h" #include "lldb/Interpreter/ScriptInterpreter.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/Broadcaster.h" #include "lldb/Utility/CompletionRequest.h" +#include "lldb/Utility/Event.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StringList.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" +#include <mutex> namespace lldb_private { class CommandInterpreterRunOptions { public: //------------------------------------------------------------------ - /// Construct a CommandInterpreterRunOptions object. - /// This class is used to control all the instances where we run multiple - /// commands, e.g. + /// Construct a CommandInterpreterRunOptions object. This class is used to + /// control all the instances where we run multiple commands, e.g. /// HandleCommands, HandleCommandsFromFile, RunCommandInterpreter. + /// /// The meanings of the options in this object are: /// /// @param[in] stop_on_continue - /// If \b true execution will end on the first command that causes the - /// process in the - /// execution context to continue. If \false, we won't check the execution - /// status. + /// If \b true, execution will end on the first command that causes the + /// process in the execution context to continue. If \b false, we won't + /// check the execution status. /// @param[in] stop_on_error - /// If \b true execution will end on the first command that causes an + /// If \b true, execution will end on the first command that causes an /// error. /// @param[in] stop_on_crash - /// If \b true when a command causes the target to run, and the end of the - /// run is a - /// signal or exception, stop executing the commands. + /// If \b true, when a command causes the target to run, and the end of the + /// run is a signal or exception, stop executing the commands. /// @param[in] echo_commands - /// If \b true echo the command before executing it. If \false, execute + /// If \b true, echo the command before executing it. If \b false, execute /// silently. + /// @param[in] echo_comments + /// If \b true, echo command even if it is a pure comment line. If + /// \b false, print no ouput in this case. This setting has an effect only + /// if \param echo_commands is \b true. /// @param[in] print_results - /// If \b true print the results of the command after executing it. If - /// \false, execute silently. + /// If \b true print the results of the command after executing it. If + /// \b false, execute silently. /// @param[in] add_to_history - /// If \b true add the commands to the command history. If \false, don't + /// If \b true add the commands to the command history. If \b false, don't /// add them. //------------------------------------------------------------------ CommandInterpreterRunOptions(LazyBool stop_on_continue, LazyBool stop_on_error, LazyBool stop_on_crash, - LazyBool echo_commands, LazyBool print_results, - LazyBool add_to_history) + LazyBool echo_commands, LazyBool echo_comments, + LazyBool print_results, LazyBool add_to_history) : m_stop_on_continue(stop_on_continue), m_stop_on_error(stop_on_error), m_stop_on_crash(stop_on_crash), m_echo_commands(echo_commands), - m_print_results(print_results), m_add_to_history(add_to_history) {} + m_echo_comment_commands(echo_comments), m_print_results(print_results), + m_add_to_history(add_to_history) {} CommandInterpreterRunOptions() : m_stop_on_continue(eLazyBoolCalculate), m_stop_on_error(eLazyBoolCalculate), m_stop_on_crash(eLazyBoolCalculate), m_echo_commands(eLazyBoolCalculate), + m_echo_comment_commands(eLazyBoolCalculate), m_print_results(eLazyBoolCalculate), m_add_to_history(eLazyBoolCalculate) {} void SetSilent(bool silent) { LazyBool value = silent ? eLazyBoolNo : eLazyBoolYes; - m_echo_commands = value; m_print_results = value; + m_echo_commands = value; + m_echo_comment_commands = value; m_add_to_history = value; } // These return the default behaviors if the behavior is not @@ -97,7 +98,7 @@ public: m_stop_on_continue = stop_on_continue ? eLazyBoolYes : eLazyBoolNo; } - bool GetStopOnError() const { return DefaultToNo(m_stop_on_continue); } + bool GetStopOnError() const { return DefaultToNo(m_stop_on_error); } void SetStopOnError(bool stop_on_error) { m_stop_on_error = stop_on_error ? eLazyBoolYes : eLazyBoolNo; @@ -115,6 +116,14 @@ public: m_echo_commands = echo_commands ? eLazyBoolYes : eLazyBoolNo; } + bool GetEchoCommentCommands() const { + return DefaultToYes(m_echo_comment_commands); + } + + void SetEchoCommentCommands(bool echo_comments) { + m_echo_comment_commands = echo_comments ? eLazyBoolYes : eLazyBoolNo; + } + bool GetPrintResults() const { return DefaultToYes(m_print_results); } void SetPrintResults(bool print_results) { @@ -131,6 +140,7 @@ public: LazyBool m_stop_on_error; LazyBool m_stop_on_crash; LazyBool m_echo_commands; + LazyBool m_echo_comment_commands; LazyBool m_print_results; LazyBool m_add_to_history; @@ -206,7 +216,8 @@ public: bool include_aliases) const; CommandObject *GetCommandObject(llvm::StringRef cmd, - StringList *matches = nullptr) const; + StringList *matches = nullptr, + StringList *descriptions = nullptr) const; bool CommandExists(llvm::StringRef cmd) const; @@ -310,7 +321,8 @@ public: // FIXME: Only max_return_elements == -1 is supported at present. int HandleCompletion(const char *current_line, const char *cursor, const char *last_char, int match_start_point, - int max_return_elements, StringList &matches); + int max_return_elements, StringList &matches, + StringList &descriptions); // This version just returns matches, and doesn't compute the substring. It // is here so the Help command can call it for the first argument. It uses @@ -319,7 +331,8 @@ public: int GetCommandNamesMatchingPartialString(const char *cmd_cstr, bool include_aliases, - StringList &matches); + StringList &matches, + StringList &descriptions); void GetHelp(CommandReturnObject &result, uint32_t types = eCommandTypesAllThem); @@ -456,6 +469,12 @@ public: void SetPromptOnQuit(bool b); + bool GetEchoCommands() const; + void SetEchoCommands(bool b); + + bool GetEchoCommentCommands() const; + void SetEchoCommentCommands(bool b); + //------------------------------------------------------------------ /// Specify if the command interpreter should allow that the user can /// specify a custom exit code when calling 'quit'. @@ -520,7 +539,8 @@ protected: lldb::CommandObjectSP GetCommandSP(llvm::StringRef cmd, bool include_aliases = true, bool exact = true, - StringList *matches = nullptr) const; + StringList *matches = nullptr, + StringList *descriptions = nullptr) const; private: Status PreprocessCommand(std::string &command); @@ -538,6 +558,9 @@ private: // An interruptible wrapper around the stream output void PrintCommandOutput(Stream &stream, llvm::StringRef str); + bool EchoCommandNonInteractive(llvm::StringRef line, + const Flags &io_handler_flags) const; + // A very simple state machine which models the command handling transitions enum class CommandHandlingState { eIdle, |
