]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tools/driver/Driver.h
Vendor import of (stripped) lldb trunk r242221:
[FreeBSD/FreeBSD.git] / 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/Utility/PseudoTerminal.h"
15
16 #include <set>
17 #include <bitset>
18 #include <string>
19 #include <vector>
20
21 #include "lldb/API/SBDefines.h"
22 #include "lldb/API/SBBroadcaster.h"
23 #include "lldb/API/SBDebugger.h"
24 #include "lldb/API/SBError.h"
25
26 class IOChannel;
27
28 class Driver : public lldb::SBBroadcaster
29 {
30 public:
31     typedef enum CommandPlacement
32     {
33         eCommandPlacementBeforeFile,
34         eCommandPlacementAfterFile,
35         eCommandPlacementAfterCrash,
36     } CommandPlacement;
37
38     Driver ();
39
40     virtual
41     ~Driver ();
42
43     void
44     MainLoop ();
45
46     lldb::SBError
47     ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &do_exit);
48
49     const char *
50     GetFilename() const;
51
52     const char *
53     GetCrashLogFilename() const;
54
55     const char *
56     GetArchName() const;
57
58     lldb::ScriptLanguage
59     GetScriptLanguage() const;
60
61     void
62     WriteCommandsForSourcing (CommandPlacement placement, lldb::SBStream &strm);
63     
64     bool
65     GetDebugMode() const;
66
67
68     class OptionData
69     {
70     public:
71         OptionData ();
72        ~OptionData ();
73
74         void
75         Clear();
76
77         void
78         AddInitialCommand (const char *command, CommandPlacement placement, bool is_file, lldb::SBError &error);
79     
80         //static OptionDefinition m_cmd_option_table[];
81
82         struct InitialCmdEntry
83         {
84             InitialCmdEntry (const char *in_contents, bool in_is_file, bool in_quiet = false) :
85                 contents (in_contents),
86                 is_file  (in_is_file),
87                 source_quietly(in_quiet)
88             {}
89
90             std::string contents;
91             bool        is_file;
92             bool        source_quietly;
93         };
94
95         std::vector<std::string> m_args;
96         lldb::ScriptLanguage m_script_lang;
97         std::string m_core_file;
98         std::string m_crash_log;
99         std::vector<InitialCmdEntry> m_initial_commands;
100         std::vector<InitialCmdEntry> m_after_file_commands;
101         std::vector<InitialCmdEntry> m_after_crash_commands;
102         bool m_debug_mode;
103         bool m_source_quietly;
104         bool m_print_version;
105         bool m_print_python_path;
106         bool m_print_help;
107         bool m_wait_for;
108         std::string m_process_name;
109         lldb::pid_t m_process_pid;
110         bool m_use_external_editor;  // FIXME: When we have set/show variables we can remove this from here.
111         bool m_batch;
112         typedef std::set<char> OptionSet;
113         OptionSet m_seen_options;
114     };
115
116
117     static lldb::SBError
118     SetOptionValue (int option_idx,
119                     const char *option_arg,
120                     Driver::OptionData &data);
121
122
123     lldb::SBDebugger &
124     GetDebugger()
125     {
126         return m_debugger;
127     }
128     
129     void
130     ResizeWindow (unsigned short col);
131
132 private:
133     lldb::SBDebugger m_debugger;
134     OptionData m_option_data;
135
136     void
137     ResetOptionValues ();
138
139     void
140     ReadyForCommand ();
141 };
142
143 #endif // lldb_Driver_h_