SBDebugger.h revision df83db835a5e026a2270dcc334e848452208691d
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 log_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    uint32_t
132    GetIndexOfTarget (lldb::SBTarget target);
133
134    lldb::SBTarget
135    FindTargetWithProcessID (pid_t pid);
136
137    lldb::SBTarget
138    FindTargetWithFileAndArch (const char *filename,
139                               const char *arch);
140
141    uint32_t
142    GetNumTargets ();
143
144    lldb::SBTarget
145    GetSelectedTarget ();
146
147    void
148    SetSelectedTarget (SBTarget& target);
149
150    lldb::SBSourceManager
151    GetSourceManager ();
152
153    // REMOVE: just for a quick fix, need to expose platforms through
154    // SBPlatform from this class.
155    lldb::SBError
156    SetCurrentPlatform (const char *platform_name);
157
158    bool
159    SetCurrentPlatformSDKRoot (const char *sysroot);
160
161    // FIXME: Once we get the set show stuff in place, the driver won't need
162    // an interface to the Set/Get UseExternalEditor.
163    bool
164    SetUseExternalEditor (bool input);
165
166    bool
167    GetUseExternalEditor ();
168
169    static bool
170    GetDefaultArchitecture (char *arch_name, size_t arch_name_len);
171
172    static bool
173    SetDefaultArchitecture (const char *arch_name);
174
175    lldb::ScriptLanguage
176    GetScriptingLanguage (const char *script_language_name);
177
178    static const char *
179    GetVersionString ();
180
181    static const char *
182    StateAsCString (lldb::StateType state);
183
184    static bool
185    StateIsRunningState (lldb::StateType state);
186
187    static bool
188    StateIsStoppedState (lldb::StateType state);
189
190    bool
191    EnableLog (const char *channel, const char **categories);
192
193    void
194    SetLoggingCallback (lldb::LogOutputCallback log_callback, void *baton);
195
196    // DEPRECATED
197    void
198    DispatchInput (void* baton,
199                   const void* data,
200                   size_t data_len);
201
202    void
203    DispatchInput (const void *data, size_t data_len);
204
205    void
206    DispatchInputInterrupt ();
207
208    void
209    DispatchInputEndOfFile ();
210
211    void
212    PushInputReader (lldb::SBInputReader &reader);
213
214    void
215    NotifyTopInputReader (lldb::InputReaderAction notification);
216
217    bool
218    InputReaderIsTopReader (const lldb::SBInputReader &reader);
219
220    const char *
221    GetInstanceName  ();
222
223    static SBDebugger
224    FindDebuggerWithID (int id);
225
226    static lldb::SBError
227    SetInternalVariable (const char *var_name, const char *value, const char *debugger_instance_name);
228
229    static lldb::SBStringList
230    GetInternalVariableValue (const char *var_name, const char *debugger_instance_name);
231
232    bool
233    GetDescription (lldb::SBStream &description);
234
235    uint32_t
236    GetTerminalWidth () const;
237
238    void
239    SetTerminalWidth (uint32_t term_width);
240
241    lldb::user_id_t
242    GetID ();
243
244    const char *
245    GetPrompt() const;
246
247    void
248    SetPrompt (const char *prompt);
249
250    lldb::ScriptLanguage
251    GetScriptLanguage() const;
252
253    void
254    SetScriptLanguage (lldb::ScriptLanguage script_lang);
255
256    bool
257    GetCloseInputOnEOF () const;
258
259    void
260    SetCloseInputOnEOF (bool b);
261
262    SBTypeCategory
263    GetCategory (const char* category_name);
264
265    SBTypeCategory
266    CreateCategory (const char* category_name);
267
268    bool
269    DeleteCategory (const char* category_name);
270
271    uint32_t
272    GetNumCategories ();
273
274    SBTypeCategory
275    GetCategoryAtIndex (uint32_t);
276
277    SBTypeCategory
278    GetDefaultCategory();
279
280    SBTypeFormat
281    GetFormatForType (SBTypeNameSpecifier);
282
283#ifndef LLDB_DISABLE_PYTHON
284    SBTypeSummary
285    GetSummaryForType (SBTypeNameSpecifier);
286#endif
287
288    SBTypeFilter
289    GetFilterForType (SBTypeNameSpecifier);
290
291#ifndef LLDB_DISABLE_PYTHON
292    SBTypeSynthetic
293    GetSyntheticForType (SBTypeNameSpecifier);
294#endif
295
296private:
297
298    friend class SBInputReader;
299    friend class SBProcess;
300    friend class SBSourceManager;
301    friend class SBTarget;
302    friend class SBListener;
303
304    lldb::SBTarget
305    FindTargetWithLLDBProcess (const lldb::ProcessSP &processSP);
306
307    void
308    reset (const lldb::DebuggerSP &debugger_sp);
309
310    lldb_private::Debugger *
311    get () const;
312
313    lldb_private::Debugger &
314    ref () const;
315
316    const lldb::DebuggerSP &
317    get_sp () const;
318
319    lldb::DebuggerSP m_opaque_sp;
320
321}; // class SBDebugger
322
323
324} // namespace lldb
325
326#endif // LLDB_SBDebugger_h_
327