SBDebugger.h revision 604f0d336f0d9390a0405022ef660ae922ef29bf
1//===-- SBDebugger.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_SBDebugger_h_
11#define LLDB_SBDebugger_h_
12
13#include "lldb/API/SBDefines.h"
14#include <stdio.h>
15
16namespace lldb {
17
18class SBDebugger
19{
20public:
21
22    static void
23    Initialize();
24
25    static void
26    Terminate();
27
28    static lldb::SBDebugger
29    Create();
30
31    static void
32    Destroy (lldb::SBDebugger &debugger);
33
34    SBDebugger();
35
36    SBDebugger(const lldb::SBDebugger &rhs);
37
38#ifndef SWIG
39    lldb::SBDebugger &
40    operator = (const lldb::SBDebugger &rhs);
41#endif
42
43    ~SBDebugger();
44
45    bool
46    IsValid() const;
47
48    void
49    Clear ();
50
51    void
52    SetAsync (bool b);
53
54    void
55    SkipLLDBInitFiles (bool b);
56
57    void
58    SetInputFileHandle (FILE *f, bool transfer_ownership);
59
60    void
61    SetOutputFileHandle (FILE *f, bool transfer_ownership);
62
63    void
64    SetErrorFileHandle (FILE *f, bool transfer_ownership);
65
66    FILE *
67    GetInputFileHandle ();
68
69    FILE *
70    GetOutputFileHandle ();
71
72    FILE *
73    GetErrorFileHandle ();
74
75    lldb::SBCommandInterpreter
76    GetCommandInterpreter ();
77
78    void
79    HandleCommand (const char *command);
80
81    lldb::SBListener
82    GetListener ();
83
84    void
85    HandleProcessEvent (const lldb::SBProcess &process,
86                        const lldb::SBEvent &event,
87                        FILE *out,
88                        FILE *err);
89
90    lldb::SBTarget
91    CreateTargetWithFileAndTargetTriple (const char *filename,
92                                         const char *target_triple);
93
94    lldb::SBTarget
95    CreateTargetWithFileAndArch (const char *filename,
96                                 const char *archname);
97
98    lldb::SBTarget
99    CreateTarget (const char *filename);
100
101    // Return true if target is deleted from the target list of the debugger.
102    bool
103    DeleteTarget (lldb::SBTarget &target);
104
105    lldb::SBTarget
106    GetTargetAtIndex (uint32_t idx);
107
108    lldb::SBTarget
109    FindTargetWithProcessID (pid_t pid);
110
111    lldb::SBTarget
112    FindTargetWithFileAndArch (const char *filename,
113                               const char *arch);
114
115    uint32_t
116    GetNumTargets ();
117
118    lldb::SBTarget
119    GetSelectedTarget ();
120
121    lldb::SBSourceManager &
122    GetSourceManager ();
123
124    // REMOVE: just for a quick fix, need to expose platforms through
125    // SBPlatform from this class.
126    lldb::SBError
127    SetCurrentPlatform (const char *platform_name);
128
129    bool
130    SetCurrentPlatformSDKRoot (const char *sysroot);
131
132    // FIXME: Once we get the set show stuff in place, the driver won't need
133    // an interface to the Set/Get UseExternalEditor.
134    bool
135    SetUseExternalEditor (bool input);
136
137    bool
138    GetUseExternalEditor ();
139
140    static bool
141    GetDefaultArchitecture (char *arch_name, size_t arch_name_len);
142
143    static bool
144    SetDefaultArchitecture (const char *arch_name);
145
146    lldb::ScriptLanguage
147    GetScriptingLanguage (const char *script_language_name);
148
149    static const char *
150    GetVersionString ();
151
152    static const char *
153    StateAsCString (lldb::StateType state);
154
155    static bool
156    StateIsRunningState (lldb::StateType state);
157
158    static bool
159    StateIsStoppedState (lldb::StateType state);
160
161    void
162    DispatchInput (void *baton, const void *data, size_t data_len);
163
164    void
165    DispatchInputInterrupt ();
166
167    void
168    DispatchInputEndOfFile ();
169
170    void
171    PushInputReader (lldb::SBInputReader &reader);
172
173    void
174    NotifyTopInputReader (lldb::InputReaderAction notification);
175
176    bool
177    InputReaderIsTopReader (const lldb::SBInputReader &reader);
178
179    const char *
180    GetInstanceName  ();
181
182    static SBDebugger
183    FindDebuggerWithID (int id);
184
185    static lldb::SBError
186    SetInternalVariable (const char *var_name, const char *value, const char *debugger_instance_name);
187
188    static lldb::SBStringList
189    GetInternalVariableValue (const char *var_name, const char *debugger_instance_name);
190
191    bool
192    GetDescription (lldb::SBStream &description);
193
194    uint32_t
195    GetTerminalWidth () const;
196
197    void
198    SetTerminalWidth (uint32_t term_width);
199
200    lldb::user_id_t
201    GetID ();
202
203    const char *
204    GetPrompt() const;
205
206    void
207    SetPrompt (const char *prompt);
208
209    lldb::ScriptLanguage
210    GetScriptLanguage() const;
211
212    void
213    SetScriptLanguage (lldb::ScriptLanguage script_lang);
214
215    bool
216    GetCloseInputOnEOF () const;
217
218    void
219    SetCloseInputOnEOF (bool b);
220
221private:
222
223#ifndef SWIG
224
225    friend class SBInputReader;
226    friend class SBProcess;
227    friend class SBTarget;
228
229    lldb::SBTarget
230    FindTargetWithLLDBProcess (const lldb::ProcessSP &processSP);
231
232    void
233    reset (const lldb::DebuggerSP &debugger_sp);
234
235    lldb_private::Debugger *
236    get () const;
237
238    lldb_private::Debugger &
239    ref () const;
240
241#endif
242
243    lldb::DebuggerSP m_opaque_sp;
244
245}; // class SBDebugger
246
247
248} // namespace lldb
249
250#endif // LLDB_SBDebugger_h_
251