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