[Lldb-commits] [PATCH] D48659: Allow specifying an exit code for the 'quit' command
Greg Clayton via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Jun 27 13:50:18 PDT 2018
clayborg requested changes to this revision.
clayborg added a comment.
This change seems fine to me. It allows each debugger to have a different exit status and each debugger can grab one. Seems like this should belong in lldb_private::CommandInterpreter and lldb::SBCommandInterpreter instead of in lldb_private::Debugger and lldb::SBDebugger
================
Comment at: include/lldb/API/SBDebugger.h:225-226
+ /// Returns the exit code that the user has set from the prompt.
+ int GetExitCode();
+
----------------
How do you know if the quit command has been called? I mean, we can return zero when "quit" hasn't been called yet, but it might be nice to know by changing the signature a bit:
```
int GetExitCode(bool &exited);
```
**exited** would be set to true if the quit command has been called, false otherwise if the command interpreter is still running?
Also "GetExitCode()" might be better and more clear as being named "GetQuitStatus()" or "GetQuitCommandStatus()" to be more clear this the result of the "quit" command?
This seems like this belongs more on the SBCommandInterpreter since it is the result of the "quit" command. Maybe something like:
```
class SBCommandInterpreter {
bool QuitHasBeenCalled();
int GetQuitStatus();
};
```
Then the user can call "SBCommandInterpreter::QuitHasBeenCalled()" first and follow it with SBCommandInterpreter::GetQuitStatus() to get the status? So I this should be moved to SBCommandInterpreter.h
================
Comment at: include/lldb/Core/Debugger.h:331-334
+ void SetExitCode(int i) { m_exit_code = i; }
+
+ int GetExitCode() const { return m_exit_code; }
+
----------------
move to command interpreter.
================
Comment at: include/lldb/Core/Debugger.h:411-412
llvm::once_flag m_clear_once;
+ // The exit code the user has requested for the current debugger process.
+ int m_exit_code = 0;
----------------
move to command interpreter
================
Comment at: source/API/SBDebugger.cpp:1084-1087
+int SBDebugger::GetExitCode() {
+ return (m_opaque_sp ? m_opaque_sp->GetExitCode() : 0);
+}
+
----------------
move to SBCommandInterpreter
================
Comment at: source/Commands/CommandObjectQuit.cpp:101
+ }
+ m_interpreter.GetDebugger().SetExitCode(exit_code);
+ }
----------------
```
m_interpreter.SetExitCode(exit_code);
```
================
Comment at: tools/driver/Driver.cpp:1162
+ int exit_code = m_debugger.GetExitCode();
SBDebugger::Destroy(m_debugger);
----------------
Get exit from command interpreter
https://reviews.llvm.org/D48659
More information about the lldb-commits
mailing list