1 //===-- SBCommandInterpreter.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/lldb-python.h" 11 12 #include "lldb/lldb-types.h" 13 #include "lldb/Core/SourceManager.h" 14 #include "lldb/Core/Listener.h" 15 #include "lldb/Interpreter/CommandInterpreter.h" 16 #include "lldb/Interpreter/CommandObjectMultiword.h" 17 #include "lldb/Interpreter/CommandReturnObject.h" 18 #include "lldb/Target/Target.h" 19 20 #include "lldb/API/SBBroadcaster.h" 21 #include "lldb/API/SBCommandReturnObject.h" 22 #include "lldb/API/SBCommandInterpreter.h" 23 #include "lldb/API/SBExecutionContext.h" 24 #include "lldb/API/SBProcess.h" 25 #include "lldb/API/SBTarget.h" 26 #include "lldb/API/SBListener.h" 27 #include "lldb/API/SBStream.h" 28 #include "lldb/API/SBStringList.h" 29 30 using namespace lldb; 31 using namespace lldb_private; 32 33 SBCommandInterpreterRunOptions::SBCommandInterpreterRunOptions() 34 { 35 m_opaque_up.reset(new CommandInterpreterRunOptions()); 36 } 37 38 SBCommandInterpreterRunOptions::~SBCommandInterpreterRunOptions() 39 { 40 41 } 42 43 bool 44 SBCommandInterpreterRunOptions::GetStopOnContinue () const 45 { 46 return m_opaque_up->GetStopOnContinue(); 47 } 48 49 void 50 SBCommandInterpreterRunOptions::SetStopOnContinue (bool stop_on_continue) 51 { 52 m_opaque_up->SetStopOnContinue(stop_on_continue); 53 } 54 55 bool 56 SBCommandInterpreterRunOptions::GetStopOnError () const 57 { 58 return m_opaque_up->GetStopOnError(); 59 } 60 61 void 62 SBCommandInterpreterRunOptions::SetStopOnError (bool stop_on_error) 63 { 64 m_opaque_up->SetStopOnError(stop_on_error); 65 } 66 67 bool 68 SBCommandInterpreterRunOptions::GetStopOnCrash () const 69 { 70 return m_opaque_up->GetStopOnCrash(); 71 } 72 73 void 74 SBCommandInterpreterRunOptions::SetStopOnCrash (bool stop_on_crash) 75 { 76 m_opaque_up->SetStopOnCrash(stop_on_crash); 77 } 78 79 bool 80 SBCommandInterpreterRunOptions::GetEchoCommands () const 81 { 82 return m_opaque_up->GetEchoCommands(); 83 } 84 85 void 86 SBCommandInterpreterRunOptions::SetEchoCommands (bool echo_commands) 87 { 88 m_opaque_up->SetEchoCommands(echo_commands); 89 } 90 91 bool 92 SBCommandInterpreterRunOptions::GetPrintResults () const 93 { 94 return m_opaque_up->GetPrintResults(); 95 } 96 97 void 98 SBCommandInterpreterRunOptions::SetPrintResults (bool print_results) 99 { 100 m_opaque_up->SetPrintResults(print_results); 101 } 102 103 bool 104 SBCommandInterpreterRunOptions::GetAddToHistory () const 105 { 106 return m_opaque_up->GetAddToHistory(); 107 } 108 109 void 110 SBCommandInterpreterRunOptions::SetAddToHistory (bool add_to_history) 111 { 112 m_opaque_up->SetAddToHistory(add_to_history); 113 } 114 115 lldb_private::CommandInterpreterRunOptions * 116 SBCommandInterpreterRunOptions::get () const 117 { 118 return m_opaque_up.get(); 119 } 120 121 lldb_private::CommandInterpreterRunOptions & 122 SBCommandInterpreterRunOptions::ref () const 123 { 124 return *m_opaque_up.get(); 125 } 126 127 class CommandPluginInterfaceImplementation : public CommandObjectParsed 128 { 129 public: 130 CommandPluginInterfaceImplementation (CommandInterpreter &interpreter, 131 const char *name, 132 lldb::SBCommandPluginInterface* backend, 133 const char *help = NULL, 134 const char *syntax = NULL, 135 uint32_t flags = 0) : 136 CommandObjectParsed (interpreter, name, help, syntax, flags), 137 m_backend(backend) {} 138 139 virtual bool 140 IsRemovable() const { return true; } 141 142 protected: 143 virtual bool 144 DoExecute (Args& command, CommandReturnObject &result) 145 { 146 SBCommandReturnObject sb_return(&result); 147 SBCommandInterpreter sb_interpreter(&m_interpreter); 148 SBDebugger debugger_sb(m_interpreter.GetDebugger().shared_from_this()); 149 bool ret = m_backend->DoExecute (debugger_sb,(char**)command.GetArgumentVector(), sb_return); 150 sb_return.Release(); 151 return ret; 152 } 153 lldb::SBCommandPluginInterface* m_backend; 154 }; 155 156 SBCommandInterpreter::SBCommandInterpreter (CommandInterpreter *interpreter) : 157 m_opaque_ptr (interpreter) 158 { 159 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 160 161 if (log) 162 log->Printf ("SBCommandInterpreter::SBCommandInterpreter (interpreter=%p)" 163 " => SBCommandInterpreter(%p)", 164 static_cast<void*>(interpreter), 165 static_cast<void*>(m_opaque_ptr)); 166 } 167 168 SBCommandInterpreter::SBCommandInterpreter(const SBCommandInterpreter &rhs) : 169 m_opaque_ptr (rhs.m_opaque_ptr) 170 { 171 } 172 173 const SBCommandInterpreter & 174 SBCommandInterpreter::operator = (const SBCommandInterpreter &rhs) 175 { 176 m_opaque_ptr = rhs.m_opaque_ptr; 177 return *this; 178 } 179 180 SBCommandInterpreter::~SBCommandInterpreter () 181 { 182 } 183 184 bool 185 SBCommandInterpreter::IsValid() const 186 { 187 return m_opaque_ptr != NULL; 188 } 189 190 191 bool 192 SBCommandInterpreter::CommandExists (const char *cmd) 193 { 194 if (cmd && m_opaque_ptr) 195 return m_opaque_ptr->CommandExists (cmd); 196 return false; 197 } 198 199 bool 200 SBCommandInterpreter::AliasExists (const char *cmd) 201 { 202 if (cmd && m_opaque_ptr) 203 return m_opaque_ptr->AliasExists (cmd); 204 return false; 205 } 206 207 bool 208 SBCommandInterpreter::IsActive () 209 { 210 if (m_opaque_ptr) 211 return m_opaque_ptr->IsActive (); 212 return false; 213 } 214 215 const char * 216 SBCommandInterpreter::GetIOHandlerControlSequence(char ch) 217 { 218 if (m_opaque_ptr) 219 return m_opaque_ptr->GetDebugger().GetTopIOHandlerControlSequence (ch).GetCString(); 220 return NULL; 221 } 222 223 lldb::ReturnStatus 224 SBCommandInterpreter::HandleCommand (const char *command_line, SBCommandReturnObject &result, bool add_to_history) 225 { 226 SBExecutionContext sb_exe_ctx; 227 return HandleCommand (command_line, sb_exe_ctx, result, add_to_history); 228 } 229 230 lldb::ReturnStatus 231 SBCommandInterpreter::HandleCommand (const char *command_line, SBExecutionContext &override_context, SBCommandReturnObject &result, bool add_to_history) 232 { 233 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 234 235 if (log) 236 log->Printf ("SBCommandInterpreter(%p)::HandleCommand (command=\"%s\", SBCommandReturnObject(%p), add_to_history=%i)", 237 static_cast<void*>(m_opaque_ptr), command_line, 238 static_cast<void*>(result.get()), add_to_history); 239 240 ExecutionContext ctx, *ctx_ptr; 241 if (override_context.get()) 242 { 243 ctx = override_context.get()->Lock(true); 244 ctx_ptr = &ctx; 245 } 246 else 247 ctx_ptr = nullptr; 248 249 250 result.Clear(); 251 if (command_line && m_opaque_ptr) 252 { 253 result.ref().SetInteractive(false); 254 m_opaque_ptr->HandleCommand (command_line, add_to_history ? eLazyBoolYes : eLazyBoolNo, result.ref(), ctx_ptr); 255 } 256 else 257 { 258 result->AppendError ("SBCommandInterpreter or the command line is not valid"); 259 result->SetStatus (eReturnStatusFailed); 260 } 261 262 // We need to get the value again, in case the command disabled the log! 263 log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); 264 if (log) 265 { 266 SBStream sstr; 267 result.GetDescription (sstr); 268 log->Printf ("SBCommandInterpreter(%p)::HandleCommand (command=\"%s\", SBCommandReturnObject(%p): %s, add_to_history=%i) => %i", 269 static_cast<void*>(m_opaque_ptr), command_line, 270 static_cast<void*>(result.get()), sstr.GetData(), 271 add_to_history, result.GetStatus()); 272 } 273 274 return result.GetStatus(); 275 } 276 277 void 278 SBCommandInterpreter::HandleCommandsFromFile (lldb::SBFileSpec &file, 279 lldb::SBExecutionContext &override_context, 280 lldb::SBCommandInterpreterRunOptions &options, 281 lldb::SBCommandReturnObject result) 282 { 283 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 284 285 if (log) 286 { 287 SBStream s; 288 file.GetDescription (s); 289 log->Printf ("SBCommandInterpreter(%p)::HandleCommandsFromFile (file=\"%s\", SBCommandReturnObject(%p))", 290 static_cast<void*>(m_opaque_ptr), s.GetData(), 291 static_cast<void*>(result.get())); 292 } 293 294 if (!m_opaque_ptr) 295 { 296 result->AppendError ("SBCommandInterpreter is not valid."); 297 result->SetStatus (eReturnStatusFailed); 298 return; 299 } 300 301 if (!file.IsValid()) 302 { 303 SBStream s; 304 file.GetDescription (s); 305 result->AppendErrorWithFormat ("File is not valid: %s.", s.GetData()); 306 result->SetStatus (eReturnStatusFailed); 307 } 308 309 FileSpec tmp_spec = file.ref(); 310 ExecutionContext ctx, *ctx_ptr; 311 if (override_context.get()) 312 { 313 ctx = override_context.get()->Lock(true); 314 ctx_ptr = &ctx; 315 } 316 else 317 ctx_ptr = nullptr; 318 319 320 m_opaque_ptr->HandleCommandsFromFile (tmp_spec, ctx_ptr, options.ref(), result.ref()); 321 322 } 323 324 325 int 326 SBCommandInterpreter::HandleCompletion (const char *current_line, 327 const char *cursor, 328 const char *last_char, 329 int match_start_point, 330 int max_return_elements, 331 SBStringList &matches) 332 { 333 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 334 int num_completions = 0; 335 336 // Sanity check the arguments that are passed in: 337 // cursor & last_char have to be within the current_line. 338 if (current_line == NULL || cursor == NULL || last_char == NULL) 339 return 0; 340 341 if (cursor < current_line || last_char < current_line) 342 return 0; 343 344 size_t current_line_size = strlen (current_line); 345 if (cursor - current_line > static_cast<ptrdiff_t>(current_line_size) || 346 last_char - current_line > static_cast<ptrdiff_t>(current_line_size)) 347 return 0; 348 349 if (log) 350 log->Printf ("SBCommandInterpreter(%p)::HandleCompletion (current_line=\"%s\", cursor at: %" PRId64 ", last char at: %" PRId64 ", match_start_point: %d, max_return_elements: %d)", 351 static_cast<void*>(m_opaque_ptr), current_line, 352 static_cast<uint64_t>(cursor - current_line), 353 static_cast<uint64_t>(last_char - current_line), 354 match_start_point, max_return_elements); 355 356 if (m_opaque_ptr) 357 { 358 lldb_private::StringList lldb_matches; 359 num_completions = m_opaque_ptr->HandleCompletion (current_line, cursor, last_char, match_start_point, 360 max_return_elements, lldb_matches); 361 362 SBStringList temp_list (&lldb_matches); 363 matches.AppendList (temp_list); 364 } 365 if (log) 366 log->Printf ("SBCommandInterpreter(%p)::HandleCompletion - Found %d completions.", 367 static_cast<void*>(m_opaque_ptr), num_completions); 368 369 return num_completions; 370 } 371 372 int 373 SBCommandInterpreter::HandleCompletion (const char *current_line, 374 uint32_t cursor_pos, 375 int match_start_point, 376 int max_return_elements, 377 lldb::SBStringList &matches) 378 { 379 const char *cursor = current_line + cursor_pos; 380 const char *last_char = current_line + strlen (current_line); 381 return HandleCompletion (current_line, cursor, last_char, match_start_point, max_return_elements, matches); 382 } 383 384 bool 385 SBCommandInterpreter::HasCommands () 386 { 387 if (m_opaque_ptr) 388 return m_opaque_ptr->HasCommands(); 389 return false; 390 } 391 392 bool 393 SBCommandInterpreter::HasAliases () 394 { 395 if (m_opaque_ptr) 396 return m_opaque_ptr->HasAliases(); 397 return false; 398 } 399 400 bool 401 SBCommandInterpreter::HasAliasOptions () 402 { 403 if (m_opaque_ptr) 404 return m_opaque_ptr->HasAliasOptions (); 405 return false; 406 } 407 408 SBProcess 409 SBCommandInterpreter::GetProcess () 410 { 411 SBProcess sb_process; 412 ProcessSP process_sp; 413 if (m_opaque_ptr) 414 { 415 TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); 416 if (target_sp) 417 { 418 Mutex::Locker api_locker(target_sp->GetAPIMutex()); 419 process_sp = target_sp->GetProcessSP(); 420 sb_process.SetSP(process_sp); 421 } 422 } 423 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 424 425 if (log) 426 log->Printf ("SBCommandInterpreter(%p)::GetProcess () => SBProcess(%p)", 427 static_cast<void*>(m_opaque_ptr), 428 static_cast<void*>(process_sp.get())); 429 430 return sb_process; 431 } 432 433 SBDebugger 434 SBCommandInterpreter::GetDebugger () 435 { 436 SBDebugger sb_debugger; 437 if (m_opaque_ptr) 438 sb_debugger.reset(m_opaque_ptr->GetDebugger().shared_from_this()); 439 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 440 441 if (log) 442 log->Printf ("SBCommandInterpreter(%p)::GetDebugger () => SBDebugger(%p)", 443 static_cast<void*>(m_opaque_ptr), 444 static_cast<void*>(sb_debugger.get())); 445 446 return sb_debugger; 447 } 448 449 CommandInterpreter * 450 SBCommandInterpreter::get () 451 { 452 return m_opaque_ptr; 453 } 454 455 CommandInterpreter & 456 SBCommandInterpreter::ref () 457 { 458 assert (m_opaque_ptr); 459 return *m_opaque_ptr; 460 } 461 462 void 463 SBCommandInterpreter::reset (lldb_private::CommandInterpreter *interpreter) 464 { 465 m_opaque_ptr = interpreter; 466 } 467 468 void 469 SBCommandInterpreter::SourceInitFileInHomeDirectory (SBCommandReturnObject &result) 470 { 471 result.Clear(); 472 if (m_opaque_ptr) 473 { 474 TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); 475 Mutex::Locker api_locker; 476 if (target_sp) 477 api_locker.Lock(target_sp->GetAPIMutex()); 478 m_opaque_ptr->SourceInitFile (false, result.ref()); 479 } 480 else 481 { 482 result->AppendError ("SBCommandInterpreter is not valid"); 483 result->SetStatus (eReturnStatusFailed); 484 } 485 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 486 487 if (log) 488 log->Printf ("SBCommandInterpreter(%p)::SourceInitFileInHomeDirectory (&SBCommandReturnObject(%p))", 489 static_cast<void*>(m_opaque_ptr), 490 static_cast<void*>(result.get())); 491 } 492 493 void 494 SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory (SBCommandReturnObject &result) 495 { 496 result.Clear(); 497 if (m_opaque_ptr) 498 { 499 TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); 500 Mutex::Locker api_locker; 501 if (target_sp) 502 api_locker.Lock(target_sp->GetAPIMutex()); 503 m_opaque_ptr->SourceInitFile (true, result.ref()); 504 } 505 else 506 { 507 result->AppendError ("SBCommandInterpreter is not valid"); 508 result->SetStatus (eReturnStatusFailed); 509 } 510 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 511 512 if (log) 513 log->Printf ("SBCommandInterpreter(%p)::SourceInitFileInCurrentWorkingDirectory (&SBCommandReturnObject(%p))", 514 static_cast<void*>(m_opaque_ptr), 515 static_cast<void*>(result.get())); 516 } 517 518 SBBroadcaster 519 SBCommandInterpreter::GetBroadcaster () 520 { 521 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 522 523 SBBroadcaster broadcaster (m_opaque_ptr, false); 524 525 if (log) 526 log->Printf ("SBCommandInterpreter(%p)::GetBroadcaster() => SBBroadcaster(%p)", 527 static_cast<void*>(m_opaque_ptr), static_cast<void*>(broadcaster.get())); 528 529 return broadcaster; 530 } 531 532 const char * 533 SBCommandInterpreter::GetBroadcasterClass () 534 { 535 return Communication::GetStaticBroadcasterClass().AsCString(); 536 } 537 538 const char * 539 SBCommandInterpreter::GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type) 540 { 541 return CommandObject::GetArgumentTypeAsCString (arg_type); 542 } 543 544 const char * 545 SBCommandInterpreter::GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type) 546 { 547 return CommandObject::GetArgumentDescriptionAsCString (arg_type); 548 } 549 550 bool 551 SBCommandInterpreter::SetCommandOverrideCallback (const char *command_name, 552 lldb::CommandOverrideCallback callback, 553 void *baton) 554 { 555 if (command_name && command_name[0] && m_opaque_ptr) 556 { 557 std::string command_name_str (command_name); 558 CommandObject *cmd_obj = m_opaque_ptr->GetCommandObjectForCommand(command_name_str); 559 if (cmd_obj) 560 { 561 assert(command_name_str.empty()); 562 cmd_obj->SetOverrideCallback (callback, baton); 563 return true; 564 } 565 } 566 return false; 567 } 568 569 #ifndef LLDB_DISABLE_PYTHON 570 571 // Defined in the SWIG source file 572 extern "C" void 573 init_lldb(void); 574 575 // these are the Pythonic implementations of the required callbacks 576 // these are scripting-language specific, which is why they belong here 577 // we still need to use function pointers to them instead of relying 578 // on linkage-time resolution because the SWIG stuff and this file 579 // get built at different times 580 extern "C" bool 581 LLDBSwigPythonBreakpointCallbackFunction (const char *python_function_name, 582 const char *session_dictionary_name, 583 const lldb::StackFrameSP& sb_frame, 584 const lldb::BreakpointLocationSP& sb_bp_loc); 585 586 extern "C" bool 587 LLDBSwigPythonWatchpointCallbackFunction (const char *python_function_name, 588 const char *session_dictionary_name, 589 const lldb::StackFrameSP& sb_frame, 590 const lldb::WatchpointSP& sb_wp); 591 592 extern "C" bool 593 LLDBSwigPythonCallTypeScript (const char *python_function_name, 594 void *session_dictionary, 595 const lldb::ValueObjectSP& valobj_sp, 596 void** pyfunct_wrapper, 597 std::string& retval); 598 599 extern "C" void* 600 LLDBSwigPythonCreateSyntheticProvider (const char *python_class_name, 601 const char *session_dictionary_name, 602 const lldb::ValueObjectSP& valobj_sp); 603 604 605 extern "C" void* 606 LLDBSwigPythonCreateScriptedThreadPlan (const char *python_class_name, 607 const char *session_dictionary_name, 608 const lldb::ThreadPlanSP& thread_plan_sp); 609 610 extern "C" bool 611 LLDBSWIGPythonCallThreadPlan (void *implementor, 612 const char *method_name, 613 Event *event_sp, 614 bool &got_error); 615 616 extern "C" uint32_t 617 LLDBSwigPython_CalculateNumChildren (void *implementor); 618 619 extern "C" void * 620 LLDBSwigPython_GetChildAtIndex (void *implementor, uint32_t idx); 621 622 extern "C" int 623 LLDBSwigPython_GetIndexOfChildWithName (void *implementor, const char* child_name); 624 625 extern "C" void * 626 LLDBSWIGPython_CastPyObjectToSBValue (void* data); 627 628 extern lldb::ValueObjectSP 629 LLDBSWIGPython_GetValueObjectSPFromSBValue (void* data); 630 631 extern "C" bool 632 LLDBSwigPython_UpdateSynthProviderInstance (void* implementor); 633 634 extern "C" bool 635 LLDBSwigPython_MightHaveChildrenSynthProviderInstance (void* implementor); 636 637 extern "C" void * 638 LLDBSwigPython_GetValueSynthProviderInstance (void* implementor); 639 640 extern "C" bool 641 LLDBSwigPythonCallCommand (const char *python_function_name, 642 const char *session_dictionary_name, 643 lldb::DebuggerSP& debugger, 644 const char* args, 645 lldb_private::CommandReturnObject &cmd_retobj, 646 lldb::ExecutionContextRefSP exe_ctx_ref_sp); 647 648 extern "C" bool 649 LLDBSwigPythonCallModuleInit (const char *python_module_name, 650 const char *session_dictionary_name, 651 lldb::DebuggerSP& debugger); 652 653 extern "C" void* 654 LLDBSWIGPythonCreateOSPlugin (const char *python_class_name, 655 const char *session_dictionary_name, 656 const lldb::ProcessSP& process_sp); 657 658 extern "C" bool 659 LLDBSWIGPythonRunScriptKeywordProcess (const char* python_function_name, 660 const char* session_dictionary_name, 661 lldb::ProcessSP& process, 662 std::string& output); 663 664 extern "C" bool 665 LLDBSWIGPythonRunScriptKeywordThread (const char* python_function_name, 666 const char* session_dictionary_name, 667 lldb::ThreadSP& thread, 668 std::string& output); 669 670 extern "C" bool 671 LLDBSWIGPythonRunScriptKeywordTarget (const char* python_function_name, 672 const char* session_dictionary_name, 673 lldb::TargetSP& target, 674 std::string& output); 675 676 extern "C" bool 677 LLDBSWIGPythonRunScriptKeywordFrame (const char* python_function_name, 678 const char* session_dictionary_name, 679 lldb::StackFrameSP& frame, 680 std::string& output); 681 682 extern "C" void* 683 LLDBSWIGPython_GetDynamicSetting (void* module, 684 const char* setting, 685 const lldb::TargetSP& target_sp); 686 687 688 #endif 689 690 void 691 SBCommandInterpreter::InitializeSWIG () 692 { 693 static bool g_initialized = false; 694 if (!g_initialized) 695 { 696 g_initialized = true; 697 #ifndef LLDB_DISABLE_PYTHON 698 ScriptInterpreter::InitializeInterpreter (init_lldb, 699 LLDBSwigPythonBreakpointCallbackFunction, 700 LLDBSwigPythonWatchpointCallbackFunction, 701 LLDBSwigPythonCallTypeScript, 702 LLDBSwigPythonCreateSyntheticProvider, 703 LLDBSwigPython_CalculateNumChildren, 704 LLDBSwigPython_GetChildAtIndex, 705 LLDBSwigPython_GetIndexOfChildWithName, 706 LLDBSWIGPython_CastPyObjectToSBValue, 707 LLDBSWIGPython_GetValueObjectSPFromSBValue, 708 LLDBSwigPython_UpdateSynthProviderInstance, 709 LLDBSwigPython_MightHaveChildrenSynthProviderInstance, 710 LLDBSwigPython_GetValueSynthProviderInstance, 711 LLDBSwigPythonCallCommand, 712 LLDBSwigPythonCallModuleInit, 713 LLDBSWIGPythonCreateOSPlugin, 714 LLDBSWIGPythonRunScriptKeywordProcess, 715 LLDBSWIGPythonRunScriptKeywordThread, 716 LLDBSWIGPythonRunScriptKeywordTarget, 717 LLDBSWIGPythonRunScriptKeywordFrame, 718 LLDBSWIGPython_GetDynamicSetting, 719 LLDBSwigPythonCreateScriptedThreadPlan, 720 LLDBSWIGPythonCallThreadPlan); 721 #endif 722 } 723 } 724 725 lldb::SBCommand 726 SBCommandInterpreter::AddMultiwordCommand (const char* name, const char* help) 727 { 728 CommandObjectMultiword *new_command = new CommandObjectMultiword(*m_opaque_ptr,name,help); 729 new_command->SetRemovable (true); 730 lldb::CommandObjectSP new_command_sp(new_command); 731 if (new_command_sp && m_opaque_ptr->AddUserCommand(name, new_command_sp, true)) 732 return lldb::SBCommand(new_command_sp); 733 return lldb::SBCommand(); 734 } 735 736 lldb::SBCommand 737 SBCommandInterpreter::AddCommand (const char* name, lldb::SBCommandPluginInterface* impl, const char* help) 738 { 739 lldb::CommandObjectSP new_command_sp; 740 new_command_sp.reset(new CommandPluginInterfaceImplementation(*m_opaque_ptr,name,impl,help)); 741 742 if (new_command_sp && m_opaque_ptr->AddUserCommand(name, new_command_sp, true)) 743 return lldb::SBCommand(new_command_sp); 744 return lldb::SBCommand(); 745 } 746 747 SBCommand::SBCommand () 748 {} 749 750 SBCommand::SBCommand (lldb::CommandObjectSP cmd_sp) : m_opaque_sp (cmd_sp) 751 {} 752 753 bool 754 SBCommand::IsValid () 755 { 756 return (bool)m_opaque_sp; 757 } 758 759 const char* 760 SBCommand::GetName () 761 { 762 if (IsValid ()) 763 return m_opaque_sp->GetCommandName (); 764 return NULL; 765 } 766 767 const char* 768 SBCommand::GetHelp () 769 { 770 if (IsValid ()) 771 return m_opaque_sp->GetHelp (); 772 return NULL; 773 } 774 775 lldb::SBCommand 776 SBCommand::AddMultiwordCommand (const char* name, const char* help) 777 { 778 if (!IsValid ()) 779 return lldb::SBCommand(); 780 if (m_opaque_sp->IsMultiwordObject() == false) 781 return lldb::SBCommand(); 782 CommandObjectMultiword *new_command = new CommandObjectMultiword(m_opaque_sp->GetCommandInterpreter(),name,help); 783 new_command->SetRemovable (true); 784 lldb::CommandObjectSP new_command_sp(new_command); 785 if (new_command_sp && m_opaque_sp->LoadSubCommand(name,new_command_sp)) 786 return lldb::SBCommand(new_command_sp); 787 return lldb::SBCommand(); 788 } 789 790 lldb::SBCommand 791 SBCommand::AddCommand (const char* name, lldb::SBCommandPluginInterface *impl, const char* help) 792 { 793 if (!IsValid ()) 794 return lldb::SBCommand(); 795 if (m_opaque_sp->IsMultiwordObject() == false) 796 return lldb::SBCommand(); 797 lldb::CommandObjectSP new_command_sp; 798 new_command_sp.reset(new CommandPluginInterfaceImplementation(m_opaque_sp->GetCommandInterpreter(),name,impl,help)); 799 if (new_command_sp && m_opaque_sp->LoadSubCommand(name,new_command_sp)) 800 return lldb::SBCommand(new_command_sp); 801 return lldb::SBCommand(); 802 } 803 804