1 //===-- SBProcess.cpp -------------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "lldb/lldb-python.h" 11 12 #include "lldb/API/SBProcess.h" 13 14 // C Includes 15 #include <inttypes.h> 16 17 #include "lldb/lldb-defines.h" 18 #include "lldb/lldb-types.h" 19 20 #include "lldb/Interpreter/Args.h" 21 #include "lldb/Core/Debugger.h" 22 #include "lldb/Core/Log.h" 23 #include "lldb/Core/Module.h" 24 #include "lldb/Core/State.h" 25 #include "lldb/Core/Stream.h" 26 #include "lldb/Core/StreamFile.h" 27 #include "lldb/Target/Process.h" 28 #include "lldb/Target/RegisterContext.h" 29 #include "lldb/Target/SystemRuntime.h" 30 #include "lldb/Target/Target.h" 31 #include "lldb/Target/Thread.h" 32 33 // Project includes 34 35 #include "lldb/API/SBBroadcaster.h" 36 #include "lldb/API/SBCommandReturnObject.h" 37 #include "lldb/API/SBDebugger.h" 38 #include "lldb/API/SBEvent.h" 39 #include "lldb/API/SBFileSpec.h" 40 #include "lldb/API/SBThread.h" 41 #include "lldb/API/SBThreadCollection.h" 42 #include "lldb/API/SBStream.h" 43 #include "lldb/API/SBStringList.h" 44 #include "lldb/API/SBUnixSignals.h" 45 46 using namespace lldb; 47 using namespace lldb_private; 48 49 50 SBProcess::SBProcess () : 51 m_opaque_wp() 52 { 53 } 54 55 56 //---------------------------------------------------------------------- 57 // SBProcess constructor 58 //---------------------------------------------------------------------- 59 60 SBProcess::SBProcess (const SBProcess& rhs) : 61 m_opaque_wp (rhs.m_opaque_wp) 62 { 63 } 64 65 66 SBProcess::SBProcess (const lldb::ProcessSP &process_sp) : 67 m_opaque_wp (process_sp) 68 { 69 } 70 71 const SBProcess& 72 SBProcess::operator = (const SBProcess& rhs) 73 { 74 if (this != &rhs) 75 m_opaque_wp = rhs.m_opaque_wp; 76 return *this; 77 } 78 79 //---------------------------------------------------------------------- 80 // Destructor 81 //---------------------------------------------------------------------- 82 SBProcess::~SBProcess() 83 { 84 } 85 86 const char * 87 SBProcess::GetBroadcasterClassName () 88 { 89 return Process::GetStaticBroadcasterClass().AsCString(); 90 } 91 92 const char * 93 SBProcess::GetPluginName () 94 { 95 ProcessSP process_sp(GetSP()); 96 if (process_sp) 97 { 98 return process_sp->GetPluginName().GetCString(); 99 } 100 return "<Unknown>"; 101 } 102 103 const char * 104 SBProcess::GetShortPluginName () 105 { 106 ProcessSP process_sp(GetSP()); 107 if (process_sp) 108 { 109 return process_sp->GetPluginName().GetCString(); 110 } 111 return "<Unknown>"; 112 } 113 114 115 lldb::ProcessSP 116 SBProcess::GetSP() const 117 { 118 return m_opaque_wp.lock(); 119 } 120 121 void 122 SBProcess::SetSP (const ProcessSP &process_sp) 123 { 124 m_opaque_wp = process_sp; 125 } 126 127 void 128 SBProcess::Clear () 129 { 130 m_opaque_wp.reset(); 131 } 132 133 134 bool 135 SBProcess::IsValid() const 136 { 137 ProcessSP process_sp(m_opaque_wp.lock()); 138 return ((bool) process_sp && process_sp->IsValid()); 139 } 140 141 bool 142 SBProcess::RemoteLaunch (char const **argv, 143 char const **envp, 144 const char *stdin_path, 145 const char *stdout_path, 146 const char *stderr_path, 147 const char *working_directory, 148 uint32_t launch_flags, 149 bool stop_at_entry, 150 lldb::SBError& error) 151 { 152 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 153 if (log) 154 log->Printf ("SBProcess(%p)::RemoteLaunch (argv=%p, envp=%p, stdin=%s, stdout=%s, stderr=%s, working-dir=%s, launch_flags=0x%x, stop_at_entry=%i, &error (%p))...", 155 static_cast<void*>(m_opaque_wp.lock().get()), 156 static_cast<void*>(argv), static_cast<void*>(envp), 157 stdin_path ? stdin_path : "NULL", 158 stdout_path ? stdout_path : "NULL", 159 stderr_path ? stderr_path : "NULL", 160 working_directory ? working_directory : "NULL", 161 launch_flags, stop_at_entry, 162 static_cast<void*>(error.get())); 163 164 ProcessSP process_sp(GetSP()); 165 if (process_sp) 166 { 167 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 168 if (process_sp->GetState() == eStateConnected) 169 { 170 if (stop_at_entry) 171 launch_flags |= eLaunchFlagStopAtEntry; 172 ProcessLaunchInfo launch_info (stdin_path, 173 stdout_path, 174 stderr_path, 175 working_directory, 176 launch_flags); 177 Module *exe_module = process_sp->GetTarget().GetExecutableModulePointer(); 178 if (exe_module) 179 launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true); 180 if (argv) 181 launch_info.GetArguments().AppendArguments (argv); 182 if (envp) 183 launch_info.GetEnvironmentEntries ().SetArguments (envp); 184 error.SetError (process_sp->Launch (launch_info)); 185 } 186 else 187 { 188 error.SetErrorString ("must be in eStateConnected to call RemoteLaunch"); 189 } 190 } 191 else 192 { 193 error.SetErrorString ("unable to attach pid"); 194 } 195 196 if (log) { 197 SBStream sstr; 198 error.GetDescription (sstr); 199 log->Printf ("SBProcess(%p)::RemoteLaunch (...) => SBError (%p): %s", 200 static_cast<void*>(process_sp.get()), 201 static_cast<void*>(error.get()), sstr.GetData()); 202 } 203 204 return error.Success(); 205 } 206 207 bool 208 SBProcess::RemoteAttachToProcessWithID (lldb::pid_t pid, lldb::SBError& error) 209 { 210 ProcessSP process_sp(GetSP()); 211 if (process_sp) 212 { 213 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 214 if (process_sp->GetState() == eStateConnected) 215 { 216 ProcessAttachInfo attach_info; 217 attach_info.SetProcessID (pid); 218 error.SetError (process_sp->Attach (attach_info)); 219 } 220 else 221 { 222 error.SetErrorString ("must be in eStateConnected to call RemoteAttachToProcessWithID"); 223 } 224 } 225 else 226 { 227 error.SetErrorString ("unable to attach pid"); 228 } 229 230 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 231 if (log) { 232 SBStream sstr; 233 error.GetDescription (sstr); 234 log->Printf ("SBProcess(%p)::RemoteAttachToProcessWithID (%" PRIu64 ") => SBError (%p): %s", 235 static_cast<void*>(process_sp.get()), pid, 236 static_cast<void*>(error.get()), sstr.GetData()); 237 } 238 239 return error.Success(); 240 } 241 242 243 uint32_t 244 SBProcess::GetNumThreads () 245 { 246 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 247 248 uint32_t num_threads = 0; 249 ProcessSP process_sp(GetSP()); 250 if (process_sp) 251 { 252 Process::StopLocker stop_locker; 253 254 const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); 255 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 256 num_threads = process_sp->GetThreadList().GetSize(can_update); 257 } 258 259 if (log) 260 log->Printf ("SBProcess(%p)::GetNumThreads () => %d", 261 static_cast<void*>(process_sp.get()), num_threads); 262 263 return num_threads; 264 } 265 266 SBThread 267 SBProcess::GetSelectedThread () const 268 { 269 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 270 271 SBThread sb_thread; 272 ThreadSP thread_sp; 273 ProcessSP process_sp(GetSP()); 274 if (process_sp) 275 { 276 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 277 thread_sp = process_sp->GetThreadList().GetSelectedThread(); 278 sb_thread.SetThread (thread_sp); 279 } 280 281 if (log) 282 log->Printf ("SBProcess(%p)::GetSelectedThread () => SBThread(%p)", 283 static_cast<void*>(process_sp.get()), 284 static_cast<void*>(thread_sp.get())); 285 286 return sb_thread; 287 } 288 289 SBThread 290 SBProcess::CreateOSPluginThread (lldb::tid_t tid, lldb::addr_t context) 291 { 292 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 293 294 SBThread sb_thread; 295 ThreadSP thread_sp; 296 ProcessSP process_sp(GetSP()); 297 if (process_sp) 298 { 299 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 300 thread_sp = process_sp->CreateOSPluginThread(tid, context); 301 sb_thread.SetThread (thread_sp); 302 } 303 304 if (log) 305 log->Printf ("SBProcess(%p)::CreateOSPluginThread (tid=0x%" PRIx64 ", context=0x%" PRIx64 ") => SBThread(%p)", 306 static_cast<void*>(process_sp.get()), tid, context, 307 static_cast<void*>(thread_sp.get())); 308 309 return sb_thread; 310 } 311 312 SBTarget 313 SBProcess::GetTarget() const 314 { 315 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 316 317 SBTarget sb_target; 318 TargetSP target_sp; 319 ProcessSP process_sp(GetSP()); 320 if (process_sp) 321 { 322 target_sp = process_sp->GetTarget().shared_from_this(); 323 sb_target.SetSP (target_sp); 324 } 325 326 if (log) 327 log->Printf ("SBProcess(%p)::GetTarget () => SBTarget(%p)", 328 static_cast<void*>(process_sp.get()), 329 static_cast<void*>(target_sp.get())); 330 331 return sb_target; 332 } 333 334 335 size_t 336 SBProcess::PutSTDIN (const char *src, size_t src_len) 337 { 338 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 339 340 size_t ret_val = 0; 341 ProcessSP process_sp(GetSP()); 342 if (process_sp) 343 { 344 Error error; 345 ret_val = process_sp->PutSTDIN (src, src_len, error); 346 } 347 348 if (log) 349 log->Printf("SBProcess(%p)::PutSTDIN (src=\"%s\", src_len=%" PRIu64 ") => %" PRIu64, 350 static_cast<void*>(process_sp.get()), src, 351 static_cast<uint64_t>(src_len), 352 static_cast<uint64_t>(ret_val)); 353 354 return ret_val; 355 } 356 357 size_t 358 SBProcess::GetSTDOUT (char *dst, size_t dst_len) const 359 { 360 size_t bytes_read = 0; 361 ProcessSP process_sp(GetSP()); 362 if (process_sp) 363 { 364 Error error; 365 bytes_read = process_sp->GetSTDOUT (dst, dst_len, error); 366 } 367 368 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 369 if (log) 370 log->Printf ("SBProcess(%p)::GetSTDOUT (dst=\"%.*s\", dst_len=%" PRIu64 ") => %" PRIu64, 371 static_cast<void*>(process_sp.get()), 372 static_cast<int>(bytes_read), dst, 373 static_cast<uint64_t>(dst_len), 374 static_cast<uint64_t>(bytes_read)); 375 376 return bytes_read; 377 } 378 379 size_t 380 SBProcess::GetSTDERR (char *dst, size_t dst_len) const 381 { 382 size_t bytes_read = 0; 383 ProcessSP process_sp(GetSP()); 384 if (process_sp) 385 { 386 Error error; 387 bytes_read = process_sp->GetSTDERR (dst, dst_len, error); 388 } 389 390 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 391 if (log) 392 log->Printf ("SBProcess(%p)::GetSTDERR (dst=\"%.*s\", dst_len=%" PRIu64 ") => %" PRIu64, 393 static_cast<void*>(process_sp.get()), 394 static_cast<int>(bytes_read), dst, 395 static_cast<uint64_t>(dst_len), 396 static_cast<uint64_t>(bytes_read)); 397 398 return bytes_read; 399 } 400 401 size_t 402 SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const 403 { 404 size_t bytes_read = 0; 405 ProcessSP process_sp(GetSP()); 406 if (process_sp) 407 { 408 Error error; 409 bytes_read = process_sp->GetAsyncProfileData (dst, dst_len, error); 410 } 411 412 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 413 if (log) 414 log->Printf ("SBProcess(%p)::GetProfileData (dst=\"%.*s\", dst_len=%" PRIu64 ") => %" PRIu64, 415 static_cast<void*>(process_sp.get()), 416 static_cast<int>(bytes_read), dst, 417 static_cast<uint64_t>(dst_len), 418 static_cast<uint64_t>(bytes_read)); 419 420 return bytes_read; 421 } 422 423 void 424 SBProcess::ReportEventState (const SBEvent &event, FILE *out) const 425 { 426 if (out == NULL) 427 return; 428 429 ProcessSP process_sp(GetSP()); 430 if (process_sp) 431 { 432 const StateType event_state = SBProcess::GetStateFromEvent (event); 433 char message[1024]; 434 int message_len = ::snprintf (message, 435 sizeof (message), 436 "Process %" PRIu64 " %s\n", 437 process_sp->GetID(), 438 SBDebugger::StateAsCString (event_state)); 439 440 if (message_len > 0) 441 ::fwrite (message, 1, message_len, out); 442 } 443 } 444 445 void 446 SBProcess::AppendEventStateReport (const SBEvent &event, SBCommandReturnObject &result) 447 { 448 ProcessSP process_sp(GetSP()); 449 if (process_sp) 450 { 451 const StateType event_state = SBProcess::GetStateFromEvent (event); 452 char message[1024]; 453 ::snprintf (message, 454 sizeof (message), 455 "Process %" PRIu64 " %s\n", 456 process_sp->GetID(), 457 SBDebugger::StateAsCString (event_state)); 458 459 result.AppendMessage (message); 460 } 461 } 462 463 bool 464 SBProcess::SetSelectedThread (const SBThread &thread) 465 { 466 ProcessSP process_sp(GetSP()); 467 if (process_sp) 468 { 469 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 470 return process_sp->GetThreadList().SetSelectedThreadByID (thread.GetThreadID()); 471 } 472 return false; 473 } 474 475 bool 476 SBProcess::SetSelectedThreadByID (lldb::tid_t tid) 477 { 478 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 479 480 bool ret_val = false; 481 ProcessSP process_sp(GetSP()); 482 if (process_sp) 483 { 484 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 485 ret_val = process_sp->GetThreadList().SetSelectedThreadByID (tid); 486 } 487 488 if (log) 489 log->Printf ("SBProcess(%p)::SetSelectedThreadByID (tid=0x%4.4" PRIx64 ") => %s", 490 static_cast<void*>(process_sp.get()), tid, 491 (ret_val ? "true" : "false")); 492 493 return ret_val; 494 } 495 496 bool 497 SBProcess::SetSelectedThreadByIndexID (uint32_t index_id) 498 { 499 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 500 501 bool ret_val = false; 502 ProcessSP process_sp(GetSP()); 503 if (process_sp) 504 { 505 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 506 ret_val = process_sp->GetThreadList().SetSelectedThreadByIndexID (index_id); 507 } 508 509 if (log) 510 log->Printf ("SBProcess(%p)::SetSelectedThreadByID (tid=0x%x) => %s", 511 static_cast<void*>(process_sp.get()), index_id, 512 (ret_val ? "true" : "false")); 513 514 return ret_val; 515 } 516 517 SBThread 518 SBProcess::GetThreadAtIndex (size_t index) 519 { 520 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 521 522 SBThread sb_thread; 523 ThreadSP thread_sp; 524 ProcessSP process_sp(GetSP()); 525 if (process_sp) 526 { 527 Process::StopLocker stop_locker; 528 const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); 529 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 530 thread_sp = process_sp->GetThreadList().GetThreadAtIndex(index, can_update); 531 sb_thread.SetThread (thread_sp); 532 } 533 534 if (log) 535 log->Printf ("SBProcess(%p)::GetThreadAtIndex (index=%d) => SBThread(%p)", 536 static_cast<void*>(process_sp.get()), 537 static_cast<uint32_t>(index), 538 static_cast<void*>(thread_sp.get())); 539 540 return sb_thread; 541 } 542 543 uint32_t 544 SBProcess::GetNumQueues () 545 { 546 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 547 548 uint32_t num_queues = 0; 549 ProcessSP process_sp(GetSP()); 550 if (process_sp) 551 { 552 Process::StopLocker stop_locker; 553 554 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 555 num_queues = process_sp->GetQueueList().GetSize(); 556 } 557 558 if (log) 559 log->Printf ("SBProcess(%p)::GetNumQueues () => %d", 560 static_cast<void*>(process_sp.get()), num_queues); 561 562 return num_queues; 563 } 564 565 SBQueue 566 SBProcess::GetQueueAtIndex (size_t index) 567 { 568 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 569 570 SBQueue sb_queue; 571 QueueSP queue_sp; 572 ProcessSP process_sp(GetSP()); 573 if (process_sp) 574 { 575 Process::StopLocker stop_locker; 576 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 577 queue_sp = process_sp->GetQueueList().GetQueueAtIndex(index); 578 sb_queue.SetQueue (queue_sp); 579 } 580 581 if (log) 582 log->Printf ("SBProcess(%p)::GetQueueAtIndex (index=%d) => SBQueue(%p)", 583 static_cast<void*>(process_sp.get()), 584 static_cast<uint32_t>(index), 585 static_cast<void*>(queue_sp.get())); 586 587 return sb_queue; 588 } 589 590 591 uint32_t 592 SBProcess::GetStopID(bool include_expression_stops) 593 { 594 ProcessSP process_sp(GetSP()); 595 if (process_sp) 596 { 597 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 598 if (include_expression_stops) 599 return process_sp->GetStopID(); 600 else 601 return process_sp->GetLastNaturalStopID(); 602 } 603 return 0; 604 } 605 606 StateType 607 SBProcess::GetState () 608 { 609 610 StateType ret_val = eStateInvalid; 611 ProcessSP process_sp(GetSP()); 612 if (process_sp) 613 { 614 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 615 ret_val = process_sp->GetState(); 616 } 617 618 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 619 if (log) 620 log->Printf ("SBProcess(%p)::GetState () => %s", 621 static_cast<void*>(process_sp.get()), 622 lldb_private::StateAsCString (ret_val)); 623 624 return ret_val; 625 } 626 627 628 int 629 SBProcess::GetExitStatus () 630 { 631 int exit_status = 0; 632 ProcessSP process_sp(GetSP()); 633 if (process_sp) 634 { 635 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 636 exit_status = process_sp->GetExitStatus (); 637 } 638 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 639 if (log) 640 log->Printf ("SBProcess(%p)::GetExitStatus () => %i (0x%8.8x)", 641 static_cast<void*>(process_sp.get()), exit_status, 642 exit_status); 643 644 return exit_status; 645 } 646 647 const char * 648 SBProcess::GetExitDescription () 649 { 650 const char *exit_desc = NULL; 651 ProcessSP process_sp(GetSP()); 652 if (process_sp) 653 { 654 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 655 exit_desc = process_sp->GetExitDescription (); 656 } 657 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 658 if (log) 659 log->Printf ("SBProcess(%p)::GetExitDescription () => %s", 660 static_cast<void*>(process_sp.get()), exit_desc); 661 return exit_desc; 662 } 663 664 lldb::pid_t 665 SBProcess::GetProcessID () 666 { 667 lldb::pid_t ret_val = LLDB_INVALID_PROCESS_ID; 668 ProcessSP process_sp(GetSP()); 669 if (process_sp) 670 ret_val = process_sp->GetID(); 671 672 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 673 if (log) 674 log->Printf ("SBProcess(%p)::GetProcessID () => %" PRIu64, 675 static_cast<void*>(process_sp.get()), ret_val); 676 677 return ret_val; 678 } 679 680 uint32_t 681 SBProcess::GetUniqueID() 682 { 683 uint32_t ret_val = 0; 684 ProcessSP process_sp(GetSP()); 685 if (process_sp) 686 ret_val = process_sp->GetUniqueID(); 687 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 688 if (log) 689 log->Printf ("SBProcess(%p)::GetUniqueID () => %" PRIu32, 690 static_cast<void*>(process_sp.get()), ret_val); 691 return ret_val; 692 } 693 694 ByteOrder 695 SBProcess::GetByteOrder () const 696 { 697 ByteOrder byteOrder = eByteOrderInvalid; 698 ProcessSP process_sp(GetSP()); 699 if (process_sp) 700 byteOrder = process_sp->GetTarget().GetArchitecture().GetByteOrder(); 701 702 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 703 if (log) 704 log->Printf ("SBProcess(%p)::GetByteOrder () => %d", 705 static_cast<void*>(process_sp.get()), byteOrder); 706 707 return byteOrder; 708 } 709 710 uint32_t 711 SBProcess::GetAddressByteSize () const 712 { 713 uint32_t size = 0; 714 ProcessSP process_sp(GetSP()); 715 if (process_sp) 716 size = process_sp->GetTarget().GetArchitecture().GetAddressByteSize(); 717 718 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 719 if (log) 720 log->Printf ("SBProcess(%p)::GetAddressByteSize () => %d", 721 static_cast<void*>(process_sp.get()), size); 722 723 return size; 724 } 725 726 SBError 727 SBProcess::Continue () 728 { 729 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 730 731 SBError sb_error; 732 ProcessSP process_sp(GetSP()); 733 734 if (log) 735 log->Printf ("SBProcess(%p)::Continue ()...", 736 static_cast<void*>(process_sp.get())); 737 738 if (process_sp) 739 { 740 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 741 742 Error error (process_sp->Resume()); 743 if (error.Success()) 744 { 745 if (process_sp->GetTarget().GetDebugger().GetAsyncExecution () == false) 746 { 747 if (log) 748 log->Printf ("SBProcess(%p)::Continue () waiting for process to stop...", 749 static_cast<void*>(process_sp.get())); 750 process_sp->WaitForProcessToStop (NULL); 751 } 752 } 753 sb_error.SetError(error); 754 } 755 else 756 sb_error.SetErrorString ("SBProcess is invalid"); 757 758 if (log) 759 { 760 SBStream sstr; 761 sb_error.GetDescription (sstr); 762 log->Printf ("SBProcess(%p)::Continue () => SBError (%p): %s", 763 static_cast<void*>(process_sp.get()), 764 static_cast<void*>(sb_error.get()), sstr.GetData()); 765 } 766 767 return sb_error; 768 } 769 770 771 SBError 772 SBProcess::Destroy () 773 { 774 SBError sb_error; 775 ProcessSP process_sp(GetSP()); 776 if (process_sp) 777 { 778 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 779 sb_error.SetError(process_sp->Destroy()); 780 } 781 else 782 sb_error.SetErrorString ("SBProcess is invalid"); 783 784 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 785 if (log) 786 { 787 SBStream sstr; 788 sb_error.GetDescription (sstr); 789 log->Printf ("SBProcess(%p)::Destroy () => SBError (%p): %s", 790 static_cast<void*>(process_sp.get()), 791 static_cast<void*>(sb_error.get()), sstr.GetData()); 792 } 793 794 return sb_error; 795 } 796 797 798 SBError 799 SBProcess::Stop () 800 { 801 SBError sb_error; 802 ProcessSP process_sp(GetSP()); 803 if (process_sp) 804 { 805 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 806 sb_error.SetError (process_sp->Halt()); 807 } 808 else 809 sb_error.SetErrorString ("SBProcess is invalid"); 810 811 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 812 if (log) 813 { 814 SBStream sstr; 815 sb_error.GetDescription (sstr); 816 log->Printf ("SBProcess(%p)::Stop () => SBError (%p): %s", 817 static_cast<void*>(process_sp.get()), 818 static_cast<void*>(sb_error.get()), sstr.GetData()); 819 } 820 821 return sb_error; 822 } 823 824 SBError 825 SBProcess::Kill () 826 { 827 SBError sb_error; 828 ProcessSP process_sp(GetSP()); 829 if (process_sp) 830 { 831 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 832 sb_error.SetError (process_sp->Destroy()); 833 } 834 else 835 sb_error.SetErrorString ("SBProcess is invalid"); 836 837 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 838 if (log) 839 { 840 SBStream sstr; 841 sb_error.GetDescription (sstr); 842 log->Printf ("SBProcess(%p)::Kill () => SBError (%p): %s", 843 static_cast<void*>(process_sp.get()), 844 static_cast<void*>(sb_error.get()), sstr.GetData()); 845 } 846 847 return sb_error; 848 } 849 850 SBError 851 SBProcess::Detach () 852 { 853 // FIXME: This should come from a process default. 854 bool keep_stopped = false; 855 return Detach (keep_stopped); 856 } 857 858 SBError 859 SBProcess::Detach (bool keep_stopped) 860 { 861 SBError sb_error; 862 ProcessSP process_sp(GetSP()); 863 if (process_sp) 864 { 865 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 866 sb_error.SetError (process_sp->Detach(keep_stopped)); 867 } 868 else 869 sb_error.SetErrorString ("SBProcess is invalid"); 870 871 return sb_error; 872 } 873 874 SBError 875 SBProcess::Signal (int signo) 876 { 877 SBError sb_error; 878 ProcessSP process_sp(GetSP()); 879 if (process_sp) 880 { 881 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 882 sb_error.SetError (process_sp->Signal (signo)); 883 } 884 else 885 sb_error.SetErrorString ("SBProcess is invalid"); 886 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 887 if (log) 888 { 889 SBStream sstr; 890 sb_error.GetDescription (sstr); 891 log->Printf ("SBProcess(%p)::Signal (signo=%i) => SBError (%p): %s", 892 static_cast<void*>(process_sp.get()), signo, 893 static_cast<void*>(sb_error.get()), sstr.GetData()); 894 } 895 return sb_error; 896 } 897 898 SBUnixSignals 899 SBProcess::GetUnixSignals() 900 { 901 SBUnixSignals sb_unix_signals; 902 ProcessSP process_sp(GetSP()); 903 if (process_sp) 904 { 905 sb_unix_signals.SetSP(process_sp); 906 } 907 908 return sb_unix_signals; 909 } 910 911 void 912 SBProcess::SendAsyncInterrupt () 913 { 914 ProcessSP process_sp(GetSP()); 915 if (process_sp) 916 { 917 process_sp->SendAsyncInterrupt (); 918 } 919 } 920 921 SBThread 922 SBProcess::GetThreadByID (tid_t tid) 923 { 924 SBThread sb_thread; 925 ThreadSP thread_sp; 926 ProcessSP process_sp(GetSP()); 927 if (process_sp) 928 { 929 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 930 Process::StopLocker stop_locker; 931 const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); 932 thread_sp = process_sp->GetThreadList().FindThreadByID (tid, can_update); 933 sb_thread.SetThread (thread_sp); 934 } 935 936 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 937 if (log) 938 log->Printf ("SBProcess(%p)::GetThreadByID (tid=0x%4.4" PRIx64 ") => SBThread (%p)", 939 static_cast<void*>(process_sp.get()), tid, 940 static_cast<void*>(thread_sp.get())); 941 942 return sb_thread; 943 } 944 945 SBThread 946 SBProcess::GetThreadByIndexID (uint32_t index_id) 947 { 948 SBThread sb_thread; 949 ThreadSP thread_sp; 950 ProcessSP process_sp(GetSP()); 951 if (process_sp) 952 { 953 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 954 Process::StopLocker stop_locker; 955 const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock()); 956 thread_sp = process_sp->GetThreadList().FindThreadByIndexID (index_id, can_update); 957 sb_thread.SetThread (thread_sp); 958 } 959 960 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 961 if (log) 962 log->Printf ("SBProcess(%p)::GetThreadByID (tid=0x%x) => SBThread (%p)", 963 static_cast<void*>(process_sp.get()), index_id, 964 static_cast<void*>(thread_sp.get())); 965 966 return sb_thread; 967 } 968 969 StateType 970 SBProcess::GetStateFromEvent (const SBEvent &event) 971 { 972 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 973 974 StateType ret_val = Process::ProcessEventData::GetStateFromEvent (event.get()); 975 976 if (log) 977 log->Printf ("SBProcess::GetStateFromEvent (event.sp=%p) => %s", 978 static_cast<void*>(event.get()), 979 lldb_private::StateAsCString (ret_val)); 980 981 return ret_val; 982 } 983 984 bool 985 SBProcess::GetRestartedFromEvent (const SBEvent &event) 986 { 987 return Process::ProcessEventData::GetRestartedFromEvent (event.get()); 988 } 989 990 size_t 991 SBProcess::GetNumRestartedReasonsFromEvent (const lldb::SBEvent &event) 992 { 993 return Process::ProcessEventData::GetNumRestartedReasons(event.get()); 994 } 995 996 const char * 997 SBProcess::GetRestartedReasonAtIndexFromEvent (const lldb::SBEvent &event, size_t idx) 998 { 999 return Process::ProcessEventData::GetRestartedReasonAtIndex(event.get(), idx); 1000 } 1001 1002 SBProcess 1003 SBProcess::GetProcessFromEvent (const SBEvent &event) 1004 { 1005 SBProcess process(Process::ProcessEventData::GetProcessFromEvent (event.get())); 1006 return process; 1007 } 1008 1009 bool 1010 SBProcess::EventIsProcessEvent (const SBEvent &event) 1011 { 1012 return strcmp (event.GetBroadcasterClass(), SBProcess::GetBroadcasterClass()) == 0; 1013 } 1014 1015 SBBroadcaster 1016 SBProcess::GetBroadcaster () const 1017 { 1018 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1019 1020 ProcessSP process_sp(GetSP()); 1021 1022 SBBroadcaster broadcaster(process_sp.get(), false); 1023 1024 if (log) 1025 log->Printf ("SBProcess(%p)::GetBroadcaster () => SBBroadcaster (%p)", 1026 static_cast<void*>(process_sp.get()), 1027 static_cast<void*>(broadcaster.get())); 1028 1029 return broadcaster; 1030 } 1031 1032 const char * 1033 SBProcess::GetBroadcasterClass () 1034 { 1035 return Process::GetStaticBroadcasterClass().AsCString(); 1036 } 1037 1038 size_t 1039 SBProcess::ReadMemory (addr_t addr, void *dst, size_t dst_len, SBError &sb_error) 1040 { 1041 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1042 1043 size_t bytes_read = 0; 1044 1045 ProcessSP process_sp(GetSP()); 1046 1047 if (log) 1048 log->Printf ("SBProcess(%p)::ReadMemory (addr=0x%" PRIx64 ", dst=%p, dst_len=%" PRIu64 ", SBError (%p))...", 1049 static_cast<void*>(process_sp.get()), addr, 1050 static_cast<void*>(dst), static_cast<uint64_t>(dst_len), 1051 static_cast<void*>(sb_error.get())); 1052 1053 if (process_sp) 1054 { 1055 Process::StopLocker stop_locker; 1056 if (stop_locker.TryLock(&process_sp->GetRunLock())) 1057 { 1058 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 1059 bytes_read = process_sp->ReadMemory (addr, dst, dst_len, sb_error.ref()); 1060 } 1061 else 1062 { 1063 if (log) 1064 log->Printf ("SBProcess(%p)::ReadMemory() => error: process is running", 1065 static_cast<void*>(process_sp.get())); 1066 sb_error.SetErrorString("process is running"); 1067 } 1068 } 1069 else 1070 { 1071 sb_error.SetErrorString ("SBProcess is invalid"); 1072 } 1073 1074 if (log) 1075 { 1076 SBStream sstr; 1077 sb_error.GetDescription (sstr); 1078 log->Printf ("SBProcess(%p)::ReadMemory (addr=0x%" PRIx64 ", dst=%p, dst_len=%" PRIu64 ", SBError (%p): %s) => %" PRIu64, 1079 static_cast<void*>(process_sp.get()), addr, 1080 static_cast<void*>(dst), static_cast<uint64_t>(dst_len), 1081 static_cast<void*>(sb_error.get()), sstr.GetData(), 1082 static_cast<uint64_t>(bytes_read)); 1083 } 1084 1085 return bytes_read; 1086 } 1087 1088 size_t 1089 SBProcess::ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &sb_error) 1090 { 1091 size_t bytes_read = 0; 1092 ProcessSP process_sp(GetSP()); 1093 if (process_sp) 1094 { 1095 Process::StopLocker stop_locker; 1096 if (stop_locker.TryLock(&process_sp->GetRunLock())) 1097 { 1098 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 1099 bytes_read = process_sp->ReadCStringFromMemory (addr, (char *)buf, size, sb_error.ref()); 1100 } 1101 else 1102 { 1103 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1104 if (log) 1105 log->Printf ("SBProcess(%p)::ReadCStringFromMemory() => error: process is running", 1106 static_cast<void*>(process_sp.get())); 1107 sb_error.SetErrorString("process is running"); 1108 } 1109 } 1110 else 1111 { 1112 sb_error.SetErrorString ("SBProcess is invalid"); 1113 } 1114 return bytes_read; 1115 } 1116 1117 uint64_t 1118 SBProcess::ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &sb_error) 1119 { 1120 uint64_t value = 0; 1121 ProcessSP process_sp(GetSP()); 1122 if (process_sp) 1123 { 1124 Process::StopLocker stop_locker; 1125 if (stop_locker.TryLock(&process_sp->GetRunLock())) 1126 { 1127 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 1128 value = process_sp->ReadUnsignedIntegerFromMemory (addr, byte_size, 0, sb_error.ref()); 1129 } 1130 else 1131 { 1132 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1133 if (log) 1134 log->Printf ("SBProcess(%p)::ReadUnsignedFromMemory() => error: process is running", 1135 static_cast<void*>(process_sp.get())); 1136 sb_error.SetErrorString("process is running"); 1137 } 1138 } 1139 else 1140 { 1141 sb_error.SetErrorString ("SBProcess is invalid"); 1142 } 1143 return value; 1144 } 1145 1146 lldb::addr_t 1147 SBProcess::ReadPointerFromMemory (addr_t addr, lldb::SBError &sb_error) 1148 { 1149 lldb::addr_t ptr = LLDB_INVALID_ADDRESS; 1150 ProcessSP process_sp(GetSP()); 1151 if (process_sp) 1152 { 1153 Process::StopLocker stop_locker; 1154 if (stop_locker.TryLock(&process_sp->GetRunLock())) 1155 { 1156 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 1157 ptr = process_sp->ReadPointerFromMemory (addr, sb_error.ref()); 1158 } 1159 else 1160 { 1161 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1162 if (log) 1163 log->Printf ("SBProcess(%p)::ReadPointerFromMemory() => error: process is running", 1164 static_cast<void*>(process_sp.get())); 1165 sb_error.SetErrorString("process is running"); 1166 } 1167 } 1168 else 1169 { 1170 sb_error.SetErrorString ("SBProcess is invalid"); 1171 } 1172 return ptr; 1173 } 1174 1175 size_t 1176 SBProcess::WriteMemory (addr_t addr, const void *src, size_t src_len, SBError &sb_error) 1177 { 1178 size_t bytes_written = 0; 1179 1180 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1181 1182 ProcessSP process_sp(GetSP()); 1183 1184 if (log) 1185 log->Printf ("SBProcess(%p)::WriteMemory (addr=0x%" PRIx64 ", src=%p, src_len=%" PRIu64 ", SBError (%p))...", 1186 static_cast<void*>(process_sp.get()), addr, 1187 static_cast<const void*>(src), 1188 static_cast<uint64_t>(src_len), 1189 static_cast<void*>(sb_error.get())); 1190 1191 if (process_sp) 1192 { 1193 Process::StopLocker stop_locker; 1194 if (stop_locker.TryLock(&process_sp->GetRunLock())) 1195 { 1196 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 1197 bytes_written = process_sp->WriteMemory (addr, src, src_len, sb_error.ref()); 1198 } 1199 else 1200 { 1201 if (log) 1202 log->Printf ("SBProcess(%p)::WriteMemory() => error: process is running", 1203 static_cast<void*>(process_sp.get())); 1204 sb_error.SetErrorString("process is running"); 1205 } 1206 } 1207 1208 if (log) 1209 { 1210 SBStream sstr; 1211 sb_error.GetDescription (sstr); 1212 log->Printf ("SBProcess(%p)::WriteMemory (addr=0x%" PRIx64 ", src=%p, src_len=%" PRIu64 ", SBError (%p): %s) => %" PRIu64, 1213 static_cast<void*>(process_sp.get()), addr, 1214 static_cast<const void*>(src), 1215 static_cast<uint64_t>(src_len), 1216 static_cast<void*>(sb_error.get()), sstr.GetData(), 1217 static_cast<uint64_t>(bytes_written)); 1218 } 1219 1220 return bytes_written; 1221 } 1222 1223 bool 1224 SBProcess::GetDescription (SBStream &description) 1225 { 1226 Stream &strm = description.ref(); 1227 1228 ProcessSP process_sp(GetSP()); 1229 if (process_sp) 1230 { 1231 char path[PATH_MAX]; 1232 GetTarget().GetExecutable().GetPath (path, sizeof(path)); 1233 Module *exe_module = process_sp->GetTarget().GetExecutableModulePointer(); 1234 const char *exe_name = NULL; 1235 if (exe_module) 1236 exe_name = exe_module->GetFileSpec().GetFilename().AsCString(); 1237 1238 strm.Printf ("SBProcess: pid = %" PRIu64 ", state = %s, threads = %d%s%s", 1239 process_sp->GetID(), 1240 lldb_private::StateAsCString (GetState()), 1241 GetNumThreads(), 1242 exe_name ? ", executable = " : "", 1243 exe_name ? exe_name : ""); 1244 } 1245 else 1246 strm.PutCString ("No value"); 1247 1248 return true; 1249 } 1250 1251 uint32_t 1252 SBProcess::GetNumSupportedHardwareWatchpoints (lldb::SBError &sb_error) const 1253 { 1254 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1255 1256 uint32_t num = 0; 1257 ProcessSP process_sp(GetSP()); 1258 if (process_sp) 1259 { 1260 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 1261 sb_error.SetError(process_sp->GetWatchpointSupportInfo (num)); 1262 if (log) 1263 log->Printf ("SBProcess(%p)::GetNumSupportedHardwareWatchpoints () => %u", 1264 static_cast<void*>(process_sp.get()), num); 1265 } 1266 else 1267 { 1268 sb_error.SetErrorString ("SBProcess is invalid"); 1269 } 1270 return num; 1271 } 1272 1273 uint32_t 1274 SBProcess::LoadImage (lldb::SBFileSpec &sb_image_spec, lldb::SBError &sb_error) 1275 { 1276 ProcessSP process_sp(GetSP()); 1277 if (process_sp) 1278 { 1279 Process::StopLocker stop_locker; 1280 if (stop_locker.TryLock(&process_sp->GetRunLock())) 1281 { 1282 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 1283 return process_sp->LoadImage (*sb_image_spec, sb_error.ref()); 1284 } 1285 else 1286 { 1287 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1288 if (log) 1289 log->Printf ("SBProcess(%p)::LoadImage() => error: process is running", 1290 static_cast<void*>(process_sp.get())); 1291 sb_error.SetErrorString("process is running"); 1292 } 1293 } 1294 return LLDB_INVALID_IMAGE_TOKEN; 1295 } 1296 1297 lldb::SBError 1298 SBProcess::UnloadImage (uint32_t image_token) 1299 { 1300 lldb::SBError sb_error; 1301 ProcessSP process_sp(GetSP()); 1302 if (process_sp) 1303 { 1304 Process::StopLocker stop_locker; 1305 if (stop_locker.TryLock(&process_sp->GetRunLock())) 1306 { 1307 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 1308 sb_error.SetError (process_sp->UnloadImage (image_token)); 1309 } 1310 else 1311 { 1312 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1313 if (log) 1314 log->Printf ("SBProcess(%p)::UnloadImage() => error: process is running", 1315 static_cast<void*>(process_sp.get())); 1316 sb_error.SetErrorString("process is running"); 1317 } 1318 } 1319 else 1320 sb_error.SetErrorString("invalid process"); 1321 return sb_error; 1322 } 1323 1324 lldb::SBError 1325 SBProcess::SendEventData (const char *event_data) 1326 { 1327 lldb::SBError sb_error; 1328 ProcessSP process_sp(GetSP()); 1329 if (process_sp) 1330 { 1331 Process::StopLocker stop_locker; 1332 if (stop_locker.TryLock(&process_sp->GetRunLock())) 1333 { 1334 Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); 1335 sb_error.SetError (process_sp->SendEventData (event_data)); 1336 } 1337 else 1338 { 1339 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1340 if (log) 1341 log->Printf ("SBProcess(%p)::SendEventData() => error: process is running", 1342 static_cast<void*>(process_sp.get())); 1343 sb_error.SetErrorString("process is running"); 1344 } 1345 } 1346 else 1347 sb_error.SetErrorString("invalid process"); 1348 return sb_error; 1349 } 1350 1351 uint32_t 1352 SBProcess::GetNumExtendedBacktraceTypes () 1353 { 1354 ProcessSP process_sp(GetSP()); 1355 if (process_sp && process_sp->GetSystemRuntime()) 1356 { 1357 SystemRuntime *runtime = process_sp->GetSystemRuntime(); 1358 return runtime->GetExtendedBacktraceTypes().size(); 1359 } 1360 return 0; 1361 } 1362 1363 const char * 1364 SBProcess::GetExtendedBacktraceTypeAtIndex (uint32_t idx) 1365 { 1366 ProcessSP process_sp(GetSP()); 1367 if (process_sp && process_sp->GetSystemRuntime()) 1368 { 1369 SystemRuntime *runtime = process_sp->GetSystemRuntime(); 1370 const std::vector<ConstString> &names = runtime->GetExtendedBacktraceTypes(); 1371 if (idx < names.size()) 1372 { 1373 return names[idx].AsCString(); 1374 } 1375 else 1376 { 1377 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1378 if (log) 1379 log->Printf("SBProcess(%p)::GetExtendedBacktraceTypeAtIndex() => error: requested extended backtrace name out of bounds", 1380 static_cast<void*>(process_sp.get())); 1381 } 1382 } 1383 return NULL; 1384 } 1385 1386 SBThreadCollection 1387 SBProcess::GetHistoryThreads (addr_t addr) 1388 { 1389 ProcessSP process_sp(GetSP()); 1390 SBThreadCollection threads; 1391 if (process_sp) 1392 { 1393 threads = SBThreadCollection(process_sp->GetHistoryThreads(addr)); 1394 } 1395 return threads; 1396 } 1397 1398 bool 1399 SBProcess::IsInstrumentationRuntimePresent(InstrumentationRuntimeType type) 1400 { 1401 ProcessSP process_sp(GetSP()); 1402 if (! process_sp) 1403 return false; 1404 1405 InstrumentationRuntimeSP runtime_sp = process_sp->GetInstrumentationRuntime(type); 1406 1407 if (! runtime_sp.get()) 1408 return false; 1409 1410 return runtime_sp->IsActive(); 1411 } 1412