1 //===-- SBDebugger.cpp ------------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "lldb/API/SBDebugger.h" 11 12 #include "lldb/lldb-include.h" 13 14 #include "lldb/API/SBListener.h" 15 #include "lldb/API/SBBroadcaster.h" 16 #include "lldb/API/SBCommandInterpreter.h" 17 #include "lldb/API/SBCommandReturnObject.h" 18 #include "lldb/API/SBEvent.h" 19 #include "lldb/API/SBFrame.h" 20 #include "lldb/API/SBInputReader.h" 21 #include "lldb/API/SBProcess.h" 22 #include "lldb/API/SBSourceManager.h" 23 #include "lldb/API/SBStream.h" 24 #include "lldb/API/SBStringList.h" 25 #include "lldb/API/SBTarget.h" 26 #include "lldb/API/SBThread.h" 27 #include "lldb/Core/Debugger.h" 28 #include "lldb/Core/State.h" 29 #include "lldb/Interpreter/Args.h" 30 #include "lldb/Interpreter/CommandInterpreter.h" 31 #include "lldb/Target/Process.h" 32 #include "lldb/Target/TargetList.h" 33 34 using namespace lldb; 35 using namespace lldb_private; 36 37 void 38 SBDebugger::Initialize () 39 { 40 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 41 42 if (log) 43 log->Printf ("SBDebugger::Initialize ()"); 44 45 Debugger::Initialize(); 46 } 47 48 void 49 SBDebugger::Terminate () 50 { 51 Debugger::Terminate(); 52 } 53 54 void 55 SBDebugger::Clear () 56 { 57 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 58 59 if (log) 60 log->Printf ("SBDebugger(%p)::Clear ()", m_opaque_sp.get()); 61 62 if (m_opaque_sp) 63 m_opaque_sp->CleanUpInputReaders (); 64 65 m_opaque_sp.reset(); 66 } 67 68 SBDebugger 69 SBDebugger::Create() 70 { 71 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 72 73 SBDebugger debugger; 74 debugger.reset(Debugger::CreateInstance()); 75 76 if (log) 77 { 78 SBStream sstr; 79 debugger.GetDescription (sstr); 80 log->Printf ("SBDebugger::Create () => SBDebugger(%p): %s", debugger.m_opaque_sp.get(), sstr.GetData()); 81 } 82 83 return debugger; 84 } 85 86 SBDebugger::SBDebugger () : 87 m_opaque_sp () 88 { 89 } 90 91 SBDebugger::SBDebugger(const SBDebugger &rhs) : 92 m_opaque_sp (rhs.m_opaque_sp) 93 { 94 } 95 96 SBDebugger & 97 SBDebugger::operator = (const SBDebugger &rhs) 98 { 99 if (this != &rhs) 100 { 101 m_opaque_sp = rhs.m_opaque_sp; 102 } 103 return *this; 104 } 105 106 SBDebugger::~SBDebugger () 107 { 108 } 109 110 bool 111 SBDebugger::IsValid() const 112 { 113 return m_opaque_sp.get() != NULL; 114 } 115 116 117 void 118 SBDebugger::SetAsync (bool b) 119 { 120 if (m_opaque_sp) 121 m_opaque_sp->SetAsyncExecution(b); 122 } 123 124 void 125 SBDebugger::SkipLLDBInitFiles (bool b) 126 { 127 if (m_opaque_sp) 128 m_opaque_sp->GetCommandInterpreter().SkipLLDBInitFiles (b); 129 } 130 131 // Shouldn't really be settable after initialization as this could cause lots of problems; don't want users 132 // trying to switch modes in the middle of a debugging session. 133 void 134 SBDebugger::SetInputFileHandle (FILE *fh, bool transfer_ownership) 135 { 136 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 137 138 if (log) 139 log->Printf ("SBDebugger(%p)::SetInputFileHandle (fh=%p, transfer_ownership=%i)", m_opaque_sp.get(), 140 fh, transfer_ownership); 141 142 if (m_opaque_sp) 143 m_opaque_sp->SetInputFileHandle (fh, transfer_ownership); 144 } 145 146 void 147 SBDebugger::SetOutputFileHandle (FILE *fh, bool transfer_ownership) 148 { 149 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 150 151 152 if (log) 153 log->Printf ("SBDebugger(%p)::SetOutputFileHandle (fh=%p, transfer_ownership=%i)", m_opaque_sp.get(), 154 fh, transfer_ownership); 155 156 if (m_opaque_sp) 157 m_opaque_sp->SetOutputFileHandle (fh, transfer_ownership); 158 } 159 160 void 161 SBDebugger::SetErrorFileHandle (FILE *fh, bool transfer_ownership) 162 { 163 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 164 165 166 if (log) 167 log->Printf ("SBDebugger(%p)::SetErrorFileHandle (fh=%p, transfer_ownership=%i)", m_opaque_sp.get(), 168 fh, transfer_ownership); 169 170 if (m_opaque_sp) 171 m_opaque_sp->SetErrorFileHandle (fh, transfer_ownership); 172 } 173 174 FILE * 175 SBDebugger::GetInputFileHandle () 176 { 177 if (m_opaque_sp) 178 return m_opaque_sp->GetInputFileHandle(); 179 return NULL; 180 } 181 182 FILE * 183 SBDebugger::GetOutputFileHandle () 184 { 185 if (m_opaque_sp) 186 return m_opaque_sp->GetOutputFileHandle(); 187 return NULL; 188 } 189 190 FILE * 191 SBDebugger::GetErrorFileHandle () 192 { 193 if (m_opaque_sp) 194 return m_opaque_sp->GetErrorFileHandle(); 195 return NULL; 196 } 197 198 SBCommandInterpreter 199 SBDebugger::GetCommandInterpreter () 200 { 201 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 202 203 SBCommandInterpreter sb_interpreter; 204 if (m_opaque_sp) 205 sb_interpreter.reset (&m_opaque_sp->GetCommandInterpreter()); 206 207 if (log) 208 log->Printf ("SBDebugger(%p)::GetCommandInterpreter () => SBCommandInterpreter(%p)", 209 m_opaque_sp.get(), sb_interpreter.get()); 210 211 return sb_interpreter; 212 } 213 214 void 215 SBDebugger::HandleCommand (const char *command) 216 { 217 if (m_opaque_sp) 218 { 219 TargetSP target_sp (m_opaque_sp->GetSelectedTarget()); 220 Mutex::Locker api_locker; 221 if (target_sp) 222 api_locker.Reset(target_sp->GetAPIMutex().GetMutex()); 223 224 SBCommandInterpreter sb_interpreter(GetCommandInterpreter ()); 225 SBCommandReturnObject result; 226 227 sb_interpreter.HandleCommand (command, result, false); 228 229 if (GetErrorFileHandle() != NULL) 230 result.PutError (GetErrorFileHandle()); 231 if (GetOutputFileHandle() != NULL) 232 result.PutOutput (GetOutputFileHandle()); 233 234 if (m_opaque_sp->GetAsyncExecution() == false) 235 { 236 SBProcess process(GetCommandInterpreter().GetProcess ()); 237 if (process.IsValid()) 238 { 239 EventSP event_sp; 240 Listener &lldb_listener = m_opaque_sp->GetListener(); 241 while (lldb_listener.GetNextEventForBroadcaster (process.get(), event_sp)) 242 { 243 SBEvent event(event_sp); 244 HandleProcessEvent (process, event, GetOutputFileHandle(), GetErrorFileHandle()); 245 } 246 } 247 } 248 } 249 } 250 251 SBListener 252 SBDebugger::GetListener () 253 { 254 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 255 256 SBListener sb_listener; 257 if (m_opaque_sp) 258 sb_listener.reset(&m_opaque_sp->GetListener(), false); 259 260 if (log) 261 log->Printf ("SBDebugger(%p)::GetListener () => SBListener(%p)", m_opaque_sp.get(), 262 sb_listener.get()); 263 264 return sb_listener; 265 } 266 267 void 268 SBDebugger::HandleProcessEvent (const SBProcess &process, const SBEvent &event, FILE *out, FILE *err) 269 { 270 if (!process.IsValid()) 271 return; 272 273 const uint32_t event_type = event.GetType(); 274 char stdio_buffer[1024]; 275 size_t len; 276 277 Mutex::Locker api_locker (process.GetTarget()->GetAPIMutex()); 278 279 if (event_type & (Process::eBroadcastBitSTDOUT | Process::eBroadcastBitStateChanged)) 280 { 281 // Drain stdout when we stop just in case we have any bytes 282 while ((len = process.GetSTDOUT (stdio_buffer, sizeof (stdio_buffer))) > 0) 283 if (out != NULL) 284 ::fwrite (stdio_buffer, 1, len, out); 285 } 286 287 if (event_type & (Process::eBroadcastBitSTDERR | Process::eBroadcastBitStateChanged)) 288 { 289 // Drain stderr when we stop just in case we have any bytes 290 while ((len = process.GetSTDERR (stdio_buffer, sizeof (stdio_buffer))) > 0) 291 if (err != NULL) 292 ::fwrite (stdio_buffer, 1, len, err); 293 } 294 295 if (event_type & Process::eBroadcastBitStateChanged) 296 { 297 StateType event_state = SBProcess::GetStateFromEvent (event); 298 299 if (event_state == eStateInvalid) 300 return; 301 302 bool is_stopped = StateIsStoppedState (event_state); 303 if (!is_stopped) 304 process.ReportEventState (event, out); 305 } 306 } 307 308 SBSourceManager & 309 SBDebugger::GetSourceManager () 310 { 311 static SourceManager g_lldb_source_manager; 312 static SBSourceManager g_sb_source_manager (&g_lldb_source_manager); 313 return g_sb_source_manager; 314 } 315 316 317 bool 318 SBDebugger::GetDefaultArchitecture (char *arch_name, size_t arch_name_len) 319 { 320 if (arch_name && arch_name_len) 321 { 322 ArchSpec default_arch = lldb_private::Target::GetDefaultArchitecture (); 323 324 if (default_arch.IsValid()) 325 { 326 ::snprintf (arch_name, arch_name_len, "%s", default_arch.AsCString()); 327 return true; 328 } 329 } 330 if (arch_name && arch_name_len) 331 arch_name[0] = '\0'; 332 return false; 333 } 334 335 336 bool 337 SBDebugger::SetDefaultArchitecture (const char *arch_name) 338 { 339 if (arch_name) 340 { 341 ArchSpec arch (arch_name); 342 if (arch.IsValid()) 343 { 344 lldb_private::Target::SetDefaultArchitecture (arch); 345 return true; 346 } 347 } 348 return false; 349 } 350 351 ScriptLanguage 352 SBDebugger::GetScriptingLanguage (const char *script_language_name) 353 { 354 355 return Args::StringToScriptLanguage (script_language_name, 356 eScriptLanguageDefault, 357 NULL); 358 } 359 360 const char * 361 SBDebugger::GetVersionString () 362 { 363 return lldb_private::GetVersion(); 364 } 365 366 const char * 367 SBDebugger::StateAsCString (lldb::StateType state) 368 { 369 return lldb_private::StateAsCString (state); 370 } 371 372 bool 373 SBDebugger::StateIsRunningState (lldb::StateType state) 374 { 375 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 376 377 const bool result = lldb_private::StateIsRunningState (state); 378 if (log) 379 log->Printf ("SBDebugger::StateIsRunningState (state=%s) => %i", 380 lldb_private::StateAsCString (state), result); 381 382 return result; 383 } 384 385 bool 386 SBDebugger::StateIsStoppedState (lldb::StateType state) 387 { 388 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 389 390 const bool result = lldb_private::StateIsStoppedState (state); 391 if (log) 392 log->Printf ("SBDebugger::StateIsStoppedState (state=%s) => %i", 393 lldb_private::StateAsCString (state), result); 394 395 return result; 396 } 397 398 399 SBTarget 400 SBDebugger::CreateTargetWithFileAndTargetTriple (const char *filename, 401 const char *target_triple) 402 { 403 SBTarget target; 404 if (m_opaque_sp) 405 { 406 ArchSpec arch; 407 FileSpec file_spec (filename, true); 408 arch.SetArchFromTargetTriple(target_triple); 409 TargetSP target_sp; 410 Error error (m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file_spec, arch, NULL, true, target_sp)); 411 target.reset (target_sp); 412 } 413 414 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 415 if (log) 416 { 417 log->Printf ("SBDebugger(%p)::CreateTargetWithFileAndTargetTriple (filename=\"%s\", triple=%s) => SBTarget(%p)", 418 m_opaque_sp.get(), filename, target_triple, target.get()); 419 } 420 421 return target; 422 } 423 424 SBTarget 425 SBDebugger::CreateTargetWithFileAndArch (const char *filename, const char *archname) 426 { 427 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 428 429 SBTarget target; 430 if (m_opaque_sp) 431 { 432 FileSpec file (filename, true); 433 ArchSpec arch = lldb_private::Target::GetDefaultArchitecture (); 434 TargetSP target_sp; 435 Error error; 436 437 if (archname != NULL) 438 { 439 ArchSpec arch2 (archname); 440 error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file, arch2, NULL, true, target_sp); 441 } 442 else 443 { 444 if (!arch.IsValid()) 445 arch = LLDB_ARCH_DEFAULT; 446 447 error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file, arch, NULL, true, target_sp); 448 449 if (error.Fail()) 450 { 451 if (arch == LLDB_ARCH_DEFAULT_32BIT) 452 arch = LLDB_ARCH_DEFAULT_64BIT; 453 else 454 arch = LLDB_ARCH_DEFAULT_32BIT; 455 456 error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file, arch, NULL, true, target_sp); 457 } 458 } 459 460 if (error.Success()) 461 { 462 m_opaque_sp->GetTargetList().SetSelectedTarget (target_sp.get()); 463 target.reset(target_sp); 464 } 465 } 466 467 if (log) 468 { 469 log->Printf ("SBDebugger(%p)::CreateTargetWithFileAndArch (filename=\"%s\", arch=%s) => SBTarget(%p)", 470 m_opaque_sp.get(), filename, archname, target.get()); 471 } 472 473 return target; 474 } 475 476 SBTarget 477 SBDebugger::CreateTarget (const char *filename) 478 { 479 SBTarget target; 480 if (m_opaque_sp) 481 { 482 FileSpec file (filename, true); 483 ArchSpec arch = lldb_private::Target::GetDefaultArchitecture (); 484 TargetSP target_sp; 485 Error error; 486 487 if (!arch.IsValid()) 488 arch = LLDB_ARCH_DEFAULT; 489 490 error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file, arch, NULL, true, target_sp); 491 492 if (error.Fail()) 493 { 494 if (arch == LLDB_ARCH_DEFAULT_32BIT) 495 arch = LLDB_ARCH_DEFAULT_64BIT; 496 else 497 arch = LLDB_ARCH_DEFAULT_32BIT; 498 499 error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file, arch, NULL, true, target_sp); 500 } 501 502 if (error.Success()) 503 { 504 m_opaque_sp->GetTargetList().SetSelectedTarget (target_sp.get()); 505 target.reset (target_sp); 506 } 507 } 508 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 509 if (log) 510 { 511 log->Printf ("SBDebugger(%p)::CreateTarget (filename=\"%s\") => SBTarget(%p)", 512 m_opaque_sp.get(), filename, target.get()); 513 } 514 return target; 515 } 516 517 SBTarget 518 SBDebugger::GetTargetAtIndex (uint32_t idx) 519 { 520 SBTarget sb_target; 521 if (m_opaque_sp) 522 { 523 // No need to lock, the target list is thread safe 524 sb_target.reset(m_opaque_sp->GetTargetList().GetTargetAtIndex (idx)); 525 } 526 return sb_target; 527 } 528 529 SBTarget 530 SBDebugger::FindTargetWithProcessID (pid_t pid) 531 { 532 SBTarget sb_target; 533 if (m_opaque_sp) 534 { 535 // No need to lock, the target list is thread safe 536 sb_target.reset(m_opaque_sp->GetTargetList().FindTargetWithProcessID (pid)); 537 } 538 return sb_target; 539 } 540 541 SBTarget 542 SBDebugger::FindTargetWithFileAndArch (const char *filename, const char *arch_name) 543 { 544 SBTarget sb_target; 545 if (m_opaque_sp && filename && filename[0]) 546 { 547 // No need to lock, the target list is thread safe 548 ArchSpec arch; 549 if (arch_name) 550 arch.SetArch(arch_name); 551 TargetSP target_sp (m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture (FileSpec(filename, false), arch_name ? &arch : NULL)); 552 sb_target.reset(target_sp); 553 } 554 return sb_target; 555 } 556 557 SBTarget 558 SBDebugger::FindTargetWithLLDBProcess (const lldb::ProcessSP &process_sp) 559 { 560 SBTarget sb_target; 561 if (m_opaque_sp) 562 { 563 // No need to lock, the target list is thread safe 564 sb_target.reset(m_opaque_sp->GetTargetList().FindTargetWithProcess (process_sp.get())); 565 } 566 return sb_target; 567 } 568 569 570 uint32_t 571 SBDebugger::GetNumTargets () 572 { 573 if (m_opaque_sp) 574 { 575 // No need to lock, the target list is thread safe 576 return m_opaque_sp->GetTargetList().GetNumTargets (); 577 } 578 return 0; 579 } 580 581 SBTarget 582 SBDebugger::GetSelectedTarget () 583 { 584 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 585 586 SBTarget sb_target; 587 if (m_opaque_sp) 588 { 589 // No need to lock, the target list is thread safe 590 sb_target.reset(m_opaque_sp->GetTargetList().GetSelectedTarget ()); 591 } 592 593 if (log) 594 { 595 SBStream sstr; 596 sb_target.GetDescription (sstr, lldb::eDescriptionLevelBrief); 597 log->Printf ("SBDebugger(%p)::GetSelectedTarget () => SBTarget(%p): %s", m_opaque_sp.get(), 598 sb_target.get(), sstr.GetData()); 599 } 600 601 return sb_target; 602 } 603 604 void 605 SBDebugger::DispatchInput (void *baton, const void *data, size_t data_len) 606 { 607 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 608 609 if (log) 610 log->Printf ("SBDebugger(%p)::DispatchInput (baton=%p, data=\"%.*s\", size_t=%zu)", m_opaque_sp.get(), 611 baton, (int) data_len, (const char *) data, data_len); 612 613 if (m_opaque_sp) 614 m_opaque_sp->DispatchInput ((const char *) data, data_len); 615 } 616 617 void 618 SBDebugger::DispatchInputInterrupt () 619 { 620 if (m_opaque_sp) 621 m_opaque_sp->DispatchInputInterrupt (); 622 } 623 624 void 625 SBDebugger::DispatchInputEndOfFile () 626 { 627 if (m_opaque_sp) 628 m_opaque_sp->DispatchInputEndOfFile (); 629 } 630 631 void 632 SBDebugger::PushInputReader (SBInputReader &reader) 633 { 634 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 635 636 if (log) 637 log->Printf ("SBDebugger(%p)::PushInputReader (SBInputReader(%p))", m_opaque_sp.get(), &reader); 638 639 if (m_opaque_sp && reader.IsValid()) 640 { 641 TargetSP target_sp (m_opaque_sp->GetSelectedTarget()); 642 Mutex::Locker api_locker; 643 if (target_sp) 644 api_locker.Reset(target_sp->GetAPIMutex().GetMutex()); 645 InputReaderSP reader_sp(*reader); 646 m_opaque_sp->PushInputReader (reader_sp); 647 } 648 } 649 650 void 651 SBDebugger::reset (const lldb::DebuggerSP &debugger_sp) 652 { 653 m_opaque_sp = debugger_sp; 654 } 655 656 Debugger * 657 SBDebugger::get () const 658 { 659 return m_opaque_sp.get(); 660 } 661 662 Debugger & 663 SBDebugger::ref () const 664 { 665 assert (m_opaque_sp.get()); 666 return *m_opaque_sp; 667 } 668 669 670 SBDebugger 671 SBDebugger::FindDebuggerWithID (int id) 672 { 673 // No need to lock, the debugger list is thread safe 674 SBDebugger sb_debugger; 675 lldb::DebuggerSP debugger_sp = Debugger::FindDebuggerWithID (id); 676 if (debugger_sp) 677 sb_debugger.reset (debugger_sp); 678 return sb_debugger; 679 } 680 681 const char * 682 SBDebugger::GetInstanceName() 683 { 684 if (m_opaque_sp) 685 return m_opaque_sp->GetInstanceName().AsCString(); 686 else 687 return NULL; 688 } 689 690 SBError 691 SBDebugger::SetInternalVariable (const char *var_name, const char *value, const char *debugger_instance_name) 692 { 693 lldb::UserSettingsControllerSP root_settings_controller = lldb_private::Debugger::GetSettingsController(); 694 695 Error err = root_settings_controller->SetVariable (var_name, value, lldb::eVarSetOperationAssign, true, 696 debugger_instance_name); 697 SBError sb_error; 698 sb_error.SetError (err); 699 700 return sb_error; 701 } 702 703 lldb::SBStringList 704 SBDebugger::GetInternalVariableValue (const char *var_name, const char *debugger_instance_name) 705 { 706 SBStringList ret_value; 707 lldb::SettableVariableType var_type; 708 lldb_private::Error err; 709 710 lldb::UserSettingsControllerSP root_settings_controller = lldb_private::Debugger::GetSettingsController(); 711 712 StringList value = root_settings_controller->GetVariable (var_name, var_type, debugger_instance_name, err); 713 714 if (err.Success()) 715 { 716 for (unsigned i = 0; i != value.GetSize(); ++i) 717 ret_value.AppendString (value.GetStringAtIndex(i)); 718 } 719 else 720 { 721 ret_value.AppendString (err.AsCString()); 722 } 723 724 725 return ret_value; 726 } 727 728 uint32_t 729 SBDebugger::GetTerminalWidth () const 730 { 731 if (m_opaque_sp) 732 return m_opaque_sp->GetTerminalWidth (); 733 return 0; 734 } 735 736 void 737 SBDebugger::SetTerminalWidth (uint32_t term_width) 738 { 739 if (m_opaque_sp) 740 m_opaque_sp->SetTerminalWidth (term_width); 741 } 742 743 const char * 744 SBDebugger::GetPrompt() const 745 { 746 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 747 748 if (log) 749 log->Printf ("SBDebugger(%p)::GetPrompt () => \"%s\"", m_opaque_sp.get(), 750 (m_opaque_sp ? m_opaque_sp->GetPrompt() : "")); 751 752 if (m_opaque_sp) 753 return m_opaque_sp->GetPrompt (); 754 return 0; 755 } 756 757 void 758 SBDebugger::SetPrompt (const char *prompt) 759 { 760 if (m_opaque_sp) 761 m_opaque_sp->SetPrompt (prompt); 762 } 763 764 765 lldb::ScriptLanguage 766 SBDebugger::GetScriptLanguage() const 767 { 768 if (m_opaque_sp) 769 return m_opaque_sp->GetScriptLanguage (); 770 return eScriptLanguageNone; 771 } 772 773 void 774 SBDebugger::SetScriptLanguage (lldb::ScriptLanguage script_lang) 775 { 776 if (m_opaque_sp) 777 { 778 m_opaque_sp->SetScriptLanguage (script_lang); 779 } 780 } 781 782 bool 783 SBDebugger::SetUseExternalEditor (bool value) 784 { 785 if (m_opaque_sp) 786 return m_opaque_sp->SetUseExternalEditor (value); 787 return false; 788 } 789 790 bool 791 SBDebugger::GetUseExternalEditor () 792 { 793 if (m_opaque_sp) 794 return m_opaque_sp->GetUseExternalEditor (); 795 return false; 796 } 797 798 bool 799 SBDebugger::GetDescription (SBStream &description) 800 { 801 if (m_opaque_sp) 802 { 803 const char *name = m_opaque_sp->GetInstanceName().AsCString(); 804 lldb::user_id_t id = m_opaque_sp->GetID(); 805 description.Printf ("Debugger (instance: \"%s\", id: %d)", name, id); 806 } 807 else 808 description.Printf ("No value"); 809 810 return true; 811 } 812 813 lldb::user_id_t 814 SBDebugger::GetID() 815 { 816 if (m_opaque_sp) 817 return m_opaque_sp->GetID(); 818 return LLDB_INVALID_UID; 819 } 820