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