1 //===-- SBDebugger.cpp ------------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "SBReproducerPrivate.h" 10 #include "SystemInitializerFull.h" 11 12 #include "lldb/API/SBDebugger.h" 13 14 #include "lldb/lldb-private.h" 15 16 #include "lldb/API/SBBroadcaster.h" 17 #include "lldb/API/SBCommandInterpreter.h" 18 #include "lldb/API/SBCommandReturnObject.h" 19 #include "lldb/API/SBError.h" 20 #include "lldb/API/SBEvent.h" 21 #include "lldb/API/SBFrame.h" 22 #include "lldb/API/SBListener.h" 23 #include "lldb/API/SBProcess.h" 24 #include "lldb/API/SBSourceManager.h" 25 #include "lldb/API/SBStream.h" 26 #include "lldb/API/SBStringList.h" 27 #include "lldb/API/SBStructuredData.h" 28 #include "lldb/API/SBTarget.h" 29 #include "lldb/API/SBThread.h" 30 #include "lldb/API/SBTypeCategory.h" 31 #include "lldb/API/SBTypeFilter.h" 32 #include "lldb/API/SBTypeFormat.h" 33 #include "lldb/API/SBTypeNameSpecifier.h" 34 #include "lldb/API/SBTypeSummary.h" 35 #include "lldb/API/SBTypeSynthetic.h" 36 37 #include "lldb/Core/Debugger.h" 38 #include "lldb/Core/PluginManager.h" 39 #include "lldb/Core/StreamFile.h" 40 #include "lldb/Core/StructuredDataImpl.h" 41 #include "lldb/DataFormatters/DataVisualization.h" 42 #include "lldb/Host/XML.h" 43 #include "lldb/Initialization/SystemLifetimeManager.h" 44 #include "lldb/Interpreter/CommandInterpreter.h" 45 #include "lldb/Interpreter/OptionArgParser.h" 46 #include "lldb/Interpreter/OptionGroupPlatform.h" 47 #include "lldb/Target/Process.h" 48 #include "lldb/Target/TargetList.h" 49 #include "lldb/Utility/Args.h" 50 #include "lldb/Utility/State.h" 51 52 #include "llvm/ADT/STLExtras.h" 53 #include "llvm/ADT/StringRef.h" 54 #include "llvm/Support/DynamicLibrary.h" 55 #include "llvm/Support/ManagedStatic.h" 56 57 using namespace lldb; 58 using namespace lldb_private; 59 60 static llvm::sys::DynamicLibrary LoadPlugin(const lldb::DebuggerSP &debugger_sp, 61 const FileSpec &spec, 62 Status &error) { 63 llvm::sys::DynamicLibrary dynlib = 64 llvm::sys::DynamicLibrary::getPermanentLibrary(spec.GetPath().c_str()); 65 if (dynlib.isValid()) { 66 typedef bool (*LLDBCommandPluginInit)(lldb::SBDebugger & debugger); 67 68 lldb::SBDebugger debugger_sb(debugger_sp); 69 // This calls the bool lldb::PluginInitialize(lldb::SBDebugger debugger) 70 // function. 71 // TODO: mangle this differently for your system - on OSX, the first 72 // underscore needs to be removed and the second one stays 73 LLDBCommandPluginInit init_func = 74 (LLDBCommandPluginInit)(uintptr_t)dynlib.getAddressOfSymbol( 75 "_ZN4lldb16PluginInitializeENS_10SBDebuggerE"); 76 if (init_func) { 77 if (init_func(debugger_sb)) 78 return dynlib; 79 else 80 error.SetErrorString("plug-in refused to load " 81 "(lldb::PluginInitialize(lldb::SBDebugger) " 82 "returned false)"); 83 } else { 84 error.SetErrorString("plug-in is missing the required initialization: " 85 "lldb::PluginInitialize(lldb::SBDebugger)"); 86 } 87 } else { 88 if (FileSystem::Instance().Exists(spec)) 89 error.SetErrorString("this file does not represent a loadable dylib"); 90 else 91 error.SetErrorString("no such file"); 92 } 93 return llvm::sys::DynamicLibrary(); 94 } 95 96 static llvm::ManagedStatic<SystemLifetimeManager> g_debugger_lifetime; 97 98 SBError SBInputReader::Initialize( 99 lldb::SBDebugger &sb_debugger, 100 unsigned long (*callback)(void *, lldb::SBInputReader *, 101 lldb::InputReaderAction, char const *, 102 unsigned long), 103 void *a, lldb::InputReaderGranularity b, char const *c, char const *d, 104 bool e) { 105 LLDB_RECORD_DUMMY( 106 lldb::SBError, SBInputReader, Initialize, 107 (lldb::SBDebugger &, 108 unsigned long (*)(void *, lldb::SBInputReader *, lldb::InputReaderAction, 109 const char *, unsigned long), 110 void *, lldb::InputReaderGranularity, const char *, const char *, bool), 111 sb_debugger, callback, a, b, c, d, e); 112 113 return SBError(); 114 } 115 116 void SBInputReader::SetIsDone(bool b) { 117 LLDB_RECORD_METHOD(void, SBInputReader, SetIsDone, (bool), b); 118 } 119 120 bool SBInputReader::IsActive() const { 121 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBInputReader, IsActive); 122 123 return false; 124 } 125 126 SBDebugger::SBDebugger() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBDebugger); } 127 128 SBDebugger::SBDebugger(const lldb::DebuggerSP &debugger_sp) 129 : m_opaque_sp(debugger_sp) { 130 LLDB_RECORD_CONSTRUCTOR(SBDebugger, (const lldb::DebuggerSP &), debugger_sp); 131 } 132 133 SBDebugger::SBDebugger(const SBDebugger &rhs) : m_opaque_sp(rhs.m_opaque_sp) { 134 LLDB_RECORD_CONSTRUCTOR(SBDebugger, (const lldb::SBDebugger &), rhs); 135 } 136 137 SBDebugger::~SBDebugger() = default; 138 139 SBDebugger &SBDebugger::operator=(const SBDebugger &rhs) { 140 LLDB_RECORD_METHOD(lldb::SBDebugger &, 141 SBDebugger, operator=,(const lldb::SBDebugger &), rhs); 142 143 if (this != &rhs) { 144 m_opaque_sp = rhs.m_opaque_sp; 145 } 146 return LLDB_RECORD_RESULT(*this); 147 } 148 149 void SBDebugger::Initialize() { 150 LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBDebugger, Initialize); 151 SBError ignored = SBDebugger::InitializeWithErrorHandling(); 152 } 153 154 lldb::SBError SBDebugger::InitializeWithErrorHandling() { 155 LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBError, SBDebugger, 156 InitializeWithErrorHandling); 157 158 SBError error; 159 if (auto e = g_debugger_lifetime->Initialize( 160 std::make_unique<SystemInitializerFull>(), LoadPlugin)) { 161 error.SetError(Status(std::move(e))); 162 } 163 return LLDB_RECORD_RESULT(error); 164 } 165 166 void SBDebugger::Terminate() { 167 LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBDebugger, Terminate); 168 169 g_debugger_lifetime->Terminate(); 170 } 171 172 void SBDebugger::Clear() { 173 LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, Clear); 174 175 if (m_opaque_sp) 176 m_opaque_sp->ClearIOHandlers(); 177 178 m_opaque_sp.reset(); 179 } 180 181 SBDebugger SBDebugger::Create() { 182 LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBDebugger, SBDebugger, Create); 183 184 return LLDB_RECORD_RESULT(SBDebugger::Create(false, nullptr, nullptr)); 185 } 186 187 SBDebugger SBDebugger::Create(bool source_init_files) { 188 LLDB_RECORD_STATIC_METHOD(lldb::SBDebugger, SBDebugger, Create, (bool), 189 source_init_files); 190 191 return LLDB_RECORD_RESULT( 192 SBDebugger::Create(source_init_files, nullptr, nullptr)); 193 } 194 195 SBDebugger SBDebugger::Create(bool source_init_files, 196 lldb::LogOutputCallback callback, void *baton) 197 198 { 199 LLDB_RECORD_DUMMY(lldb::SBDebugger, SBDebugger, Create, 200 (bool, lldb::LogOutputCallback, void *), source_init_files, 201 callback, baton); 202 203 SBDebugger debugger; 204 205 // Currently we have issues if this function is called simultaneously on two 206 // different threads. The issues mainly revolve around the fact that the 207 // lldb_private::FormatManager uses global collections and having two threads 208 // parsing the .lldbinit files can cause mayhem. So to get around this for 209 // now we need to use a mutex to prevent bad things from happening. 210 static std::recursive_mutex g_mutex; 211 std::lock_guard<std::recursive_mutex> guard(g_mutex); 212 213 debugger.reset(Debugger::CreateInstance(callback, baton)); 214 215 SBCommandInterpreter interp = debugger.GetCommandInterpreter(); 216 if (source_init_files) { 217 interp.get()->SkipLLDBInitFiles(false); 218 interp.get()->SkipAppInitFiles(false); 219 SBCommandReturnObject result; 220 interp.SourceInitFileInHomeDirectory(result); 221 } else { 222 interp.get()->SkipLLDBInitFiles(true); 223 interp.get()->SkipAppInitFiles(true); 224 } 225 return debugger; 226 } 227 228 void SBDebugger::Destroy(SBDebugger &debugger) { 229 LLDB_RECORD_STATIC_METHOD(void, SBDebugger, Destroy, (lldb::SBDebugger &), 230 debugger); 231 232 Debugger::Destroy(debugger.m_opaque_sp); 233 234 if (debugger.m_opaque_sp.get() != nullptr) 235 debugger.m_opaque_sp.reset(); 236 } 237 238 void SBDebugger::MemoryPressureDetected() { 239 LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBDebugger, MemoryPressureDetected); 240 241 // Since this function can be call asynchronously, we allow it to be non- 242 // mandatory. We have seen deadlocks with this function when called so we 243 // need to safeguard against this until we can determine what is causing the 244 // deadlocks. 245 246 const bool mandatory = false; 247 248 ModuleList::RemoveOrphanSharedModules(mandatory); 249 } 250 251 bool SBDebugger::IsValid() const { 252 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, IsValid); 253 return this->operator bool(); 254 } 255 SBDebugger::operator bool() const { 256 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, operator bool); 257 258 return m_opaque_sp.get() != nullptr; 259 } 260 261 void SBDebugger::SetAsync(bool b) { 262 LLDB_RECORD_METHOD(void, SBDebugger, SetAsync, (bool), b); 263 264 if (m_opaque_sp) 265 m_opaque_sp->SetAsyncExecution(b); 266 } 267 268 bool SBDebugger::GetAsync() { 269 LLDB_RECORD_METHOD_NO_ARGS(bool, SBDebugger, GetAsync); 270 271 return (m_opaque_sp ? m_opaque_sp->GetAsyncExecution() : false); 272 } 273 274 void SBDebugger::SkipLLDBInitFiles(bool b) { 275 LLDB_RECORD_METHOD(void, SBDebugger, SkipLLDBInitFiles, (bool), b); 276 277 if (m_opaque_sp) 278 m_opaque_sp->GetCommandInterpreter().SkipLLDBInitFiles(b); 279 } 280 281 void SBDebugger::SkipAppInitFiles(bool b) { 282 LLDB_RECORD_METHOD(void, SBDebugger, SkipAppInitFiles, (bool), b); 283 284 if (m_opaque_sp) 285 m_opaque_sp->GetCommandInterpreter().SkipAppInitFiles(b); 286 } 287 288 // Shouldn't really be settable after initialization as this could cause lots 289 // of problems; don't want users trying to switch modes in the middle of a 290 // debugging session. 291 void SBDebugger::SetInputFileHandle(FILE *fh, bool transfer_ownership) { 292 LLDB_RECORD_METHOD(void, SBDebugger, SetInputFileHandle, (FILE *, bool), fh, 293 transfer_ownership); 294 295 if (!m_opaque_sp) 296 return; 297 298 repro::DataRecorder *recorder = nullptr; 299 if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator()) 300 recorder = g->GetOrCreate<repro::CommandProvider>().GetNewDataRecorder(); 301 302 static std::unique_ptr<repro::CommandLoader> loader = 303 repro::CommandLoader::Create(repro::Reproducer::Instance().GetLoader()); 304 if (loader) { 305 llvm::Optional<std::string> file = loader->GetNextFile(); 306 fh = file ? FileSystem::Instance().Fopen(file->c_str(), "r") : nullptr; 307 } 308 309 m_opaque_sp->SetInputFileHandle(fh, transfer_ownership, recorder); 310 } 311 312 void SBDebugger::SetOutputFileHandle(FILE *fh, bool transfer_ownership) { 313 LLDB_RECORD_METHOD(void, SBDebugger, SetOutputFileHandle, (FILE *, bool), fh, 314 transfer_ownership); 315 316 if (m_opaque_sp) 317 m_opaque_sp->SetOutputFileHandle(fh, transfer_ownership); 318 } 319 320 void SBDebugger::SetErrorFileHandle(FILE *fh, bool transfer_ownership) { 321 LLDB_RECORD_METHOD(void, SBDebugger, SetErrorFileHandle, (FILE *, bool), fh, 322 transfer_ownership); 323 324 if (m_opaque_sp) 325 m_opaque_sp->SetErrorFileHandle(fh, transfer_ownership); 326 } 327 328 FILE *SBDebugger::GetInputFileHandle() { 329 LLDB_RECORD_METHOD_NO_ARGS(FILE *, SBDebugger, GetInputFileHandle); 330 331 if (m_opaque_sp) { 332 StreamFileSP stream_file_sp(m_opaque_sp->GetInputFile()); 333 if (stream_file_sp) 334 return LLDB_RECORD_RESULT(stream_file_sp->GetFile().GetStream()); 335 } 336 return nullptr; 337 } 338 339 FILE *SBDebugger::GetOutputFileHandle() { 340 LLDB_RECORD_METHOD_NO_ARGS(FILE *, SBDebugger, GetOutputFileHandle); 341 342 if (m_opaque_sp) { 343 StreamFileSP stream_file_sp(m_opaque_sp->GetOutputFile()); 344 if (stream_file_sp) 345 return LLDB_RECORD_RESULT(stream_file_sp->GetFile().GetStream()); 346 } 347 return nullptr; 348 } 349 350 FILE *SBDebugger::GetErrorFileHandle() { 351 LLDB_RECORD_METHOD_NO_ARGS(FILE *, SBDebugger, GetErrorFileHandle); 352 353 if (m_opaque_sp) { 354 StreamFileSP stream_file_sp(m_opaque_sp->GetErrorFile()); 355 if (stream_file_sp) 356 return LLDB_RECORD_RESULT(stream_file_sp->GetFile().GetStream()); 357 } 358 return nullptr; 359 } 360 361 void SBDebugger::SaveInputTerminalState() { 362 LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, SaveInputTerminalState); 363 364 if (m_opaque_sp) 365 m_opaque_sp->SaveInputTerminalState(); 366 } 367 368 void SBDebugger::RestoreInputTerminalState() { 369 LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, RestoreInputTerminalState); 370 371 if (m_opaque_sp) 372 m_opaque_sp->RestoreInputTerminalState(); 373 } 374 SBCommandInterpreter SBDebugger::GetCommandInterpreter() { 375 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBCommandInterpreter, SBDebugger, 376 GetCommandInterpreter); 377 378 SBCommandInterpreter sb_interpreter; 379 if (m_opaque_sp) 380 sb_interpreter.reset(&m_opaque_sp->GetCommandInterpreter()); 381 382 return LLDB_RECORD_RESULT(sb_interpreter); 383 } 384 385 void SBDebugger::HandleCommand(const char *command) { 386 LLDB_RECORD_METHOD(void, SBDebugger, HandleCommand, (const char *), command); 387 388 if (m_opaque_sp) { 389 TargetSP target_sp(m_opaque_sp->GetSelectedTarget()); 390 std::unique_lock<std::recursive_mutex> lock; 391 if (target_sp) 392 lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex()); 393 394 SBCommandInterpreter sb_interpreter(GetCommandInterpreter()); 395 SBCommandReturnObject result; 396 397 sb_interpreter.HandleCommand(command, result, false); 398 399 if (GetErrorFileHandle() != nullptr) 400 result.PutError(GetErrorFileHandle()); 401 if (GetOutputFileHandle() != nullptr) 402 result.PutOutput(GetOutputFileHandle()); 403 404 if (!m_opaque_sp->GetAsyncExecution()) { 405 SBProcess process(GetCommandInterpreter().GetProcess()); 406 ProcessSP process_sp(process.GetSP()); 407 if (process_sp) { 408 EventSP event_sp; 409 ListenerSP lldb_listener_sp = m_opaque_sp->GetListener(); 410 while (lldb_listener_sp->GetEventForBroadcaster( 411 process_sp.get(), event_sp, std::chrono::seconds(0))) { 412 SBEvent event(event_sp); 413 HandleProcessEvent(process, event, GetOutputFileHandle(), 414 GetErrorFileHandle()); 415 } 416 } 417 } 418 } 419 } 420 421 SBListener SBDebugger::GetListener() { 422 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBListener, SBDebugger, GetListener); 423 424 SBListener sb_listener; 425 if (m_opaque_sp) 426 sb_listener.reset(m_opaque_sp->GetListener()); 427 428 return LLDB_RECORD_RESULT(sb_listener); 429 } 430 431 void SBDebugger::HandleProcessEvent(const SBProcess &process, 432 const SBEvent &event, FILE *out, 433 FILE *err) { 434 LLDB_RECORD_METHOD( 435 void, SBDebugger, HandleProcessEvent, 436 (const lldb::SBProcess &, const lldb::SBEvent &, FILE *, FILE *), process, 437 event, out, err); 438 439 if (!process.IsValid()) 440 return; 441 442 TargetSP target_sp(process.GetTarget().GetSP()); 443 if (!target_sp) 444 return; 445 446 const uint32_t event_type = event.GetType(); 447 char stdio_buffer[1024]; 448 size_t len; 449 450 std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); 451 452 if (event_type & 453 (Process::eBroadcastBitSTDOUT | Process::eBroadcastBitStateChanged)) { 454 // Drain stdout when we stop just in case we have any bytes 455 while ((len = process.GetSTDOUT(stdio_buffer, sizeof(stdio_buffer))) > 0) 456 if (out != nullptr) 457 ::fwrite(stdio_buffer, 1, len, out); 458 } 459 460 if (event_type & 461 (Process::eBroadcastBitSTDERR | Process::eBroadcastBitStateChanged)) { 462 // Drain stderr when we stop just in case we have any bytes 463 while ((len = process.GetSTDERR(stdio_buffer, sizeof(stdio_buffer))) > 0) 464 if (err != nullptr) 465 ::fwrite(stdio_buffer, 1, len, err); 466 } 467 468 if (event_type & Process::eBroadcastBitStateChanged) { 469 StateType event_state = SBProcess::GetStateFromEvent(event); 470 471 if (event_state == eStateInvalid) 472 return; 473 474 bool is_stopped = StateIsStoppedState(event_state); 475 if (!is_stopped) 476 process.ReportEventState(event, out); 477 } 478 } 479 480 SBSourceManager SBDebugger::GetSourceManager() { 481 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSourceManager, SBDebugger, 482 GetSourceManager); 483 484 SBSourceManager sb_source_manager(*this); 485 return LLDB_RECORD_RESULT(sb_source_manager); 486 } 487 488 bool SBDebugger::GetDefaultArchitecture(char *arch_name, size_t arch_name_len) { 489 LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, GetDefaultArchitecture, 490 (char *, size_t), "", arch_name_len); 491 492 if (arch_name && arch_name_len) { 493 ArchSpec default_arch = Target::GetDefaultArchitecture(); 494 495 if (default_arch.IsValid()) { 496 const std::string &triple_str = default_arch.GetTriple().str(); 497 if (!triple_str.empty()) 498 ::snprintf(arch_name, arch_name_len, "%s", triple_str.c_str()); 499 else 500 ::snprintf(arch_name, arch_name_len, "%s", 501 default_arch.GetArchitectureName()); 502 return true; 503 } 504 } 505 if (arch_name && arch_name_len) 506 arch_name[0] = '\0'; 507 return false; 508 } 509 510 bool SBDebugger::SetDefaultArchitecture(const char *arch_name) { 511 LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, SetDefaultArchitecture, 512 (const char *), arch_name); 513 514 if (arch_name) { 515 ArchSpec arch(arch_name); 516 if (arch.IsValid()) { 517 Target::SetDefaultArchitecture(arch); 518 return true; 519 } 520 } 521 return false; 522 } 523 524 ScriptLanguage 525 SBDebugger::GetScriptingLanguage(const char *script_language_name) { 526 LLDB_RECORD_METHOD(lldb::ScriptLanguage, SBDebugger, GetScriptingLanguage, 527 (const char *), script_language_name); 528 529 if (!script_language_name) 530 return eScriptLanguageDefault; 531 return OptionArgParser::ToScriptLanguage( 532 llvm::StringRef(script_language_name), eScriptLanguageDefault, nullptr); 533 } 534 535 const char *SBDebugger::GetVersionString() { 536 LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBDebugger, GetVersionString); 537 538 return lldb_private::GetVersion(); 539 } 540 541 const char *SBDebugger::StateAsCString(StateType state) { 542 LLDB_RECORD_STATIC_METHOD(const char *, SBDebugger, StateAsCString, 543 (lldb::StateType), state); 544 545 return lldb_private::StateAsCString(state); 546 } 547 548 static void AddBoolConfigEntry(StructuredData::Dictionary &dict, 549 llvm::StringRef name, bool value, 550 llvm::StringRef description) { 551 auto entry_up = std::make_unique<StructuredData::Dictionary>(); 552 entry_up->AddBooleanItem("value", value); 553 entry_up->AddStringItem("description", description); 554 dict.AddItem(name, std::move(entry_up)); 555 } 556 557 static void AddLLVMTargets(StructuredData::Dictionary &dict) { 558 auto array_up = std::make_unique<StructuredData::Array>(); 559 #define LLVM_TARGET(target) \ 560 array_up->AddItem(std::make_unique<StructuredData::String>(#target)); 561 #include "llvm/Config/Targets.def" 562 auto entry_up = std::make_unique<StructuredData::Dictionary>(); 563 entry_up->AddItem("value", std::move(array_up)); 564 entry_up->AddStringItem("description", "A list of configured LLVM targets."); 565 dict.AddItem("targets", std::move(entry_up)); 566 } 567 568 SBStructuredData SBDebugger::GetBuildConfiguration() { 569 LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBStructuredData, SBDebugger, 570 GetBuildConfiguration); 571 572 auto config_up = std::make_unique<StructuredData::Dictionary>(); 573 AddBoolConfigEntry( 574 *config_up, "xml", XMLDocument::XMLEnabled(), 575 "A boolean value that indicates if XML support is enabled in LLDB"); 576 bool have_curses = true; 577 #ifdef LLDB_DISABLE_CURSES 578 have_curses = false; 579 #endif 580 AddBoolConfigEntry( 581 *config_up, "curses", have_curses, 582 "A boolean value that indicates if curses support is enabled in LLDB"); 583 AddLLVMTargets(*config_up); 584 585 SBStructuredData data; 586 data.m_impl_up->SetObjectSP(std::move(config_up)); 587 return LLDB_RECORD_RESULT(data); 588 } 589 590 bool SBDebugger::StateIsRunningState(StateType state) { 591 LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, StateIsRunningState, 592 (lldb::StateType), state); 593 594 const bool result = lldb_private::StateIsRunningState(state); 595 596 return result; 597 } 598 599 bool SBDebugger::StateIsStoppedState(StateType state) { 600 LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, StateIsStoppedState, 601 (lldb::StateType), state); 602 603 const bool result = lldb_private::StateIsStoppedState(state, false); 604 605 return result; 606 } 607 608 lldb::SBTarget SBDebugger::CreateTarget(const char *filename, 609 const char *target_triple, 610 const char *platform_name, 611 bool add_dependent_modules, 612 lldb::SBError &sb_error) { 613 LLDB_RECORD_METHOD( 614 lldb::SBTarget, SBDebugger, CreateTarget, 615 (const char *, const char *, const char *, bool, lldb::SBError &), 616 filename, target_triple, platform_name, add_dependent_modules, sb_error); 617 618 SBTarget sb_target; 619 TargetSP target_sp; 620 if (m_opaque_sp) { 621 sb_error.Clear(); 622 OptionGroupPlatform platform_options(false); 623 platform_options.SetPlatformName(platform_name); 624 625 sb_error.ref() = m_opaque_sp->GetTargetList().CreateTarget( 626 *m_opaque_sp, filename, target_triple, 627 add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, 628 &platform_options, target_sp); 629 630 if (sb_error.Success()) 631 sb_target.SetSP(target_sp); 632 } else { 633 sb_error.SetErrorString("invalid debugger"); 634 } 635 636 Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); 637 LLDB_LOGF(log, 638 "SBDebugger(%p)::CreateTarget (filename=\"%s\", triple=%s, " 639 "platform_name=%s, add_dependent_modules=%u, error=%s) => " 640 "SBTarget(%p)", 641 static_cast<void *>(m_opaque_sp.get()), filename, target_triple, 642 platform_name, add_dependent_modules, sb_error.GetCString(), 643 static_cast<void *>(target_sp.get())); 644 645 return LLDB_RECORD_RESULT(sb_target); 646 } 647 648 SBTarget 649 SBDebugger::CreateTargetWithFileAndTargetTriple(const char *filename, 650 const char *target_triple) { 651 LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, 652 CreateTargetWithFileAndTargetTriple, 653 (const char *, const char *), filename, target_triple); 654 655 SBTarget sb_target; 656 TargetSP target_sp; 657 if (m_opaque_sp) { 658 const bool add_dependent_modules = true; 659 Status error(m_opaque_sp->GetTargetList().CreateTarget( 660 *m_opaque_sp, filename, target_triple, 661 add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, nullptr, 662 target_sp)); 663 sb_target.SetSP(target_sp); 664 } 665 666 Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); 667 LLDB_LOGF(log, 668 "SBDebugger(%p)::CreateTargetWithFileAndTargetTriple " 669 "(filename=\"%s\", triple=%s) => SBTarget(%p)", 670 static_cast<void *>(m_opaque_sp.get()), filename, target_triple, 671 static_cast<void *>(target_sp.get())); 672 673 return LLDB_RECORD_RESULT(sb_target); 674 } 675 676 SBTarget SBDebugger::CreateTargetWithFileAndArch(const char *filename, 677 const char *arch_cstr) { 678 LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, CreateTargetWithFileAndArch, 679 (const char *, const char *), filename, arch_cstr); 680 681 Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); 682 683 SBTarget sb_target; 684 TargetSP target_sp; 685 if (m_opaque_sp) { 686 Status error; 687 const bool add_dependent_modules = true; 688 689 error = m_opaque_sp->GetTargetList().CreateTarget( 690 *m_opaque_sp, filename, arch_cstr, 691 add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, nullptr, 692 target_sp); 693 694 if (error.Success()) { 695 m_opaque_sp->GetTargetList().SetSelectedTarget(target_sp.get()); 696 sb_target.SetSP(target_sp); 697 } 698 } 699 700 LLDB_LOGF(log, 701 "SBDebugger(%p)::CreateTargetWithFileAndArch (filename=\"%s\", " 702 "arch=%s) => SBTarget(%p)", 703 static_cast<void *>(m_opaque_sp.get()), filename, arch_cstr, 704 static_cast<void *>(target_sp.get())); 705 706 return LLDB_RECORD_RESULT(sb_target); 707 } 708 709 SBTarget SBDebugger::CreateTarget(const char *filename) { 710 LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, CreateTarget, (const char *), 711 filename); 712 713 SBTarget sb_target; 714 TargetSP target_sp; 715 if (m_opaque_sp) { 716 Status error; 717 const bool add_dependent_modules = true; 718 error = m_opaque_sp->GetTargetList().CreateTarget( 719 *m_opaque_sp, filename, "", 720 add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, nullptr, 721 target_sp); 722 723 if (error.Success()) { 724 m_opaque_sp->GetTargetList().SetSelectedTarget(target_sp.get()); 725 sb_target.SetSP(target_sp); 726 } 727 } 728 Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); 729 LLDB_LOGF(log, 730 "SBDebugger(%p)::CreateTarget (filename=\"%s\") => SBTarget(%p)", 731 static_cast<void *>(m_opaque_sp.get()), filename, 732 static_cast<void *>(target_sp.get())); 733 return LLDB_RECORD_RESULT(sb_target); 734 } 735 736 SBTarget SBDebugger::GetDummyTarget() { 737 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTarget, SBDebugger, GetDummyTarget); 738 739 SBTarget sb_target; 740 if (m_opaque_sp) { 741 sb_target.SetSP(m_opaque_sp->GetDummyTarget()->shared_from_this()); 742 } 743 Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); 744 LLDB_LOGF(log, "SBDebugger(%p)::GetDummyTarget() => SBTarget(%p)", 745 static_cast<void *>(m_opaque_sp.get()), 746 static_cast<void *>(sb_target.GetSP().get())); 747 return LLDB_RECORD_RESULT(sb_target); 748 } 749 750 bool SBDebugger::DeleteTarget(lldb::SBTarget &target) { 751 LLDB_RECORD_METHOD(bool, SBDebugger, DeleteTarget, (lldb::SBTarget &), 752 target); 753 754 bool result = false; 755 if (m_opaque_sp) { 756 TargetSP target_sp(target.GetSP()); 757 if (target_sp) { 758 // No need to lock, the target list is thread safe 759 result = m_opaque_sp->GetTargetList().DeleteTarget(target_sp); 760 target_sp->Destroy(); 761 target.Clear(); 762 const bool mandatory = true; 763 ModuleList::RemoveOrphanSharedModules(mandatory); 764 } 765 } 766 767 Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); 768 LLDB_LOGF(log, "SBDebugger(%p)::DeleteTarget (SBTarget(%p)) => %i", 769 static_cast<void *>(m_opaque_sp.get()), 770 static_cast<void *>(target.m_opaque_sp.get()), result); 771 772 return result; 773 } 774 775 SBTarget SBDebugger::GetTargetAtIndex(uint32_t idx) { 776 LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, GetTargetAtIndex, (uint32_t), 777 idx); 778 779 SBTarget sb_target; 780 if (m_opaque_sp) { 781 // No need to lock, the target list is thread safe 782 sb_target.SetSP(m_opaque_sp->GetTargetList().GetTargetAtIndex(idx)); 783 } 784 return LLDB_RECORD_RESULT(sb_target); 785 } 786 787 uint32_t SBDebugger::GetIndexOfTarget(lldb::SBTarget target) { 788 LLDB_RECORD_METHOD(uint32_t, SBDebugger, GetIndexOfTarget, (lldb::SBTarget), 789 target); 790 791 lldb::TargetSP target_sp = target.GetSP(); 792 if (!target_sp) 793 return UINT32_MAX; 794 795 if (!m_opaque_sp) 796 return UINT32_MAX; 797 798 return m_opaque_sp->GetTargetList().GetIndexOfTarget(target.GetSP()); 799 } 800 801 SBTarget SBDebugger::FindTargetWithProcessID(lldb::pid_t pid) { 802 LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithProcessID, 803 (lldb::pid_t), pid); 804 805 SBTarget sb_target; 806 if (m_opaque_sp) { 807 // No need to lock, the target list is thread safe 808 sb_target.SetSP(m_opaque_sp->GetTargetList().FindTargetWithProcessID(pid)); 809 } 810 return LLDB_RECORD_RESULT(sb_target); 811 } 812 813 SBTarget SBDebugger::FindTargetWithFileAndArch(const char *filename, 814 const char *arch_name) { 815 LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithFileAndArch, 816 (const char *, const char *), filename, arch_name); 817 818 SBTarget sb_target; 819 if (m_opaque_sp && filename && filename[0]) { 820 // No need to lock, the target list is thread safe 821 ArchSpec arch = Platform::GetAugmentedArchSpec( 822 m_opaque_sp->GetPlatformList().GetSelectedPlatform().get(), arch_name); 823 TargetSP target_sp( 824 m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture( 825 FileSpec(filename), arch_name ? &arch : nullptr)); 826 sb_target.SetSP(target_sp); 827 } 828 return LLDB_RECORD_RESULT(sb_target); 829 } 830 831 SBTarget SBDebugger::FindTargetWithLLDBProcess(const ProcessSP &process_sp) { 832 SBTarget sb_target; 833 if (m_opaque_sp) { 834 // No need to lock, the target list is thread safe 835 sb_target.SetSP( 836 m_opaque_sp->GetTargetList().FindTargetWithProcess(process_sp.get())); 837 } 838 return sb_target; 839 } 840 841 uint32_t SBDebugger::GetNumTargets() { 842 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumTargets); 843 844 if (m_opaque_sp) { 845 // No need to lock, the target list is thread safe 846 return m_opaque_sp->GetTargetList().GetNumTargets(); 847 } 848 return 0; 849 } 850 851 SBTarget SBDebugger::GetSelectedTarget() { 852 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTarget, SBDebugger, GetSelectedTarget); 853 854 Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); 855 856 SBTarget sb_target; 857 TargetSP target_sp; 858 if (m_opaque_sp) { 859 // No need to lock, the target list is thread safe 860 target_sp = m_opaque_sp->GetTargetList().GetSelectedTarget(); 861 sb_target.SetSP(target_sp); 862 } 863 864 if (log) { 865 SBStream sstr; 866 sb_target.GetDescription(sstr, eDescriptionLevelBrief); 867 LLDB_LOGF(log, "SBDebugger(%p)::GetSelectedTarget () => SBTarget(%p): %s", 868 static_cast<void *>(m_opaque_sp.get()), 869 static_cast<void *>(target_sp.get()), sstr.GetData()); 870 } 871 872 return LLDB_RECORD_RESULT(sb_target); 873 } 874 875 void SBDebugger::SetSelectedTarget(SBTarget &sb_target) { 876 LLDB_RECORD_METHOD(void, SBDebugger, SetSelectedTarget, (lldb::SBTarget &), 877 sb_target); 878 879 Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); 880 881 TargetSP target_sp(sb_target.GetSP()); 882 if (m_opaque_sp) { 883 m_opaque_sp->GetTargetList().SetSelectedTarget(target_sp.get()); 884 } 885 if (log) { 886 SBStream sstr; 887 sb_target.GetDescription(sstr, eDescriptionLevelBrief); 888 LLDB_LOGF(log, "SBDebugger(%p)::SetSelectedTarget () => SBTarget(%p): %s", 889 static_cast<void *>(m_opaque_sp.get()), 890 static_cast<void *>(target_sp.get()), sstr.GetData()); 891 } 892 } 893 894 SBPlatform SBDebugger::GetSelectedPlatform() { 895 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBPlatform, SBDebugger, GetSelectedPlatform); 896 897 Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); 898 899 SBPlatform sb_platform; 900 DebuggerSP debugger_sp(m_opaque_sp); 901 if (debugger_sp) { 902 sb_platform.SetSP(debugger_sp->GetPlatformList().GetSelectedPlatform()); 903 } 904 LLDB_LOGF(log, "SBDebugger(%p)::GetSelectedPlatform () => SBPlatform(%p): %s", 905 static_cast<void *>(m_opaque_sp.get()), 906 static_cast<void *>(sb_platform.GetSP().get()), 907 sb_platform.GetName()); 908 return LLDB_RECORD_RESULT(sb_platform); 909 } 910 911 void SBDebugger::SetSelectedPlatform(SBPlatform &sb_platform) { 912 LLDB_RECORD_METHOD(void, SBDebugger, SetSelectedPlatform, 913 (lldb::SBPlatform &), sb_platform); 914 915 Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); 916 917 DebuggerSP debugger_sp(m_opaque_sp); 918 if (debugger_sp) { 919 debugger_sp->GetPlatformList().SetSelectedPlatform(sb_platform.GetSP()); 920 } 921 922 LLDB_LOGF(log, "SBDebugger(%p)::SetSelectedPlatform (SBPlatform(%p) %s)", 923 static_cast<void *>(m_opaque_sp.get()), 924 static_cast<void *>(sb_platform.GetSP().get()), 925 sb_platform.GetName()); 926 } 927 928 uint32_t SBDebugger::GetNumPlatforms() { 929 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumPlatforms); 930 931 if (m_opaque_sp) { 932 // No need to lock, the platform list is thread safe 933 return m_opaque_sp->GetPlatformList().GetSize(); 934 } 935 return 0; 936 } 937 938 SBPlatform SBDebugger::GetPlatformAtIndex(uint32_t idx) { 939 LLDB_RECORD_METHOD(lldb::SBPlatform, SBDebugger, GetPlatformAtIndex, 940 (uint32_t), idx); 941 942 SBPlatform sb_platform; 943 if (m_opaque_sp) { 944 // No need to lock, the platform list is thread safe 945 sb_platform.SetSP(m_opaque_sp->GetPlatformList().GetAtIndex(idx)); 946 } 947 return LLDB_RECORD_RESULT(sb_platform); 948 } 949 950 uint32_t SBDebugger::GetNumAvailablePlatforms() { 951 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumAvailablePlatforms); 952 953 uint32_t idx = 0; 954 while (true) { 955 if (!PluginManager::GetPlatformPluginNameAtIndex(idx)) { 956 break; 957 } 958 ++idx; 959 } 960 // +1 for the host platform, which should always appear first in the list. 961 return idx + 1; 962 } 963 964 SBStructuredData SBDebugger::GetAvailablePlatformInfoAtIndex(uint32_t idx) { 965 LLDB_RECORD_METHOD(lldb::SBStructuredData, SBDebugger, 966 GetAvailablePlatformInfoAtIndex, (uint32_t), idx); 967 968 SBStructuredData data; 969 auto platform_dict = std::make_unique<StructuredData::Dictionary>(); 970 llvm::StringRef name_str("name"), desc_str("description"); 971 972 if (idx == 0) { 973 PlatformSP host_platform_sp(Platform::GetHostPlatform()); 974 platform_dict->AddStringItem( 975 name_str, host_platform_sp->GetPluginName().GetStringRef()); 976 platform_dict->AddStringItem( 977 desc_str, llvm::StringRef(host_platform_sp->GetDescription())); 978 } else if (idx > 0) { 979 const char *plugin_name = 980 PluginManager::GetPlatformPluginNameAtIndex(idx - 1); 981 if (!plugin_name) { 982 return LLDB_RECORD_RESULT(data); 983 } 984 platform_dict->AddStringItem(name_str, llvm::StringRef(plugin_name)); 985 986 const char *plugin_desc = 987 PluginManager::GetPlatformPluginDescriptionAtIndex(idx - 1); 988 if (!plugin_desc) { 989 return LLDB_RECORD_RESULT(data); 990 } 991 platform_dict->AddStringItem(desc_str, llvm::StringRef(plugin_desc)); 992 } 993 994 data.m_impl_up->SetObjectSP( 995 StructuredData::ObjectSP(platform_dict.release())); 996 return LLDB_RECORD_RESULT(data); 997 } 998 999 void SBDebugger::DispatchInput(void *baton, const void *data, size_t data_len) { 1000 LLDB_RECORD_DUMMY(void, SBDebugger, DispatchInput, 1001 (void *, const void *, size_t), baton, data, data_len); 1002 1003 DispatchInput(data, data_len); 1004 } 1005 1006 void SBDebugger::DispatchInput(const void *data, size_t data_len) { 1007 LLDB_RECORD_DUMMY(void, SBDebugger, DispatchInput, (const void *, size_t), 1008 data, data_len); 1009 1010 // Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1011 // 1012 // if (log) 1013 // LLDB_LOGF(log, "SBDebugger(%p)::DispatchInput (data=\"%.*s\", 1014 // size_t=%" PRIu64 ")", 1015 // m_opaque_sp.get(), 1016 // (int) data_len, 1017 // (const char *) data, 1018 // (uint64_t)data_len); 1019 // 1020 // if (m_opaque_sp) 1021 // m_opaque_sp->DispatchInput ((const char *) data, data_len); 1022 } 1023 1024 void SBDebugger::DispatchInputInterrupt() { 1025 LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, DispatchInputInterrupt); 1026 1027 if (m_opaque_sp) 1028 m_opaque_sp->DispatchInputInterrupt(); 1029 } 1030 1031 void SBDebugger::DispatchInputEndOfFile() { 1032 LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, DispatchInputEndOfFile); 1033 1034 if (m_opaque_sp) 1035 m_opaque_sp->DispatchInputEndOfFile(); 1036 } 1037 1038 void SBDebugger::PushInputReader(SBInputReader &reader) { 1039 LLDB_RECORD_METHOD(void, SBDebugger, PushInputReader, (lldb::SBInputReader &), 1040 reader); 1041 } 1042 1043 void SBDebugger::RunCommandInterpreter(bool auto_handle_events, 1044 bool spawn_thread) { 1045 LLDB_RECORD_METHOD(void, SBDebugger, RunCommandInterpreter, (bool, bool), 1046 auto_handle_events, spawn_thread); 1047 1048 if (m_opaque_sp) { 1049 CommandInterpreterRunOptions options; 1050 1051 m_opaque_sp->GetCommandInterpreter().RunCommandInterpreter( 1052 auto_handle_events, spawn_thread, options); 1053 } 1054 } 1055 1056 void SBDebugger::RunCommandInterpreter(bool auto_handle_events, 1057 bool spawn_thread, 1058 SBCommandInterpreterRunOptions &options, 1059 int &num_errors, bool &quit_requested, 1060 bool &stopped_for_crash) 1061 1062 { 1063 LLDB_RECORD_METHOD(void, SBDebugger, RunCommandInterpreter, 1064 (bool, bool, lldb::SBCommandInterpreterRunOptions &, int &, 1065 bool &, bool &), 1066 auto_handle_events, spawn_thread, options, num_errors, 1067 quit_requested, stopped_for_crash); 1068 1069 if (m_opaque_sp) { 1070 CommandInterpreter &interp = m_opaque_sp->GetCommandInterpreter(); 1071 interp.RunCommandInterpreter(auto_handle_events, spawn_thread, 1072 options.ref()); 1073 num_errors = interp.GetNumErrors(); 1074 quit_requested = interp.GetQuitRequested(); 1075 stopped_for_crash = interp.GetStoppedForCrash(); 1076 } 1077 } 1078 1079 SBError SBDebugger::RunREPL(lldb::LanguageType language, 1080 const char *repl_options) { 1081 LLDB_RECORD_METHOD(lldb::SBError, SBDebugger, RunREPL, 1082 (lldb::LanguageType, const char *), language, 1083 repl_options); 1084 1085 SBError error; 1086 if (m_opaque_sp) 1087 error.ref() = m_opaque_sp->RunREPL(language, repl_options); 1088 else 1089 error.SetErrorString("invalid debugger"); 1090 return LLDB_RECORD_RESULT(error); 1091 } 1092 1093 void SBDebugger::reset(const DebuggerSP &debugger_sp) { 1094 m_opaque_sp = debugger_sp; 1095 } 1096 1097 Debugger *SBDebugger::get() const { return m_opaque_sp.get(); } 1098 1099 Debugger &SBDebugger::ref() const { 1100 assert(m_opaque_sp.get()); 1101 return *m_opaque_sp; 1102 } 1103 1104 const lldb::DebuggerSP &SBDebugger::get_sp() const { return m_opaque_sp; } 1105 1106 SBDebugger SBDebugger::FindDebuggerWithID(int id) { 1107 LLDB_RECORD_STATIC_METHOD(lldb::SBDebugger, SBDebugger, FindDebuggerWithID, 1108 (int), id); 1109 1110 // No need to lock, the debugger list is thread safe 1111 SBDebugger sb_debugger; 1112 DebuggerSP debugger_sp = Debugger::FindDebuggerWithID(id); 1113 if (debugger_sp) 1114 sb_debugger.reset(debugger_sp); 1115 return LLDB_RECORD_RESULT(sb_debugger); 1116 } 1117 1118 const char *SBDebugger::GetInstanceName() { 1119 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBDebugger, GetInstanceName); 1120 1121 return (m_opaque_sp ? m_opaque_sp->GetInstanceName().AsCString() : nullptr); 1122 } 1123 1124 SBError SBDebugger::SetInternalVariable(const char *var_name, const char *value, 1125 const char *debugger_instance_name) { 1126 LLDB_RECORD_STATIC_METHOD(lldb::SBError, SBDebugger, SetInternalVariable, 1127 (const char *, const char *, const char *), 1128 var_name, value, debugger_instance_name); 1129 1130 SBError sb_error; 1131 DebuggerSP debugger_sp(Debugger::FindDebuggerWithInstanceName( 1132 ConstString(debugger_instance_name))); 1133 Status error; 1134 if (debugger_sp) { 1135 ExecutionContext exe_ctx( 1136 debugger_sp->GetCommandInterpreter().GetExecutionContext()); 1137 error = debugger_sp->SetPropertyValue(&exe_ctx, eVarSetOperationAssign, 1138 var_name, value); 1139 } else { 1140 error.SetErrorStringWithFormat("invalid debugger instance name '%s'", 1141 debugger_instance_name); 1142 } 1143 if (error.Fail()) 1144 sb_error.SetError(error); 1145 return LLDB_RECORD_RESULT(sb_error); 1146 } 1147 1148 SBStringList 1149 SBDebugger::GetInternalVariableValue(const char *var_name, 1150 const char *debugger_instance_name) { 1151 LLDB_RECORD_STATIC_METHOD( 1152 lldb::SBStringList, SBDebugger, GetInternalVariableValue, 1153 (const char *, const char *), var_name, debugger_instance_name); 1154 1155 SBStringList ret_value; 1156 DebuggerSP debugger_sp(Debugger::FindDebuggerWithInstanceName( 1157 ConstString(debugger_instance_name))); 1158 Status error; 1159 if (debugger_sp) { 1160 ExecutionContext exe_ctx( 1161 debugger_sp->GetCommandInterpreter().GetExecutionContext()); 1162 lldb::OptionValueSP value_sp( 1163 debugger_sp->GetPropertyValue(&exe_ctx, var_name, false, error)); 1164 if (value_sp) { 1165 StreamString value_strm; 1166 value_sp->DumpValue(&exe_ctx, value_strm, OptionValue::eDumpOptionValue); 1167 const std::string &value_str = value_strm.GetString(); 1168 if (!value_str.empty()) { 1169 StringList string_list; 1170 string_list.SplitIntoLines(value_str); 1171 return LLDB_RECORD_RESULT(SBStringList(&string_list)); 1172 } 1173 } 1174 } 1175 return LLDB_RECORD_RESULT(SBStringList()); 1176 } 1177 1178 uint32_t SBDebugger::GetTerminalWidth() const { 1179 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBDebugger, GetTerminalWidth); 1180 1181 return (m_opaque_sp ? m_opaque_sp->GetTerminalWidth() : 0); 1182 } 1183 1184 void SBDebugger::SetTerminalWidth(uint32_t term_width) { 1185 LLDB_RECORD_METHOD(void, SBDebugger, SetTerminalWidth, (uint32_t), 1186 term_width); 1187 1188 if (m_opaque_sp) 1189 m_opaque_sp->SetTerminalWidth(term_width); 1190 } 1191 1192 const char *SBDebugger::GetPrompt() const { 1193 LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBDebugger, GetPrompt); 1194 1195 Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); 1196 1197 LLDB_LOGF(log, "SBDebugger(%p)::GetPrompt () => \"%s\"", 1198 static_cast<void *>(m_opaque_sp.get()), 1199 (m_opaque_sp ? m_opaque_sp->GetPrompt().str().c_str() : "")); 1200 1201 return (m_opaque_sp ? ConstString(m_opaque_sp->GetPrompt()).GetCString() 1202 : nullptr); 1203 } 1204 1205 void SBDebugger::SetPrompt(const char *prompt) { 1206 LLDB_RECORD_METHOD(void, SBDebugger, SetPrompt, (const char *), prompt); 1207 1208 if (m_opaque_sp) 1209 m_opaque_sp->SetPrompt(llvm::StringRef::withNullAsEmpty(prompt)); 1210 } 1211 1212 const char *SBDebugger::GetReproducerPath() const { 1213 LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBDebugger, GetReproducerPath); 1214 1215 return (m_opaque_sp 1216 ? ConstString(m_opaque_sp->GetReproducerPath()).GetCString() 1217 : nullptr); 1218 } 1219 1220 ScriptLanguage SBDebugger::GetScriptLanguage() const { 1221 LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::ScriptLanguage, SBDebugger, 1222 GetScriptLanguage); 1223 1224 return (m_opaque_sp ? m_opaque_sp->GetScriptLanguage() : eScriptLanguageNone); 1225 } 1226 1227 void SBDebugger::SetScriptLanguage(ScriptLanguage script_lang) { 1228 LLDB_RECORD_METHOD(void, SBDebugger, SetScriptLanguage, 1229 (lldb::ScriptLanguage), script_lang); 1230 1231 if (m_opaque_sp) { 1232 m_opaque_sp->SetScriptLanguage(script_lang); 1233 } 1234 } 1235 1236 bool SBDebugger::SetUseExternalEditor(bool value) { 1237 LLDB_RECORD_METHOD(bool, SBDebugger, SetUseExternalEditor, (bool), value); 1238 1239 return (m_opaque_sp ? m_opaque_sp->SetUseExternalEditor(value) : false); 1240 } 1241 1242 bool SBDebugger::GetUseExternalEditor() { 1243 LLDB_RECORD_METHOD_NO_ARGS(bool, SBDebugger, GetUseExternalEditor); 1244 1245 return (m_opaque_sp ? m_opaque_sp->GetUseExternalEditor() : false); 1246 } 1247 1248 bool SBDebugger::SetUseColor(bool value) { 1249 LLDB_RECORD_METHOD(bool, SBDebugger, SetUseColor, (bool), value); 1250 1251 return (m_opaque_sp ? m_opaque_sp->SetUseColor(value) : false); 1252 } 1253 1254 bool SBDebugger::GetUseColor() const { 1255 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, GetUseColor); 1256 1257 return (m_opaque_sp ? m_opaque_sp->GetUseColor() : false); 1258 } 1259 1260 bool SBDebugger::GetDescription(SBStream &description) { 1261 LLDB_RECORD_METHOD(bool, SBDebugger, GetDescription, (lldb::SBStream &), 1262 description); 1263 1264 Stream &strm = description.ref(); 1265 1266 if (m_opaque_sp) { 1267 const char *name = m_opaque_sp->GetInstanceName().AsCString(); 1268 user_id_t id = m_opaque_sp->GetID(); 1269 strm.Printf("Debugger (instance: \"%s\", id: %" PRIu64 ")", name, id); 1270 } else 1271 strm.PutCString("No value"); 1272 1273 return true; 1274 } 1275 1276 user_id_t SBDebugger::GetID() { 1277 LLDB_RECORD_METHOD_NO_ARGS(lldb::user_id_t, SBDebugger, GetID); 1278 1279 return (m_opaque_sp ? m_opaque_sp->GetID() : LLDB_INVALID_UID); 1280 } 1281 1282 SBError SBDebugger::SetCurrentPlatform(const char *platform_name_cstr) { 1283 LLDB_RECORD_METHOD(lldb::SBError, SBDebugger, SetCurrentPlatform, 1284 (const char *), platform_name_cstr); 1285 1286 SBError sb_error; 1287 if (m_opaque_sp) { 1288 if (platform_name_cstr && platform_name_cstr[0]) { 1289 ConstString platform_name(platform_name_cstr); 1290 PlatformSP platform_sp(Platform::Find(platform_name)); 1291 1292 if (platform_sp) { 1293 // Already have a platform with this name, just select it 1294 m_opaque_sp->GetPlatformList().SetSelectedPlatform(platform_sp); 1295 } else { 1296 // We don't have a platform by this name yet, create one 1297 platform_sp = Platform::Create(platform_name, sb_error.ref()); 1298 if (platform_sp) { 1299 // We created the platform, now append and select it 1300 bool make_selected = true; 1301 m_opaque_sp->GetPlatformList().Append(platform_sp, make_selected); 1302 } 1303 } 1304 } else { 1305 sb_error.ref().SetErrorString("invalid platform name"); 1306 } 1307 } else { 1308 sb_error.ref().SetErrorString("invalid debugger"); 1309 } 1310 return LLDB_RECORD_RESULT(sb_error); 1311 } 1312 1313 bool SBDebugger::SetCurrentPlatformSDKRoot(const char *sysroot) { 1314 LLDB_RECORD_METHOD(bool, SBDebugger, SetCurrentPlatformSDKRoot, 1315 (const char *), sysroot); 1316 1317 Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); 1318 if (m_opaque_sp) { 1319 PlatformSP platform_sp( 1320 m_opaque_sp->GetPlatformList().GetSelectedPlatform()); 1321 1322 if (platform_sp) { 1323 if (log && sysroot) 1324 LLDB_LOGF(log, "SBDebugger::SetCurrentPlatformSDKRoot (\"%s\")", 1325 sysroot); 1326 platform_sp->SetSDKRootDirectory(ConstString(sysroot)); 1327 return true; 1328 } 1329 } 1330 return false; 1331 } 1332 1333 bool SBDebugger::GetCloseInputOnEOF() const { 1334 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, GetCloseInputOnEOF); 1335 1336 return (m_opaque_sp ? m_opaque_sp->GetCloseInputOnEOF() : false); 1337 } 1338 1339 void SBDebugger::SetCloseInputOnEOF(bool b) { 1340 LLDB_RECORD_METHOD(void, SBDebugger, SetCloseInputOnEOF, (bool), b); 1341 1342 if (m_opaque_sp) 1343 m_opaque_sp->SetCloseInputOnEOF(b); 1344 } 1345 1346 SBTypeCategory SBDebugger::GetCategory(const char *category_name) { 1347 LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory, 1348 (const char *), category_name); 1349 1350 if (!category_name || *category_name == 0) 1351 return LLDB_RECORD_RESULT(SBTypeCategory()); 1352 1353 TypeCategoryImplSP category_sp; 1354 1355 if (DataVisualization::Categories::GetCategory(ConstString(category_name), 1356 category_sp, false)) { 1357 return LLDB_RECORD_RESULT(SBTypeCategory(category_sp)); 1358 } else { 1359 return LLDB_RECORD_RESULT(SBTypeCategory()); 1360 } 1361 } 1362 1363 SBTypeCategory SBDebugger::GetCategory(lldb::LanguageType lang_type) { 1364 LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory, 1365 (lldb::LanguageType), lang_type); 1366 1367 TypeCategoryImplSP category_sp; 1368 if (DataVisualization::Categories::GetCategory(lang_type, category_sp)) { 1369 return LLDB_RECORD_RESULT(SBTypeCategory(category_sp)); 1370 } else { 1371 return LLDB_RECORD_RESULT(SBTypeCategory()); 1372 } 1373 } 1374 1375 SBTypeCategory SBDebugger::CreateCategory(const char *category_name) { 1376 LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, CreateCategory, 1377 (const char *), category_name); 1378 1379 if (!category_name || *category_name == 0) 1380 return LLDB_RECORD_RESULT(SBTypeCategory()); 1381 1382 TypeCategoryImplSP category_sp; 1383 1384 if (DataVisualization::Categories::GetCategory(ConstString(category_name), 1385 category_sp, true)) { 1386 return LLDB_RECORD_RESULT(SBTypeCategory(category_sp)); 1387 } else { 1388 return LLDB_RECORD_RESULT(SBTypeCategory()); 1389 } 1390 } 1391 1392 bool SBDebugger::DeleteCategory(const char *category_name) { 1393 LLDB_RECORD_METHOD(bool, SBDebugger, DeleteCategory, (const char *), 1394 category_name); 1395 1396 if (!category_name || *category_name == 0) 1397 return false; 1398 1399 return DataVisualization::Categories::Delete(ConstString(category_name)); 1400 } 1401 1402 uint32_t SBDebugger::GetNumCategories() { 1403 LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumCategories); 1404 1405 return DataVisualization::Categories::GetCount(); 1406 } 1407 1408 SBTypeCategory SBDebugger::GetCategoryAtIndex(uint32_t index) { 1409 LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategoryAtIndex, 1410 (uint32_t), index); 1411 1412 return LLDB_RECORD_RESULT( 1413 SBTypeCategory(DataVisualization::Categories::GetCategoryAtIndex(index))); 1414 } 1415 1416 SBTypeCategory SBDebugger::GetDefaultCategory() { 1417 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeCategory, SBDebugger, 1418 GetDefaultCategory); 1419 1420 return LLDB_RECORD_RESULT(GetCategory("default")); 1421 } 1422 1423 SBTypeFormat SBDebugger::GetFormatForType(SBTypeNameSpecifier type_name) { 1424 LLDB_RECORD_METHOD(lldb::SBTypeFormat, SBDebugger, GetFormatForType, 1425 (lldb::SBTypeNameSpecifier), type_name); 1426 1427 SBTypeCategory default_category_sb = GetDefaultCategory(); 1428 if (default_category_sb.GetEnabled()) 1429 return LLDB_RECORD_RESULT(default_category_sb.GetFormatForType(type_name)); 1430 return LLDB_RECORD_RESULT(SBTypeFormat()); 1431 } 1432 1433 SBTypeSummary SBDebugger::GetSummaryForType(SBTypeNameSpecifier type_name) { 1434 LLDB_RECORD_METHOD(lldb::SBTypeSummary, SBDebugger, GetSummaryForType, 1435 (lldb::SBTypeNameSpecifier), type_name); 1436 1437 if (!type_name.IsValid()) 1438 return LLDB_RECORD_RESULT(SBTypeSummary()); 1439 return LLDB_RECORD_RESULT( 1440 SBTypeSummary(DataVisualization::GetSummaryForType(type_name.GetSP()))); 1441 } 1442 1443 SBTypeFilter SBDebugger::GetFilterForType(SBTypeNameSpecifier type_name) { 1444 LLDB_RECORD_METHOD(lldb::SBTypeFilter, SBDebugger, GetFilterForType, 1445 (lldb::SBTypeNameSpecifier), type_name); 1446 1447 if (!type_name.IsValid()) 1448 return LLDB_RECORD_RESULT(SBTypeFilter()); 1449 return LLDB_RECORD_RESULT( 1450 SBTypeFilter(DataVisualization::GetFilterForType(type_name.GetSP()))); 1451 } 1452 1453 SBTypeSynthetic SBDebugger::GetSyntheticForType(SBTypeNameSpecifier type_name) { 1454 LLDB_RECORD_METHOD(lldb::SBTypeSynthetic, SBDebugger, GetSyntheticForType, 1455 (lldb::SBTypeNameSpecifier), type_name); 1456 1457 if (!type_name.IsValid()) 1458 return LLDB_RECORD_RESULT(SBTypeSynthetic()); 1459 return LLDB_RECORD_RESULT(SBTypeSynthetic( 1460 DataVisualization::GetSyntheticForType(type_name.GetSP()))); 1461 } 1462 1463 static llvm::ArrayRef<const char *> GetCategoryArray(const char **categories) { 1464 if (categories == nullptr) 1465 return {}; 1466 size_t len = 0; 1467 while (categories[len] != nullptr) 1468 ++len; 1469 return llvm::makeArrayRef(categories, len); 1470 } 1471 1472 bool SBDebugger::EnableLog(const char *channel, const char **categories) { 1473 LLDB_RECORD_METHOD(bool, SBDebugger, EnableLog, (const char *, const char **), 1474 channel, categories); 1475 1476 if (m_opaque_sp) { 1477 uint32_t log_options = 1478 LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_THREAD_NAME; 1479 std::string error; 1480 llvm::raw_string_ostream error_stream(error); 1481 return m_opaque_sp->EnableLog(channel, GetCategoryArray(categories), "", 1482 log_options, error_stream); 1483 } else 1484 return false; 1485 } 1486 1487 void SBDebugger::SetLoggingCallback(lldb::LogOutputCallback log_callback, 1488 void *baton) { 1489 LLDB_RECORD_DUMMY(void, SBDebugger, SetLoggingCallback, 1490 (lldb::LogOutputCallback, void *), log_callback, baton); 1491 1492 if (m_opaque_sp) { 1493 return m_opaque_sp->SetLoggingCallback(log_callback, baton); 1494 } 1495 } 1496 1497 namespace lldb_private { 1498 namespace repro { 1499 1500 template <> void RegisterMethods<SBInputReader>(Registry &R) { 1501 LLDB_REGISTER_METHOD(void, SBInputReader, SetIsDone, (bool)); 1502 LLDB_REGISTER_METHOD_CONST(bool, SBInputReader, IsActive, ()); 1503 } 1504 1505 static void SetFileHandleRedirect(SBDebugger *, FILE *, bool) { 1506 // Do nothing. 1507 } 1508 1509 static bool GetDefaultArchitectureRedirect(char *arch_name, 1510 size_t arch_name_len) { 1511 // The function is writing to its argument. Without the redirect it would 1512 // write into the replay buffer. 1513 char buffer[1024]; 1514 return SBDebugger::GetDefaultArchitecture(buffer, arch_name_len); 1515 } 1516 1517 template <> void RegisterMethods<SBDebugger>(Registry &R) { 1518 // Custom implementation. 1519 R.Register(&invoke<void (SBDebugger::*)( 1520 FILE *, bool)>::method<&SBDebugger::SetErrorFileHandle>::doit, 1521 &SetFileHandleRedirect); 1522 R.Register(&invoke<void (SBDebugger::*)( 1523 FILE *, bool)>::method<&SBDebugger::SetOutputFileHandle>::doit, 1524 &SetFileHandleRedirect); 1525 R.Register<bool(char *, size_t)>(static_cast<bool (*)(char *, size_t)>( 1526 &SBDebugger::GetDefaultArchitecture), 1527 &GetDefaultArchitectureRedirect); 1528 1529 LLDB_REGISTER_CONSTRUCTOR(SBDebugger, ()); 1530 LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::DebuggerSP &)); 1531 LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::SBDebugger &)); 1532 LLDB_REGISTER_METHOD(lldb::SBDebugger &, 1533 SBDebugger, operator=,(const lldb::SBDebugger &)); 1534 LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, Initialize, ()); 1535 LLDB_REGISTER_STATIC_METHOD(lldb::SBError, SBDebugger, 1536 InitializeWithErrorHandling, ()); 1537 LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, Terminate, ()); 1538 LLDB_REGISTER_METHOD(void, SBDebugger, Clear, ()); 1539 LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger, Create, ()); 1540 LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger, Create, (bool)); 1541 LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, Destroy, (lldb::SBDebugger &)); 1542 LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, MemoryPressureDetected, ()); 1543 LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, IsValid, ()); 1544 LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, operator bool,()); 1545 LLDB_REGISTER_METHOD(void, SBDebugger, SetAsync, (bool)); 1546 LLDB_REGISTER_METHOD(bool, SBDebugger, GetAsync, ()); 1547 LLDB_REGISTER_METHOD(void, SBDebugger, SkipLLDBInitFiles, (bool)); 1548 LLDB_REGISTER_METHOD(void, SBDebugger, SkipAppInitFiles, (bool)); 1549 LLDB_REGISTER_METHOD(void, SBDebugger, SetInputFileHandle, (FILE *, bool)); 1550 LLDB_REGISTER_METHOD(FILE *, SBDebugger, GetInputFileHandle, ()); 1551 LLDB_REGISTER_METHOD(FILE *, SBDebugger, GetOutputFileHandle, ()); 1552 LLDB_REGISTER_METHOD(FILE *, SBDebugger, GetErrorFileHandle, ()); 1553 LLDB_REGISTER_METHOD(void, SBDebugger, SaveInputTerminalState, ()); 1554 LLDB_REGISTER_METHOD(void, SBDebugger, RestoreInputTerminalState, ()); 1555 LLDB_REGISTER_METHOD(lldb::SBCommandInterpreter, SBDebugger, 1556 GetCommandInterpreter, ()); 1557 LLDB_REGISTER_METHOD(void, SBDebugger, HandleCommand, (const char *)); 1558 LLDB_REGISTER_METHOD(lldb::SBListener, SBDebugger, GetListener, ()); 1559 LLDB_REGISTER_METHOD( 1560 void, SBDebugger, HandleProcessEvent, 1561 (const lldb::SBProcess &, const lldb::SBEvent &, FILE *, FILE *)); 1562 LLDB_REGISTER_METHOD(lldb::SBSourceManager, SBDebugger, GetSourceManager, ()); 1563 LLDB_REGISTER_STATIC_METHOD(bool, SBDebugger, SetDefaultArchitecture, 1564 (const char *)); 1565 LLDB_REGISTER_METHOD(lldb::ScriptLanguage, SBDebugger, GetScriptingLanguage, 1566 (const char *)); 1567 LLDB_REGISTER_STATIC_METHOD(const char *, SBDebugger, GetVersionString, ()); 1568 LLDB_REGISTER_STATIC_METHOD(const char *, SBDebugger, StateAsCString, 1569 (lldb::StateType)); 1570 LLDB_REGISTER_STATIC_METHOD(lldb::SBStructuredData, SBDebugger, 1571 GetBuildConfiguration, ()); 1572 LLDB_REGISTER_STATIC_METHOD(bool, SBDebugger, StateIsRunningState, 1573 (lldb::StateType)); 1574 LLDB_REGISTER_STATIC_METHOD(bool, SBDebugger, StateIsStoppedState, 1575 (lldb::StateType)); 1576 LLDB_REGISTER_METHOD( 1577 lldb::SBTarget, SBDebugger, CreateTarget, 1578 (const char *, const char *, const char *, bool, lldb::SBError &)); 1579 LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, 1580 CreateTargetWithFileAndTargetTriple, 1581 (const char *, const char *)); 1582 LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, CreateTargetWithFileAndArch, 1583 (const char *, const char *)); 1584 LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, CreateTarget, 1585 (const char *)); 1586 LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, GetDummyTarget, ()); 1587 LLDB_REGISTER_METHOD(bool, SBDebugger, DeleteTarget, (lldb::SBTarget &)); 1588 LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, GetTargetAtIndex, 1589 (uint32_t)); 1590 LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetIndexOfTarget, 1591 (lldb::SBTarget)); 1592 LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithProcessID, 1593 (lldb::pid_t)); 1594 LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithFileAndArch, 1595 (const char *, const char *)); 1596 LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumTargets, ()); 1597 LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, GetSelectedTarget, ()); 1598 LLDB_REGISTER_METHOD(void, SBDebugger, SetSelectedTarget, (lldb::SBTarget &)); 1599 LLDB_REGISTER_METHOD(lldb::SBPlatform, SBDebugger, GetSelectedPlatform, ()); 1600 LLDB_REGISTER_METHOD(void, SBDebugger, SetSelectedPlatform, 1601 (lldb::SBPlatform &)); 1602 LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumPlatforms, ()); 1603 LLDB_REGISTER_METHOD(lldb::SBPlatform, SBDebugger, GetPlatformAtIndex, 1604 (uint32_t)); 1605 LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumAvailablePlatforms, ()); 1606 LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBDebugger, 1607 GetAvailablePlatformInfoAtIndex, (uint32_t)); 1608 LLDB_REGISTER_METHOD(void, SBDebugger, DispatchInputInterrupt, ()); 1609 LLDB_REGISTER_METHOD(void, SBDebugger, DispatchInputEndOfFile, ()); 1610 LLDB_REGISTER_METHOD(void, SBDebugger, PushInputReader, 1611 (lldb::SBInputReader &)); 1612 LLDB_REGISTER_METHOD(void, SBDebugger, RunCommandInterpreter, (bool, bool)); 1613 LLDB_REGISTER_METHOD(void, SBDebugger, RunCommandInterpreter, 1614 (bool, bool, lldb::SBCommandInterpreterRunOptions &, 1615 int &, bool &, bool &)); 1616 LLDB_REGISTER_METHOD(lldb::SBError, SBDebugger, RunREPL, 1617 (lldb::LanguageType, const char *)); 1618 LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger, FindDebuggerWithID, 1619 (int)); 1620 LLDB_REGISTER_METHOD(const char *, SBDebugger, GetInstanceName, ()); 1621 LLDB_REGISTER_STATIC_METHOD(lldb::SBError, SBDebugger, SetInternalVariable, 1622 (const char *, const char *, const char *)); 1623 LLDB_REGISTER_STATIC_METHOD(lldb::SBStringList, SBDebugger, 1624 GetInternalVariableValue, 1625 (const char *, const char *)); 1626 LLDB_REGISTER_METHOD_CONST(uint32_t, SBDebugger, GetTerminalWidth, ()); 1627 LLDB_REGISTER_METHOD(void, SBDebugger, SetTerminalWidth, (uint32_t)); 1628 LLDB_REGISTER_METHOD_CONST(const char *, SBDebugger, GetPrompt, ()); 1629 LLDB_REGISTER_METHOD(void, SBDebugger, SetPrompt, (const char *)); 1630 LLDB_REGISTER_METHOD_CONST(const char *, SBDebugger, GetReproducerPath, ()); 1631 LLDB_REGISTER_METHOD_CONST(lldb::ScriptLanguage, SBDebugger, 1632 GetScriptLanguage, ()); 1633 LLDB_REGISTER_METHOD(void, SBDebugger, SetScriptLanguage, 1634 (lldb::ScriptLanguage)); 1635 LLDB_REGISTER_METHOD(bool, SBDebugger, SetUseExternalEditor, (bool)); 1636 LLDB_REGISTER_METHOD(bool, SBDebugger, GetUseExternalEditor, ()); 1637 LLDB_REGISTER_METHOD(bool, SBDebugger, SetUseColor, (bool)); 1638 LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, GetUseColor, ()); 1639 LLDB_REGISTER_METHOD(bool, SBDebugger, GetDescription, (lldb::SBStream &)); 1640 LLDB_REGISTER_METHOD(lldb::user_id_t, SBDebugger, GetID, ()); 1641 LLDB_REGISTER_METHOD(lldb::SBError, SBDebugger, SetCurrentPlatform, 1642 (const char *)); 1643 LLDB_REGISTER_METHOD(bool, SBDebugger, SetCurrentPlatformSDKRoot, 1644 (const char *)); 1645 LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, GetCloseInputOnEOF, ()); 1646 LLDB_REGISTER_METHOD(void, SBDebugger, SetCloseInputOnEOF, (bool)); 1647 LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory, 1648 (const char *)); 1649 LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory, 1650 (lldb::LanguageType)); 1651 LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, CreateCategory, 1652 (const char *)); 1653 LLDB_REGISTER_METHOD(bool, SBDebugger, DeleteCategory, (const char *)); 1654 LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumCategories, ()); 1655 LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategoryAtIndex, 1656 (uint32_t)); 1657 LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetDefaultCategory, 1658 ()); 1659 LLDB_REGISTER_METHOD(lldb::SBTypeFormat, SBDebugger, GetFormatForType, 1660 (lldb::SBTypeNameSpecifier)); 1661 LLDB_REGISTER_METHOD(lldb::SBTypeSummary, SBDebugger, GetSummaryForType, 1662 (lldb::SBTypeNameSpecifier)); 1663 LLDB_REGISTER_METHOD(lldb::SBTypeSynthetic, SBDebugger, GetSyntheticForType, 1664 (lldb::SBTypeNameSpecifier)); 1665 LLDB_REGISTER_METHOD(lldb::SBTypeFilter, SBDebugger, GetFilterForType, 1666 (lldb::SBTypeNameSpecifier)); 1667 LLDB_REGISTER_METHOD(bool, SBDebugger, EnableLog, 1668 (const char *, const char **)); 1669 } 1670 1671 } // namespace repro 1672 } // namespace lldb_private 1673