Driver.h revision 269024
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#define ASYNC true
27#define NO_ASYNC false
28
29class IOChannel;
30
31class Driver : public lldb::SBBroadcaster
32{
33public:
34    Driver ();
35
36    virtual
37    ~Driver ();
38
39    void
40    MainLoop ();
41
42    lldb::SBError
43    ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &do_exit);
44
45    const char *
46    GetFilename() const;
47
48    const char *
49    GetCrashLogFilename() const;
50
51    const char *
52    GetArchName() const;
53
54    lldb::ScriptLanguage
55    GetScriptLanguage() const;
56
57    void
58    ExecuteInitialCommands (bool before_file);
59
60    bool
61    GetDebugMode() const;
62
63
64    class OptionData
65    {
66    public:
67        OptionData ();
68       ~OptionData ();
69
70        void
71        Clear();
72
73        void
74        AddInitialCommand (const char *command, bool before_file, bool is_file, lldb::SBError &error);
75
76        //static OptionDefinition m_cmd_option_table[];
77
78        std::vector<std::string> m_args;
79        lldb::ScriptLanguage m_script_lang;
80        std::string m_core_file;
81        std::string m_crash_log;
82        std::vector<std::pair<bool,std::string> > m_initial_commands;
83        std::vector<std::pair<bool,std::string> > m_after_file_commands;
84        bool m_debug_mode;
85        bool m_source_quietly;
86        bool m_print_version;
87        bool m_print_python_path;
88        bool m_print_help;
89        bool m_wait_for;
90        std::string m_process_name;
91        lldb::pid_t m_process_pid;
92        bool m_use_external_editor;  // FIXME: When we have set/show variables we can remove this from here.
93        typedef std::set<char> OptionSet;
94        OptionSet m_seen_options;
95    };
96
97
98    static lldb::SBError
99    SetOptionValue (int option_idx,
100                    const char *option_arg,
101                    Driver::OptionData &data);
102
103
104    lldb::SBDebugger &
105    GetDebugger()
106    {
107        return m_debugger;
108    }
109
110    void
111    ResizeWindow (unsigned short col);
112
113private:
114    lldb::SBDebugger m_debugger;
115    OptionData m_option_data;
116
117    void
118    ResetOptionValues ();
119
120    void
121    ReadyForCommand ();
122};
123
124#endif // lldb_Driver_h_
125