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