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