1 //===-- Driver.h ------------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_TOOLS_DRIVER_DRIVER_H
10 #define LLDB_TOOLS_DRIVER_DRIVER_H
14 #include "lldb/API/SBBroadcaster.h"
15 #include "lldb/API/SBDebugger.h"
16 #include "lldb/API/SBDefines.h"
17 #include "lldb/API/SBError.h"
19 #include "llvm/Option/Arg.h"
20 #include "llvm/Option/ArgList.h"
21 #include "llvm/Option/Option.h"
27 class Driver
: public lldb::SBBroadcaster
{
29 enum CommandPlacement
{
30 eCommandPlacementBeforeFile
,
31 eCommandPlacementAfterFile
,
32 eCommandPlacementAfterCrash
,
39 /// Runs the main loop.
41 /// \return The exit code that the process should return.
44 lldb::SBError
ProcessArgs(const llvm::opt::InputArgList
&args
, bool &exiting
);
46 void WriteCommandsForSourcing(CommandPlacement placement
,
47 lldb::SBStream
&strm
);
50 void AddInitialCommand(std::string command
, CommandPlacement placement
,
51 bool is_file
, lldb::SBError
&error
);
53 struct InitialCmdEntry
{
54 InitialCmdEntry(std::string contents
, bool in_is_file
,
55 bool in_quiet
= false)
56 : contents(std::move(contents
)), is_file(in_is_file
),
57 source_quietly(in_quiet
) {}
64 std::vector
<std::string
> m_args
;
66 lldb::LanguageType m_repl_lang
= lldb::eLanguageTypeUnknown
;
67 lldb::pid_t m_process_pid
= LLDB_INVALID_PROCESS_ID
;
69 std::string m_core_file
;
70 std::string m_crash_log
;
71 std::string m_repl_options
;
72 std::string m_process_name
;
74 std::vector
<InitialCmdEntry
> m_initial_commands
;
75 std::vector
<InitialCmdEntry
> m_after_file_commands
;
76 std::vector
<InitialCmdEntry
> m_after_crash_commands
;
78 bool m_source_quietly
= false;
79 bool m_print_version
= false;
80 bool m_print_python_path
= false;
81 bool m_print_script_interpreter_info
= false;
82 bool m_wait_for
= false;
86 // FIXME: When we have set/show variables we can remove this from here.
87 bool m_use_external_editor
= false;
89 using OptionSet
= std::set
<char>;
90 OptionSet m_seen_options
;
93 lldb::SBDebugger
&GetDebugger() { return m_debugger
; }
95 void ResizeWindow(unsigned short col
);
98 lldb::SBDebugger m_debugger
;
99 OptionData m_option_data
;
102 #endif // LLDB_TOOLS_DRIVER_DRIVER_H