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