1 //===-- SBDebugger.h --------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLDB_SBDebugger_h_
11 #define LLDB_SBDebugger_h_
15 #include "lldb/API/SBDefines.h"
16 #include "lldb/API/SBPlatform.h"
20 class LLDB_API SBInputReader {
22 SBInputReader() = default;
23 ~SBInputReader() = default;
25 SBError Initialize(lldb::SBDebugger &,
26 unsigned long (*)(void *, lldb::SBInputReader *,
27 lldb::InputReaderAction, char const *,
29 void *, lldb::InputReaderGranularity, char const *,
32 bool IsActive() const;
35 class LLDB_API SBDebugger {
39 SBDebugger(const lldb::SBDebugger &rhs);
41 SBDebugger(const lldb::DebuggerSP &debugger_sp);
45 lldb::SBDebugger &operator=(const lldb::SBDebugger &rhs);
47 static void Initialize();
49 static void Terminate();
51 // Deprecated, use the one that takes a source_init_files bool.
52 static lldb::SBDebugger Create();
54 static lldb::SBDebugger Create(bool source_init_files);
56 static lldb::SBDebugger Create(bool source_init_files,
57 lldb::LogOutputCallback log_callback,
60 static void Destroy(lldb::SBDebugger &debugger);
62 static void MemoryPressureDetected();
68 void SetAsync(bool b);
72 void SkipLLDBInitFiles(bool b);
74 void SkipAppInitFiles(bool b);
76 void SetInputFileHandle(FILE *f, bool transfer_ownership);
78 void SetOutputFileHandle(FILE *f, bool transfer_ownership);
80 void SetErrorFileHandle(FILE *f, bool transfer_ownership);
82 FILE *GetInputFileHandle();
84 FILE *GetOutputFileHandle();
86 FILE *GetErrorFileHandle();
88 void SaveInputTerminalState();
90 void RestoreInputTerminalState();
92 lldb::SBCommandInterpreter GetCommandInterpreter();
94 void HandleCommand(const char *command);
96 lldb::SBListener GetListener();
98 void HandleProcessEvent(const lldb::SBProcess &process,
99 const lldb::SBEvent &event, FILE *out, FILE *err);
101 lldb::SBTarget CreateTarget(const char *filename, const char *target_triple,
102 const char *platform_name,
103 bool add_dependent_modules, lldb::SBError &error);
105 lldb::SBTarget CreateTargetWithFileAndTargetTriple(const char *filename,
106 const char *target_triple);
108 lldb::SBTarget CreateTargetWithFileAndArch(const char *filename,
109 const char *archname);
111 lldb::SBTarget CreateTarget(const char *filename);
113 // Return true if target is deleted from the target list of the debugger.
114 bool DeleteTarget(lldb::SBTarget &target);
116 lldb::SBTarget GetTargetAtIndex(uint32_t idx);
118 uint32_t GetIndexOfTarget(lldb::SBTarget target);
120 lldb::SBTarget FindTargetWithProcessID(pid_t pid);
122 lldb::SBTarget FindTargetWithFileAndArch(const char *filename,
125 uint32_t GetNumTargets();
127 lldb::SBTarget GetSelectedTarget();
129 void SetSelectedTarget(SBTarget &target);
131 lldb::SBPlatform GetSelectedPlatform();
133 void SetSelectedPlatform(lldb::SBPlatform &platform);
135 lldb::SBSourceManager GetSourceManager();
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);
141 bool SetCurrentPlatformSDKRoot(const char *sysroot);
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);
147 bool GetUseExternalEditor();
149 bool SetUseColor(bool use_color);
151 bool GetUseColor() const;
153 static bool GetDefaultArchitecture(char *arch_name, size_t arch_name_len);
155 static bool SetDefaultArchitecture(const char *arch_name);
157 lldb::ScriptLanguage GetScriptingLanguage(const char *script_language_name);
159 static const char *GetVersionString();
161 static const char *StateAsCString(lldb::StateType state);
163 static bool StateIsRunningState(lldb::StateType state);
165 static bool StateIsStoppedState(lldb::StateType state);
167 bool EnableLog(const char *channel, const char **categories);
169 void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton);
172 void DispatchInput(void *baton, const void *data, size_t data_len);
174 void DispatchInput(const void *data, size_t data_len);
176 void DispatchInputInterrupt();
178 void DispatchInputEndOfFile();
180 void PushInputReader(lldb::SBInputReader &reader);
182 const char *GetInstanceName();
184 static SBDebugger FindDebuggerWithID(int id);
186 static lldb::SBError SetInternalVariable(const char *var_name,
188 const char *debugger_instance_name);
190 static lldb::SBStringList
191 GetInternalVariableValue(const char *var_name,
192 const char *debugger_instance_name);
194 bool GetDescription(lldb::SBStream &description);
196 uint32_t GetTerminalWidth() const;
198 void SetTerminalWidth(uint32_t term_width);
200 lldb::user_id_t GetID();
202 const char *GetPrompt() const;
204 void SetPrompt(const char *prompt);
206 lldb::ScriptLanguage GetScriptLanguage() const;
208 void SetScriptLanguage(lldb::ScriptLanguage script_lang);
210 bool GetCloseInputOnEOF() const;
212 void SetCloseInputOnEOF(bool b);
214 SBTypeCategory GetCategory(const char *category_name);
216 SBTypeCategory GetCategory(lldb::LanguageType lang_type);
218 SBTypeCategory CreateCategory(const char *category_name);
220 bool DeleteCategory(const char *category_name);
222 uint32_t GetNumCategories();
224 SBTypeCategory GetCategoryAtIndex(uint32_t);
226 SBTypeCategory GetDefaultCategory();
228 SBTypeFormat GetFormatForType(SBTypeNameSpecifier);
230 #ifndef LLDB_DISABLE_PYTHON
231 SBTypeSummary GetSummaryForType(SBTypeNameSpecifier);
234 SBTypeFilter GetFilterForType(SBTypeNameSpecifier);
236 #ifndef LLDB_DISABLE_PYTHON
237 SBTypeSynthetic GetSyntheticForType(SBTypeNameSpecifier);
240 void RunCommandInterpreter(bool auto_handle_events, bool spawn_thread);
242 void RunCommandInterpreter(bool auto_handle_events, bool spawn_thread,
243 SBCommandInterpreterRunOptions &options,
244 int &num_errors, bool &quit_requested,
245 bool &stopped_for_crash);
247 SBError RunREPL(lldb::LanguageType language, const char *repl_options);
250 friend class SBCommandInterpreter;
251 friend class SBInputReader;
252 friend class SBListener;
253 friend class SBProcess;
254 friend class SBSourceManager;
255 friend class SBTarget;
257 lldb::SBTarget FindTargetWithLLDBProcess(const lldb::ProcessSP &processSP);
259 void reset(const lldb::DebuggerSP &debugger_sp);
261 lldb_private::Debugger *get() const;
263 lldb_private::Debugger &ref() const;
265 const lldb::DebuggerSP &get_sp() const;
267 lldb::DebuggerSP m_opaque_sp;
269 }; // class SBDebugger
273 #endif // LLDB_SBDebugger_h_