43#include "llvm/ADT/STLExtras.h"
51 : m_opaque_wp(rhs.m_opaque_wp) {
56 : m_opaque_wp(bp_sp) {
84 BreakpointSP bkpt_sp =
GetSP();
86 return SBTarget(bkpt_sp->GetTargetSP());
95 BreakpointSP bkpt_sp =
GetSP();
97 break_id = bkpt_sp->GetID();
104 return this->
operator bool();
106SBBreakpoint::operator bool()
const {
109 BreakpointSP bkpt_sp = GetSP();
112 else if (bkpt_sp->GetTarget().GetBreakpointByID(bkpt_sp->GetID()))
121 BreakpointSP bkpt_sp =
GetSP();
123 std::lock_guard<std::recursive_mutex> guard(
124 bkpt_sp->GetTarget().GetAPIMutex());
125 bkpt_sp->ClearAllBreakpointSites();
134 BreakpointSP bkpt_sp =
GetSP();
137 std::lock_guard<std::recursive_mutex> guard(
138 bkpt_sp->GetTarget().GetAPIMutex());
140 Target &target = bkpt_sp->GetTarget();
144 sb_bp_location.
SetLocation(bkpt_sp->FindLocationByAddress(address));
147 return sb_bp_location;
154 BreakpointSP bkpt_sp =
GetSP();
157 std::lock_guard<std::recursive_mutex> guard(
158 bkpt_sp->GetTarget().GetAPIMutex());
160 Target &target = bkpt_sp->GetTarget();
164 break_id = bkpt_sp->FindLocationIDByAddress(address);
174 BreakpointSP bkpt_sp =
GetSP();
177 std::lock_guard<std::recursive_mutex> guard(
178 bkpt_sp->GetTarget().GetAPIMutex());
179 sb_bp_location.
SetLocation(bkpt_sp->FindLocationByID(bp_loc_id));
182 return sb_bp_location;
189 BreakpointSP bkpt_sp =
GetSP();
192 std::lock_guard<std::recursive_mutex> guard(
193 bkpt_sp->GetTarget().GetAPIMutex());
194 sb_bp_location.
SetLocation(bkpt_sp->GetLocationAtIndex(index));
197 return sb_bp_location;
203 BreakpointSP bkpt_sp =
GetSP();
206 std::lock_guard<std::recursive_mutex> guard(
207 bkpt_sp->GetTarget().GetAPIMutex());
208 bkpt_sp->SetEnabled(enable);
215 BreakpointSP bkpt_sp =
GetSP();
217 std::lock_guard<std::recursive_mutex> guard(
218 bkpt_sp->GetTarget().GetAPIMutex());
219 return bkpt_sp->IsEnabled();
227 BreakpointSP bkpt_sp =
GetSP();
230 std::lock_guard<std::recursive_mutex> guard(
231 bkpt_sp->GetTarget().GetAPIMutex());
232 bkpt_sp->SetOneShot(one_shot);
239 BreakpointSP bkpt_sp =
GetSP();
241 std::lock_guard<std::recursive_mutex> guard(
242 bkpt_sp->GetTarget().GetAPIMutex());
243 return bkpt_sp->IsOneShot();
251 BreakpointSP bkpt_sp =
GetSP();
253 std::lock_guard<std::recursive_mutex> guard(
254 bkpt_sp->GetTarget().GetAPIMutex());
255 return bkpt_sp->IsInternal();
263 BreakpointSP bkpt_sp =
GetSP();
266 std::lock_guard<std::recursive_mutex> guard(
267 bkpt_sp->GetTarget().GetAPIMutex());
268 bkpt_sp->SetIgnoreCount(count);
275 BreakpointSP bkpt_sp =
GetSP();
277 std::lock_guard<std::recursive_mutex> guard(
278 bkpt_sp->GetTarget().GetAPIMutex());
279 bkpt_sp->SetCondition(condition);
286 BreakpointSP bkpt_sp =
GetSP();
288 std::lock_guard<std::recursive_mutex> guard(
289 bkpt_sp->GetTarget().GetAPIMutex());
290 return bkpt_sp->GetConditionText();
298 BreakpointSP bkpt_sp =
GetSP();
300 std::lock_guard<std::recursive_mutex> guard(
301 bkpt_sp->GetTarget().GetAPIMutex());
302 bkpt_sp->SetAutoContinue(auto_continue);
309 BreakpointSP bkpt_sp =
GetSP();
311 std::lock_guard<std::recursive_mutex> guard(
312 bkpt_sp->GetTarget().GetAPIMutex());
313 return bkpt_sp->IsAutoContinue();
322 BreakpointSP bkpt_sp =
GetSP();
324 std::lock_guard<std::recursive_mutex> guard(
325 bkpt_sp->GetTarget().GetAPIMutex());
326 count = bkpt_sp->GetHitCount();
336 BreakpointSP bkpt_sp =
GetSP();
338 std::lock_guard<std::recursive_mutex> guard(
339 bkpt_sp->GetTarget().GetAPIMutex());
340 count = bkpt_sp->GetIgnoreCount();
349 BreakpointSP bkpt_sp =
GetSP();
351 std::lock_guard<std::recursive_mutex> guard(
352 bkpt_sp->GetTarget().GetAPIMutex());
353 bkpt_sp->SetThreadID(tid);
361 BreakpointSP bkpt_sp =
GetSP();
363 std::lock_guard<std::recursive_mutex> guard(
364 bkpt_sp->GetTarget().GetAPIMutex());
365 tid = bkpt_sp->GetThreadID();
374 BreakpointSP bkpt_sp =
GetSP();
376 std::lock_guard<std::recursive_mutex> guard(
377 bkpt_sp->GetTarget().GetAPIMutex());
378 bkpt_sp->GetOptions().GetThreadSpec()->SetIndex(index);
386 BreakpointSP bkpt_sp =
GetSP();
388 std::lock_guard<std::recursive_mutex> guard(
389 bkpt_sp->GetTarget().GetAPIMutex());
391 bkpt_sp->GetOptions().GetThreadSpecNoCreate();
392 if (thread_spec !=
nullptr)
393 thread_idx = thread_spec->
GetIndex();
402 BreakpointSP bkpt_sp =
GetSP();
405 std::lock_guard<std::recursive_mutex> guard(
406 bkpt_sp->GetTarget().GetAPIMutex());
407 bkpt_sp->GetOptions().GetThreadSpec()->SetName(thread_name);
414 const char *name =
nullptr;
415 BreakpointSP bkpt_sp =
GetSP();
417 std::lock_guard<std::recursive_mutex> guard(
418 bkpt_sp->GetTarget().GetAPIMutex());
420 bkpt_sp->GetOptions().GetThreadSpecNoCreate();
421 if (thread_spec !=
nullptr)
431 BreakpointSP bkpt_sp =
GetSP();
433 std::lock_guard<std::recursive_mutex> guard(
434 bkpt_sp->GetTarget().GetAPIMutex());
435 bkpt_sp->GetOptions().GetThreadSpec()->SetQueueName(queue_name);
442 const char *name =
nullptr;
443 BreakpointSP bkpt_sp =
GetSP();
445 std::lock_guard<std::recursive_mutex> guard(
446 bkpt_sp->GetTarget().GetAPIMutex());
448 bkpt_sp->GetOptions().GetThreadSpecNoCreate();
459 size_t num_resolved = 0;
460 BreakpointSP bkpt_sp =
GetSP();
462 std::lock_guard<std::recursive_mutex> guard(
463 bkpt_sp->GetTarget().GetAPIMutex());
464 num_resolved = bkpt_sp->GetNumResolvedLocations();
472 BreakpointSP bkpt_sp =
GetSP();
475 std::lock_guard<std::recursive_mutex> guard(
476 bkpt_sp->GetTarget().GetAPIMutex());
477 num_locs = bkpt_sp->GetNumLocations();
485 BreakpointSP bkpt_sp =
GetSP();
491 std::lock_guard<std::recursive_mutex> guard(
492 bkpt_sp->GetTarget().GetAPIMutex());
493 std::unique_ptr<BreakpointOptions::CommandData> cmd_data_up(
496 bkpt_sp->GetOptions().SetCommandDataCallback(cmd_data_up);
502 BreakpointSP bkpt_sp =
GetSP();
507 bkpt_sp->GetOptions().GetCommandLineCallbacks(command_list);
522 BreakpointSP bkpt_sp =
GetSP();
524 std::lock_guard<std::recursive_mutex> guard(
525 bkpt_sp->GetTarget().GetAPIMutex());
526 s.Printf(
"SBBreakpoint: id = %i, ", bkpt_sp->GetID());
527 bkpt_sp->GetResolverDescription(s.
get());
528 bkpt_sp->GetFilterDescription(s.
get());
529 if (include_locations) {
530 const size_t num_locations = bkpt_sp->GetNumLocations();
531 s.Printf(
", locations = %" PRIu64, (uint64_t)num_locations);
535 s.Printf(
"No value");
542 BreakpointSP bkpt_sp =
GetSP();
546 error.SetErrorString(
"Can't add an invalid address.");
551 error.SetErrorString(
"No breakpoint to add a location to.");
555 if (!llvm::isa<BreakpointResolverScripted>(bkpt_sp->GetResolver().get())) {
556 error.SetErrorString(
"Only a scripted resolver can add locations.");
560 if (bkpt_sp->GetSearchFilter()->AddressPasses(address.
ref()))
561 bkpt_sp->AddLocation(address.
ref());
564 address.
get()->
Dump(&s, &bkpt_sp->GetTarget(),
566 error.SetErrorStringWithFormat(
"Address: %s didn't pass the filter.",
576 BreakpointSP bkpt_sp =
GetSP();
589 BreakpointSP bkpt_sp =
GetSP();
592 std::lock_guard<std::recursive_mutex> guard(
593 bkpt_sp->GetTarget().GetAPIMutex());
596 ::PrivateBreakpointHitCallback, baton_sp,
602 const char *callback_function_name) {
609 const char *callback_function_name,
613 BreakpointSP bkpt_sp =
GetSP();
617 std::lock_guard<std::recursive_mutex> guard(
618 bkpt_sp->GetTarget().GetAPIMutex());
620 error = bkpt_sp->GetTarget()
622 .GetScriptInterpreter()
623 ->SetBreakpointCommandCallbackFunction(bp_options,
624 callback_function_name,
637 BreakpointSP bkpt_sp =
GetSP();
641 std::lock_guard<std::recursive_mutex> guard(
642 bkpt_sp->GetTarget().GetAPIMutex());
647 .GetScriptInterpreter()
648 ->SetBreakpointCommandCallback(bp_options, callback_body_text,
667 BreakpointSP bkpt_sp =
GetSP();
671 std::lock_guard<std::recursive_mutex> guard(
672 bkpt_sp->GetTarget().GetAPIMutex());
674 bkpt_sp->GetTarget().AddNameToBreakpoint(bkpt_sp, new_name,
error);
686 BreakpointSP bkpt_sp =
GetSP();
689 std::lock_guard<std::recursive_mutex> guard(
690 bkpt_sp->GetTarget().GetAPIMutex());
691 bkpt_sp->GetTarget().RemoveNameFromBreakpoint(bkpt_sp,
699 BreakpointSP bkpt_sp =
GetSP();
702 std::lock_guard<std::recursive_mutex> guard(
703 bkpt_sp->GetTarget().GetAPIMutex());
704 return bkpt_sp->MatchesName(name);
713 BreakpointSP bkpt_sp =
GetSP();
716 std::lock_guard<std::recursive_mutex> guard(
717 bkpt_sp->GetTarget().GetAPIMutex());
718 std::vector<std::string> names_vec;
719 bkpt_sp->GetNames(names_vec);
720 for (std::string name : names_vec) {
740 return eBreakpointEventTypeInvalidType;
761 event.
GetSP(), loc_idx));
762 return sb_breakpoint_loc;
774 return num_locations;
780 BreakpointSP bkpt_sp =
GetSP();
782 return bkpt_sp->IsHardware();
792 if (target_sp && target_sp->IsValid())
793 m_target_wp = target_sp;
798 size_t GetSize() {
return m_break_ids.size(); }
801 if (idx >= m_break_ids.size())
802 return BreakpointSP();
803 TargetSP target_sp = m_target_wp.lock();
805 return BreakpointSP();
807 return target_sp->GetBreakpointList().FindBreakpointByID(bp_id);
811 TargetSP target_sp = m_target_wp.lock();
813 return BreakpointSP();
816 if (break_id == desired_id)
817 return target_sp->GetBreakpointList().FindBreakpointByID(break_id);
819 return BreakpointSP();
823 TargetSP target_sp = m_target_wp.lock();
824 if (!target_sp || !bkpt)
826 if (bkpt->GetTargetSP() != target_sp)
828 m_break_ids.push_back(bkpt->GetID());
833 TargetSP target_sp = m_target_wp.lock();
834 if (!target_sp || !bkpt)
836 if (bkpt->GetTargetSP() != target_sp)
839 if (!llvm::is_contained(m_break_ids, bp_id))
842 m_break_ids.push_back(bkpt->GetID());
847 TargetSP target_sp = m_target_wp.lock();
852 m_break_ids.push_back(
id);
856 void Clear() { m_break_ids.clear(); }
893 BreakpointSP bkpt_sp =
m_opaque_sp->GetBreakpointAtIndex(idx);
902 BreakpointSP bkpt_sp =
m_opaque_sp->FindBreakpointByID(
id);
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_INSTRUMENT_VA(...)
BreakpointSP GetBreakpointAtIndex(size_t idx)
SBBreakpointListImpl(lldb::TargetSP target_sp)
bool Append(BreakpointSP bkpt)
bool AppendIfUnique(BreakpointSP bkpt)
BreakpointSP FindBreakpointByID(lldb::break_id_t desired_id)
std::vector< lldb::break_id_t > m_break_ids
~SBBreakpointListImpl()=default
bool AppendByID(lldb::break_id_t id)
void CopyToBreakpointIDList(lldb_private::BreakpointIDList &bp_list)
lldb_private::Address * get()
lldb_private::Address & ref()
std::shared_ptr< SBBreakpointListImpl > m_opaque_sp
SBBreakpoint GetBreakpointAtIndex(size_t idx)
bool AppendIfUnique(const SBBreakpoint &sb_bkpt)
SBBreakpoint FindBreakpointByID(lldb::break_id_t)
SBBreakpointList(SBTarget &target)
void CopyToBreakpointIDList(lldb_private::BreakpointIDList &bp_id_list)
void Append(const SBBreakpoint &sb_bkpt)
void AppendByID(lldb::break_id_t id)
void SetLocation(const lldb::BreakpointLocationSP &break_loc_sp)
void SetOneShot(bool one_shot)
SBError SetScriptCallbackBody(const char *script_body_text)
uint32_t GetThreadIndex() const
lldb::SBBreakpointLocation FindLocationByID(lldb::break_id_t bp_loc_id)
void ClearAllBreakpointSites()
SBError AddLocation(SBAddress &address)
lldb::tid_t GetThreadID()
void SetThreadID(lldb::tid_t sb_thread_id)
lldb::BreakpointWP m_opaque_wp
bool GetCommandLineCommands(SBStringList &commands)
void SetAutoContinue(bool auto_continue)
void SetEnabled(bool enable)
void SetThreadName(const char *thread_name)
void SetThreadIndex(uint32_t index)
const char * GetThreadName() const
bool AddName(const char *new_name)
static lldb::BreakpointEventType GetBreakpointEventTypeFromEvent(const lldb::SBEvent &event)
uint32_t GetHitCount() const
static lldb::SBBreakpointLocation GetBreakpointLocationAtIndexFromEvent(const lldb::SBEvent &event, uint32_t loc_idx)
bool MatchesName(const char *name)
bool operator!=(const lldb::SBBreakpoint &rhs)
void SetIgnoreCount(uint32_t count)
lldb::break_id_t FindLocationIDByAddress(lldb::addr_t vm_addr)
size_t GetNumLocations() const
SBStructuredData SerializeToStructuredData()
const lldb::SBBreakpoint & operator=(const lldb::SBBreakpoint &rhs)
lldb::SBTarget GetTarget() const
void SetScriptCallbackFunction(const char *callback_function_name)
lldb::BreakpointSP GetSP() const
static lldb::SBBreakpoint GetBreakpointFromEvent(const lldb::SBEvent &event)
bool GetDescription(lldb::SBStream &description)
static bool EventIsBreakpointEvent(const lldb::SBEvent &event)
void SetCommandLineCommands(SBStringList &commands)
size_t GetNumResolvedLocations() const
void SetCondition(const char *condition)
void SetQueueName(const char *queue_name)
lldb::SBBreakpointLocation FindLocationByAddress(lldb::addr_t vm_addr)
const char * GetCondition()
const char * GetQueueName() const
void GetNames(SBStringList &names)
void RemoveName(const char *name_to_remove)
uint32_t GetIgnoreCount() const
static uint32_t GetNumBreakpointLocationsFromEvent(const lldb::SBEvent &event_sp)
SBError AddNameWithErrorHandling(const char *new_name)
lldb::SBBreakpointLocation GetLocationAtIndex(uint32_t index)
bool operator==(const lldb::SBBreakpoint &rhs)
void SetCallback(SBBreakpointHitCallback callback, void *baton)
void SetErrorString(const char *err_str)
void SetError(uint32_t err, lldb::ErrorType type)
lldb_private::Event * get() const
lldb::EventSP & GetSP() const
lldb_private::Stream * get()
void AppendString(const char *str)
void AppendList(const char **strv, int strc)
StructuredDataImplUP m_impl_up
A section + offset based address class.
void SetRawAddress(lldb::addr_t addr)
@ DumpStyleModuleWithFileAddress
Display as the file address with the module name prepended (if any).
bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style=DumpStyleInvalid, uint32_t addr_byte_size=UINT32_MAX, bool all_ranges=false) const
Dump a description of this object to a Stream.
bool AddBreakpointID(BreakpointID bp_id)
"lldb/Breakpoint/BreakpointOptions.h" Class that manages the options on a breakpoint or breakpoint lo...
static lldb::BreakpointEventType GetBreakpointEventTypeFromEvent(const lldb::EventSP &event_sp)
static lldb::BreakpointLocationSP GetBreakpointLocationAtIndexFromEvent(const lldb::EventSP &event_sp, uint32_t loc_idx)
static lldb::BreakpointSP GetBreakpointFromEvent(const lldb::EventSP &event_sp)
static const BreakpointEventData * GetEventDataFromEvent(const Event *event_sp)
static size_t GetNumBreakpointLocationsFromEvent(const lldb::EventSP &event_sp)
A uniqued constant string class.
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, bool allow_section_end=false) const
const char * GetData() const
std::shared_ptr< Object > ObjectSP
SectionLoadList & GetSectionLoadList()
uint32_t GetIndex() const
const char * GetName() const
const char * GetQueueName() const
#define LLDB_INVALID_BREAK_ID
#define LLDB_INVALID_THREAD_ID
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
bool(* SBBreakpointHitCallback)(void *baton, SBProcess &process, SBThread &thread, lldb::SBBreakpointLocation &location)