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