diff options
author | Raphael Isemann <teemperor@gmail.com> | 2018-07-11 17:18:01 +0000 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2018-07-11 17:18:01 +0000 |
commit | c094d23f6f23a2bec0c7aa00a7113bee456f78c5 (patch) | |
tree | 7a8ad3568fa360199085ffd7e8b49ebb6a8097bc /lldb/include | |
parent | 3f27e57adeb5fc262e07c191eca07f28977a1f3b (diff) | |
download | bcm5719-llvm-c094d23f6f23a2bec0c7aa00a7113bee456f78c5.tar.gz bcm5719-llvm-c094d23f6f23a2bec0c7aa00a7113bee456f78c5.zip |
Allow specifying an exit code for the 'quit' command
Summary:
This patch adds the possibility to specify an exit code when calling quit.
We accept any int, even though it depends on the user what happens if the int is
out of the range of what the operating system supports as exit codes.
Fixes rdar://problem/38452312
Reviewers: davide, jingham, clayborg
Reviewed By: jingham
Subscribers: clayborg, jingham, lldb-commits
Differential Revision: https://reviews.llvm.org/D48659
llvm-svn: 336824
Diffstat (limited to 'lldb/include')
-rw-r--r-- | lldb/include/lldb/API/SBCommandInterpreter.h | 19 | ||||
-rw-r--r-- | lldb/include/lldb/Interpreter/CommandInterpreter.h | 30 |
2 files changed, 49 insertions, 0 deletions
diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h b/lldb/include/lldb/API/SBCommandInterpreter.h index 928e40bad28..8b9f0659936 100644 --- a/lldb/include/lldb/API/SBCommandInterpreter.h +++ b/lldb/include/lldb/API/SBCommandInterpreter.h @@ -208,6 +208,25 @@ public: void SetPromptOnQuit(bool b); //---------------------------------------------------------------------- + /// Sets whether the command interpreter should allow custom exit codes + /// for the 'quit' command. + //---------------------------------------------------------------------- + void AllowExitCodeOnQuit(bool allow); + + //---------------------------------------------------------------------- + /// Returns true if the user has called the 'quit' command with a custom exit + /// code. + //---------------------------------------------------------------------- + bool HasCustomQuitExitCode(); + + //---------------------------------------------------------------------- + /// Returns the exit code that the user has specified when running the + /// 'quit' command. Returns 0 if the user hasn't called 'quit' at all or + /// without a custom exit code. + //---------------------------------------------------------------------- + int GetQuitStatus(); + + //---------------------------------------------------------------------- /// Resolve the command just as HandleCommand would, expanding abbreviations /// and aliases. If successful, result->GetOutput has the full expansion. //---------------------------------------------------------------------- diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index 60e67f2271f..0a556cc6b3f 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -455,6 +455,30 @@ public: void SetPromptOnQuit(bool b); + //------------------------------------------------------------------ + /// Specify if the command interpreter should allow that the user can + /// specify a custom exit code when calling 'quit'. + //------------------------------------------------------------------ + void AllowExitCodeOnQuit(bool allow); + + //------------------------------------------------------------------ + /// Sets the exit code for the quit command. + /// @param[in] exit_code + /// The exit code that the driver should return on exit. + /// @return True if the exit code was successfully set; false if the + /// interpreter doesn't allow custom exit codes. + /// @see AllowExitCodeOnQuit + //------------------------------------------------------------------ + LLVM_NODISCARD bool SetQuitExitCode(int exit_code); + + //------------------------------------------------------------------ + /// Returns the exit code that the user has specified when running the + /// 'quit' command. + /// @param[out] exited + /// Set to true if the user has called quit with a custom exit code. + //------------------------------------------------------------------ + int GetQuitExitCode(bool &exited) const; + void ResolveCommand(const char *command_line, CommandReturnObject &result); bool GetStopCmdSourceOnError() const; @@ -558,6 +582,12 @@ private: uint32_t m_num_errors; bool m_quit_requested; bool m_stopped_for_crash; + + // The exit code the user has requested when calling the 'quit' command. + // No value means the user hasn't set a custom exit code so far. + llvm::Optional<int> m_quit_exit_code; + // If the driver is accepts custom exit codes for the 'quit' command. + bool m_allow_exit_code = false; }; } // namespace lldb_private |