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