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");
543 error.SetErrorString(
"Can't add an invalid address.");
548 error.SetErrorString(
"No breakpoint to add a location to.");
552 if (!llvm::isa<BreakpointResolverScripted>(bkpt_sp->GetResolver().get())) {
553 error.SetErrorString(
"Only a scripted resolver can add locations.");
557 if (bkpt_sp->GetSearchFilter()->AddressPasses(address.
ref()))
558 bkpt_sp->AddLocation(address.
ref());
561 address.
get()->
Dump(&s, &bkpt_sp->GetTarget(),
563 error.SetErrorStringWithFormat(
"Address: %s didn't pass the filter.",
589 std::lock_guard<std::recursive_mutex> guard(
590 bkpt_sp->GetTarget().GetAPIMutex());
593 ::PrivateBreakpointHitCallback, baton_sp,
599 const char *callback_function_name) {
606 const char *callback_function_name,
614 std::lock_guard<std::recursive_mutex> guard(
615 bkpt_sp->GetTarget().GetAPIMutex());
617 error = bkpt_sp->GetTarget()
619 .GetScriptInterpreter()
620 ->SetBreakpointCommandCallbackFunction(bp_options,
621 callback_function_name,
638 std::lock_guard<std::recursive_mutex> guard(
639 bkpt_sp->GetTarget().GetAPIMutex());
644 .GetScriptInterpreter()
645 ->SetBreakpointCommandCallback(bp_options, callback_body_text,
654bool SBBreakpoint::AddName(
const char *new_name) {
668 std::lock_guard<std::recursive_mutex> guard(
669 bkpt_sp->GetTarget().GetAPIMutex());
671 bkpt_sp->GetTarget().AddNameToBreakpoint(bkpt_sp, new_name,
error);
686 std::lock_guard<std::recursive_mutex> guard(
687 bkpt_sp->GetTarget().GetAPIMutex());
688 bkpt_sp->GetTarget().RemoveNameFromBreakpoint(bkpt_sp,
699 std::lock_guard<std::recursive_mutex> guard(
700 bkpt_sp->GetTarget().GetAPIMutex());
701 return bkpt_sp->MatchesName(name);
713 std::lock_guard<std::recursive_mutex> guard(
714 bkpt_sp->GetTarget().GetAPIMutex());
715 std::vector<std::string> names_vec;
716 bkpt_sp->GetNames(names_vec);
717 for (
const std::string &name : names_vec) {
737 return eBreakpointEventTypeInvalidType;
758 event.
GetSP(), loc_idx));
759 return sb_breakpoint_loc;
766 uint32_t num_locations = 0;
771 return num_locations;
779 return bkpt_sp->IsHardware();
789 if (target_sp && target_sp->IsValid())
790 m_target_wp = target_sp;
795 size_t GetSize() {
return m_break_ids.size(); }
798 if (idx >= m_break_ids.size())
800 TargetSP target_sp = m_target_wp.lock();
804 return target_sp->GetBreakpointList().FindBreakpointByID(bp_id);
808 TargetSP target_sp = m_target_wp.lock();
813 if (break_id == desired_id)
814 return target_sp->GetBreakpointList().FindBreakpointByID(break_id);
820 TargetSP target_sp = m_target_wp.lock();
821 if (!target_sp || !bkpt)
823 if (bkpt->GetTargetSP() != target_sp)
825 m_break_ids.push_back(bkpt->GetID());
830 TargetSP target_sp = m_target_wp.lock();
831 if (!target_sp || !bkpt)
833 if (bkpt->GetTargetSP() != target_sp)
836 if (!llvm::is_contained(m_break_ids, bp_id))
839 m_break_ids.push_back(bkpt->GetID());
844 TargetSP target_sp = m_target_wp.lock();
849 m_break_ids.push_back(
id);
853 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 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, 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
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