SBDebugger.h revision b1087a27f7babc43f332c9d49ac4554892133a41
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 log_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 void 92 SaveInputTerminalState(); 93 94 void 95 RestoreInputTerminalState(); 96 97 lldb::SBCommandInterpreter 98 GetCommandInterpreter (); 99 100 void 101 HandleCommand (const char *command); 102 103 lldb::SBListener 104 GetListener (); 105 106 void 107 HandleProcessEvent (const lldb::SBProcess &process, 108 const lldb::SBEvent &event, 109 FILE *out, 110 FILE *err); 111 112 lldb::SBTarget 113 CreateTarget (const char *filename, 114 const char *target_triple, 115 const char *platform_name, 116 bool add_dependent_modules, 117 lldb::SBError& error); 118 119 lldb::SBTarget 120 CreateTargetWithFileAndTargetTriple (const char *filename, 121 const char *target_triple); 122 123 lldb::SBTarget 124 CreateTargetWithFileAndArch (const char *filename, 125 const char *archname); 126 127 lldb::SBTarget 128 CreateTarget (const char *filename); 129 130 // Return true if target is deleted from the target list of the debugger. 131 bool 132 DeleteTarget (lldb::SBTarget &target); 133 134 lldb::SBTarget 135 GetTargetAtIndex (uint32_t idx); 136 137 uint32_t 138 GetIndexOfTarget (lldb::SBTarget target); 139 140 lldb::SBTarget 141 FindTargetWithProcessID (pid_t pid); 142 143 lldb::SBTarget 144 FindTargetWithFileAndArch (const char *filename, 145 const char *arch); 146 147 uint32_t 148 GetNumTargets (); 149 150 lldb::SBTarget 151 GetSelectedTarget (); 152 153 void 154 SetSelectedTarget (SBTarget& target); 155 156 lldb::SBSourceManager 157 GetSourceManager (); 158 159 // REMOVE: just for a quick fix, need to expose platforms through 160 // SBPlatform from this class. 161 lldb::SBError 162 SetCurrentPlatform (const char *platform_name); 163 164 bool 165 SetCurrentPlatformSDKRoot (const char *sysroot); 166 167 // FIXME: Once we get the set show stuff in place, the driver won't need 168 // an interface to the Set/Get UseExternalEditor. 169 bool 170 SetUseExternalEditor (bool input); 171 172 bool 173 GetUseExternalEditor (); 174 175 static bool 176 GetDefaultArchitecture (char *arch_name, size_t arch_name_len); 177 178 static bool 179 SetDefaultArchitecture (const char *arch_name); 180 181 lldb::ScriptLanguage 182 GetScriptingLanguage (const char *script_language_name); 183 184 static const char * 185 GetVersionString (); 186 187 static const char * 188 StateAsCString (lldb::StateType state); 189 190 static bool 191 StateIsRunningState (lldb::StateType state); 192 193 static bool 194 StateIsStoppedState (lldb::StateType state); 195 196 bool 197 EnableLog (const char *channel, const char **categories); 198 199 void 200 SetLoggingCallback (lldb::LogOutputCallback log_callback, void *baton); 201 202 // DEPRECATED 203 void 204 DispatchInput (void* baton, 205 const void* data, 206 size_t data_len); 207 208 void 209 DispatchInput (const void *data, size_t data_len); 210 211 void 212 DispatchInputInterrupt (); 213 214 void 215 DispatchInputEndOfFile (); 216 217 void 218 PushInputReader (lldb::SBInputReader &reader); 219 220 void 221 NotifyTopInputReader (lldb::InputReaderAction notification); 222 223 bool 224 InputReaderIsTopReader (const lldb::SBInputReader &reader); 225 226 const char * 227 GetInstanceName (); 228 229 static SBDebugger 230 FindDebuggerWithID (int id); 231 232 static lldb::SBError 233 SetInternalVariable (const char *var_name, const char *value, const char *debugger_instance_name); 234 235 static lldb::SBStringList 236 GetInternalVariableValue (const char *var_name, const char *debugger_instance_name); 237 238 bool 239 GetDescription (lldb::SBStream &description); 240 241 uint32_t 242 GetTerminalWidth () const; 243 244 void 245 SetTerminalWidth (uint32_t term_width); 246 247 lldb::user_id_t 248 GetID (); 249 250 const char * 251 GetPrompt() const; 252 253 void 254 SetPrompt (const char *prompt); 255 256 lldb::ScriptLanguage 257 GetScriptLanguage() const; 258 259 void 260 SetScriptLanguage (lldb::ScriptLanguage script_lang); 261 262 bool 263 GetCloseInputOnEOF () const; 264 265 void 266 SetCloseInputOnEOF (bool b); 267 268 SBTypeCategory 269 GetCategory (const char* category_name); 270 271 SBTypeCategory 272 CreateCategory (const char* category_name); 273 274 bool 275 DeleteCategory (const char* category_name); 276 277 uint32_t 278 GetNumCategories (); 279 280 SBTypeCategory 281 GetCategoryAtIndex (uint32_t); 282 283 SBTypeCategory 284 GetDefaultCategory(); 285 286 SBTypeFormat 287 GetFormatForType (SBTypeNameSpecifier); 288 289#ifndef LLDB_DISABLE_PYTHON 290 SBTypeSummary 291 GetSummaryForType (SBTypeNameSpecifier); 292#endif 293 294 SBTypeFilter 295 GetFilterForType (SBTypeNameSpecifier); 296 297#ifndef LLDB_DISABLE_PYTHON 298 SBTypeSynthetic 299 GetSyntheticForType (SBTypeNameSpecifier); 300#endif 301 302private: 303 304 friend class SBCommandInterpreter; 305 friend class SBInputReader; 306 friend class SBListener; 307 friend class SBProcess; 308 friend class SBSourceManager; 309 friend class SBTarget; 310 311 lldb::SBTarget 312 FindTargetWithLLDBProcess (const lldb::ProcessSP &processSP); 313 314 void 315 reset (const lldb::DebuggerSP &debugger_sp); 316 317 lldb_private::Debugger * 318 get () const; 319 320 lldb_private::Debugger & 321 ref () const; 322 323 const lldb::DebuggerSP & 324 get_sp () const; 325 326 lldb::DebuggerSP m_opaque_sp; 327 328}; // class SBDebugger 329 330 331} // namespace lldb 332 333#endif // LLDB_SBDebugger_h_ 334