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