1 //===-- Driver.h ------------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef lldb_Driver_h_
11 #define lldb_Driver_h_
15 #include "lldb/API/SBBroadcaster.h"
16 #include "lldb/API/SBDebugger.h"
17 #include "lldb/API/SBDefines.h"
18 #include "lldb/API/SBError.h"
20 #include "llvm/Option/Arg.h"
21 #include "llvm/Option/ArgList.h"
22 #include "llvm/Option/Option.h"
28 class Driver : public lldb::SBBroadcaster {
30 typedef enum CommandPlacement {
31 eCommandPlacementBeforeFile,
32 eCommandPlacementAfterFile,
33 eCommandPlacementAfterCrash,
40 /// Runs the main loop.
42 /// @return The exit code that the process should return.
45 lldb::SBError ProcessArgs(const llvm::opt::InputArgList &args, bool &exiting);
47 const char *GetFilename() const;
49 const char *GetCrashLogFilename() const;
51 const char *GetArchName() const;
53 lldb::ScriptLanguage GetScriptLanguage() const;
55 void WriteCommandsForSourcing(CommandPlacement placement,
56 lldb::SBStream &strm);
58 bool GetDebugMode() const;
61 void AddLocalLLDBInit();
62 void AddInitialCommand(std::string command, CommandPlacement placement,
63 bool is_file, lldb::SBError &error);
65 struct InitialCmdEntry {
66 InitialCmdEntry(std::string contents, bool in_is_file,
67 bool is_cwd_lldbinit_file_read, bool in_quiet = false)
68 : contents(std::move(contents)), is_file(in_is_file),
69 source_quietly(in_quiet),
70 is_cwd_lldbinit_file_read(is_cwd_lldbinit_file_read) {}
76 /// Remember if this is reading the local lldbinit file so we can skip it
78 bool is_cwd_lldbinit_file_read;
81 std::vector<std::string> m_args;
83 lldb::ScriptLanguage m_script_lang = lldb::eScriptLanguageDefault;
84 lldb::LanguageType m_repl_lang = lldb::eLanguageTypeUnknown;
85 lldb::pid_t m_process_pid = LLDB_INVALID_PROCESS_ID;
87 std::string m_core_file;
88 std::string m_crash_log;
89 std::string m_repl_options;
90 std::string m_process_name;
92 std::vector<InitialCmdEntry> m_initial_commands;
93 std::vector<InitialCmdEntry> m_after_file_commands;
94 std::vector<InitialCmdEntry> m_after_crash_commands;
96 bool m_debug_mode = false;
97 bool m_source_quietly = false;
98 bool m_print_version = false;
99 bool m_print_python_path = false;
100 bool m_wait_for = false;
102 bool m_batch = false;
104 // FIXME: When we have set/show variables we can remove this from here.
105 bool m_use_external_editor = false;
107 using OptionSet = std::set<char>;
108 OptionSet m_seen_options;
111 lldb::SBDebugger &GetDebugger() { return m_debugger; }
113 void ResizeWindow(unsigned short col);
116 lldb::SBDebugger m_debugger;
117 OptionData m_option_data;
120 #endif // lldb_Driver_h_