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