1 //===-- CommandInterpreter.h ------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef liblldb_CommandInterpreter_h_
11 #define liblldb_CommandInterpreter_h_
12 
13 #include "lldb/Core/Debugger.h"
14 #include "lldb/Core/IOHandler.h"
15 #include "lldb/Interpreter/CommandAlias.h"
16 #include "lldb/Interpreter/CommandHistory.h"
17 #include "lldb/Interpreter/CommandObject.h"
18 #include "lldb/Interpreter/ScriptInterpreter.h"
19 #include "lldb/Utility/Args.h"
20 #include "lldb/Utility/Broadcaster.h"
21 #include "lldb/Utility/CompletionRequest.h"
22 #include "lldb/Utility/Event.h"
23 #include "lldb/Utility/Log.h"
24 #include "lldb/Utility/StringList.h"
25 #include "lldb/lldb-forward.h"
26 #include "lldb/lldb-private.h"
27 #include <mutex>
28 
29 namespace lldb_private {
30 
31 class CommandInterpreterRunOptions {
32 public:
33   //------------------------------------------------------------------
34   /// Construct a CommandInterpreterRunOptions object. This class is used to
35   /// control all the instances where we run multiple commands, e.g.
36   /// HandleCommands, HandleCommandsFromFile, RunCommandInterpreter.
37   ///
38   /// The meanings of the options in this object are:
39   ///
40   /// @param[in] stop_on_continue
41   ///    If \b true, execution will end on the first command that causes the
42   ///    process in the execution context to continue. If \b false, we won't
43   ///    check the execution status.
44   /// @param[in] stop_on_error
45   ///    If \b true, execution will end on the first command that causes an
46   ///    error.
47   /// @param[in] stop_on_crash
48   ///    If \b true, when a command causes the target to run, and the end of the
49   ///    run is a signal or exception, stop executing the commands.
50   /// @param[in] echo_commands
51   ///    If \b true, echo the command before executing it. If \b false, execute
52   ///    silently.
53   /// @param[in] echo_comments
54   ///    If \b true, echo command even if it is a pure comment line. If
55   ///    \b false, print no ouput in this case. This setting has an effect only
56   ///    if \param echo_commands is \b true.
57   /// @param[in] print_results
58   ///    If \b true print the results of the command after executing it. If
59   ///    \b false, execute silently.
60   /// @param[in] add_to_history
61   ///    If \b true add the commands to the command history. If \b false, don't
62   ///    add them.
63   //------------------------------------------------------------------
CommandInterpreterRunOptions(LazyBool stop_on_continue,LazyBool stop_on_error,LazyBool stop_on_crash,LazyBool echo_commands,LazyBool echo_comments,LazyBool print_results,LazyBool add_to_history)64   CommandInterpreterRunOptions(LazyBool stop_on_continue,
65                                LazyBool stop_on_error, LazyBool stop_on_crash,
66                                LazyBool echo_commands, LazyBool echo_comments,
67                                LazyBool print_results, LazyBool add_to_history)
68       : m_stop_on_continue(stop_on_continue), m_stop_on_error(stop_on_error),
69         m_stop_on_crash(stop_on_crash), m_echo_commands(echo_commands),
70         m_echo_comment_commands(echo_comments), m_print_results(print_results),
71         m_add_to_history(add_to_history) {}
72 
CommandInterpreterRunOptions()73   CommandInterpreterRunOptions()
74       : m_stop_on_continue(eLazyBoolCalculate),
75         m_stop_on_error(eLazyBoolCalculate),
76         m_stop_on_crash(eLazyBoolCalculate),
77         m_echo_commands(eLazyBoolCalculate),
78         m_echo_comment_commands(eLazyBoolCalculate),
79         m_print_results(eLazyBoolCalculate),
80         m_add_to_history(eLazyBoolCalculate) {}
81 
SetSilent(bool silent)82   void SetSilent(bool silent) {
83     LazyBool value = silent ? eLazyBoolNo : eLazyBoolYes;
84 
85     m_print_results = value;
86     m_echo_commands = value;
87     m_echo_comment_commands = value;
88     m_add_to_history = value;
89   }
90   // These return the default behaviors if the behavior is not
91   // eLazyBoolCalculate. But I've also left the ivars public since for
92   // different ways of running the interpreter you might want to force
93   // different defaults...  In that case, just grab the LazyBool ivars directly
94   // and do what you want with eLazyBoolCalculate.
GetStopOnContinue()95   bool GetStopOnContinue() const { return DefaultToNo(m_stop_on_continue); }
96 
SetStopOnContinue(bool stop_on_continue)97   void SetStopOnContinue(bool stop_on_continue) {
98     m_stop_on_continue = stop_on_continue ? eLazyBoolYes : eLazyBoolNo;
99   }
100 
GetStopOnError()101   bool GetStopOnError() const { return DefaultToNo(m_stop_on_error); }
102 
SetStopOnError(bool stop_on_error)103   void SetStopOnError(bool stop_on_error) {
104     m_stop_on_error = stop_on_error ? eLazyBoolYes : eLazyBoolNo;
105   }
106 
GetStopOnCrash()107   bool GetStopOnCrash() const { return DefaultToNo(m_stop_on_crash); }
108 
SetStopOnCrash(bool stop_on_crash)109   void SetStopOnCrash(bool stop_on_crash) {
110     m_stop_on_crash = stop_on_crash ? eLazyBoolYes : eLazyBoolNo;
111   }
112 
GetEchoCommands()113   bool GetEchoCommands() const { return DefaultToYes(m_echo_commands); }
114 
SetEchoCommands(bool echo_commands)115   void SetEchoCommands(bool echo_commands) {
116     m_echo_commands = echo_commands ? eLazyBoolYes : eLazyBoolNo;
117   }
118 
GetEchoCommentCommands()119   bool GetEchoCommentCommands() const {
120     return DefaultToYes(m_echo_comment_commands);
121   }
122 
SetEchoCommentCommands(bool echo_comments)123   void SetEchoCommentCommands(bool echo_comments) {
124     m_echo_comment_commands = echo_comments ? eLazyBoolYes : eLazyBoolNo;
125   }
126 
GetPrintResults()127   bool GetPrintResults() const { return DefaultToYes(m_print_results); }
128 
SetPrintResults(bool print_results)129   void SetPrintResults(bool print_results) {
130     m_print_results = print_results ? eLazyBoolYes : eLazyBoolNo;
131   }
132 
GetAddToHistory()133   bool GetAddToHistory() const { return DefaultToYes(m_add_to_history); }
134 
SetAddToHistory(bool add_to_history)135   void SetAddToHistory(bool add_to_history) {
136     m_add_to_history = add_to_history ? eLazyBoolYes : eLazyBoolNo;
137   }
138 
139   LazyBool m_stop_on_continue;
140   LazyBool m_stop_on_error;
141   LazyBool m_stop_on_crash;
142   LazyBool m_echo_commands;
143   LazyBool m_echo_comment_commands;
144   LazyBool m_print_results;
145   LazyBool m_add_to_history;
146 
147 private:
DefaultToYes(LazyBool flag)148   static bool DefaultToYes(LazyBool flag) {
149     switch (flag) {
150     case eLazyBoolNo:
151       return false;
152     default:
153       return true;
154     }
155   }
156 
DefaultToNo(LazyBool flag)157   static bool DefaultToNo(LazyBool flag) {
158     switch (flag) {
159     case eLazyBoolYes:
160       return true;
161     default:
162       return false;
163     }
164   }
165 };
166 
167 class CommandInterpreter : public Broadcaster,
168                            public Properties,
169                            public IOHandlerDelegate {
170 public:
171   enum {
172     eBroadcastBitThreadShouldExit = (1 << 0),
173     eBroadcastBitResetPrompt = (1 << 1),
174     eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit
175     eBroadcastBitAsynchronousOutputData = (1 << 3),
176     eBroadcastBitAsynchronousErrorData = (1 << 4)
177   };
178 
179   enum ChildrenTruncatedWarningStatus // tristate boolean to manage children
180                                       // truncation warning
181   { eNoTruncation = 0,                // never truncated
182     eUnwarnedTruncation = 1,          // truncated but did not notify
183     eWarnedTruncation = 2             // truncated and notified
184   };
185 
186   enum CommandTypes {
187     eCommandTypesBuiltin = 0x0001, // native commands such as "frame"
188     eCommandTypesUserDef = 0x0002, // scripted commands
189     eCommandTypesAliases = 0x0004, // aliases such as "po"
190     eCommandTypesHidden = 0x0008,  // commands prefixed with an underscore
191     eCommandTypesAllThem = 0xFFFF  // all commands
192   };
193 
194   CommandInterpreter(Debugger &debugger, lldb::ScriptLanguage script_language,
195                      bool synchronous_execution);
196 
197   ~CommandInterpreter() override;
198 
199   // These two functions fill out the Broadcaster interface:
200 
201   static ConstString &GetStaticBroadcasterClass();
202 
GetBroadcasterClass()203   ConstString &GetBroadcasterClass() const override {
204     return GetStaticBroadcasterClass();
205   }
206 
207   void SourceInitFile(bool in_cwd, CommandReturnObject &result);
208 
209   bool AddCommand(llvm::StringRef name, const lldb::CommandObjectSP &cmd_sp,
210                   bool can_replace);
211 
212   bool AddUserCommand(llvm::StringRef name, const lldb::CommandObjectSP &cmd_sp,
213                       bool can_replace);
214 
215   lldb::CommandObjectSP GetCommandSPExact(llvm::StringRef cmd,
216                                           bool include_aliases) const;
217 
218   CommandObject *GetCommandObject(llvm::StringRef cmd,
219                                   StringList *matches = nullptr,
220                                   StringList *descriptions = nullptr) const;
221 
222   bool CommandExists(llvm::StringRef cmd) const;
223 
224   bool AliasExists(llvm::StringRef cmd) const;
225 
226   bool UserCommandExists(llvm::StringRef cmd) const;
227 
228   CommandAlias *AddAlias(llvm::StringRef alias_name,
229                          lldb::CommandObjectSP &command_obj_sp,
230                          llvm::StringRef args_string = llvm::StringRef());
231 
232   // Remove a command if it is removable (python or regex command)
233   bool RemoveCommand(llvm::StringRef cmd);
234 
235   bool RemoveAlias(llvm::StringRef alias_name);
236 
237   bool GetAliasFullName(llvm::StringRef cmd, std::string &full_name) const;
238 
239   bool RemoveUser(llvm::StringRef alias_name);
240 
RemoveAllUser()241   void RemoveAllUser() { m_user_dict.clear(); }
242 
243   const CommandAlias *GetAlias(llvm::StringRef alias_name) const;
244 
245   CommandObject *BuildAliasResult(llvm::StringRef alias_name,
246                                   std::string &raw_input_string,
247                                   std::string &alias_result,
248                                   CommandReturnObject &result);
249 
250   bool HandleCommand(const char *command_line, LazyBool add_to_history,
251                      CommandReturnObject &result,
252                      ExecutionContext *override_context = nullptr,
253                      bool repeat_on_empty_command = true,
254                      bool no_context_switching = false);
255 
256   bool WasInterrupted() const;
257 
258   //------------------------------------------------------------------
259   /// Execute a list of commands in sequence.
260   ///
261   /// @param[in] commands
262   ///    The list of commands to execute.
263   /// @param[in,out] context
264   ///    The execution context in which to run the commands. Can be nullptr in
265   ///    which case the default
266   ///    context will be used.
267   /// @param[in] options
268   ///    This object holds the options used to control when to stop, whether to
269   ///    execute commands,
270   ///    etc.
271   /// @param[out] result
272   ///    This is marked as succeeding with no output if all commands execute
273   ///    safely,
274   ///    and failed with some explanation if we aborted executing the commands
275   ///    at some point.
276   //------------------------------------------------------------------
277   void HandleCommands(const StringList &commands, ExecutionContext *context,
278                       CommandInterpreterRunOptions &options,
279                       CommandReturnObject &result);
280 
281   //------------------------------------------------------------------
282   /// Execute a list of commands from a file.
283   ///
284   /// @param[in] file
285   ///    The file from which to read in commands.
286   /// @param[in,out] context
287   ///    The execution context in which to run the commands. Can be nullptr in
288   ///    which case the default
289   ///    context will be used.
290   /// @param[in] options
291   ///    This object holds the options used to control when to stop, whether to
292   ///    execute commands,
293   ///    etc.
294   /// @param[out] result
295   ///    This is marked as succeeding with no output if all commands execute
296   ///    safely,
297   ///    and failed with some explanation if we aborted executing the commands
298   ///    at some point.
299   //------------------------------------------------------------------
300   void HandleCommandsFromFile(FileSpec &file, ExecutionContext *context,
301                               CommandInterpreterRunOptions &options,
302                               CommandReturnObject &result);
303 
304   CommandObject *GetCommandObjectForCommand(llvm::StringRef &command_line);
305 
306   // This handles command line completion.  You are given a pointer to the
307   // command string buffer, to the current cursor, and to the end of the string
308   // (in case it is not NULL terminated). You also passed in an StringList
309   // object to fill with the returns. The first element of the array will be
310   // filled with the string that you would need to insert at the cursor point
311   // to complete the cursor point to the longest common matching prefix. If you
312   // want to limit the number of elements returned, set max_return_elements to
313   // the number of elements you want returned.  Otherwise set
314   // max_return_elements to -1. If you want to start some way into the match
315   // list, then set match_start_point to the desired start point. Returns: -1
316   // if the completion character should be inserted -2 if the entire command
317   // line should be deleted and replaced with matches.GetStringAtIndex(0)
318   // INT_MAX if the number of matches is > max_return_elements, but it is
319   // expensive to compute. Otherwise, returns the number of matches.
320   //
321   // FIXME: Only max_return_elements == -1 is supported at present.
322   int HandleCompletion(const char *current_line, const char *cursor,
323                        const char *last_char, int match_start_point,
324                        int max_return_elements, StringList &matches,
325                        StringList &descriptions);
326 
327   // This version just returns matches, and doesn't compute the substring.  It
328   // is here so the Help command can call it for the first argument. It uses
329   // a CompletionRequest for simplicity reasons.
330   int HandleCompletionMatches(CompletionRequest &request);
331 
332   int GetCommandNamesMatchingPartialString(const char *cmd_cstr,
333                                            bool include_aliases,
334                                            StringList &matches,
335                                            StringList &descriptions);
336 
337   void GetHelp(CommandReturnObject &result,
338                uint32_t types = eCommandTypesAllThem);
339 
340   void GetAliasHelp(const char *alias_name, StreamString &help_string);
341 
342   void OutputFormattedHelpText(Stream &strm, llvm::StringRef prefix,
343                                llvm::StringRef help_text);
344 
345   void OutputFormattedHelpText(Stream &stream, llvm::StringRef command_word,
346                                llvm::StringRef separator,
347                                llvm::StringRef help_text, size_t max_word_len);
348 
349   // this mimics OutputFormattedHelpText but it does perform a much simpler
350   // formatting, basically ensuring line alignment. This is only good if you
351   // have some complicated layout for your help text and want as little help as
352   // reasonable in properly displaying it. Most of the times, you simply want
353   // to type some text and have it printed in a reasonable way on screen. If
354   // so, use OutputFormattedHelpText
355   void OutputHelpText(Stream &stream, llvm::StringRef command_word,
356                       llvm::StringRef separator, llvm::StringRef help_text,
357                       uint32_t max_word_len);
358 
GetDebugger()359   Debugger &GetDebugger() { return m_debugger; }
360 
GetExecutionContext()361   ExecutionContext GetExecutionContext() {
362     const bool thread_and_frame_only_if_stopped = true;
363     return m_exe_ctx_ref.Lock(thread_and_frame_only_if_stopped);
364   }
365 
366   void UpdateExecutionContext(ExecutionContext *override_context);
367 
368   lldb::PlatformSP GetPlatform(bool prefer_target_platform);
369 
370   const char *ProcessEmbeddedScriptCommands(const char *arg);
371 
372   void UpdatePrompt(llvm::StringRef prompt);
373 
374   bool Confirm(llvm::StringRef message, bool default_answer);
375 
376   void LoadCommandDictionary();
377 
378   void Initialize();
379 
380   void Clear();
381 
382   void SetScriptLanguage(lldb::ScriptLanguage lang);
383 
384   bool HasCommands() const;
385 
386   bool HasAliases() const;
387 
388   bool HasUserCommands() const;
389 
390   bool HasAliasOptions() const;
391 
392   void BuildAliasCommandArgs(CommandObject *alias_cmd_obj,
393                              const char *alias_name, Args &cmd_args,
394                              std::string &raw_input_string,
395                              CommandReturnObject &result);
396 
397   int GetOptionArgumentPosition(const char *in_string);
398 
399   ScriptInterpreter *GetScriptInterpreter(bool can_create = true);
400 
401   void SetScriptInterpreter();
402 
SkipLLDBInitFiles(bool skip_lldbinit_files)403   void SkipLLDBInitFiles(bool skip_lldbinit_files) {
404     m_skip_lldbinit_files = skip_lldbinit_files;
405   }
406 
SkipAppInitFiles(bool skip_app_init_files)407   void SkipAppInitFiles(bool skip_app_init_files) {
408     m_skip_app_init_files = m_skip_lldbinit_files;
409   }
410 
411   bool GetSynchronous();
412 
413   void FindCommandsForApropos(llvm::StringRef word, StringList &commands_found,
414                               StringList &commands_help,
415                               bool search_builtin_commands,
416                               bool search_user_commands,
417                               bool search_alias_commands);
418 
GetBatchCommandMode()419   bool GetBatchCommandMode() { return m_batch_command_mode; }
420 
SetBatchCommandMode(bool value)421   bool SetBatchCommandMode(bool value) {
422     const bool old_value = m_batch_command_mode;
423     m_batch_command_mode = value;
424     return old_value;
425   }
426 
ChildrenTruncated()427   void ChildrenTruncated() {
428     if (m_truncation_warning == eNoTruncation)
429       m_truncation_warning = eUnwarnedTruncation;
430   }
431 
TruncationWarningNecessary()432   bool TruncationWarningNecessary() {
433     return (m_truncation_warning == eUnwarnedTruncation);
434   }
435 
TruncationWarningGiven()436   void TruncationWarningGiven() { m_truncation_warning = eWarnedTruncation; }
437 
TruncationWarningText()438   const char *TruncationWarningText() {
439     return "*** Some of your variables have more members than the debugger "
440            "will show by default. To show all of them, you can either use the "
441            "--show-all-children option to %s or raise the limit by changing "
442            "the target.max-children-count setting.\n";
443   }
444 
GetCommandHistory()445   const CommandHistory &GetCommandHistory() const { return m_command_history; }
446 
GetCommandHistory()447   CommandHistory &GetCommandHistory() { return m_command_history; }
448 
449   bool IsActive();
450 
451   void RunCommandInterpreter(bool auto_handle_events, bool spawn_thread,
452                              CommandInterpreterRunOptions &options);
453   void GetLLDBCommandsFromIOHandler(const char *prompt,
454                                     IOHandlerDelegate &delegate,
455                                     bool asynchronously, void *baton);
456 
457   void GetPythonCommandsFromIOHandler(const char *prompt,
458                                       IOHandlerDelegate &delegate,
459                                       bool asynchronously, void *baton);
460 
461   const char *GetCommandPrefix();
462 
463   //------------------------------------------------------------------
464   // Properties
465   //------------------------------------------------------------------
466   bool GetExpandRegexAliases() const;
467 
468   bool GetPromptOnQuit() const;
469 
470   void SetPromptOnQuit(bool b);
471 
472   bool GetEchoCommands() const;
473   void SetEchoCommands(bool b);
474 
475   bool GetEchoCommentCommands() const;
476   void SetEchoCommentCommands(bool b);
477 
478   //------------------------------------------------------------------
479   /// Specify if the command interpreter should allow that the user can
480   /// specify a custom exit code when calling 'quit'.
481   //------------------------------------------------------------------
482   void AllowExitCodeOnQuit(bool allow);
483 
484   //------------------------------------------------------------------
485   /// Sets the exit code for the quit command.
486   /// @param[in] exit_code
487   ///     The exit code that the driver should return on exit.
488   /// @return True if the exit code was successfully set; false if the
489   ///         interpreter doesn't allow custom exit codes.
490   /// @see AllowExitCodeOnQuit
491   //------------------------------------------------------------------
492   LLVM_NODISCARD bool SetQuitExitCode(int exit_code);
493 
494   //------------------------------------------------------------------
495   /// Returns the exit code that the user has specified when running the
496   /// 'quit' command.
497   /// @param[out] exited
498   ///     Set to true if the user has called quit with a custom exit code.
499   //------------------------------------------------------------------
500   int GetQuitExitCode(bool &exited) const;
501 
502   void ResolveCommand(const char *command_line, CommandReturnObject &result);
503 
504   bool GetStopCmdSourceOnError() const;
505 
GetNumErrors()506   uint32_t GetNumErrors() const { return m_num_errors; }
507 
GetQuitRequested()508   bool GetQuitRequested() const { return m_quit_requested; }
509 
510   lldb::IOHandlerSP
511   GetIOHandler(bool force_create = false,
512                CommandInterpreterRunOptions *options = nullptr);
513 
GetStoppedForCrash()514   bool GetStoppedForCrash() const { return m_stopped_for_crash; }
515 
516   bool GetSpaceReplPrompts() const;
517 
518 protected:
519   friend class Debugger;
520 
521   //------------------------------------------------------------------
522   // IOHandlerDelegate functions
523   //------------------------------------------------------------------
524   void IOHandlerInputComplete(IOHandler &io_handler,
525                               std::string &line) override;
526 
IOHandlerGetControlSequence(char ch)527   ConstString IOHandlerGetControlSequence(char ch) override {
528     if (ch == 'd')
529       return ConstString("quit\n");
530     return ConstString();
531   }
532 
533   bool IOHandlerInterrupt(IOHandler &io_handler) override;
534 
535   size_t GetProcessOutput();
536 
537   void SetSynchronous(bool value);
538 
539   lldb::CommandObjectSP GetCommandSP(llvm::StringRef cmd,
540                                      bool include_aliases = true,
541                                      bool exact = true,
542                                      StringList *matches = nullptr,
543                                      StringList *descriptions = nullptr) const;
544 
545 private:
546   Status PreprocessCommand(std::string &command);
547 
548   // Completely resolves aliases and abbreviations, returning a pointer to the
549   // final command object and updating command_line to the fully substituted
550   // and translated command.
551   CommandObject *ResolveCommandImpl(std::string &command_line,
552                                     CommandReturnObject &result);
553 
554   void FindCommandsForApropos(llvm::StringRef word, StringList &commands_found,
555                               StringList &commands_help,
556                               CommandObject::CommandMap &command_map);
557 
558   // An interruptible wrapper around the stream output
559   void PrintCommandOutput(Stream &stream, llvm::StringRef str);
560 
561   bool EchoCommandNonInteractive(llvm::StringRef line,
562                                  const Flags &io_handler_flags) const;
563 
564   // A very simple state machine which models the command handling transitions
565   enum class CommandHandlingState {
566     eIdle,
567     eInProgress,
568     eInterrupted,
569   };
570 
571   std::atomic<CommandHandlingState> m_command_state{
572       CommandHandlingState::eIdle};
573 
574   int m_iohandler_nesting_level = 0;
575 
576   void StartHandlingCommand();
577   void FinishHandlingCommand();
578   bool InterruptCommand();
579 
580   Debugger &m_debugger; // The debugger session that this interpreter is
581                         // associated with
582   ExecutionContextRef m_exe_ctx_ref; // The current execution context to use
583                                      // when handling commands
584   bool m_synchronous_execution;
585   bool m_skip_lldbinit_files;
586   bool m_skip_app_init_files;
587   CommandObject::CommandMap m_command_dict; // Stores basic built-in commands
588                                             // (they cannot be deleted, removed
589                                             // or overwritten).
590   CommandObject::CommandMap
591       m_alias_dict; // Stores user aliases/abbreviations for commands
592   CommandObject::CommandMap m_user_dict; // Stores user-defined commands
593   CommandHistory m_command_history;
594   std::string m_repeat_command; // Stores the command that will be executed for
595                                 // an empty command string.
596   lldb::ScriptInterpreterSP m_script_interpreter_sp;
597   std::recursive_mutex m_script_interpreter_mutex;
598   lldb::IOHandlerSP m_command_io_handler_sp;
599   char m_comment_char;
600   bool m_batch_command_mode;
601   ChildrenTruncatedWarningStatus m_truncation_warning; // Whether we truncated
602                                                        // children and whether
603                                                        // the user has been told
604   uint32_t m_command_source_depth;
605   std::vector<uint32_t> m_command_source_flags;
606   uint32_t m_num_errors;
607   bool m_quit_requested;
608   bool m_stopped_for_crash;
609 
610   // The exit code the user has requested when calling the 'quit' command.
611   // No value means the user hasn't set a custom exit code so far.
612   llvm::Optional<int> m_quit_exit_code;
613   // If the driver is accepts custom exit codes for the 'quit' command.
614   bool m_allow_exit_code = false;
615 };
616 
617 } // namespace lldb_private
618 
619 #endif // liblldb_CommandInterpreter_h_
620