1 //===-- SBBreakpoint.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/SBBreakpoint.h" 11 #include "lldb/API/SBBreakpointLocation.h" 12 #include "lldb/API/SBDebugger.h" 13 #include "lldb/API/SBEvent.h" 14 #include "lldb/API/SBProcess.h" 15 #include "lldb/API/SBStream.h" 16 #include "lldb/API/SBStringList.h" 17 #include "lldb/API/SBThread.h" 18 19 #include "lldb/Breakpoint/Breakpoint.h" 20 #include "lldb/Breakpoint/BreakpointLocation.h" 21 #include "lldb/Breakpoint/StoppointCallbackContext.h" 22 #include "lldb/Core/Address.h" 23 #include "lldb/Core/Debugger.h" 24 #include "lldb/Core/Log.h" 25 #include "lldb/Core/Stream.h" 26 #include "lldb/Core/StreamFile.h" 27 #include "lldb/Interpreter/CommandInterpreter.h" 28 #include "lldb/Interpreter/ScriptInterpreter.h" 29 #include "lldb/Target/Process.h" 30 #include "lldb/Target/SectionLoadList.h" 31 #include "lldb/Target/Target.h" 32 #include "lldb/Target/Thread.h" 33 #include "lldb/Target/ThreadSpec.h" 34 35 36 #include "lldb/lldb-enumerations.h" 37 38 using namespace lldb; 39 using namespace lldb_private; 40 41 struct CallbackData 42 { 43 SBBreakpoint::BreakpointHitCallback callback; 44 void *callback_baton; 45 }; 46 47 class SBBreakpointCallbackBaton : public Baton 48 { 49 public: 50 51 SBBreakpointCallbackBaton (SBBreakpoint::BreakpointHitCallback callback, void *baton) : 52 Baton (new CallbackData) 53 { 54 CallbackData *data = (CallbackData *)m_data; 55 data->callback = callback; 56 data->callback_baton = baton; 57 } 58 59 virtual ~SBBreakpointCallbackBaton() 60 { 61 CallbackData *data = (CallbackData *)m_data; 62 63 if (data) 64 { 65 delete data; 66 m_data = NULL; 67 } 68 } 69 }; 70 71 72 SBBreakpoint::SBBreakpoint () : 73 m_opaque_sp () 74 { 75 } 76 77 SBBreakpoint::SBBreakpoint (const SBBreakpoint& rhs) : 78 m_opaque_sp (rhs.m_opaque_sp) 79 { 80 } 81 82 83 SBBreakpoint::SBBreakpoint (const lldb::BreakpointSP &bp_sp) : 84 m_opaque_sp (bp_sp) 85 { 86 } 87 88 SBBreakpoint::~SBBreakpoint() 89 { 90 } 91 92 const SBBreakpoint & 93 SBBreakpoint::operator = (const SBBreakpoint& rhs) 94 { 95 if (this != &rhs) 96 m_opaque_sp = rhs.m_opaque_sp; 97 return *this; 98 } 99 100 bool 101 SBBreakpoint::operator == (const lldb::SBBreakpoint& rhs) 102 { 103 if (m_opaque_sp && rhs.m_opaque_sp) 104 return m_opaque_sp.get() == rhs.m_opaque_sp.get(); 105 return false; 106 } 107 108 bool 109 SBBreakpoint::operator != (const lldb::SBBreakpoint& rhs) 110 { 111 if (m_opaque_sp && rhs.m_opaque_sp) 112 return m_opaque_sp.get() != rhs.m_opaque_sp.get(); 113 return (m_opaque_sp && !rhs.m_opaque_sp) || (rhs.m_opaque_sp && !m_opaque_sp); 114 } 115 116 break_id_t 117 SBBreakpoint::GetID () const 118 { 119 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 120 121 break_id_t break_id = LLDB_INVALID_BREAK_ID; 122 if (m_opaque_sp) 123 break_id = m_opaque_sp->GetID(); 124 125 if (log) 126 { 127 if (break_id == LLDB_INVALID_BREAK_ID) 128 log->Printf ("SBBreakpoint(%p)::GetID () => LLDB_INVALID_BREAK_ID", 129 static_cast<void*>(m_opaque_sp.get())); 130 else 131 log->Printf ("SBBreakpoint(%p)::GetID () => %u", 132 static_cast<void*>(m_opaque_sp.get()), break_id); 133 } 134 135 return break_id; 136 } 137 138 139 bool 140 SBBreakpoint::IsValid() const 141 { 142 if (!m_opaque_sp) 143 return false; 144 else if (m_opaque_sp->GetTarget().GetBreakpointByID(m_opaque_sp->GetID())) 145 return true; 146 else 147 return false; 148 } 149 150 void 151 SBBreakpoint::ClearAllBreakpointSites () 152 { 153 if (m_opaque_sp) 154 { 155 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 156 m_opaque_sp->ClearAllBreakpointSites (); 157 } 158 } 159 160 SBBreakpointLocation 161 SBBreakpoint::FindLocationByAddress (addr_t vm_addr) 162 { 163 SBBreakpointLocation sb_bp_location; 164 165 if (m_opaque_sp) 166 { 167 if (vm_addr != LLDB_INVALID_ADDRESS) 168 { 169 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 170 Address address; 171 Target &target = m_opaque_sp->GetTarget(); 172 if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false) 173 { 174 address.SetRawAddress (vm_addr); 175 } 176 sb_bp_location.SetLocation (m_opaque_sp->FindLocationByAddress (address)); 177 } 178 } 179 return sb_bp_location; 180 } 181 182 break_id_t 183 SBBreakpoint::FindLocationIDByAddress (addr_t vm_addr) 184 { 185 break_id_t break_id = LLDB_INVALID_BREAK_ID; 186 187 if (m_opaque_sp && vm_addr != LLDB_INVALID_ADDRESS) 188 { 189 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 190 Address address; 191 Target &target = m_opaque_sp->GetTarget(); 192 if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false) 193 { 194 address.SetRawAddress (vm_addr); 195 } 196 break_id = m_opaque_sp->FindLocationIDByAddress (address); 197 } 198 199 return break_id; 200 } 201 202 SBBreakpointLocation 203 SBBreakpoint::FindLocationByID (break_id_t bp_loc_id) 204 { 205 SBBreakpointLocation sb_bp_location; 206 207 if (m_opaque_sp) 208 { 209 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 210 sb_bp_location.SetLocation (m_opaque_sp->FindLocationByID (bp_loc_id)); 211 } 212 213 return sb_bp_location; 214 } 215 216 SBBreakpointLocation 217 SBBreakpoint::GetLocationAtIndex (uint32_t index) 218 { 219 SBBreakpointLocation sb_bp_location; 220 221 if (m_opaque_sp) 222 { 223 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 224 sb_bp_location.SetLocation (m_opaque_sp->GetLocationAtIndex (index)); 225 } 226 227 return sb_bp_location; 228 } 229 230 void 231 SBBreakpoint::SetEnabled (bool enable) 232 { 233 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 234 235 if (log) 236 log->Printf ("SBBreakpoint(%p)::SetEnabled (enabled=%i)", 237 static_cast<void*>(m_opaque_sp.get()), enable); 238 239 if (m_opaque_sp) 240 { 241 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 242 m_opaque_sp->SetEnabled (enable); 243 } 244 } 245 246 bool 247 SBBreakpoint::IsEnabled () 248 { 249 if (m_opaque_sp) 250 { 251 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 252 return m_opaque_sp->IsEnabled(); 253 } 254 else 255 return false; 256 } 257 258 void 259 SBBreakpoint::SetOneShot (bool one_shot) 260 { 261 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 262 263 if (log) 264 log->Printf ("SBBreakpoint(%p)::SetOneShot (one_shot=%i)", 265 static_cast<void*>(m_opaque_sp.get()), one_shot); 266 267 if (m_opaque_sp) 268 { 269 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 270 m_opaque_sp->SetOneShot (one_shot); 271 } 272 } 273 274 bool 275 SBBreakpoint::IsOneShot () const 276 { 277 if (m_opaque_sp) 278 { 279 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 280 return m_opaque_sp->IsOneShot(); 281 } 282 else 283 return false; 284 } 285 286 bool 287 SBBreakpoint::IsInternal () 288 { 289 if (m_opaque_sp) 290 { 291 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 292 return m_opaque_sp->IsInternal(); 293 } 294 else 295 return false; 296 } 297 298 void 299 SBBreakpoint::SetIgnoreCount (uint32_t count) 300 { 301 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 302 303 if (log) 304 log->Printf ("SBBreakpoint(%p)::SetIgnoreCount (count=%u)", 305 static_cast<void*>(m_opaque_sp.get()), count); 306 307 if (m_opaque_sp) 308 { 309 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 310 m_opaque_sp->SetIgnoreCount (count); 311 } 312 } 313 314 void 315 SBBreakpoint::SetCondition (const char *condition) 316 { 317 if (m_opaque_sp) 318 { 319 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 320 m_opaque_sp->SetCondition (condition); 321 } 322 } 323 324 const char * 325 SBBreakpoint::GetCondition () 326 { 327 if (m_opaque_sp) 328 { 329 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 330 return m_opaque_sp->GetConditionText (); 331 } 332 return NULL; 333 } 334 335 uint32_t 336 SBBreakpoint::GetHitCount () const 337 { 338 uint32_t count = 0; 339 if (m_opaque_sp) 340 { 341 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 342 count = m_opaque_sp->GetHitCount(); 343 } 344 345 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 346 if (log) 347 log->Printf ("SBBreakpoint(%p)::GetHitCount () => %u", 348 static_cast<void*>(m_opaque_sp.get()), count); 349 350 return count; 351 } 352 353 uint32_t 354 SBBreakpoint::GetIgnoreCount () const 355 { 356 uint32_t count = 0; 357 if (m_opaque_sp) 358 { 359 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 360 count = m_opaque_sp->GetIgnoreCount(); 361 } 362 363 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 364 if (log) 365 log->Printf ("SBBreakpoint(%p)::GetIgnoreCount () => %u", 366 static_cast<void*>(m_opaque_sp.get()), count); 367 368 return count; 369 } 370 371 void 372 SBBreakpoint::SetThreadID (tid_t tid) 373 { 374 if (m_opaque_sp) 375 { 376 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 377 m_opaque_sp->SetThreadID (tid); 378 } 379 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 380 if (log) 381 log->Printf ("SBBreakpoint(%p)::SetThreadID (tid=0x%4.4" PRIx64 ")", 382 static_cast<void*>(m_opaque_sp.get()), tid); 383 384 } 385 386 tid_t 387 SBBreakpoint::GetThreadID () 388 { 389 tid_t tid = LLDB_INVALID_THREAD_ID; 390 if (m_opaque_sp) 391 { 392 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 393 tid = m_opaque_sp->GetThreadID(); 394 } 395 396 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 397 if (log) 398 log->Printf ("SBBreakpoint(%p)::GetThreadID () => 0x%4.4" PRIx64, 399 static_cast<void*>(m_opaque_sp.get()), tid); 400 return tid; 401 } 402 403 void 404 SBBreakpoint::SetThreadIndex (uint32_t index) 405 { 406 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 407 if (log) 408 log->Printf ("SBBreakpoint(%p)::SetThreadIndex (%u)", 409 static_cast<void*>(m_opaque_sp.get()), index); 410 if (m_opaque_sp) 411 { 412 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 413 m_opaque_sp->GetOptions()->GetThreadSpec()->SetIndex (index); 414 } 415 } 416 417 uint32_t 418 SBBreakpoint::GetThreadIndex() const 419 { 420 uint32_t thread_idx = UINT32_MAX; 421 if (m_opaque_sp) 422 { 423 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 424 const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate(); 425 if (thread_spec != NULL) 426 thread_idx = thread_spec->GetIndex(); 427 } 428 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 429 if (log) 430 log->Printf ("SBBreakpoint(%p)::GetThreadIndex () => %u", 431 static_cast<void*>(m_opaque_sp.get()), thread_idx); 432 433 return thread_idx; 434 } 435 436 void 437 SBBreakpoint::SetThreadName (const char *thread_name) 438 { 439 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 440 if (log) 441 log->Printf ("SBBreakpoint(%p)::SetThreadName (%s)", 442 static_cast<void*>(m_opaque_sp.get()), thread_name); 443 444 if (m_opaque_sp) 445 { 446 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 447 m_opaque_sp->GetOptions()->GetThreadSpec()->SetName (thread_name); 448 } 449 } 450 451 const char * 452 SBBreakpoint::GetThreadName () const 453 { 454 const char *name = NULL; 455 if (m_opaque_sp) 456 { 457 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 458 const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate(); 459 if (thread_spec != NULL) 460 name = thread_spec->GetName(); 461 } 462 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 463 if (log) 464 log->Printf ("SBBreakpoint(%p)::GetThreadName () => %s", 465 static_cast<void*>(m_opaque_sp.get()), name); 466 467 return name; 468 } 469 470 void 471 SBBreakpoint::SetQueueName (const char *queue_name) 472 { 473 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 474 if (log) 475 log->Printf ("SBBreakpoint(%p)::SetQueueName (%s)", 476 static_cast<void*>(m_opaque_sp.get()), queue_name); 477 if (m_opaque_sp) 478 { 479 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 480 m_opaque_sp->GetOptions()->GetThreadSpec()->SetQueueName (queue_name); 481 } 482 } 483 484 const char * 485 SBBreakpoint::GetQueueName () const 486 { 487 const char *name = NULL; 488 if (m_opaque_sp) 489 { 490 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 491 const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate(); 492 if (thread_spec) 493 name = thread_spec->GetQueueName(); 494 } 495 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 496 if (log) 497 log->Printf ("SBBreakpoint(%p)::GetQueueName () => %s", 498 static_cast<void*>(m_opaque_sp.get()), name); 499 500 return name; 501 } 502 503 size_t 504 SBBreakpoint::GetNumResolvedLocations() const 505 { 506 size_t num_resolved = 0; 507 if (m_opaque_sp) 508 { 509 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 510 num_resolved = m_opaque_sp->GetNumResolvedLocations(); 511 } 512 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 513 if (log) 514 log->Printf ("SBBreakpoint(%p)::GetNumResolvedLocations () => %" PRIu64, 515 static_cast<void*>(m_opaque_sp.get()), 516 static_cast<uint64_t>(num_resolved)); 517 return num_resolved; 518 } 519 520 size_t 521 SBBreakpoint::GetNumLocations() const 522 { 523 size_t num_locs = 0; 524 if (m_opaque_sp) 525 { 526 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 527 num_locs = m_opaque_sp->GetNumLocations(); 528 } 529 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 530 if (log) 531 log->Printf ("SBBreakpoint(%p)::GetNumLocations () => %" PRIu64, 532 static_cast<void*>(m_opaque_sp.get()), 533 static_cast<uint64_t>(num_locs)); 534 return num_locs; 535 } 536 537 bool 538 SBBreakpoint::GetDescription (SBStream &s) 539 { 540 if (m_opaque_sp) 541 { 542 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 543 s.Printf("SBBreakpoint: id = %i, ", m_opaque_sp->GetID()); 544 m_opaque_sp->GetResolverDescription (s.get()); 545 m_opaque_sp->GetFilterDescription (s.get()); 546 const size_t num_locations = m_opaque_sp->GetNumLocations (); 547 s.Printf(", locations = %" PRIu64, (uint64_t)num_locations); 548 return true; 549 } 550 s.Printf ("No value"); 551 return false; 552 } 553 554 bool 555 SBBreakpoint::PrivateBreakpointHitCallback 556 ( 557 void *baton, 558 StoppointCallbackContext *ctx, 559 lldb::user_id_t break_id, 560 lldb::user_id_t break_loc_id 561 ) 562 { 563 ExecutionContext exe_ctx (ctx->exe_ctx_ref); 564 BreakpointSP bp_sp(exe_ctx.GetTargetRef().GetBreakpointList().FindBreakpointByID(break_id)); 565 if (baton && bp_sp) 566 { 567 CallbackData *data = (CallbackData *)baton; 568 lldb_private::Breakpoint *bp = bp_sp.get(); 569 if (bp && data->callback) 570 { 571 Process *process = exe_ctx.GetProcessPtr(); 572 if (process) 573 { 574 SBProcess sb_process (process->shared_from_this()); 575 SBThread sb_thread; 576 SBBreakpointLocation sb_location; 577 assert (bp_sp); 578 sb_location.SetLocation (bp_sp->FindLocationByID (break_loc_id)); 579 Thread *thread = exe_ctx.GetThreadPtr(); 580 if (thread) 581 sb_thread.SetThread(thread->shared_from_this()); 582 583 return data->callback (data->callback_baton, 584 sb_process, 585 sb_thread, 586 sb_location); 587 } 588 } 589 } 590 return true; // Return true if we should stop at this breakpoint 591 } 592 593 void 594 SBBreakpoint::SetCallback (BreakpointHitCallback callback, void *baton) 595 { 596 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 597 598 if (log) 599 { 600 void *pointer = &callback; 601 log->Printf ("SBBreakpoint(%p)::SetCallback (callback=%p, baton=%p)", 602 static_cast<void*>(m_opaque_sp.get()), 603 *static_cast<void**>(&pointer), static_cast<void*>(baton)); 604 } 605 606 if (m_opaque_sp) 607 { 608 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 609 BatonSP baton_sp(new SBBreakpointCallbackBaton (callback, baton)); 610 m_opaque_sp->SetCallback (SBBreakpoint::PrivateBreakpointHitCallback, baton_sp, false); 611 } 612 } 613 614 void 615 SBBreakpoint::SetScriptCallbackFunction (const char *callback_function_name) 616 { 617 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 618 619 if (log) 620 log->Printf ("SBBreakpoint(%p)::SetScriptCallbackFunction (callback=%s)", 621 static_cast<void*>(m_opaque_sp.get()), 622 callback_function_name); 623 624 if (m_opaque_sp) 625 { 626 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 627 BreakpointOptions *bp_options = m_opaque_sp->GetOptions(); 628 m_opaque_sp->GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter()->SetBreakpointCommandCallbackFunction (bp_options, 629 callback_function_name); 630 } 631 } 632 633 SBError 634 SBBreakpoint::SetScriptCallbackBody (const char *callback_body_text) 635 { 636 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 637 638 if (log) 639 log->Printf ("SBBreakpoint(%p)::SetScriptCallbackBody: callback body:\n%s)", 640 static_cast<void*>(m_opaque_sp.get()), callback_body_text); 641 642 SBError sb_error; 643 if (m_opaque_sp) 644 { 645 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 646 BreakpointOptions *bp_options = m_opaque_sp->GetOptions(); 647 Error error = m_opaque_sp->GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter()->SetBreakpointCommandCallback (bp_options, 648 callback_body_text); 649 sb_error.SetError(error); 650 } 651 else 652 sb_error.SetErrorString("invalid breakpoint"); 653 654 return sb_error; 655 } 656 657 bool 658 SBBreakpoint::AddName (const char *new_name) 659 { 660 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 661 662 if (log) 663 log->Printf ("SBBreakpoint(%p)::AddName (name=%s)", 664 static_cast<void*>(m_opaque_sp.get()), 665 new_name); 666 667 if (m_opaque_sp) 668 { 669 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 670 Error error; // Think I'm just going to swallow the error here, it's probably more annoying to have to provide it. 671 return m_opaque_sp->AddName(new_name, error); 672 } 673 674 return false; 675 } 676 677 void 678 SBBreakpoint::RemoveName (const char *name_to_remove) 679 { 680 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 681 682 if (log) 683 log->Printf ("SBBreakpoint(%p)::RemoveName (name=%s)", 684 static_cast<void*>(m_opaque_sp.get()), 685 name_to_remove); 686 687 if (m_opaque_sp) 688 { 689 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 690 m_opaque_sp->RemoveName(name_to_remove); 691 } 692 } 693 694 bool 695 SBBreakpoint::MatchesName (const char *name) 696 { 697 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 698 699 if (log) 700 log->Printf ("SBBreakpoint(%p)::MatchesName (name=%s)", 701 static_cast<void*>(m_opaque_sp.get()), 702 name); 703 704 if (m_opaque_sp) 705 { 706 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 707 return m_opaque_sp->MatchesName(name); 708 } 709 710 return false; 711 } 712 713 void 714 SBBreakpoint::GetNames (SBStringList &names) 715 { 716 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 717 718 if (log) 719 log->Printf ("SBBreakpoint(%p)::GetNames ()", 720 static_cast<void*>(m_opaque_sp.get())); 721 722 if (m_opaque_sp) 723 { 724 Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); 725 std::vector<std::string> names_vec; 726 m_opaque_sp->GetNames(names_vec); 727 for (std::string name : names_vec) 728 { 729 names.AppendString (name.c_str()); 730 } 731 } 732 } 733 734 lldb_private::Breakpoint * 735 SBBreakpoint::operator->() const 736 { 737 return m_opaque_sp.get(); 738 } 739 740 lldb_private::Breakpoint * 741 SBBreakpoint::get() const 742 { 743 return m_opaque_sp.get(); 744 } 745 746 lldb::BreakpointSP & 747 SBBreakpoint::operator *() 748 { 749 return m_opaque_sp; 750 } 751 752 const lldb::BreakpointSP & 753 SBBreakpoint::operator *() const 754 { 755 return m_opaque_sp; 756 } 757 758 bool 759 SBBreakpoint::EventIsBreakpointEvent (const lldb::SBEvent &event) 760 { 761 return Breakpoint::BreakpointEventData::GetEventDataFromEvent(event.get()) != NULL; 762 763 } 764 765 BreakpointEventType 766 SBBreakpoint::GetBreakpointEventTypeFromEvent (const SBEvent& event) 767 { 768 if (event.IsValid()) 769 return Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent (event.GetSP()); 770 return eBreakpointEventTypeInvalidType; 771 } 772 773 SBBreakpoint 774 SBBreakpoint::GetBreakpointFromEvent (const lldb::SBEvent& event) 775 { 776 SBBreakpoint sb_breakpoint; 777 if (event.IsValid()) 778 sb_breakpoint.m_opaque_sp = Breakpoint::BreakpointEventData::GetBreakpointFromEvent (event.GetSP()); 779 return sb_breakpoint; 780 } 781 782 SBBreakpointLocation 783 SBBreakpoint::GetBreakpointLocationAtIndexFromEvent (const lldb::SBEvent& event, uint32_t loc_idx) 784 { 785 SBBreakpointLocation sb_breakpoint_loc; 786 if (event.IsValid()) 787 sb_breakpoint_loc.SetLocation (Breakpoint::BreakpointEventData::GetBreakpointLocationAtIndexFromEvent (event.GetSP(), loc_idx)); 788 return sb_breakpoint_loc; 789 } 790 791 uint32_t 792 SBBreakpoint::GetNumBreakpointLocationsFromEvent (const lldb::SBEvent &event) 793 { 794 uint32_t num_locations = 0; 795 if (event.IsValid()) 796 num_locations = (Breakpoint::BreakpointEventData::GetNumBreakpointLocationsFromEvent (event.GetSP())); 797 return num_locations; 798 } 799 800 801