]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/tools/driver/Driver.h
Merge clang 7.0.1 and several follow-up changes
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / tools / driver / Driver.h
1 //===-- Driver.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 lldb_Driver_h_
11 #define lldb_Driver_h_
12
13 #include "Platform.h"
14 #include "lldb/Host/PseudoTerminal.h"
15
16 #include <bitset>
17 #include <set>
18 #include <string>
19 #include <vector>
20
21 #include "lldb/API/SBBroadcaster.h"
22 #include "lldb/API/SBDebugger.h"
23 #include "lldb/API/SBDefines.h"
24 #include "lldb/API/SBError.h"
25
26 class IOChannel;
27
28 class Driver : public lldb::SBBroadcaster {
29 public:
30   typedef enum CommandPlacement {
31     eCommandPlacementBeforeFile,
32     eCommandPlacementAfterFile,
33     eCommandPlacementAfterCrash,
34   } CommandPlacement;
35
36   Driver();
37
38   virtual ~Driver();
39
40   /// Runs the main loop.
41   ///
42   /// @return The exit code that the process should return.
43   int MainLoop();
44
45   lldb::SBError ParseArgs(int argc, const char *argv[], FILE *out_fh,
46                           bool &do_exit);
47
48   const char *GetFilename() const;
49
50   const char *GetCrashLogFilename() const;
51
52   const char *GetArchName() const;
53
54   lldb::ScriptLanguage GetScriptLanguage() const;
55
56   void WriteCommandsForSourcing(CommandPlacement placement,
57                                 lldb::SBStream &strm);
58
59   bool GetDebugMode() const;
60
61   class OptionData {
62   public:
63     OptionData();
64     ~OptionData();
65
66     void Clear();
67
68     void AddInitialCommand(const char *command, CommandPlacement placement,
69                            bool is_file, lldb::SBError &error);
70
71     // static OptionDefinition m_cmd_option_table[];
72
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) {}
79
80       std::string contents;
81       bool is_file;
82       bool is_cwd_lldbinit_file_read; // if this is reading ./.lldbinit - so we
83                                       // may skip if not permitted
84       bool source_quietly;
85     };
86
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;
94     bool m_debug_mode;
95     bool m_source_quietly;
96     bool m_print_version;
97     bool m_print_python_path;
98     bool m_print_help;
99     bool m_wait_for;
100     bool m_repl;
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.
107     bool m_batch;
108     typedef std::set<char> OptionSet;
109     OptionSet m_seen_options;
110   };
111
112   static lldb::SBError SetOptionValue(int option_idx, const char *option_arg,
113                                       Driver::OptionData &data);
114
115   lldb::SBDebugger &GetDebugger() { return m_debugger; }
116
117   void ResizeWindow(unsigned short col);
118
119 private:
120   lldb::SBDebugger m_debugger;
121   OptionData m_option_data;
122
123   void ResetOptionValues();
124
125   void ReadyForCommand();
126 };
127
128 #endif // lldb_Driver_h_