42#include "llvm/ADT/STLExtras.h"
50 : m_opaque_wp(rhs.m_opaque_wp) {
55 : m_opaque_wp(bp_sp) {
85 return SBTarget(bkpt_sp->GetTargetSP());
96 break_id = bkpt_sp->GetID();
103 return this->
operator bool();
105SBBreakpoint::operator bool()
const {
111 else if (bkpt_sp->GetTarget().GetBreakpointByID(bkpt_sp->GetID()))
122 std::lock_guard<std::recursive_mutex> guard(
123 bkpt_sp->GetTarget().GetAPIMutex());
124 bkpt_sp->ClearAllBreakpointSites();
136 std::lock_guard<std::recursive_mutex> guard(
137 bkpt_sp->GetTarget().GetAPIMutex());
139 Target &target = bkpt_sp->GetTarget();
143 sb_bp_location.
SetLocation(bkpt_sp->FindLocationByAddress(address));
146 return sb_bp_location;
156 std::lock_guard<std::recursive_mutex> guard(
157 bkpt_sp->GetTarget().GetAPIMutex());
159 Target &target = bkpt_sp->GetTarget();
163 break_id = bkpt_sp->FindLocationIDByAddress(address);
176 std::lock_guard<std::recursive_mutex> guard(
177 bkpt_sp->GetTarget().GetAPIMutex());
178 sb_bp_location.
SetLocation(bkpt_sp->FindLocationByID(bp_loc_id));
181 return sb_bp_location;
191 std::lock_guard<std::recursive_mutex> guard(
192 bkpt_sp->GetTarget().GetAPIMutex());
193 sb_bp_location.
SetLocation(bkpt_sp->GetLocationAtIndex(index));
196 return sb_bp_location;
205 std::lock_guard<std::recursive_mutex> guard(
206 bkpt_sp->GetTarget().GetAPIMutex());
207 bkpt_sp->SetEnabled(enable);
216 std::lock_guard<std::recursive_mutex> guard(
217 bkpt_sp->GetTarget().GetAPIMutex());
218 return bkpt_sp->IsEnabled();
229 std::lock_guard<std::recursive_mutex> guard(
230 bkpt_sp->GetTarget().GetAPIMutex());
231 bkpt_sp->SetOneShot(one_shot);
240 std::lock_guard<std::recursive_mutex> guard(
241 bkpt_sp->GetTarget().GetAPIMutex());
242 return bkpt_sp->IsOneShot();
252 std::lock_guard<std::recursive_mutex> guard(
253 bkpt_sp->GetTarget().GetAPIMutex());
254 return bkpt_sp->IsInternal();
265 std::lock_guard<std::recursive_mutex> guard(
266 bkpt_sp->GetTarget().GetAPIMutex());
267 bkpt_sp->SetIgnoreCount(count);
276 std::lock_guard<std::recursive_mutex> guard(
277 bkpt_sp->GetTarget().GetAPIMutex());
278 bkpt_sp->SetCondition(condition);
289 std::lock_guard<std::recursive_mutex> guard(
290 bkpt_sp->GetTarget().GetAPIMutex());
299 std::lock_guard<std::recursive_mutex> guard(
300 bkpt_sp->GetTarget().GetAPIMutex());
301 bkpt_sp->SetAutoContinue(auto_continue);
310 std::lock_guard<std::recursive_mutex> guard(
311 bkpt_sp->GetTarget().GetAPIMutex());
312 return bkpt_sp->IsAutoContinue();
323 std::lock_guard<std::recursive_mutex> guard(
324 bkpt_sp->GetTarget().GetAPIMutex());
325 count = bkpt_sp->GetHitCount();
337 std::lock_guard<std::recursive_mutex> guard(
338 bkpt_sp->GetTarget().GetAPIMutex());
339 count = bkpt_sp->GetIgnoreCount();
350 std::lock_guard<std::recursive_mutex> guard(
351 bkpt_sp->GetTarget().GetAPIMutex());
352 bkpt_sp->SetThreadID(tid);
362 std::lock_guard<std::recursive_mutex> guard(
363 bkpt_sp->GetTarget().GetAPIMutex());
364 tid = bkpt_sp->GetThreadID();
375 std::lock_guard<std::recursive_mutex> guard(
376 bkpt_sp->GetTarget().GetAPIMutex());
377 bkpt_sp->GetOptions().GetThreadSpec()->SetIndex(index);
387 std::lock_guard<std::recursive_mutex> guard(
388 bkpt_sp->GetTarget().GetAPIMutex());
390 bkpt_sp->GetOptions().GetThreadSpecNoCreate();
391 if (thread_spec !=
nullptr)
392 thread_idx = thread_spec->
GetIndex();
404 std::lock_guard<std::recursive_mutex> guard(
405 bkpt_sp->GetTarget().GetAPIMutex());
406 bkpt_sp->GetOptions().GetThreadSpec()->SetName(thread_name);
417 std::lock_guard<std::recursive_mutex> guard(
418 bkpt_sp->GetTarget().GetAPIMutex());
420 bkpt_sp->GetOptions().GetThreadSpecNoCreate())
431 std::lock_guard<std::recursive_mutex> guard(
432 bkpt_sp->GetTarget().GetAPIMutex());
433 bkpt_sp->GetOptions().GetThreadSpec()->SetQueueName(queue_name);
444 std::lock_guard<std::recursive_mutex> guard(
445 bkpt_sp->GetTarget().GetAPIMutex());
447 bkpt_sp->GetOptions().GetThreadSpecNoCreate())
456 size_t num_resolved = 0;
459 std::lock_guard<std::recursive_mutex> guard(
460 bkpt_sp->GetTarget().GetAPIMutex());
461 num_resolved = bkpt_sp->GetNumResolvedLocations();
472 std::lock_guard<std::recursive_mutex> guard(
473 bkpt_sp->GetTarget().GetAPIMutex());
474 num_locs = bkpt_sp->GetNumLocations();
488 std::lock_guard<std::recursive_mutex> guard(
489 bkpt_sp->GetTarget().GetAPIMutex());
490 std::unique_ptr<BreakpointOptions::CommandData> cmd_data_up(
493 bkpt_sp->GetOptions().SetCommandDataCallback(cmd_data_up);
504 bkpt_sp->GetOptions().GetCommandLineCallbacks(command_list);
521 std::lock_guard<std::recursive_mutex> guard(
522 bkpt_sp->GetTarget().GetAPIMutex());
523 s.Printf(
"SBBreakpoint: id = %i, ", bkpt_sp->GetID());
524 bkpt_sp->GetResolverDescription(s.
get());
525 bkpt_sp->GetFilterDescription(s.
get());
526 if (include_locations) {
527 const size_t num_locations = bkpt_sp->GetNumLocations();
528 s.Printf(
", locations = %" PRIu64, (uint64_t)num_locations);
532 s.Printf(
"No value");
552 if (!llvm::isa<BreakpointResolverScripted>(bkpt_sp->GetResolver().get())) {
558 if (bkpt_sp->GetSearchFilter()->AddressPasses(address.
ref()))
559 bkpt_sp->AddLocation(address.
ref());
562 address.
get()->
Dump(&s, &bkpt_sp->GetTarget(),
565 "Address: %s didn't pass the filter.", s.
GetData());
590 std::lock_guard<std::recursive_mutex> guard(
591 bkpt_sp->GetTarget().GetAPIMutex());
594 ::PrivateBreakpointHitCallback, baton_sp,
600 const char *callback_function_name) {
607 const char *callback_function_name,
615 std::lock_guard<std::recursive_mutex> guard(
616 bkpt_sp->GetTarget().GetAPIMutex());
618 error = bkpt_sp->GetTarget()
620 .GetScriptInterpreter()
621 ->SetBreakpointCommandCallbackFunction(bp_options,
622 callback_function_name,
639 std::lock_guard<std::recursive_mutex> guard(
640 bkpt_sp->GetTarget().GetAPIMutex());
645 .GetScriptInterpreter()
646 ->SetBreakpointCommandCallback(bp_options, callback_body_text,
655bool SBBreakpoint::AddName(
const char *new_name) {
669 std::lock_guard<std::recursive_mutex> guard(
670 bkpt_sp->GetTarget().GetAPIMutex());
672 bkpt_sp->GetTarget().AddNameToBreakpoint(bkpt_sp, new_name,
error);
687 std::lock_guard<std::recursive_mutex> guard(
688 bkpt_sp->GetTarget().GetAPIMutex());
689 bkpt_sp->GetTarget().RemoveNameFromBreakpoint(bkpt_sp,
700 std::lock_guard<std::recursive_mutex> guard(
701 bkpt_sp->GetTarget().GetAPIMutex());
702 return bkpt_sp->MatchesName(name);
714 std::lock_guard<std::recursive_mutex> guard(
715 bkpt_sp->GetTarget().GetAPIMutex());
716 std::vector<std::string> names_vec;
717 bkpt_sp->GetNames(names_vec);
718 for (
const std::string &name : names_vec) {
738 return eBreakpointEventTypeInvalidType;
759 event.
GetSP(), loc_idx));
760 return sb_breakpoint_loc;
767 uint32_t num_locations = 0;
772 return num_locations;
780 return bkpt_sp->IsHardware();
790 if (target_sp && target_sp->IsValid())
791 m_target_wp = target_sp;
796 size_t GetSize() {
return m_break_ids.size(); }
799 if (idx >= m_break_ids.size())
801 TargetSP target_sp = m_target_wp.lock();
805 return target_sp->GetBreakpointList().FindBreakpointByID(bp_id);
809 TargetSP target_sp = m_target_wp.lock();
814 if (break_id == desired_id)
815 return target_sp->GetBreakpointList().FindBreakpointByID(break_id);
821 TargetSP target_sp = m_target_wp.lock();
822 if (!target_sp || !bkpt)
824 if (bkpt->GetTargetSP() != target_sp)
826 m_break_ids.push_back(bkpt->GetID());
831 TargetSP target_sp = m_target_wp.lock();
832 if (!target_sp || !bkpt)
834 if (bkpt->GetTargetSP() != target_sp)
837 if (!llvm::is_contained(m_break_ids, bp_id))
840 m_break_ids.push_back(bkpt->GetID());
845 TargetSP target_sp = m_target_wp.lock();
850 m_break_ids.push_back(
id);
854 void Clear() { m_break_ids.clear(); }
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)
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
static lldb::BreakpointEventType GetBreakpointEventTypeFromEvent(const lldb::SBEvent &event)
uint32_t GetHitCount() const
static lldb::SBBreakpointLocation GetBreakpointLocationAtIndexFromEvent(const lldb::SBEvent &event, uint32_t loc_idx)
lldb::tid_t GetThreadID()
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 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, std::optional< Stream::HighlightSettings > settings=std::nullopt) 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.
const char * GetCString() const
Get the string value as a C string.
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, bool allow_section_end=false) const
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
static Status FromErrorString(const char *str)
const char * GetData() const
std::shared_ptr< Object > ObjectSP
SectionLoadList & GetSectionLoadList()
uint32_t GetIndex() 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.
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
std::shared_ptr< lldb_private::Baton > BatonSP
bool(* SBBreakpointHitCallback)(void *baton, lldb::SBProcess &process, lldb::SBThread &thread, lldb::SBBreakpointLocation &location)
std::weak_ptr< lldb_private::Target > TargetWP
std::shared_ptr< lldb_private::Target > TargetSP