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