1 //===-- SBTarget.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/SBTarget.h" 11 12 #include "lldb/lldb-public.h" 13 14 #include "lldb/API/SBDebugger.h" 15 #include "lldb/API/SBBreakpoint.h" 16 #include "lldb/API/SBFileSpec.h" 17 #include "lldb/API/SBListener.h" 18 #include "lldb/API/SBModule.h" 19 #include "lldb/API/SBSourceManager.h" 20 #include "lldb/API/SBProcess.h" 21 #include "lldb/API/SBStream.h" 22 #include "lldb/API/SBSymbolContextList.h" 23 #include "lldb/Breakpoint/BreakpointID.h" 24 #include "lldb/Breakpoint/BreakpointIDList.h" 25 #include "lldb/Breakpoint/BreakpointList.h" 26 #include "lldb/Breakpoint/BreakpointLocation.h" 27 #include "lldb/Core/Address.h" 28 #include "lldb/Core/AddressResolver.h" 29 #include "lldb/Core/AddressResolverName.h" 30 #include "lldb/Core/ArchSpec.h" 31 #include "lldb/Core/Debugger.h" 32 #include "lldb/Core/Disassembler.h" 33 #include "lldb/Core/Log.h" 34 #include "lldb/Core/RegularExpression.h" 35 #include "lldb/Core/SearchFilter.h" 36 #include "lldb/Core/STLUtils.h" 37 #include "lldb/Core/ValueObjectList.h" 38 #include "lldb/Core/ValueObjectVariable.h" 39 #include "lldb/Host/FileSpec.h" 40 #include "lldb/Host/Host.h" 41 #include "lldb/Interpreter/Args.h" 42 #include "lldb/Symbol/SymbolVendor.h" 43 #include "lldb/Symbol/VariableList.h" 44 #include "lldb/Target/LanguageRuntime.h" 45 #include "lldb/Target/Process.h" 46 #include "lldb/Target/Target.h" 47 #include "lldb/Target/TargetList.h" 48 49 #include "lldb/Interpreter/CommandReturnObject.h" 50 #include "../source/Commands/CommandObjectBreakpoint.h" 51 52 53 using namespace lldb; 54 using namespace lldb_private; 55 56 #define DEFAULT_DISASM_BYTE_SIZE 32 57 58 SBLaunchInfo::SBLaunchInfo (const char **argv) : 59 m_opaque_sp(new ProcessLaunchInfo()) 60 { 61 m_opaque_sp->GetFlags().Reset (eLaunchFlagDebug | eLaunchFlagDisableASLR); 62 if (argv && argv[0]) 63 m_opaque_sp->GetArguments().SetArguments(argv); 64 } 65 66 SBLaunchInfo::~SBLaunchInfo() 67 { 68 } 69 70 lldb_private::ProcessLaunchInfo & 71 SBLaunchInfo::ref () 72 { 73 return *m_opaque_sp; 74 } 75 76 77 uint32_t 78 SBLaunchInfo::GetUserID() 79 { 80 return m_opaque_sp->GetUserID(); 81 } 82 83 uint32_t 84 SBLaunchInfo::GetGroupID() 85 { 86 return m_opaque_sp->GetGroupID(); 87 } 88 89 bool 90 SBLaunchInfo::UserIDIsValid () 91 { 92 return m_opaque_sp->UserIDIsValid(); 93 } 94 95 bool 96 SBLaunchInfo::GroupIDIsValid () 97 { 98 return m_opaque_sp->GroupIDIsValid(); 99 } 100 101 void 102 SBLaunchInfo::SetUserID (uint32_t uid) 103 { 104 m_opaque_sp->SetUserID (uid); 105 } 106 107 void 108 SBLaunchInfo::SetGroupID (uint32_t gid) 109 { 110 m_opaque_sp->SetGroupID (gid); 111 } 112 113 uint32_t 114 SBLaunchInfo::GetNumArguments () 115 { 116 return m_opaque_sp->GetArguments().GetArgumentCount(); 117 } 118 119 const char * 120 SBLaunchInfo::GetArgumentAtIndex (uint32_t idx) 121 { 122 return m_opaque_sp->GetArguments().GetArgumentAtIndex(idx); 123 } 124 125 void 126 SBLaunchInfo::SetArguments (const char **argv, bool append) 127 { 128 if (append) 129 { 130 if (argv) 131 m_opaque_sp->GetArguments().AppendArguments(argv); 132 } 133 else 134 { 135 if (argv) 136 m_opaque_sp->GetArguments().SetArguments(argv); 137 else 138 m_opaque_sp->GetArguments().Clear(); 139 } 140 } 141 142 uint32_t 143 SBLaunchInfo::GetNumEnvironmentEntries () 144 { 145 return m_opaque_sp->GetEnvironmentEntries().GetArgumentCount(); 146 } 147 148 const char * 149 SBLaunchInfo::GetEnvironmentEntryAtIndex (uint32_t idx) 150 { 151 return m_opaque_sp->GetEnvironmentEntries().GetArgumentAtIndex(idx); 152 } 153 154 void 155 SBLaunchInfo::SetEnvironmentEntries (const char **envp, bool append) 156 { 157 if (append) 158 { 159 if (envp) 160 m_opaque_sp->GetEnvironmentEntries().AppendArguments(envp); 161 } 162 else 163 { 164 if (envp) 165 m_opaque_sp->GetEnvironmentEntries().SetArguments(envp); 166 else 167 m_opaque_sp->GetEnvironmentEntries().Clear(); 168 } 169 } 170 171 void 172 SBLaunchInfo::Clear () 173 { 174 m_opaque_sp->Clear(); 175 } 176 177 const char * 178 SBLaunchInfo::GetWorkingDirectory () const 179 { 180 return m_opaque_sp->GetWorkingDirectory(); 181 } 182 183 void 184 SBLaunchInfo::SetWorkingDirectory (const char *working_dir) 185 { 186 m_opaque_sp->SetWorkingDirectory(working_dir); 187 } 188 189 uint32_t 190 SBLaunchInfo::GetLaunchFlags () 191 { 192 return m_opaque_sp->GetFlags().Get(); 193 } 194 195 void 196 SBLaunchInfo::SetLaunchFlags (uint32_t flags) 197 { 198 m_opaque_sp->GetFlags().Reset(flags); 199 } 200 201 const char * 202 SBLaunchInfo::GetProcessPluginName () 203 { 204 return m_opaque_sp->GetProcessPluginName(); 205 } 206 207 void 208 SBLaunchInfo::SetProcessPluginName (const char *plugin_name) 209 { 210 return m_opaque_sp->SetProcessPluginName (plugin_name); 211 } 212 213 const char * 214 SBLaunchInfo::GetShell () 215 { 216 return m_opaque_sp->GetShell(); 217 } 218 219 void 220 SBLaunchInfo::SetShell (const char * path) 221 { 222 m_opaque_sp->SetShell (path); 223 } 224 225 uint32_t 226 SBLaunchInfo::GetResumeCount () 227 { 228 return m_opaque_sp->GetResumeCount(); 229 } 230 231 void 232 SBLaunchInfo::SetResumeCount (uint32_t c) 233 { 234 m_opaque_sp->SetResumeCount (c); 235 } 236 237 bool 238 SBLaunchInfo::AddCloseFileAction (int fd) 239 { 240 return m_opaque_sp->AppendCloseFileAction(fd); 241 } 242 243 bool 244 SBLaunchInfo::AddDuplicateFileAction (int fd, int dup_fd) 245 { 246 return m_opaque_sp->AppendDuplicateFileAction(fd, dup_fd); 247 } 248 249 bool 250 SBLaunchInfo::AddOpenFileAction (int fd, const char *path, bool read, bool write) 251 { 252 return m_opaque_sp->AppendOpenFileAction(fd, path, read, write); 253 } 254 255 bool 256 SBLaunchInfo::AddSuppressFileAction (int fd, bool read, bool write) 257 { 258 return m_opaque_sp->AppendSuppressFileAction(fd, read, write); 259 } 260 261 262 SBAttachInfo::SBAttachInfo () : 263 m_opaque_sp (new ProcessAttachInfo()) 264 { 265 } 266 267 SBAttachInfo::SBAttachInfo (lldb::pid_t pid) : 268 m_opaque_sp (new ProcessAttachInfo()) 269 { 270 m_opaque_sp->SetProcessID (pid); 271 } 272 273 SBAttachInfo::SBAttachInfo (const char *path, bool wait_for) : 274 m_opaque_sp (new ProcessAttachInfo()) 275 { 276 if (path && path[0]) 277 m_opaque_sp->GetExecutableFile().SetFile(path, false); 278 m_opaque_sp->SetWaitForLaunch (wait_for); 279 } 280 281 SBAttachInfo::SBAttachInfo (const SBAttachInfo &rhs) : 282 m_opaque_sp (new ProcessAttachInfo()) 283 { 284 *m_opaque_sp = *rhs.m_opaque_sp; 285 } 286 287 SBAttachInfo::~SBAttachInfo() 288 { 289 } 290 291 lldb_private::ProcessAttachInfo & 292 SBAttachInfo::ref () 293 { 294 return *m_opaque_sp; 295 } 296 297 SBAttachInfo & 298 SBAttachInfo::operator = (const SBAttachInfo &rhs) 299 { 300 if (this != &rhs) 301 *m_opaque_sp = *rhs.m_opaque_sp; 302 return *this; 303 } 304 305 lldb::pid_t 306 SBAttachInfo::GetProcessID () 307 { 308 return m_opaque_sp->GetProcessID(); 309 } 310 311 void 312 SBAttachInfo::SetProcessID (lldb::pid_t pid) 313 { 314 m_opaque_sp->SetProcessID (pid); 315 } 316 317 318 uint32_t 319 SBAttachInfo::GetResumeCount () 320 { 321 return m_opaque_sp->GetResumeCount(); 322 } 323 324 void 325 SBAttachInfo::SetResumeCount (uint32_t c) 326 { 327 m_opaque_sp->SetResumeCount (c); 328 } 329 330 const char * 331 SBAttachInfo::GetProcessPluginName () 332 { 333 return m_opaque_sp->GetProcessPluginName(); 334 } 335 336 void 337 SBAttachInfo::SetProcessPluginName (const char *plugin_name) 338 { 339 return m_opaque_sp->SetProcessPluginName (plugin_name); 340 } 341 342 void 343 SBAttachInfo::SetExecutable (const char *path) 344 { 345 if (path && path[0]) 346 m_opaque_sp->GetExecutableFile().SetFile(path, false); 347 else 348 m_opaque_sp->GetExecutableFile().Clear(); 349 } 350 351 void 352 SBAttachInfo::SetExecutable (SBFileSpec exe_file) 353 { 354 if (exe_file.IsValid()) 355 m_opaque_sp->GetExecutableFile() = exe_file.ref(); 356 else 357 m_opaque_sp->GetExecutableFile().Clear(); 358 } 359 360 bool 361 SBAttachInfo::GetWaitForLaunch () 362 { 363 return m_opaque_sp->GetWaitForLaunch(); 364 } 365 366 void 367 SBAttachInfo::SetWaitForLaunch (bool b) 368 { 369 m_opaque_sp->SetWaitForLaunch (b); 370 } 371 372 bool 373 SBAttachInfo::GetIgnoreExisting () 374 { 375 return m_opaque_sp->GetIgnoreExisting(); 376 } 377 378 void 379 SBAttachInfo::SetIgnoreExisting (bool b) 380 { 381 m_opaque_sp->SetIgnoreExisting (b); 382 } 383 384 uint32_t 385 SBAttachInfo::GetUserID() 386 { 387 return m_opaque_sp->GetUserID(); 388 } 389 390 uint32_t 391 SBAttachInfo::GetGroupID() 392 { 393 return m_opaque_sp->GetGroupID(); 394 } 395 396 bool 397 SBAttachInfo::UserIDIsValid () 398 { 399 return m_opaque_sp->UserIDIsValid(); 400 } 401 402 bool 403 SBAttachInfo::GroupIDIsValid () 404 { 405 return m_opaque_sp->GroupIDIsValid(); 406 } 407 408 void 409 SBAttachInfo::SetUserID (uint32_t uid) 410 { 411 m_opaque_sp->SetUserID (uid); 412 } 413 414 void 415 SBAttachInfo::SetGroupID (uint32_t gid) 416 { 417 m_opaque_sp->SetGroupID (gid); 418 } 419 420 uint32_t 421 SBAttachInfo::GetEffectiveUserID() 422 { 423 return m_opaque_sp->GetEffectiveUserID(); 424 } 425 426 uint32_t 427 SBAttachInfo::GetEffectiveGroupID() 428 { 429 return m_opaque_sp->GetEffectiveGroupID(); 430 } 431 432 bool 433 SBAttachInfo::EffectiveUserIDIsValid () 434 { 435 return m_opaque_sp->EffectiveUserIDIsValid(); 436 } 437 438 bool 439 SBAttachInfo::EffectiveGroupIDIsValid () 440 { 441 return m_opaque_sp->EffectiveGroupIDIsValid (); 442 } 443 444 void 445 SBAttachInfo::SetEffectiveUserID (uint32_t uid) 446 { 447 m_opaque_sp->SetEffectiveUserID(uid); 448 } 449 450 void 451 SBAttachInfo::SetEffectiveGroupID (uint32_t gid) 452 { 453 m_opaque_sp->SetEffectiveGroupID(gid); 454 } 455 456 lldb::pid_t 457 SBAttachInfo::GetParentProcessID () 458 { 459 return m_opaque_sp->GetParentProcessID(); 460 } 461 462 void 463 SBAttachInfo::SetParentProcessID (lldb::pid_t pid) 464 { 465 m_opaque_sp->SetParentProcessID (pid); 466 } 467 468 bool 469 SBAttachInfo::ParentProcessIDIsValid() 470 { 471 return m_opaque_sp->ParentProcessIDIsValid(); 472 } 473 474 475 //---------------------------------------------------------------------- 476 // SBTarget constructor 477 //---------------------------------------------------------------------- 478 SBTarget::SBTarget () : 479 m_opaque_sp () 480 { 481 } 482 483 SBTarget::SBTarget (const SBTarget& rhs) : 484 m_opaque_sp (rhs.m_opaque_sp) 485 { 486 } 487 488 SBTarget::SBTarget(const TargetSP& target_sp) : 489 m_opaque_sp (target_sp) 490 { 491 } 492 493 const SBTarget& 494 SBTarget::operator = (const SBTarget& rhs) 495 { 496 if (this != &rhs) 497 m_opaque_sp = rhs.m_opaque_sp; 498 return *this; 499 } 500 501 //---------------------------------------------------------------------- 502 // Destructor 503 //---------------------------------------------------------------------- 504 SBTarget::~SBTarget() 505 { 506 } 507 508 const char * 509 SBTarget::GetBroadcasterClassName () 510 { 511 return Target::GetStaticBroadcasterClass().AsCString(); 512 } 513 514 bool 515 SBTarget::IsValid () const 516 { 517 return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid(); 518 } 519 520 SBProcess 521 SBTarget::GetProcess () 522 { 523 SBProcess sb_process; 524 ProcessSP process_sp; 525 TargetSP target_sp(GetSP()); 526 if (target_sp) 527 { 528 process_sp = target_sp->GetProcessSP(); 529 sb_process.SetSP (process_sp); 530 } 531 532 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 533 if (log) 534 { 535 log->Printf ("SBTarget(%p)::GetProcess () => SBProcess(%p)", 536 target_sp.get(), process_sp.get()); 537 } 538 539 return sb_process; 540 } 541 542 SBDebugger 543 SBTarget::GetDebugger () const 544 { 545 SBDebugger debugger; 546 TargetSP target_sp(GetSP()); 547 if (target_sp) 548 debugger.reset (target_sp->GetDebugger().shared_from_this()); 549 return debugger; 550 } 551 552 SBProcess 553 SBTarget::LaunchSimple 554 ( 555 char const **argv, 556 char const **envp, 557 const char *working_directory 558 ) 559 { 560 char *stdin_path = NULL; 561 char *stdout_path = NULL; 562 char *stderr_path = NULL; 563 uint32_t launch_flags = 0; 564 bool stop_at_entry = false; 565 SBError error; 566 SBListener listener = GetDebugger().GetListener(); 567 return Launch (listener, 568 argv, 569 envp, 570 stdin_path, 571 stdout_path, 572 stderr_path, 573 working_directory, 574 launch_flags, 575 stop_at_entry, 576 error); 577 } 578 579 SBProcess 580 SBTarget::Launch 581 ( 582 SBListener &listener, 583 char const **argv, 584 char const **envp, 585 const char *stdin_path, 586 const char *stdout_path, 587 const char *stderr_path, 588 const char *working_directory, 589 uint32_t launch_flags, // See LaunchFlags 590 bool stop_at_entry, 591 lldb::SBError& error 592 ) 593 { 594 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 595 596 SBProcess sb_process; 597 ProcessSP process_sp; 598 TargetSP target_sp(GetSP()); 599 600 if (log) 601 { 602 log->Printf ("SBTarget(%p)::Launch (argv=%p, envp=%p, stdin=%s, stdout=%s, stderr=%s, working-dir=%s, launch_flags=0x%x, stop_at_entry=%i, &error (%p))...", 603 target_sp.get(), 604 argv, 605 envp, 606 stdin_path ? stdin_path : "NULL", 607 stdout_path ? stdout_path : "NULL", 608 stderr_path ? stderr_path : "NULL", 609 working_directory ? working_directory : "NULL", 610 launch_flags, 611 stop_at_entry, 612 error.get()); 613 } 614 615 if (target_sp) 616 { 617 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 618 619 if (getenv("LLDB_LAUNCH_FLAG_DISABLE_ASLR")) 620 launch_flags |= eLaunchFlagDisableASLR; 621 622 StateType state = eStateInvalid; 623 process_sp = target_sp->GetProcessSP(); 624 if (process_sp) 625 { 626 state = process_sp->GetState(); 627 628 if (process_sp->IsAlive() && state != eStateConnected) 629 { 630 if (state == eStateAttaching) 631 error.SetErrorString ("process attach is in progress"); 632 else 633 error.SetErrorString ("a process is already being debugged"); 634 return sb_process; 635 } 636 } 637 638 if (state == eStateConnected) 639 { 640 // If we are already connected, then we have already specified the 641 // listener, so if a valid listener is supplied, we need to error out 642 // to let the client know. 643 if (listener.IsValid()) 644 { 645 error.SetErrorString ("process is connected and already has a listener, pass empty listener"); 646 return sb_process; 647 } 648 } 649 else 650 { 651 if (listener.IsValid()) 652 process_sp = target_sp->CreateProcess (listener.ref(), NULL, NULL); 653 else 654 process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), NULL, NULL); 655 } 656 657 if (process_sp) 658 { 659 sb_process.SetSP (process_sp); 660 if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO")) 661 launch_flags |= eLaunchFlagDisableSTDIO; 662 663 ProcessLaunchInfo launch_info (stdin_path, stdout_path, stderr_path, working_directory, launch_flags); 664 665 Module *exe_module = target_sp->GetExecutableModulePointer(); 666 if (exe_module) 667 launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true); 668 if (argv) 669 launch_info.GetArguments().AppendArguments (argv); 670 if (envp) 671 launch_info.GetEnvironmentEntries ().SetArguments (envp); 672 673 error.SetError (process_sp->Launch (launch_info)); 674 if (error.Success()) 675 { 676 // We we are stopping at the entry point, we can return now! 677 if (stop_at_entry) 678 return sb_process; 679 680 // Make sure we are stopped at the entry 681 StateType state = process_sp->WaitForProcessToStop (NULL); 682 if (state == eStateStopped) 683 { 684 // resume the process to skip the entry point 685 error.SetError (process_sp->Resume()); 686 if (error.Success()) 687 { 688 // If we are doing synchronous mode, then wait for the 689 // process to stop yet again! 690 if (target_sp->GetDebugger().GetAsyncExecution () == false) 691 process_sp->WaitForProcessToStop (NULL); 692 } 693 } 694 } 695 } 696 else 697 { 698 error.SetErrorString ("unable to create lldb_private::Process"); 699 } 700 } 701 else 702 { 703 error.SetErrorString ("SBTarget is invalid"); 704 } 705 706 log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); 707 if (log) 708 { 709 log->Printf ("SBTarget(%p)::Launch (...) => SBProceess(%p)", 710 target_sp.get(), process_sp.get()); 711 } 712 713 return sb_process; 714 } 715 716 SBProcess 717 SBTarget::Launch (SBLaunchInfo &sb_launch_info, SBError& error) 718 { 719 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 720 721 SBProcess sb_process; 722 ProcessSP process_sp; 723 TargetSP target_sp(GetSP()); 724 725 if (log) 726 { 727 log->Printf ("SBTarget(%p)::Launch (launch_info, error)...", target_sp.get()); 728 } 729 730 if (target_sp) 731 { 732 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 733 StateType state = eStateInvalid; 734 process_sp = target_sp->GetProcessSP(); 735 if (process_sp) 736 { 737 state = process_sp->GetState(); 738 739 if (process_sp->IsAlive() && state != eStateConnected) 740 { 741 if (state == eStateAttaching) 742 error.SetErrorString ("process attach is in progress"); 743 else 744 error.SetErrorString ("a process is already being debugged"); 745 return sb_process; 746 } 747 } 748 749 if (state != eStateConnected) 750 process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), NULL, NULL); 751 752 if (process_sp) 753 { 754 sb_process.SetSP (process_sp); 755 lldb_private::ProcessLaunchInfo &launch_info = sb_launch_info.ref(); 756 757 Module *exe_module = target_sp->GetExecutableModulePointer(); 758 if (exe_module) 759 launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true); 760 761 const ArchSpec &arch_spec = target_sp->GetArchitecture(); 762 if (arch_spec.IsValid()) 763 launch_info.GetArchitecture () = arch_spec; 764 765 error.SetError (process_sp->Launch (launch_info)); 766 const bool synchronous_execution = target_sp->GetDebugger().GetAsyncExecution () == false; 767 if (error.Success()) 768 { 769 if (launch_info.GetFlags().Test(eLaunchFlagStopAtEntry)) 770 { 771 // If we are doing synchronous mode, then wait for the initial 772 // stop to happen, else, return and let the caller watch for 773 // the stop 774 if (synchronous_execution) 775 process_sp->WaitForProcessToStop (NULL); 776 // We we are stopping at the entry point, we can return now! 777 return sb_process; 778 } 779 780 // Make sure we are stopped at the entry 781 StateType state = process_sp->WaitForProcessToStop (NULL); 782 if (state == eStateStopped) 783 { 784 // resume the process to skip the entry point 785 error.SetError (process_sp->Resume()); 786 if (error.Success()) 787 { 788 // If we are doing synchronous mode, then wait for the 789 // process to stop yet again! 790 if (synchronous_execution) 791 process_sp->WaitForProcessToStop (NULL); 792 } 793 } 794 } 795 } 796 else 797 { 798 error.SetErrorString ("unable to create lldb_private::Process"); 799 } 800 } 801 else 802 { 803 error.SetErrorString ("SBTarget is invalid"); 804 } 805 806 log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); 807 if (log) 808 { 809 log->Printf ("SBTarget(%p)::Launch (...) => SBProceess(%p)", 810 target_sp.get(), process_sp.get()); 811 } 812 813 return sb_process; 814 } 815 816 lldb::SBProcess 817 SBTarget::Attach (SBAttachInfo &sb_attach_info, SBError& error) 818 { 819 SBProcess sb_process; 820 ProcessSP process_sp; 821 TargetSP target_sp(GetSP()); 822 if (target_sp) 823 { 824 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 825 826 StateType state = eStateInvalid; 827 process_sp = target_sp->GetProcessSP(); 828 if (process_sp) 829 { 830 state = process_sp->GetState(); 831 832 if (process_sp->IsAlive() && state != eStateConnected) 833 { 834 if (state == eStateAttaching) 835 error.SetErrorString ("process attach is in progress"); 836 else 837 error.SetErrorString ("a process is already being debugged"); 838 return sb_process; 839 } 840 } 841 842 if (state != eStateConnected) 843 process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), NULL, NULL); 844 845 if (process_sp) 846 { 847 ProcessAttachInfo &attach_info = sb_attach_info.ref(); 848 lldb::pid_t attach_pid = attach_info.GetProcessID(); 849 if (attach_pid != LLDB_INVALID_PROCESS_ID) 850 { 851 PlatformSP platform_sp = target_sp->GetPlatform(); 852 ProcessInstanceInfo instance_info; 853 if (platform_sp->GetProcessInfo(attach_pid, instance_info)) 854 { 855 attach_info.SetUserID(instance_info.GetEffectiveUserID()); 856 } 857 } 858 error.SetError (process_sp->Attach (attach_info)); 859 if (error.Success()) 860 { 861 sb_process.SetSP (process_sp); 862 // If we are doing synchronous mode, then wait for the 863 // process to stop! 864 if (target_sp->GetDebugger().GetAsyncExecution () == false) 865 process_sp->WaitForProcessToStop (NULL); 866 } 867 } 868 else 869 { 870 error.SetErrorString ("unable to create lldb_private::Process"); 871 } 872 } 873 else 874 { 875 error.SetErrorString ("SBTarget is invalid"); 876 } 877 return sb_process; 878 } 879 880 881 #if defined(__APPLE__) 882 883 lldb::SBProcess 884 SBTarget::AttachToProcessWithID (SBListener &listener, 885 ::pid_t pid, 886 lldb::SBError& error) 887 { 888 return AttachToProcessWithID (listener, (lldb::pid_t)pid, error); 889 } 890 891 #endif // #if defined(__APPLE__) 892 893 lldb::SBProcess 894 SBTarget::AttachToProcessWithID 895 ( 896 SBListener &listener, 897 lldb::pid_t pid,// The process ID to attach to 898 SBError& error // An error explaining what went wrong if attach fails 899 ) 900 { 901 SBProcess sb_process; 902 ProcessSP process_sp; 903 TargetSP target_sp(GetSP()); 904 if (target_sp) 905 { 906 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 907 908 StateType state = eStateInvalid; 909 process_sp = target_sp->GetProcessSP(); 910 if (process_sp) 911 { 912 state = process_sp->GetState(); 913 914 if (process_sp->IsAlive() && state != eStateConnected) 915 { 916 if (state == eStateAttaching) 917 error.SetErrorString ("process attach is in progress"); 918 else 919 error.SetErrorString ("a process is already being debugged"); 920 return sb_process; 921 } 922 } 923 924 if (state == eStateConnected) 925 { 926 // If we are already connected, then we have already specified the 927 // listener, so if a valid listener is supplied, we need to error out 928 // to let the client know. 929 if (listener.IsValid()) 930 { 931 error.SetErrorString ("process is connected and already has a listener, pass empty listener"); 932 return sb_process; 933 } 934 } 935 else 936 { 937 if (listener.IsValid()) 938 process_sp = target_sp->CreateProcess (listener.ref(), NULL, NULL); 939 else 940 process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), NULL, NULL); 941 } 942 if (process_sp) 943 { 944 sb_process.SetSP (process_sp); 945 946 ProcessAttachInfo attach_info; 947 attach_info.SetProcessID (pid); 948 949 PlatformSP platform_sp = target_sp->GetPlatform(); 950 ProcessInstanceInfo instance_info; 951 if (platform_sp->GetProcessInfo(pid, instance_info)) 952 { 953 attach_info.SetUserID(instance_info.GetEffectiveUserID()); 954 } 955 error.SetError (process_sp->Attach (attach_info)); 956 // If we are doing synchronous mode, then wait for the 957 // process to stop! 958 if (target_sp->GetDebugger().GetAsyncExecution () == false) 959 process_sp->WaitForProcessToStop (NULL); 960 } 961 else 962 { 963 error.SetErrorString ("unable to create lldb_private::Process"); 964 } 965 } 966 else 967 { 968 error.SetErrorString ("SBTarget is invalid"); 969 } 970 return sb_process; 971 972 } 973 974 lldb::SBProcess 975 SBTarget::AttachToProcessWithName 976 ( 977 SBListener &listener, 978 const char *name, // basename of process to attach to 979 bool wait_for, // if true wait for a new instance of "name" to be launched 980 SBError& error // An error explaining what went wrong if attach fails 981 ) 982 { 983 SBProcess sb_process; 984 ProcessSP process_sp; 985 TargetSP target_sp(GetSP()); 986 if (name && target_sp) 987 { 988 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 989 990 StateType state = eStateInvalid; 991 process_sp = target_sp->GetProcessSP(); 992 if (process_sp) 993 { 994 state = process_sp->GetState(); 995 996 if (process_sp->IsAlive() && state != eStateConnected) 997 { 998 if (state == eStateAttaching) 999 error.SetErrorString ("process attach is in progress"); 1000 else 1001 error.SetErrorString ("a process is already being debugged"); 1002 return sb_process; 1003 } 1004 } 1005 1006 if (state == eStateConnected) 1007 { 1008 // If we are already connected, then we have already specified the 1009 // listener, so if a valid listener is supplied, we need to error out 1010 // to let the client know. 1011 if (listener.IsValid()) 1012 { 1013 error.SetErrorString ("process is connected and already has a listener, pass empty listener"); 1014 return sb_process; 1015 } 1016 } 1017 else 1018 { 1019 if (listener.IsValid()) 1020 process_sp = target_sp->CreateProcess (listener.ref(), NULL, NULL); 1021 else 1022 process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), NULL, NULL); 1023 } 1024 1025 if (process_sp) 1026 { 1027 sb_process.SetSP (process_sp); 1028 ProcessAttachInfo attach_info; 1029 attach_info.GetExecutableFile().SetFile(name, false); 1030 attach_info.SetWaitForLaunch(wait_for); 1031 error.SetError (process_sp->Attach (attach_info)); 1032 // If we are doing synchronous mode, then wait for the 1033 // process to stop! 1034 if (target_sp->GetDebugger().GetAsyncExecution () == false) 1035 process_sp->WaitForProcessToStop (NULL); 1036 } 1037 else 1038 { 1039 error.SetErrorString ("unable to create lldb_private::Process"); 1040 } 1041 } 1042 else 1043 { 1044 error.SetErrorString ("SBTarget is invalid"); 1045 } 1046 return sb_process; 1047 1048 } 1049 1050 lldb::SBProcess 1051 SBTarget::ConnectRemote 1052 ( 1053 SBListener &listener, 1054 const char *url, 1055 const char *plugin_name, 1056 SBError& error 1057 ) 1058 { 1059 SBProcess sb_process; 1060 ProcessSP process_sp; 1061 TargetSP target_sp(GetSP()); 1062 if (target_sp) 1063 { 1064 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1065 if (listener.IsValid()) 1066 process_sp = target_sp->CreateProcess (listener.ref(), plugin_name, NULL); 1067 else 1068 process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), plugin_name, NULL); 1069 1070 1071 if (process_sp) 1072 { 1073 sb_process.SetSP (process_sp); 1074 error.SetError (process_sp->ConnectRemote (url)); 1075 } 1076 else 1077 { 1078 error.SetErrorString ("unable to create lldb_private::Process"); 1079 } 1080 } 1081 else 1082 { 1083 error.SetErrorString ("SBTarget is invalid"); 1084 } 1085 return sb_process; 1086 } 1087 1088 SBFileSpec 1089 SBTarget::GetExecutable () 1090 { 1091 1092 SBFileSpec exe_file_spec; 1093 TargetSP target_sp(GetSP()); 1094 if (target_sp) 1095 { 1096 Module *exe_module = target_sp->GetExecutableModulePointer(); 1097 if (exe_module) 1098 exe_file_spec.SetFileSpec (exe_module->GetFileSpec()); 1099 } 1100 1101 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1102 if (log) 1103 { 1104 log->Printf ("SBTarget(%p)::GetExecutable () => SBFileSpec(%p)", 1105 target_sp.get(), exe_file_spec.get()); 1106 } 1107 1108 return exe_file_spec; 1109 } 1110 1111 bool 1112 SBTarget::operator == (const SBTarget &rhs) const 1113 { 1114 return m_opaque_sp.get() == rhs.m_opaque_sp.get(); 1115 } 1116 1117 bool 1118 SBTarget::operator != (const SBTarget &rhs) const 1119 { 1120 return m_opaque_sp.get() != rhs.m_opaque_sp.get(); 1121 } 1122 1123 lldb::TargetSP 1124 SBTarget::GetSP () const 1125 { 1126 return m_opaque_sp; 1127 } 1128 1129 void 1130 SBTarget::SetSP (const lldb::TargetSP& target_sp) 1131 { 1132 m_opaque_sp = target_sp; 1133 } 1134 1135 lldb::SBAddress 1136 SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr) 1137 { 1138 lldb::SBAddress sb_addr; 1139 Address &addr = sb_addr.ref(); 1140 TargetSP target_sp(GetSP()); 1141 if (target_sp) 1142 { 1143 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1144 if (target_sp->GetSectionLoadList().ResolveLoadAddress (vm_addr, addr)) 1145 return sb_addr; 1146 } 1147 1148 // We have a load address that isn't in a section, just return an address 1149 // with the offset filled in (the address) and the section set to NULL 1150 addr.SetRawAddress(vm_addr); 1151 return sb_addr; 1152 } 1153 1154 SBSymbolContext 1155 SBTarget::ResolveSymbolContextForAddress (const SBAddress& addr, uint32_t resolve_scope) 1156 { 1157 SBSymbolContext sc; 1158 if (addr.IsValid()) 1159 { 1160 TargetSP target_sp(GetSP()); 1161 if (target_sp) 1162 target_sp->GetImages().ResolveSymbolContextForAddress (addr.ref(), resolve_scope, sc.ref()); 1163 } 1164 return sc; 1165 } 1166 1167 1168 SBBreakpoint 1169 SBTarget::BreakpointCreateByLocation (const char *file, uint32_t line) 1170 { 1171 return SBBreakpoint(BreakpointCreateByLocation (SBFileSpec (file, false), line)); 1172 } 1173 1174 SBBreakpoint 1175 SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec, uint32_t line) 1176 { 1177 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1178 1179 SBBreakpoint sb_bp; 1180 TargetSP target_sp(GetSP()); 1181 if (target_sp && line != 0) 1182 { 1183 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1184 1185 const bool check_inlines = true; 1186 const bool internal = false; 1187 const LazyBool skip_prologue = eLazyBoolCalculate; 1188 *sb_bp = target_sp->CreateBreakpoint (NULL, *sb_file_spec, line, check_inlines, skip_prologue, internal); 1189 } 1190 1191 if (log) 1192 { 1193 SBStream sstr; 1194 sb_bp.GetDescription (sstr); 1195 char path[PATH_MAX]; 1196 sb_file_spec->GetPath (path, sizeof(path)); 1197 log->Printf ("SBTarget(%p)::BreakpointCreateByLocation ( %s:%u ) => SBBreakpoint(%p): %s", 1198 target_sp.get(), 1199 path, 1200 line, 1201 sb_bp.get(), 1202 sstr.GetData()); 1203 } 1204 1205 return sb_bp; 1206 } 1207 1208 SBBreakpoint 1209 SBTarget::BreakpointCreateByName (const char *symbol_name, const char *module_name) 1210 { 1211 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1212 1213 SBBreakpoint sb_bp; 1214 TargetSP target_sp(GetSP()); 1215 if (target_sp.get()) 1216 { 1217 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1218 1219 const bool internal = false; 1220 const LazyBool skip_prologue = eLazyBoolCalculate; 1221 if (module_name && module_name[0]) 1222 { 1223 FileSpecList module_spec_list; 1224 module_spec_list.Append (FileSpec (module_name, false)); 1225 *sb_bp = target_sp->CreateBreakpoint (&module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, skip_prologue, internal); 1226 } 1227 else 1228 { 1229 *sb_bp = target_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeAuto, skip_prologue, internal); 1230 } 1231 } 1232 1233 if (log) 1234 { 1235 log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", module=\"%s\") => SBBreakpoint(%p)", 1236 target_sp.get(), symbol_name, module_name, sb_bp.get()); 1237 } 1238 1239 return sb_bp; 1240 } 1241 1242 lldb::SBBreakpoint 1243 SBTarget::BreakpointCreateByName (const char *symbol_name, 1244 const SBFileSpecList &module_list, 1245 const SBFileSpecList &comp_unit_list) 1246 { 1247 uint32_t name_type_mask = eFunctionNameTypeAuto; 1248 return BreakpointCreateByName (symbol_name, name_type_mask, module_list, comp_unit_list); 1249 } 1250 1251 lldb::SBBreakpoint 1252 SBTarget::BreakpointCreateByName (const char *symbol_name, 1253 uint32_t name_type_mask, 1254 const SBFileSpecList &module_list, 1255 const SBFileSpecList &comp_unit_list) 1256 { 1257 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1258 1259 SBBreakpoint sb_bp; 1260 TargetSP target_sp(GetSP()); 1261 if (target_sp && symbol_name && symbol_name[0]) 1262 { 1263 const bool internal = false; 1264 const LazyBool skip_prologue = eLazyBoolCalculate; 1265 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1266 *sb_bp = target_sp->CreateBreakpoint (module_list.get(), 1267 comp_unit_list.get(), 1268 symbol_name, 1269 name_type_mask, 1270 skip_prologue, 1271 internal); 1272 } 1273 1274 if (log) 1275 { 1276 log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", name_type: %d) => SBBreakpoint(%p)", 1277 target_sp.get(), symbol_name, name_type_mask, sb_bp.get()); 1278 } 1279 1280 return sb_bp; 1281 } 1282 1283 lldb::SBBreakpoint 1284 SBTarget::BreakpointCreateByNames (const char *symbol_names[], 1285 uint32_t num_names, 1286 uint32_t name_type_mask, 1287 const SBFileSpecList &module_list, 1288 const SBFileSpecList &comp_unit_list) 1289 { 1290 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1291 1292 SBBreakpoint sb_bp; 1293 TargetSP target_sp(GetSP()); 1294 if (target_sp && num_names > 0) 1295 { 1296 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1297 const bool internal = false; 1298 const LazyBool skip_prologue = eLazyBoolCalculate; 1299 *sb_bp = target_sp->CreateBreakpoint (module_list.get(), 1300 comp_unit_list.get(), 1301 symbol_names, 1302 num_names, 1303 name_type_mask, 1304 skip_prologue, 1305 internal); 1306 } 1307 1308 if (log) 1309 { 1310 log->Printf ("SBTarget(%p)::BreakpointCreateByName (symbols={", target_sp.get()); 1311 for (uint32_t i = 0 ; i < num_names; i++) 1312 { 1313 char sep; 1314 if (i < num_names - 1) 1315 sep = ','; 1316 else 1317 sep = '}'; 1318 if (symbol_names[i] != NULL) 1319 log->Printf ("\"%s\"%c ", symbol_names[i], sep); 1320 else 1321 log->Printf ("\"<NULL>\"%c ", sep); 1322 1323 } 1324 log->Printf ("name_type: %d) => SBBreakpoint(%p)", name_type_mask, sb_bp.get()); 1325 } 1326 1327 return sb_bp; 1328 } 1329 1330 SBBreakpoint 1331 SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name) 1332 { 1333 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1334 1335 SBBreakpoint sb_bp; 1336 TargetSP target_sp(GetSP()); 1337 if (target_sp && symbol_name_regex && symbol_name_regex[0]) 1338 { 1339 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1340 RegularExpression regexp(symbol_name_regex); 1341 const bool internal = false; 1342 const LazyBool skip_prologue = eLazyBoolCalculate; 1343 1344 if (module_name && module_name[0]) 1345 { 1346 FileSpecList module_spec_list; 1347 module_spec_list.Append (FileSpec (module_name, false)); 1348 1349 *sb_bp = target_sp->CreateFuncRegexBreakpoint (&module_spec_list, NULL, regexp, skip_prologue, internal); 1350 } 1351 else 1352 { 1353 *sb_bp = target_sp->CreateFuncRegexBreakpoint (NULL, NULL, regexp, skip_prologue, internal); 1354 } 1355 } 1356 1357 if (log) 1358 { 1359 log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\", module_name=\"%s\") => SBBreakpoint(%p)", 1360 target_sp.get(), symbol_name_regex, module_name, sb_bp.get()); 1361 } 1362 1363 return sb_bp; 1364 } 1365 1366 lldb::SBBreakpoint 1367 SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, 1368 const SBFileSpecList &module_list, 1369 const SBFileSpecList &comp_unit_list) 1370 { 1371 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1372 1373 SBBreakpoint sb_bp; 1374 TargetSP target_sp(GetSP()); 1375 if (target_sp && symbol_name_regex && symbol_name_regex[0]) 1376 { 1377 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1378 RegularExpression regexp(symbol_name_regex); 1379 const bool internal = false; 1380 const LazyBool skip_prologue = eLazyBoolCalculate; 1381 1382 *sb_bp = target_sp->CreateFuncRegexBreakpoint (module_list.get(), comp_unit_list.get(), regexp, skip_prologue, internal); 1383 } 1384 1385 if (log) 1386 { 1387 log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\") => SBBreakpoint(%p)", 1388 target_sp.get(), symbol_name_regex, sb_bp.get()); 1389 } 1390 1391 return sb_bp; 1392 } 1393 1394 SBBreakpoint 1395 SBTarget::BreakpointCreateByAddress (addr_t address) 1396 { 1397 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1398 1399 SBBreakpoint sb_bp; 1400 TargetSP target_sp(GetSP()); 1401 if (target_sp) 1402 { 1403 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1404 *sb_bp = target_sp->CreateBreakpoint (address, false); 1405 } 1406 1407 if (log) 1408 { 1409 log->Printf ("SBTarget(%p)::BreakpointCreateByAddress (address=%llu) => SBBreakpoint(%p)", target_sp.get(), (uint64_t) address, sb_bp.get()); 1410 } 1411 1412 return sb_bp; 1413 } 1414 1415 lldb::SBBreakpoint 1416 SBTarget::BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name) 1417 { 1418 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1419 1420 SBBreakpoint sb_bp; 1421 TargetSP target_sp(GetSP()); 1422 if (target_sp && source_regex && source_regex[0]) 1423 { 1424 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1425 RegularExpression regexp(source_regex); 1426 FileSpecList source_file_spec_list; 1427 source_file_spec_list.Append (source_file.ref()); 1428 1429 if (module_name && module_name[0]) 1430 { 1431 FileSpecList module_spec_list; 1432 module_spec_list.Append (FileSpec (module_name, false)); 1433 1434 *sb_bp = target_sp->CreateSourceRegexBreakpoint (&module_spec_list, &source_file_spec_list, regexp, false); 1435 } 1436 else 1437 { 1438 *sb_bp = target_sp->CreateSourceRegexBreakpoint (NULL, &source_file_spec_list, regexp, false); 1439 } 1440 } 1441 1442 if (log) 1443 { 1444 char path[PATH_MAX]; 1445 source_file->GetPath (path, sizeof(path)); 1446 log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\", file=\"%s\", module_name=\"%s\") => SBBreakpoint(%p)", 1447 target_sp.get(), source_regex, path, module_name, sb_bp.get()); 1448 } 1449 1450 return sb_bp; 1451 } 1452 1453 lldb::SBBreakpoint 1454 SBTarget::BreakpointCreateBySourceRegex (const char *source_regex, 1455 const SBFileSpecList &module_list, 1456 const lldb::SBFileSpecList &source_file_list) 1457 { 1458 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1459 1460 SBBreakpoint sb_bp; 1461 TargetSP target_sp(GetSP()); 1462 if (target_sp && source_regex && source_regex[0]) 1463 { 1464 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1465 RegularExpression regexp(source_regex); 1466 *sb_bp = target_sp->CreateSourceRegexBreakpoint (module_list.get(), source_file_list.get(), regexp, false); 1467 } 1468 1469 if (log) 1470 { 1471 log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\") => SBBreakpoint(%p)", 1472 target_sp.get(), source_regex, sb_bp.get()); 1473 } 1474 1475 return sb_bp; 1476 } 1477 1478 lldb::SBBreakpoint 1479 SBTarget::BreakpointCreateForException (lldb::LanguageType language, 1480 bool catch_bp, 1481 bool throw_bp) 1482 { 1483 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1484 1485 SBBreakpoint sb_bp; 1486 TargetSP target_sp(GetSP()); 1487 if (target_sp) 1488 { 1489 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1490 *sb_bp = target_sp->CreateExceptionBreakpoint (language, catch_bp, throw_bp); 1491 } 1492 1493 if (log) 1494 { 1495 log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (Language: %s, catch: %s throw: %s) => SBBreakpoint(%p)", 1496 target_sp.get(), 1497 LanguageRuntime::GetNameForLanguageType(language), 1498 catch_bp ? "on" : "off", 1499 throw_bp ? "on" : "off", 1500 sb_bp.get()); 1501 } 1502 1503 return sb_bp; 1504 } 1505 1506 uint32_t 1507 SBTarget::GetNumBreakpoints () const 1508 { 1509 TargetSP target_sp(GetSP()); 1510 if (target_sp) 1511 { 1512 // The breakpoint list is thread safe, no need to lock 1513 return target_sp->GetBreakpointList().GetSize(); 1514 } 1515 return 0; 1516 } 1517 1518 SBBreakpoint 1519 SBTarget::GetBreakpointAtIndex (uint32_t idx) const 1520 { 1521 SBBreakpoint sb_breakpoint; 1522 TargetSP target_sp(GetSP()); 1523 if (target_sp) 1524 { 1525 // The breakpoint list is thread safe, no need to lock 1526 *sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx); 1527 } 1528 return sb_breakpoint; 1529 } 1530 1531 bool 1532 SBTarget::BreakpointDelete (break_id_t bp_id) 1533 { 1534 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1535 1536 bool result = false; 1537 TargetSP target_sp(GetSP()); 1538 if (target_sp) 1539 { 1540 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1541 result = target_sp->RemoveBreakpointByID (bp_id); 1542 } 1543 1544 if (log) 1545 { 1546 log->Printf ("SBTarget(%p)::BreakpointDelete (bp_id=%d) => %i", target_sp.get(), (uint32_t) bp_id, result); 1547 } 1548 1549 return result; 1550 } 1551 1552 SBBreakpoint 1553 SBTarget::FindBreakpointByID (break_id_t bp_id) 1554 { 1555 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1556 1557 SBBreakpoint sb_breakpoint; 1558 TargetSP target_sp(GetSP()); 1559 if (target_sp && bp_id != LLDB_INVALID_BREAK_ID) 1560 { 1561 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1562 *sb_breakpoint = target_sp->GetBreakpointByID (bp_id); 1563 } 1564 1565 if (log) 1566 { 1567 log->Printf ("SBTarget(%p)::FindBreakpointByID (bp_id=%d) => SBBreakpoint(%p)", 1568 target_sp.get(), (uint32_t) bp_id, sb_breakpoint.get()); 1569 } 1570 1571 return sb_breakpoint; 1572 } 1573 1574 bool 1575 SBTarget::EnableAllBreakpoints () 1576 { 1577 TargetSP target_sp(GetSP()); 1578 if (target_sp) 1579 { 1580 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1581 target_sp->EnableAllBreakpoints (); 1582 return true; 1583 } 1584 return false; 1585 } 1586 1587 bool 1588 SBTarget::DisableAllBreakpoints () 1589 { 1590 TargetSP target_sp(GetSP()); 1591 if (target_sp) 1592 { 1593 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1594 target_sp->DisableAllBreakpoints (); 1595 return true; 1596 } 1597 return false; 1598 } 1599 1600 bool 1601 SBTarget::DeleteAllBreakpoints () 1602 { 1603 TargetSP target_sp(GetSP()); 1604 if (target_sp) 1605 { 1606 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1607 target_sp->RemoveAllBreakpoints (); 1608 return true; 1609 } 1610 return false; 1611 } 1612 1613 uint32_t 1614 SBTarget::GetNumWatchpoints () const 1615 { 1616 TargetSP target_sp(GetSP()); 1617 if (target_sp) 1618 { 1619 // The watchpoint list is thread safe, no need to lock 1620 return target_sp->GetWatchpointList().GetSize(); 1621 } 1622 return 0; 1623 } 1624 1625 SBWatchpoint 1626 SBTarget::GetWatchpointAtIndex (uint32_t idx) const 1627 { 1628 SBWatchpoint sb_watchpoint; 1629 TargetSP target_sp(GetSP()); 1630 if (target_sp) 1631 { 1632 // The watchpoint list is thread safe, no need to lock 1633 sb_watchpoint.SetSP (target_sp->GetWatchpointList().GetByIndex(idx)); 1634 } 1635 return sb_watchpoint; 1636 } 1637 1638 bool 1639 SBTarget::DeleteWatchpoint (watch_id_t wp_id) 1640 { 1641 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1642 1643 bool result = false; 1644 TargetSP target_sp(GetSP()); 1645 if (target_sp) 1646 { 1647 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1648 Mutex::Locker locker; 1649 target_sp->GetWatchpointList().GetListMutex(locker); 1650 result = target_sp->RemoveWatchpointByID (wp_id); 1651 } 1652 1653 if (log) 1654 { 1655 log->Printf ("SBTarget(%p)::WatchpointDelete (wp_id=%d) => %i", target_sp.get(), (uint32_t) wp_id, result); 1656 } 1657 1658 return result; 1659 } 1660 1661 SBWatchpoint 1662 SBTarget::FindWatchpointByID (lldb::watch_id_t wp_id) 1663 { 1664 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1665 1666 SBWatchpoint sb_watchpoint; 1667 lldb::WatchpointSP watchpoint_sp; 1668 TargetSP target_sp(GetSP()); 1669 if (target_sp && wp_id != LLDB_INVALID_WATCH_ID) 1670 { 1671 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1672 Mutex::Locker locker; 1673 target_sp->GetWatchpointList().GetListMutex(locker); 1674 watchpoint_sp = target_sp->GetWatchpointList().FindByID(wp_id); 1675 sb_watchpoint.SetSP (watchpoint_sp); 1676 } 1677 1678 if (log) 1679 { 1680 log->Printf ("SBTarget(%p)::FindWatchpointByID (bp_id=%d) => SBWatchpoint(%p)", 1681 target_sp.get(), (uint32_t) wp_id, watchpoint_sp.get()); 1682 } 1683 1684 return sb_watchpoint; 1685 } 1686 1687 lldb::SBWatchpoint 1688 SBTarget::WatchAddress (lldb::addr_t addr, size_t size, bool read, bool write, SBError &error) 1689 { 1690 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1691 1692 SBWatchpoint sb_watchpoint; 1693 lldb::WatchpointSP watchpoint_sp; 1694 TargetSP target_sp(GetSP()); 1695 if (target_sp && (read || write) && addr != LLDB_INVALID_ADDRESS && size > 0) 1696 { 1697 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1698 uint32_t watch_type = 0; 1699 if (read) 1700 watch_type |= LLDB_WATCH_TYPE_READ; 1701 if (write) 1702 watch_type |= LLDB_WATCH_TYPE_WRITE; 1703 // Target::CreateWatchpoint() is thread safe. 1704 Error cw_error; 1705 watchpoint_sp = target_sp->CreateWatchpoint(addr, size, watch_type, cw_error); 1706 error.SetError(cw_error); 1707 sb_watchpoint.SetSP (watchpoint_sp); 1708 } 1709 1710 if (log) 1711 { 1712 log->Printf ("SBTarget(%p)::WatchAddress (addr=0x%llx, 0x%u) => SBWatchpoint(%p)", 1713 target_sp.get(), addr, (uint32_t) size, watchpoint_sp.get()); 1714 } 1715 1716 return sb_watchpoint; 1717 } 1718 1719 bool 1720 SBTarget::EnableAllWatchpoints () 1721 { 1722 TargetSP target_sp(GetSP()); 1723 if (target_sp) 1724 { 1725 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1726 Mutex::Locker locker; 1727 target_sp->GetWatchpointList().GetListMutex(locker); 1728 target_sp->EnableAllWatchpoints (); 1729 return true; 1730 } 1731 return false; 1732 } 1733 1734 bool 1735 SBTarget::DisableAllWatchpoints () 1736 { 1737 TargetSP target_sp(GetSP()); 1738 if (target_sp) 1739 { 1740 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1741 Mutex::Locker locker; 1742 target_sp->GetWatchpointList().GetListMutex(locker); 1743 target_sp->DisableAllWatchpoints (); 1744 return true; 1745 } 1746 return false; 1747 } 1748 1749 bool 1750 SBTarget::DeleteAllWatchpoints () 1751 { 1752 TargetSP target_sp(GetSP()); 1753 if (target_sp) 1754 { 1755 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1756 Mutex::Locker locker; 1757 target_sp->GetWatchpointList().GetListMutex(locker); 1758 target_sp->RemoveAllWatchpoints (); 1759 return true; 1760 } 1761 return false; 1762 } 1763 1764 1765 lldb::SBModule 1766 SBTarget::AddModule (const char *path, 1767 const char *triple, 1768 const char *uuid_cstr) 1769 { 1770 return AddModule (path, triple, uuid_cstr, NULL); 1771 } 1772 1773 lldb::SBModule 1774 SBTarget::AddModule (const char *path, 1775 const char *triple, 1776 const char *uuid_cstr, 1777 const char *symfile) 1778 { 1779 lldb::SBModule sb_module; 1780 TargetSP target_sp(GetSP()); 1781 if (target_sp) 1782 { 1783 ModuleSpec module_spec; 1784 if (path) 1785 module_spec.GetFileSpec().SetFile(path, false); 1786 1787 if (uuid_cstr) 1788 module_spec.GetUUID().SetfromCString(uuid_cstr); 1789 1790 if (triple) 1791 module_spec.GetArchitecture().SetTriple (triple, target_sp->GetPlatform ().get()); 1792 1793 if (symfile) 1794 module_spec.GetSymbolFileSpec ().SetFile(symfile, false); 1795 1796 sb_module.SetSP(target_sp->GetSharedModule (module_spec)); 1797 } 1798 return sb_module; 1799 } 1800 1801 bool 1802 SBTarget::AddModule (lldb::SBModule &module) 1803 { 1804 TargetSP target_sp(GetSP()); 1805 if (target_sp) 1806 { 1807 target_sp->GetImages().AppendIfNeeded (module.GetSP()); 1808 return true; 1809 } 1810 return false; 1811 } 1812 1813 uint32_t 1814 SBTarget::GetNumModules () const 1815 { 1816 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1817 1818 uint32_t num = 0; 1819 TargetSP target_sp(GetSP()); 1820 if (target_sp) 1821 { 1822 // The module list is thread safe, no need to lock 1823 num = target_sp->GetImages().GetSize(); 1824 } 1825 1826 if (log) 1827 log->Printf ("SBTarget(%p)::GetNumModules () => %d", target_sp.get(), num); 1828 1829 return num; 1830 } 1831 1832 void 1833 SBTarget::Clear () 1834 { 1835 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1836 1837 if (log) 1838 log->Printf ("SBTarget(%p)::Clear ()", m_opaque_sp.get()); 1839 1840 m_opaque_sp.reset(); 1841 } 1842 1843 1844 SBModule 1845 SBTarget::FindModule (const SBFileSpec &sb_file_spec) 1846 { 1847 SBModule sb_module; 1848 TargetSP target_sp(GetSP()); 1849 if (target_sp && sb_file_spec.IsValid()) 1850 { 1851 ModuleSpec module_spec(*sb_file_spec); 1852 // The module list is thread safe, no need to lock 1853 sb_module.SetSP (target_sp->GetImages().FindFirstModule (module_spec)); 1854 } 1855 return sb_module; 1856 } 1857 1858 lldb::ByteOrder 1859 SBTarget::GetByteOrder () 1860 { 1861 TargetSP target_sp(GetSP()); 1862 if (target_sp) 1863 return target_sp->GetArchitecture().GetByteOrder(); 1864 return eByteOrderInvalid; 1865 } 1866 1867 const char * 1868 SBTarget::GetTriple () 1869 { 1870 TargetSP target_sp(GetSP()); 1871 if (target_sp) 1872 { 1873 std::string triple (target_sp->GetArchitecture().GetTriple().str()); 1874 // Unique the string so we don't run into ownership issues since 1875 // the const strings put the string into the string pool once and 1876 // the strings never comes out 1877 ConstString const_triple (triple.c_str()); 1878 return const_triple.GetCString(); 1879 } 1880 return NULL; 1881 } 1882 1883 uint32_t 1884 SBTarget::GetAddressByteSize() 1885 { 1886 TargetSP target_sp(GetSP()); 1887 if (target_sp) 1888 return target_sp->GetArchitecture().GetAddressByteSize(); 1889 return sizeof(void*); 1890 } 1891 1892 1893 SBModule 1894 SBTarget::GetModuleAtIndex (uint32_t idx) 1895 { 1896 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1897 1898 SBModule sb_module; 1899 ModuleSP module_sp; 1900 TargetSP target_sp(GetSP()); 1901 if (target_sp) 1902 { 1903 // The module list is thread safe, no need to lock 1904 module_sp = target_sp->GetImages().GetModuleAtIndex(idx); 1905 sb_module.SetSP (module_sp); 1906 } 1907 1908 if (log) 1909 { 1910 log->Printf ("SBTarget(%p)::GetModuleAtIndex (idx=%d) => SBModule(%p)", 1911 target_sp.get(), idx, module_sp.get()); 1912 } 1913 1914 return sb_module; 1915 } 1916 1917 bool 1918 SBTarget::RemoveModule (lldb::SBModule module) 1919 { 1920 TargetSP target_sp(GetSP()); 1921 if (target_sp) 1922 return target_sp->GetImages().Remove(module.GetSP()); 1923 return false; 1924 } 1925 1926 1927 SBBroadcaster 1928 SBTarget::GetBroadcaster () const 1929 { 1930 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1931 1932 TargetSP target_sp(GetSP()); 1933 SBBroadcaster broadcaster(target_sp.get(), false); 1934 1935 if (log) 1936 log->Printf ("SBTarget(%p)::GetBroadcaster () => SBBroadcaster(%p)", 1937 target_sp.get(), broadcaster.get()); 1938 1939 return broadcaster; 1940 } 1941 1942 bool 1943 SBTarget::GetDescription (SBStream &description, lldb::DescriptionLevel description_level) 1944 { 1945 Stream &strm = description.ref(); 1946 1947 TargetSP target_sp(GetSP()); 1948 if (target_sp) 1949 { 1950 target_sp->Dump (&strm, description_level); 1951 } 1952 else 1953 strm.PutCString ("No value"); 1954 1955 return true; 1956 } 1957 1958 lldb::SBSymbolContextList 1959 SBTarget::FindFunctions (const char *name, uint32_t name_type_mask) 1960 { 1961 lldb::SBSymbolContextList sb_sc_list; 1962 if (name && name[0]) 1963 { 1964 TargetSP target_sp(GetSP()); 1965 if (target_sp) 1966 { 1967 const bool symbols_ok = true; 1968 const bool inlines_ok = true; 1969 const bool append = true; 1970 target_sp->GetImages().FindFunctions (ConstString(name), 1971 name_type_mask, 1972 symbols_ok, 1973 inlines_ok, 1974 append, 1975 *sb_sc_list); 1976 } 1977 } 1978 return sb_sc_list; 1979 } 1980 1981 lldb::SBType 1982 SBTarget::FindFirstType (const char* type) 1983 { 1984 TargetSP target_sp(GetSP()); 1985 if (type && target_sp) 1986 { 1987 size_t count = target_sp->GetImages().GetSize(); 1988 for (size_t idx = 0; idx < count; idx++) 1989 { 1990 SBType found_at_idx = GetModuleAtIndex(idx).FindFirstType(type); 1991 1992 if (found_at_idx.IsValid()) 1993 return found_at_idx; 1994 } 1995 } 1996 return SBType(); 1997 } 1998 1999 lldb::SBTypeList 2000 SBTarget::FindTypes (const char* type) 2001 { 2002 2003 SBTypeList retval; 2004 2005 TargetSP target_sp(GetSP()); 2006 if (type && target_sp) 2007 { 2008 ModuleList& images = target_sp->GetImages(); 2009 ConstString name_const(type); 2010 bool exact_match = false; 2011 SymbolContext sc; 2012 TypeList type_list; 2013 2014 uint32_t num_matches = images.FindTypes (sc, 2015 name_const, 2016 exact_match, 2017 UINT32_MAX, 2018 type_list); 2019 2020 for (size_t idx = 0; idx < num_matches; idx++) 2021 { 2022 TypeSP type_sp (type_list.GetTypeAtIndex(idx)); 2023 if (type_sp) 2024 retval.Append(SBType(type_sp)); 2025 } 2026 } 2027 return retval; 2028 } 2029 2030 SBValueList 2031 SBTarget::FindGlobalVariables (const char *name, uint32_t max_matches) 2032 { 2033 SBValueList sb_value_list; 2034 2035 TargetSP target_sp(GetSP()); 2036 if (name && target_sp) 2037 { 2038 VariableList variable_list; 2039 const bool append = true; 2040 const uint32_t match_count = target_sp->GetImages().FindGlobalVariables (ConstString (name), 2041 append, 2042 max_matches, 2043 variable_list); 2044 2045 if (match_count > 0) 2046 { 2047 ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get(); 2048 if (exe_scope == NULL) 2049 exe_scope = target_sp.get(); 2050 ValueObjectList &value_object_list = sb_value_list.ref(); 2051 for (uint32_t i=0; i<match_count; ++i) 2052 { 2053 lldb::ValueObjectSP valobj_sp (ValueObjectVariable::Create (exe_scope, variable_list.GetVariableAtIndex(i))); 2054 if (valobj_sp) 2055 value_object_list.Append(valobj_sp); 2056 } 2057 } 2058 } 2059 2060 return sb_value_list; 2061 } 2062 2063 SBSourceManager 2064 SBTarget::GetSourceManager() 2065 { 2066 SBSourceManager source_manager (*this); 2067 return source_manager; 2068 } 2069 2070 lldb::SBInstructionList 2071 SBTarget::ReadInstructions (lldb::SBAddress base_addr, uint32_t count) 2072 { 2073 SBInstructionList sb_instructions; 2074 2075 TargetSP target_sp(GetSP()); 2076 if (target_sp) 2077 { 2078 Address *addr_ptr = base_addr.get(); 2079 2080 if (addr_ptr) 2081 { 2082 DataBufferHeap data (target_sp->GetArchitecture().GetMaximumOpcodeByteSize() * count, 0); 2083 bool prefer_file_cache = false; 2084 lldb_private::Error error; 2085 const size_t bytes_read = target_sp->ReadMemory(*addr_ptr, prefer_file_cache, data.GetBytes(), data.GetByteSize(), error); 2086 sb_instructions.SetDisassembler (Disassembler::DisassembleBytes (target_sp->GetArchitecture(), 2087 NULL, 2088 *addr_ptr, 2089 data.GetBytes(), 2090 bytes_read, 2091 count)); 2092 } 2093 } 2094 2095 return sb_instructions; 2096 2097 } 2098 2099 lldb::SBInstructionList 2100 SBTarget::GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size) 2101 { 2102 SBInstructionList sb_instructions; 2103 2104 TargetSP target_sp(GetSP()); 2105 if (target_sp) 2106 { 2107 Address addr; 2108 2109 if (base_addr.get()) 2110 addr = *base_addr.get(); 2111 2112 sb_instructions.SetDisassembler (Disassembler::DisassembleBytes (target_sp->GetArchitecture(), 2113 NULL, 2114 addr, 2115 buf, 2116 size)); 2117 } 2118 2119 return sb_instructions; 2120 } 2121 2122 lldb::SBInstructionList 2123 SBTarget::GetInstructions (lldb::addr_t base_addr, const void *buf, size_t size) 2124 { 2125 return GetInstructions (ResolveLoadAddress(base_addr), buf, size); 2126 } 2127 2128 SBError 2129 SBTarget::SetSectionLoadAddress (lldb::SBSection section, 2130 lldb::addr_t section_base_addr) 2131 { 2132 SBError sb_error; 2133 TargetSP target_sp(GetSP()); 2134 if (target_sp) 2135 { 2136 if (!section.IsValid()) 2137 { 2138 sb_error.SetErrorStringWithFormat ("invalid section"); 2139 } 2140 else 2141 { 2142 SectionSP section_sp (section.GetSP()); 2143 if (section_sp) 2144 { 2145 if (section_sp->IsThreadSpecific()) 2146 { 2147 sb_error.SetErrorString ("thread specific sections are not yet supported"); 2148 } 2149 else 2150 { 2151 target_sp->GetSectionLoadList().SetSectionLoadAddress (section_sp, section_base_addr); 2152 } 2153 } 2154 } 2155 } 2156 else 2157 { 2158 sb_error.SetErrorString ("invalid target"); 2159 } 2160 return sb_error; 2161 } 2162 2163 SBError 2164 SBTarget::ClearSectionLoadAddress (lldb::SBSection section) 2165 { 2166 SBError sb_error; 2167 2168 TargetSP target_sp(GetSP()); 2169 if (target_sp) 2170 { 2171 if (!section.IsValid()) 2172 { 2173 sb_error.SetErrorStringWithFormat ("invalid section"); 2174 } 2175 else 2176 { 2177 target_sp->GetSectionLoadList().SetSectionUnloaded (section.GetSP()); 2178 } 2179 } 2180 else 2181 { 2182 sb_error.SetErrorStringWithFormat ("invalid target"); 2183 } 2184 return sb_error; 2185 } 2186 2187 SBError 2188 SBTarget::SetModuleLoadAddress (lldb::SBModule module, int64_t slide_offset) 2189 { 2190 SBError sb_error; 2191 2192 TargetSP target_sp(GetSP()); 2193 if (target_sp) 2194 { 2195 ModuleSP module_sp (module.GetSP()); 2196 if (module_sp) 2197 { 2198 bool changed = false; 2199 if (module_sp->SetLoadAddress (*target_sp, slide_offset, changed)) 2200 { 2201 // The load was successful, make sure that at least some sections 2202 // changed before we notify that our module was loaded. 2203 if (changed) 2204 { 2205 ModuleList module_list; 2206 module_list.Append(module_sp); 2207 target_sp->ModulesDidLoad (module_list); 2208 } 2209 } 2210 } 2211 else 2212 { 2213 sb_error.SetErrorStringWithFormat ("invalid module"); 2214 } 2215 2216 } 2217 else 2218 { 2219 sb_error.SetErrorStringWithFormat ("invalid target"); 2220 } 2221 return sb_error; 2222 } 2223 2224 SBError 2225 SBTarget::ClearModuleLoadAddress (lldb::SBModule module) 2226 { 2227 SBError sb_error; 2228 2229 char path[PATH_MAX]; 2230 TargetSP target_sp(GetSP()); 2231 if (target_sp) 2232 { 2233 ModuleSP module_sp (module.GetSP()); 2234 if (module_sp) 2235 { 2236 ObjectFile *objfile = module_sp->GetObjectFile(); 2237 if (objfile) 2238 { 2239 SectionList *section_list = objfile->GetSectionList(); 2240 if (section_list) 2241 { 2242 const size_t num_sections = section_list->GetSize(); 2243 for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) 2244 { 2245 SectionSP section_sp (section_list->GetSectionAtIndex(sect_idx)); 2246 if (section_sp) 2247 target_sp->GetSectionLoadList().SetSectionUnloaded (section_sp); 2248 } 2249 } 2250 else 2251 { 2252 module_sp->GetFileSpec().GetPath (path, sizeof(path)); 2253 sb_error.SetErrorStringWithFormat ("no sections in object file '%s'", path); 2254 } 2255 } 2256 else 2257 { 2258 module_sp->GetFileSpec().GetPath (path, sizeof(path)); 2259 sb_error.SetErrorStringWithFormat ("no object file for module '%s'", path); 2260 } 2261 } 2262 else 2263 { 2264 sb_error.SetErrorStringWithFormat ("invalid module"); 2265 } 2266 } 2267 else 2268 { 2269 sb_error.SetErrorStringWithFormat ("invalid target"); 2270 } 2271 return sb_error; 2272 } 2273 2274 2275