SBDebugger.h revision c48ca82920bd333c7ccb6ec0e579207add130296
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    // Deprecated, use the one that takes a source_init_files bool.
29    static lldb::SBDebugger
30    Create();
31
32    static lldb::SBDebugger
33    Create(bool source_init_files);
34
35    static lldb::SBDebugger
36    Create(bool source_init_files, lldb::LogOutputCallback callback, void *baton);
37
38    static void
39    Destroy (lldb::SBDebugger &debugger);
40
41    static void
42    MemoryPressureDetected ();
43
44    SBDebugger();
45
46    SBDebugger(const lldb::SBDebugger &rhs);
47
48    SBDebugger(const lldb::DebuggerSP &debugger_sp);
49
50    lldb::SBDebugger &
51    operator = (const lldb::SBDebugger &rhs);
52
53    ~SBDebugger();
54
55    bool
56    IsValid() const;
57
58    void
59    Clear ();
60
61    void
62    SetAsync (bool b);
63
64    bool
65    GetAsync ();
66
67    void
68    SkipLLDBInitFiles (bool b);
69
70    void
71    SkipAppInitFiles (bool b);
72
73    void
74    SetInputFileHandle (FILE *f, bool transfer_ownership);
75
76    void
77    SetOutputFileHandle (FILE *f, bool transfer_ownership);
78
79    void
80    SetErrorFileHandle (FILE *f, bool transfer_ownership);
81
82    FILE *
83    GetInputFileHandle ();
84
85    FILE *
86    GetOutputFileHandle ();
87
88    FILE *
89    GetErrorFileHandle ();
90
91    lldb::SBCommandInterpreter
92    GetCommandInterpreter ();
93
94    void
95    HandleCommand (const char *command);
96
97    lldb::SBListener
98    GetListener ();
99
100    void
101    HandleProcessEvent (const lldb::SBProcess &process,
102                        const lldb::SBEvent &event,
103                        FILE *out,
104                        FILE *err);
105
106    lldb::SBTarget
107    CreateTarget (const char *filename,
108                  const char *target_triple,
109                  const char *platform_name,
110                  bool add_dependent_modules,
111                  lldb::SBError& error);
112
113    lldb::SBTarget
114    CreateTargetWithFileAndTargetTriple (const char *filename,
115                                         const char *target_triple);
116
117    lldb::SBTarget
118    CreateTargetWithFileAndArch (const char *filename,
119                                 const char *archname);
120
121    lldb::SBTarget
122    CreateTarget (const char *filename);
123
124    // Return true if target is deleted from the target list of the debugger.
125    bool
126    DeleteTarget (lldb::SBTarget &target);
127
128    lldb::SBTarget
129    GetTargetAtIndex (uint32_t idx);
130
131    lldb::SBTarget
132    FindTargetWithProcessID (pid_t pid);
133
134    lldb::SBTarget
135    FindTargetWithFileAndArch (const char *filename,
136                               const char *arch);
137
138    uint32_t
139    GetNumTargets ();
140
141    lldb::SBTarget
142    GetSelectedTarget ();
143
144    void
145    SetSelectedTarget (SBTarget& target);
146
147    lldb::SBSourceManager
148    GetSourceManager ();
149
150    // REMOVE: just for a quick fix, need to expose platforms through
151    // SBPlatform from this class.
152    lldb::SBError
153    SetCurrentPlatform (const char *platform_name);
154
155    bool
156    SetCurrentPlatformSDKRoot (const char *sysroot);
157
158    // FIXME: Once we get the set show stuff in place, the driver won't need
159    // an interface to the Set/Get UseExternalEditor.
160    bool
161    SetUseExternalEditor (bool input);
162
163    bool
164    GetUseExternalEditor ();
165
166    static bool
167    GetDefaultArchitecture (char *arch_name, size_t arch_name_len);
168
169    static bool
170    SetDefaultArchitecture (const char *arch_name);
171
172    lldb::ScriptLanguage
173    GetScriptingLanguage (const char *script_language_name);
174
175    static const char *
176    GetVersionString ();
177
178    static const char *
179    StateAsCString (lldb::StateType state);
180
181    static bool
182    StateIsRunningState (lldb::StateType state);
183
184    static bool
185    StateIsStoppedState (lldb::StateType state);
186
187    bool
188    EnableLog (const char *channel, const char **categories);
189
190    void
191    DispatchInput (void *baton, const void *data, size_t data_len);
192
193    void
194    DispatchInputInterrupt ();
195
196    void
197    DispatchInputEndOfFile ();
198
199    void
200    PushInputReader (lldb::SBInputReader &reader);
201
202    void
203    NotifyTopInputReader (lldb::InputReaderAction notification);
204
205    bool
206    InputReaderIsTopReader (const lldb::SBInputReader &reader);
207
208    const char *
209    GetInstanceName  ();
210
211    static SBDebugger
212    FindDebuggerWithID (int id);
213
214    static lldb::SBError
215    SetInternalVariable (const char *var_name, const char *value, const char *debugger_instance_name);
216
217    static lldb::SBStringList
218    GetInternalVariableValue (const char *var_name, const char *debugger_instance_name);
219
220    bool
221    GetDescription (lldb::SBStream &description);
222
223    uint32_t
224    GetTerminalWidth () const;
225
226    void
227    SetTerminalWidth (uint32_t term_width);
228
229    lldb::user_id_t
230    GetID ();
231
232    const char *
233    GetPrompt() const;
234
235    void
236    SetPrompt (const char *prompt);
237
238    lldb::ScriptLanguage
239    GetScriptLanguage() const;
240
241    void
242    SetScriptLanguage (lldb::ScriptLanguage script_lang);
243
244    bool
245    GetCloseInputOnEOF () const;
246
247    void
248    SetCloseInputOnEOF (bool b);
249
250    SBTypeCategory
251    GetCategory (const char* category_name);
252
253    SBTypeCategory
254    CreateCategory (const char* category_name);
255
256    bool
257    DeleteCategory (const char* category_name);
258
259    uint32_t
260    GetNumCategories ();
261
262    SBTypeCategory
263    GetCategoryAtIndex (uint32_t);
264
265    SBTypeCategory
266    GetDefaultCategory();
267
268    SBTypeFormat
269    GetFormatForType (SBTypeNameSpecifier);
270
271#ifndef LLDB_DISABLE_PYTHON
272    SBTypeSummary
273    GetSummaryForType (SBTypeNameSpecifier);
274#endif
275
276    SBTypeFilter
277    GetFilterForType (SBTypeNameSpecifier);
278
279#ifndef LLDB_DISABLE_PYTHON
280    SBTypeSynthetic
281    GetSyntheticForType (SBTypeNameSpecifier);
282#endif
283
284private:
285
286    friend class SBInputReader;
287    friend class SBProcess;
288    friend class SBSourceManager;
289    friend class SBTarget;
290    friend class SBListener;
291
292    lldb::SBTarget
293    FindTargetWithLLDBProcess (const lldb::ProcessSP &processSP);
294
295    void
296    reset (const lldb::DebuggerSP &debugger_sp);
297
298    lldb_private::Debugger *
299    get () const;
300
301    lldb_private::Debugger &
302    ref () const;
303
304    const lldb::DebuggerSP &
305    get_sp () const;
306
307    lldb::DebuggerSP m_opaque_sp;
308
309}; // class SBDebugger
310
311
312} // namespace lldb
313
314#endif // LLDB_SBDebugger_h_
315