• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 {
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::SBTarget GetTarget() const;
46 
47   lldb::SBBreakpointLocation FindLocationByAddress(lldb::addr_t vm_addr);
48 
49   lldb::break_id_t FindLocationIDByAddress(lldb::addr_t vm_addr);
50 
51   lldb::SBBreakpointLocation FindLocationByID(lldb::break_id_t bp_loc_id);
52 
53   lldb::SBBreakpointLocation GetLocationAtIndex(uint32_t index);
54 
55   void SetEnabled(bool enable);
56 
57   bool IsEnabled();
58 
59   void SetOneShot(bool one_shot);
60 
61   bool IsOneShot() const;
62 
63   bool IsInternal();
64 
65   uint32_t GetHitCount() const;
66 
67   void SetIgnoreCount(uint32_t count);
68 
69   uint32_t GetIgnoreCount() const;
70 
71   void SetCondition(const char *condition);
72 
73   const char *GetCondition();
74 
75   void SetAutoContinue(bool auto_continue);
76 
77   bool GetAutoContinue();
78 
79   void SetThreadID(lldb::tid_t sb_thread_id);
80 
81   lldb::tid_t GetThreadID();
82 
83   void SetThreadIndex(uint32_t index);
84 
85   uint32_t GetThreadIndex() const;
86 
87   void SetThreadName(const char *thread_name);
88 
89   const char *GetThreadName() const;
90 
91   void SetQueueName(const char *queue_name);
92 
93   const char *GetQueueName() const;
94 
95   void SetCallback(SBBreakpointHitCallback callback, void *baton);
96 
97   void SetScriptCallbackFunction(const char *callback_function_name);
98 
99   SBError SetScriptCallbackFunction(const char *callback_function_name,
100                                  SBStructuredData &extra_args);
101 
102   void SetCommandLineCommands(SBStringList &commands);
103 
104   bool GetCommandLineCommands(SBStringList &commands);
105 
106   SBError SetScriptCallbackBody(const char *script_body_text);
107 
108   bool AddName(const char *new_name);
109 
110   SBError AddNameWithErrorHandling(const char *new_name);
111 
112   void RemoveName(const char *name_to_remove);
113 
114   bool MatchesName(const char *name);
115 
116   void GetNames(SBStringList &names);
117 
118   size_t GetNumResolvedLocations() const;
119 
120   size_t GetNumLocations() const;
121 
122   bool GetDescription(lldb::SBStream &description);
123 
124   bool GetDescription(lldb::SBStream &description, bool include_locations);
125 
126   static bool EventIsBreakpointEvent(const lldb::SBEvent &event);
127 
128   static lldb::BreakpointEventType
129   GetBreakpointEventTypeFromEvent(const lldb::SBEvent &event);
130 
131   static lldb::SBBreakpoint GetBreakpointFromEvent(const lldb::SBEvent &event);
132 
133   static lldb::SBBreakpointLocation
134   GetBreakpointLocationAtIndexFromEvent(const lldb::SBEvent &event,
135                                         uint32_t loc_idx);
136 
137   static uint32_t
138   GetNumBreakpointLocationsFromEvent(const lldb::SBEvent &event_sp);
139 
140   bool IsHardware() const;
141 
142   // Can only be called from a ScriptedBreakpointResolver...
143   SBError
144   AddLocation(SBAddress &address);
145 
146   SBStructuredData SerializeToStructuredData();
147 
148 private:
149   friend class SBBreakpointList;
150   friend class SBBreakpointLocation;
151   friend class SBBreakpointName;
152   friend class SBTarget;
153 
154   lldb::BreakpointSP GetSP() const;
155 
156   lldb::BreakpointWP m_opaque_wp;
157 };
158 
159 class LLDB_API SBBreakpointList {
160 public:
161   SBBreakpointList(SBTarget &target);
162 
163   ~SBBreakpointList();
164 
165   size_t GetSize() const;
166 
167   SBBreakpoint GetBreakpointAtIndex(size_t idx);
168 
169   SBBreakpoint FindBreakpointByID(lldb::break_id_t);
170 
171   void Append(const SBBreakpoint &sb_bkpt);
172 
173   bool AppendIfUnique(const SBBreakpoint &sb_bkpt);
174 
175   void AppendByID(lldb::break_id_t id);
176 
177   void Clear();
178 
179 protected:
180   friend class SBTarget;
181 
182   void CopyToBreakpointIDList(lldb_private::BreakpointIDList &bp_id_list);
183 
184 private:
185   std::shared_ptr<SBBreakpointListImpl> m_opaque_sp;
186 };
187 
188 } // namespace lldb
189 
190 #endif // LLDB_API_SBBREAKPOINT_H
191