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_
14 #include "lldb/Host/PseudoTerminal.h"
21 #include "lldb/API/SBBroadcaster.h"
22 #include "lldb/API/SBDebugger.h"
23 #include "lldb/API/SBDefines.h"
24 #include "lldb/API/SBError.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 ParseArgs(int argc, const char *argv[], FILE *out_fh,
48 const char *GetFilename() const;
50 const char *GetCrashLogFilename() const;
52 const char *GetArchName() const;
54 lldb::ScriptLanguage GetScriptLanguage() const;
56 void WriteCommandsForSourcing(CommandPlacement placement,
57 lldb::SBStream &strm);
59 bool GetDebugMode() const;
68 void AddInitialCommand(const char *command, CommandPlacement placement,
69 bool is_file, lldb::SBError &error);
71 // static OptionDefinition m_cmd_option_table[];
73 struct InitialCmdEntry {
74 InitialCmdEntry(const char *in_contents, bool in_is_file,
75 bool is_cwd_lldbinit_file_read, bool in_quiet = false)
76 : contents(in_contents), is_file(in_is_file),
77 is_cwd_lldbinit_file_read(is_cwd_lldbinit_file_read),
78 source_quietly(in_quiet) {}
82 bool is_cwd_lldbinit_file_read; // if this is reading ./.lldbinit - so we
83 // may skip if not permitted
87 std::vector<std::string> m_args;
88 lldb::ScriptLanguage m_script_lang;
89 std::string m_core_file;
90 std::string m_crash_log;
91 std::vector<InitialCmdEntry> m_initial_commands;
92 std::vector<InitialCmdEntry> m_after_file_commands;
93 std::vector<InitialCmdEntry> m_after_crash_commands;
95 bool m_source_quietly;
97 bool m_print_python_path;
101 lldb::LanguageType m_repl_lang;
102 std::string m_repl_options;
103 std::string m_process_name;
104 lldb::pid_t m_process_pid;
105 bool m_use_external_editor; // FIXME: When we have set/show variables we can
106 // remove this from here.
108 typedef std::set<char> OptionSet;
109 OptionSet m_seen_options;
112 static lldb::SBError SetOptionValue(int option_idx, const char *option_arg,
113 Driver::OptionData &data);
115 lldb::SBDebugger &GetDebugger() { return m_debugger; }
117 void ResizeWindow(unsigned short col);
120 lldb::SBDebugger m_debugger;
121 OptionData m_option_data;
123 void ResetOptionValues();
125 void ReadyForCommand();
128 #endif // lldb_Driver_h_