LLDB API Documentation

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