File indexing completed on 2026-05-10 08:42:41
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLDB_API_SBDEBUGGER_H
0010 #define LLDB_API_SBDEBUGGER_H
0011
0012 #include <cstdio>
0013
0014 #include "lldb/API/SBDefines.h"
0015 #include "lldb/API/SBPlatform.h"
0016
0017 namespace lldb_private {
0018 class CommandPluginInterfaceImplementation;
0019 namespace python {
0020 class SWIGBridge;
0021 }
0022 }
0023
0024 namespace lldb {
0025
0026 #ifndef SWIG
0027 class LLDB_API SBInputReader {
0028 public:
0029 SBInputReader() = default;
0030 ~SBInputReader() = default;
0031
0032 SBError Initialize(lldb::SBDebugger &sb_debugger,
0033 unsigned long (*callback)(void *, lldb::SBInputReader *,
0034 lldb::InputReaderAction,
0035 char const *, unsigned long),
0036 void *a, lldb::InputReaderGranularity b, char const *c,
0037 char const *d, bool e);
0038 void SetIsDone(bool);
0039 bool IsActive() const;
0040 };
0041 #endif
0042
0043 class LLDB_API SBDebugger {
0044 public:
0045 FLAGS_ANONYMOUS_ENUM() {
0046 eBroadcastBitProgress = lldb::DebuggerBroadcastBit::eBroadcastBitProgress,
0047 eBroadcastBitWarning = lldb::DebuggerBroadcastBit::eBroadcastBitWarning,
0048 eBroadcastBitError = lldb::DebuggerBroadcastBit::eBroadcastBitError,
0049 eBroadcastBitProgressCategory =
0050 lldb::DebuggerBroadcastBit::eBroadcastBitProgressCategory,
0051 eBroadcastBitExternalProgress =
0052 lldb::DebuggerBroadcastBit::eBroadcastBitExternalProgress,
0053 eBroadcastBitExternalProgressCategory =
0054 lldb::DebuggerBroadcastBit::eBroadcastBitExternalProgressCategory,
0055 };
0056 SBDebugger();
0057
0058 SBDebugger(const lldb::SBDebugger &rhs);
0059
0060 ~SBDebugger();
0061
0062 static const char *GetBroadcasterClass();
0063
0064 static bool SupportsLanguage(lldb::LanguageType language);
0065
0066 lldb::SBBroadcaster GetBroadcaster();
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095 #ifdef SWIG
0096 static const char *GetProgressFromEvent(const lldb::SBEvent &event,
0097 uint64_t &OUTPUT,
0098 uint64_t &OUTPUT, uint64_t &OUTPUT,
0099 bool &OUTPUT);
0100 #else
0101 static const char *GetProgressFromEvent(const lldb::SBEvent &event,
0102 uint64_t &progress_id,
0103 uint64_t &completed, uint64_t &total,
0104 bool &is_debugger_specific);
0105 #endif
0106
0107 static lldb::SBStructuredData
0108 GetProgressDataFromEvent(const lldb::SBEvent &event);
0109
0110 static lldb::SBStructuredData
0111 GetDiagnosticFromEvent(const lldb::SBEvent &event);
0112
0113 lldb::SBDebugger &operator=(const lldb::SBDebugger &rhs);
0114
0115 static void Initialize();
0116
0117 static lldb::SBError InitializeWithErrorHandling();
0118
0119 static void PrintStackTraceOnError();
0120
0121 static void PrintDiagnosticsOnError();
0122
0123 static void Terminate();
0124
0125 LLDB_DEPRECATED_FIXME("Use one of the other Create variants", "Create(bool)")
0126 static lldb::SBDebugger Create();
0127
0128 static lldb::SBDebugger Create(bool source_init_files);
0129
0130 static lldb::SBDebugger Create(bool source_init_files,
0131 lldb::LogOutputCallback log_callback,
0132 void *baton);
0133
0134 static void Destroy(lldb::SBDebugger &debugger);
0135
0136 static void MemoryPressureDetected();
0137
0138 explicit operator bool() const;
0139
0140 bool IsValid() const;
0141
0142 void Clear();
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157 lldb::SBStructuredData GetSetting(const char *setting = nullptr);
0158
0159 void SetAsync(bool b);
0160
0161 bool GetAsync();
0162
0163 void SkipLLDBInitFiles(bool b);
0164
0165 void SkipAppInitFiles(bool b);
0166
0167 #ifndef SWIG
0168 void SetInputFileHandle(FILE *f, bool transfer_ownership);
0169
0170 void SetOutputFileHandle(FILE *f, bool transfer_ownership);
0171
0172 void SetErrorFileHandle(FILE *f, bool transfer_ownership);
0173 #endif
0174
0175 #ifndef SWIG
0176 FILE *GetInputFileHandle();
0177
0178 FILE *GetOutputFileHandle();
0179
0180 FILE *GetErrorFileHandle();
0181 #endif
0182
0183 SBError SetInputString(const char *data);
0184
0185 SBError SetInputFile(SBFile file);
0186
0187 SBError SetOutputFile(SBFile file);
0188
0189 SBError SetErrorFile(SBFile file);
0190
0191 SBError SetInputFile(FileSP file);
0192
0193 SBError SetOutputFile(FileSP file);
0194
0195 SBError SetErrorFile(FileSP file);
0196
0197 SBFile GetInputFile();
0198
0199 SBFile GetOutputFile();
0200
0201 SBFile GetErrorFile();
0202
0203 void SaveInputTerminalState();
0204
0205 void RestoreInputTerminalState();
0206
0207 lldb::SBCommandInterpreter GetCommandInterpreter();
0208
0209 void HandleCommand(const char *command);
0210
0211 void RequestInterrupt();
0212 void CancelInterruptRequest();
0213 bool InterruptRequested();
0214
0215 lldb::SBListener GetListener();
0216
0217 #ifndef SWIG
0218 LLDB_DEPRECATED_FIXME(
0219 "Use HandleProcessEvent(const SBProcess &, const SBEvent &, SBFile, "
0220 "SBFile) or HandleProcessEvent(const SBProcess &, const SBEvent &, "
0221 "FileSP, FileSP)",
0222 "HandleProcessEvent(const SBProcess &, const SBEvent &, SBFile, SBFile)")
0223 void HandleProcessEvent(const lldb::SBProcess &process,
0224 const lldb::SBEvent &event, FILE *out, FILE *err);
0225 #endif
0226
0227 void HandleProcessEvent(const lldb::SBProcess &process,
0228 const lldb::SBEvent &event, SBFile out, SBFile err);
0229
0230 #ifdef SWIG
0231 void HandleProcessEvent(const lldb::SBProcess &process,
0232 const lldb::SBEvent &event, FileSP BORROWED, FileSP BORROWED);
0233 #else
0234 void HandleProcessEvent(const lldb::SBProcess &process,
0235 const lldb::SBEvent &event, FileSP out, FileSP err);
0236 #endif
0237
0238 lldb::SBTarget CreateTarget(const char *filename, const char *target_triple,
0239 const char *platform_name,
0240 bool add_dependent_modules, lldb::SBError &error);
0241
0242 lldb::SBTarget CreateTargetWithFileAndTargetTriple(const char *filename,
0243 const char *target_triple);
0244
0245 lldb::SBTarget CreateTargetWithFileAndArch(const char *filename,
0246 const char *archname);
0247
0248 lldb::SBTarget CreateTarget(const char *filename);
0249
0250 lldb::SBTarget GetDummyTarget();
0251
0252
0253 bool DeleteTarget(lldb::SBTarget &target);
0254
0255 lldb::SBTarget GetTargetAtIndex(uint32_t idx);
0256
0257 uint32_t GetIndexOfTarget(lldb::SBTarget target);
0258
0259 lldb::SBTarget FindTargetWithProcessID(lldb::pid_t pid);
0260
0261 lldb::SBTarget FindTargetWithFileAndArch(const char *filename,
0262 const char *arch);
0263
0264 uint32_t GetNumTargets();
0265
0266 lldb::SBTarget GetSelectedTarget();
0267
0268 void SetSelectedTarget(SBTarget &target);
0269
0270 lldb::SBPlatform GetSelectedPlatform();
0271
0272 void SetSelectedPlatform(lldb::SBPlatform &platform);
0273
0274
0275 uint32_t GetNumPlatforms();
0276
0277
0278 lldb::SBPlatform GetPlatformAtIndex(uint32_t idx);
0279
0280
0281
0282
0283
0284 uint32_t GetNumAvailablePlatforms();
0285
0286
0287
0288
0289
0290
0291 lldb::SBStructuredData GetAvailablePlatformInfoAtIndex(uint32_t idx);
0292
0293 lldb::SBSourceManager GetSourceManager();
0294
0295
0296
0297 lldb::SBError SetCurrentPlatform(const char *platform_name);
0298
0299 bool SetCurrentPlatformSDKRoot(const char *sysroot);
0300
0301
0302
0303 bool SetUseExternalEditor(bool input);
0304
0305 bool GetUseExternalEditor();
0306
0307 bool SetUseColor(bool use_color);
0308
0309 bool GetUseColor() const;
0310
0311 bool SetShowInlineDiagnostics(bool);
0312
0313 bool SetUseSourceCache(bool use_source_cache);
0314
0315 bool GetUseSourceCache() const;
0316
0317 static bool GetDefaultArchitecture(char *arch_name, size_t arch_name_len);
0318
0319 static bool SetDefaultArchitecture(const char *arch_name);
0320
0321 lldb::ScriptLanguage GetScriptingLanguage(const char *script_language_name);
0322
0323 SBStructuredData GetScriptInterpreterInfo(ScriptLanguage);
0324
0325 static const char *GetVersionString();
0326
0327 static const char *StateAsCString(lldb::StateType state);
0328
0329 static SBStructuredData GetBuildConfiguration();
0330
0331 static bool StateIsRunningState(lldb::StateType state);
0332
0333 static bool StateIsStoppedState(lldb::StateType state);
0334
0335 bool EnableLog(const char *channel, const char **categories);
0336
0337 void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton);
0338
0339
0340 LLDB_DEPRECATED_FIXME("Use AddDestroyCallback and RemoveDestroyCallback",
0341 "AddDestroyCallback")
0342 void SetDestroyCallback(lldb::SBDebuggerDestroyCallback destroy_callback,
0343 void *baton);
0344
0345
0346
0347
0348 lldb::callback_token_t
0349 AddDestroyCallback(lldb::SBDebuggerDestroyCallback destroy_callback,
0350 void *baton);
0351
0352
0353 bool RemoveDestroyCallback(lldb::callback_token_t token);
0354
0355 #ifndef SWIG
0356 LLDB_DEPRECATED_FIXME("Use DispatchInput(const void *, size_t)",
0357 "DispatchInput(const void *, size_t)")
0358 void DispatchInput(void *baton, const void *data, size_t data_len);
0359 #endif
0360
0361 void DispatchInput(const void *data, size_t data_len);
0362
0363 void DispatchInputInterrupt();
0364
0365 void DispatchInputEndOfFile();
0366
0367 #ifndef SWIG
0368 void PushInputReader(lldb::SBInputReader &reader);
0369 #endif
0370
0371 const char *GetInstanceName();
0372
0373 static SBDebugger FindDebuggerWithID(int id);
0374
0375 static lldb::SBError SetInternalVariable(const char *var_name,
0376 const char *value,
0377 const char *debugger_instance_name);
0378
0379 static lldb::SBStringList
0380 GetInternalVariableValue(const char *var_name,
0381 const char *debugger_instance_name);
0382
0383 bool GetDescription(lldb::SBStream &description);
0384
0385 uint32_t GetTerminalWidth() const;
0386
0387 void SetTerminalWidth(uint32_t term_width);
0388
0389 uint32_t GetTerminalHeight() const;
0390
0391 void SetTerminalHeight(uint32_t term_height);
0392
0393 lldb::user_id_t GetID();
0394
0395 const char *GetPrompt() const;
0396
0397 void SetPrompt(const char *prompt);
0398
0399 const char *GetReproducerPath() const;
0400
0401 lldb::ScriptLanguage GetScriptLanguage() const;
0402
0403 void SetScriptLanguage(lldb::ScriptLanguage script_lang);
0404
0405 lldb::LanguageType GetREPLLanguage() const;
0406
0407 void SetREPLLanguage(lldb::LanguageType repl_lang);
0408
0409 LLDB_DEPRECATED("SBDebugger::GetCloseInputOnEOF() is deprecated.")
0410 bool GetCloseInputOnEOF() const;
0411
0412 LLDB_DEPRECATED("SBDebugger::SetCloseInputOnEOF() is deprecated.")
0413 void SetCloseInputOnEOF(bool b);
0414
0415 SBTypeCategory GetCategory(const char *category_name);
0416
0417 SBTypeCategory GetCategory(lldb::LanguageType lang_type);
0418
0419 SBTypeCategory CreateCategory(const char *category_name);
0420
0421 bool DeleteCategory(const char *category_name);
0422
0423 uint32_t GetNumCategories();
0424
0425 SBTypeCategory GetCategoryAtIndex(uint32_t);
0426
0427 SBTypeCategory GetDefaultCategory();
0428
0429 SBTypeFormat GetFormatForType(SBTypeNameSpecifier);
0430
0431 SBTypeSummary GetSummaryForType(SBTypeNameSpecifier);
0432
0433 SBTypeFilter GetFilterForType(SBTypeNameSpecifier);
0434
0435 SBTypeSynthetic GetSyntheticForType(SBTypeNameSpecifier);
0436
0437
0438
0439
0440 void ResetStatistics();
0441
0442 #ifndef SWIG
0443
0444
0445
0446
0447
0448
0449
0450
0451
0452
0453
0454 void RunCommandInterpreter(bool auto_handle_events, bool spawn_thread);
0455 #endif
0456
0457
0458
0459
0460
0461
0462
0463
0464
0465
0466
0467
0468
0469
0470
0471
0472
0473
0474
0475
0476
0477
0478
0479
0480 #ifdef SWIG
0481 %apply int& INOUT { int& num_errors };
0482 %apply bool& INOUT { bool& quit_requested };
0483 %apply bool& INOUT { bool& stopped_for_crash };
0484 #endif
0485 void RunCommandInterpreter(bool auto_handle_events, bool spawn_thread,
0486 SBCommandInterpreterRunOptions &options,
0487 int &num_errors, bool &quit_requested,
0488 bool &stopped_for_crash);
0489
0490 #ifndef SWIG
0491 SBCommandInterpreterRunResult
0492 RunCommandInterpreter(const SBCommandInterpreterRunOptions &options);
0493 #endif
0494
0495 SBError RunREPL(lldb::LanguageType language, const char *repl_options);
0496
0497
0498
0499
0500
0501
0502
0503
0504
0505 SBTrace LoadTraceFromFile(SBError &error,
0506 const SBFileSpec &trace_description_file);
0507
0508 protected:
0509 friend class lldb_private::CommandPluginInterfaceImplementation;
0510 friend class lldb_private::python::SWIGBridge;
0511
0512 SBDebugger(const lldb::DebuggerSP &debugger_sp);
0513
0514 private:
0515 friend class SBCommandInterpreter;
0516 friend class SBInputReader;
0517 friend class SBListener;
0518 friend class SBProcess;
0519 friend class SBSourceManager;
0520 friend class SBStructuredData;
0521 friend class SBPlatform;
0522 friend class SBTarget;
0523 friend class SBTrace;
0524 friend class SBProgress;
0525
0526 lldb::SBTarget FindTargetWithLLDBProcess(const lldb::ProcessSP &processSP);
0527
0528 void reset(const lldb::DebuggerSP &debugger_sp);
0529
0530 lldb_private::Debugger *get() const;
0531
0532 lldb_private::Debugger &ref() const;
0533
0534 const lldb::DebuggerSP &get_sp() const;
0535
0536 lldb::DebuggerSP m_opaque_sp;
0537
0538 };
0539
0540 }
0541
0542 #endif