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