1 //===-- SBBreakpoint.h ------------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLDB_SBBreakpoint_h_ 10 #define LLDB_SBBreakpoint_h_ 11 12 #include "lldb/API/SBDefines.h" 13 14 class SBBreakpointListImpl; 15 16 namespace lldb { 17 18 class LLDB_API SBBreakpoint { 19 public: 20 21 SBBreakpoint(); 22 23 SBBreakpoint(const lldb::SBBreakpoint &rhs); 24 25 SBBreakpoint(const lldb::BreakpointSP &bp_sp); 26 27 ~SBBreakpoint(); 28 29 const lldb::SBBreakpoint &operator=(const lldb::SBBreakpoint &rhs); 30 31 // Tests to see if the opaque breakpoint object in this object matches the 32 // opaque breakpoint object in "rhs". 33 bool operator==(const lldb::SBBreakpoint &rhs); 34 35 bool operator!=(const lldb::SBBreakpoint &rhs); 36 37 break_id_t GetID() const; 38 39 explicit operator bool() const; 40 41 bool IsValid() const; 42 43 void ClearAllBreakpointSites(); 44 45 lldb::SBBreakpointLocation FindLocationByAddress(lldb::addr_t vm_addr); 46 47 lldb::break_id_t FindLocationIDByAddress(lldb::addr_t vm_addr); 48 49 lldb::SBBreakpointLocation FindLocationByID(lldb::break_id_t bp_loc_id); 50 51 lldb::SBBreakpointLocation GetLocationAtIndex(uint32_t index); 52 53 void SetEnabled(bool enable); 54 55 bool IsEnabled(); 56 57 void SetOneShot(bool one_shot); 58 59 bool IsOneShot() const; 60 61 bool IsInternal(); 62 63 uint32_t GetHitCount() const; 64 65 void SetIgnoreCount(uint32_t count); 66 67 uint32_t GetIgnoreCount() const; 68 69 void SetCondition(const char *condition); 70 71 const char *GetCondition(); 72 73 void SetAutoContinue(bool auto_continue); 74 75 bool GetAutoContinue(); 76 77 void SetThreadID(lldb::tid_t sb_thread_id); 78 79 lldb::tid_t GetThreadID(); 80 81 void SetThreadIndex(uint32_t index); 82 83 uint32_t GetThreadIndex() const; 84 85 void SetThreadName(const char *thread_name); 86 87 const char *GetThreadName() const; 88 89 void SetQueueName(const char *queue_name); 90 91 const char *GetQueueName() const; 92 93 void SetCallback(SBBreakpointHitCallback callback, void *baton); 94 95 void SetScriptCallbackFunction(const char *callback_function_name); 96 97 SBError SetScriptCallbackFunction(const char *callback_function_name, 98 SBStructuredData &extra_args); 99 100 void SetCommandLineCommands(SBStringList &commands); 101 102 bool GetCommandLineCommands(SBStringList &commands); 103 104 SBError SetScriptCallbackBody(const char *script_body_text); 105 106 bool AddName(const char *new_name); 107 108 void RemoveName(const char *name_to_remove); 109 110 bool MatchesName(const char *name); 111 112 void GetNames(SBStringList &names); 113 114 size_t GetNumResolvedLocations() const; 115 116 size_t GetNumLocations() const; 117 118 bool GetDescription(lldb::SBStream &description); 119 120 bool GetDescription(lldb::SBStream &description, bool include_locations); 121 122 static bool EventIsBreakpointEvent(const lldb::SBEvent &event); 123 124 static lldb::BreakpointEventType 125 GetBreakpointEventTypeFromEvent(const lldb::SBEvent &event); 126 127 static lldb::SBBreakpoint GetBreakpointFromEvent(const lldb::SBEvent &event); 128 129 static lldb::SBBreakpointLocation 130 GetBreakpointLocationAtIndexFromEvent(const lldb::SBEvent &event, 131 uint32_t loc_idx); 132 133 static uint32_t 134 GetNumBreakpointLocationsFromEvent(const lldb::SBEvent &event_sp); 135 136 bool IsHardware() const; 137 138 // Can only be called from a ScriptedBreakpointResolver... 139 SBError 140 AddLocation(SBAddress &address); 141 142 private: 143 friend class SBBreakpointList; 144 friend class SBBreakpointLocation; 145 friend class SBBreakpointName; 146 friend class SBTarget; 147 148 lldb::BreakpointSP GetSP() const; 149 150 lldb::BreakpointWP m_opaque_wp; 151 }; 152 153 class LLDB_API SBBreakpointList { 154 public: 155 SBBreakpointList(SBTarget &target); 156 157 ~SBBreakpointList(); 158 159 size_t GetSize() const; 160 161 SBBreakpoint GetBreakpointAtIndex(size_t idx); 162 163 SBBreakpoint FindBreakpointByID(lldb::break_id_t); 164 165 void Append(const SBBreakpoint &sb_bkpt); 166 167 bool AppendIfUnique(const SBBreakpoint &sb_bkpt); 168 169 void AppendByID(lldb::break_id_t id); 170 171 void Clear(); 172 173 protected: 174 friend class SBTarget; 175 176 void CopyToBreakpointIDList(lldb_private::BreakpointIDList &bp_id_list); 177 178 private: 179 std::shared_ptr<SBBreakpointListImpl> m_opaque_sp; 180 }; 181 182 } // namespace lldb 183 184 #endif // LLDB_SBBreakpoint_h_ 185