1*0b57cec5SDimitry Andric //===-- SBBreakpoint.cpp ----------------------------------------*- C++ -*-===//
2*0b57cec5SDimitry Andric //
3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*0b57cec5SDimitry Andric //
7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
8*0b57cec5SDimitry Andric 
9*0b57cec5SDimitry Andric #include "lldb/API/SBBreakpoint.h"
10*0b57cec5SDimitry Andric #include "SBReproducerPrivate.h"
11*0b57cec5SDimitry Andric #include "lldb/API/SBBreakpointLocation.h"
12*0b57cec5SDimitry Andric #include "lldb/API/SBDebugger.h"
13*0b57cec5SDimitry Andric #include "lldb/API/SBEvent.h"
14*0b57cec5SDimitry Andric #include "lldb/API/SBProcess.h"
15*0b57cec5SDimitry Andric #include "lldb/API/SBStream.h"
16*0b57cec5SDimitry Andric #include "lldb/API/SBStringList.h"
17*0b57cec5SDimitry Andric #include "lldb/API/SBThread.h"
18*0b57cec5SDimitry Andric 
19*0b57cec5SDimitry Andric #include "lldb/Breakpoint/Breakpoint.h"
20*0b57cec5SDimitry Andric #include "lldb/Breakpoint/BreakpointIDList.h"
21*0b57cec5SDimitry Andric #include "lldb/Breakpoint/BreakpointLocation.h"
22*0b57cec5SDimitry Andric #include "lldb/Breakpoint/BreakpointResolver.h"
23*0b57cec5SDimitry Andric #include "lldb/Breakpoint/BreakpointResolverScripted.h"
24*0b57cec5SDimitry Andric #include "lldb/Breakpoint/StoppointCallbackContext.h"
25*0b57cec5SDimitry Andric #include "lldb/Core/Address.h"
26*0b57cec5SDimitry Andric #include "lldb/Core/Debugger.h"
27*0b57cec5SDimitry Andric #include "lldb/Core/StreamFile.h"
28*0b57cec5SDimitry Andric #include "lldb/Interpreter/CommandInterpreter.h"
29*0b57cec5SDimitry Andric #include "lldb/Interpreter/ScriptInterpreter.h"
30*0b57cec5SDimitry Andric #include "lldb/Target/Process.h"
31*0b57cec5SDimitry Andric #include "lldb/Target/SectionLoadList.h"
32*0b57cec5SDimitry Andric #include "lldb/Target/Target.h"
33*0b57cec5SDimitry Andric #include "lldb/Target/Thread.h"
34*0b57cec5SDimitry Andric #include "lldb/Target/ThreadSpec.h"
35*0b57cec5SDimitry Andric #include "lldb/Utility/Stream.h"
36*0b57cec5SDimitry Andric 
37*0b57cec5SDimitry Andric #include "SBBreakpointOptionCommon.h"
38*0b57cec5SDimitry Andric 
39*0b57cec5SDimitry Andric #include "lldb/lldb-enumerations.h"
40*0b57cec5SDimitry Andric 
41*0b57cec5SDimitry Andric #include "llvm/ADT/STLExtras.h"
42*0b57cec5SDimitry Andric 
43*0b57cec5SDimitry Andric using namespace lldb;
44*0b57cec5SDimitry Andric using namespace lldb_private;
45*0b57cec5SDimitry Andric 
46*0b57cec5SDimitry Andric SBBreakpoint::SBBreakpoint() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBreakpoint); }
47*0b57cec5SDimitry Andric 
48*0b57cec5SDimitry Andric SBBreakpoint::SBBreakpoint(const SBBreakpoint &rhs)
49*0b57cec5SDimitry Andric     : m_opaque_wp(rhs.m_opaque_wp) {
50*0b57cec5SDimitry Andric   LLDB_RECORD_CONSTRUCTOR(SBBreakpoint, (const lldb::SBBreakpoint &), rhs);
51*0b57cec5SDimitry Andric }
52*0b57cec5SDimitry Andric 
53*0b57cec5SDimitry Andric SBBreakpoint::SBBreakpoint(const lldb::BreakpointSP &bp_sp)
54*0b57cec5SDimitry Andric     : m_opaque_wp(bp_sp) {
55*0b57cec5SDimitry Andric   LLDB_RECORD_CONSTRUCTOR(SBBreakpoint, (const lldb::BreakpointSP &), bp_sp);
56*0b57cec5SDimitry Andric }
57*0b57cec5SDimitry Andric 
58*0b57cec5SDimitry Andric SBBreakpoint::~SBBreakpoint() = default;
59*0b57cec5SDimitry Andric 
60*0b57cec5SDimitry Andric const SBBreakpoint &SBBreakpoint::operator=(const SBBreakpoint &rhs) {
61*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(const lldb::SBBreakpoint &,
62*0b57cec5SDimitry Andric                      SBBreakpoint, operator=,(const lldb::SBBreakpoint &), rhs);
63*0b57cec5SDimitry Andric 
64*0b57cec5SDimitry Andric   m_opaque_wp = rhs.m_opaque_wp;
65*0b57cec5SDimitry Andric   return LLDB_RECORD_RESULT(*this);
66*0b57cec5SDimitry Andric }
67*0b57cec5SDimitry Andric 
68*0b57cec5SDimitry Andric bool SBBreakpoint::operator==(const lldb::SBBreakpoint &rhs) {
69*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(
70*0b57cec5SDimitry Andric       bool, SBBreakpoint, operator==,(const lldb::SBBreakpoint &), rhs);
71*0b57cec5SDimitry Andric 
72*0b57cec5SDimitry Andric   return m_opaque_wp.lock() == rhs.m_opaque_wp.lock();
73*0b57cec5SDimitry Andric }
74*0b57cec5SDimitry Andric 
75*0b57cec5SDimitry Andric bool SBBreakpoint::operator!=(const lldb::SBBreakpoint &rhs) {
76*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(
77*0b57cec5SDimitry Andric       bool, SBBreakpoint, operator!=,(const lldb::SBBreakpoint &), rhs);
78*0b57cec5SDimitry Andric 
79*0b57cec5SDimitry Andric   return m_opaque_wp.lock() != rhs.m_opaque_wp.lock();
80*0b57cec5SDimitry Andric }
81*0b57cec5SDimitry Andric 
82*0b57cec5SDimitry Andric break_id_t SBBreakpoint::GetID() const {
83*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::break_id_t, SBBreakpoint, GetID);
84*0b57cec5SDimitry Andric 
85*0b57cec5SDimitry Andric   break_id_t break_id = LLDB_INVALID_BREAK_ID;
86*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
87*0b57cec5SDimitry Andric   if (bkpt_sp)
88*0b57cec5SDimitry Andric     break_id = bkpt_sp->GetID();
89*0b57cec5SDimitry Andric 
90*0b57cec5SDimitry Andric   return break_id;
91*0b57cec5SDimitry Andric }
92*0b57cec5SDimitry Andric 
93*0b57cec5SDimitry Andric bool SBBreakpoint::IsValid() const {
94*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, IsValid);
95*0b57cec5SDimitry Andric   return this->operator bool();
96*0b57cec5SDimitry Andric }
97*0b57cec5SDimitry Andric SBBreakpoint::operator bool() const {
98*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, operator bool);
99*0b57cec5SDimitry Andric 
100*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
101*0b57cec5SDimitry Andric   if (!bkpt_sp)
102*0b57cec5SDimitry Andric     return false;
103*0b57cec5SDimitry Andric   else if (bkpt_sp->GetTarget().GetBreakpointByID(bkpt_sp->GetID()))
104*0b57cec5SDimitry Andric     return true;
105*0b57cec5SDimitry Andric   else
106*0b57cec5SDimitry Andric     return false;
107*0b57cec5SDimitry Andric }
108*0b57cec5SDimitry Andric 
109*0b57cec5SDimitry Andric void SBBreakpoint::ClearAllBreakpointSites() {
110*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD_NO_ARGS(void, SBBreakpoint, ClearAllBreakpointSites);
111*0b57cec5SDimitry Andric 
112*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
113*0b57cec5SDimitry Andric   if (bkpt_sp) {
114*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
115*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
116*0b57cec5SDimitry Andric     bkpt_sp->ClearAllBreakpointSites();
117*0b57cec5SDimitry Andric   }
118*0b57cec5SDimitry Andric }
119*0b57cec5SDimitry Andric 
120*0b57cec5SDimitry Andric SBBreakpointLocation SBBreakpoint::FindLocationByAddress(addr_t vm_addr) {
121*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
122*0b57cec5SDimitry Andric                      FindLocationByAddress, (lldb::addr_t), vm_addr);
123*0b57cec5SDimitry Andric 
124*0b57cec5SDimitry Andric   SBBreakpointLocation sb_bp_location;
125*0b57cec5SDimitry Andric 
126*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
127*0b57cec5SDimitry Andric   if (bkpt_sp) {
128*0b57cec5SDimitry Andric     if (vm_addr != LLDB_INVALID_ADDRESS) {
129*0b57cec5SDimitry Andric       std::lock_guard<std::recursive_mutex> guard(
130*0b57cec5SDimitry Andric           bkpt_sp->GetTarget().GetAPIMutex());
131*0b57cec5SDimitry Andric       Address address;
132*0b57cec5SDimitry Andric       Target &target = bkpt_sp->GetTarget();
133*0b57cec5SDimitry Andric       if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) {
134*0b57cec5SDimitry Andric         address.SetRawAddress(vm_addr);
135*0b57cec5SDimitry Andric       }
136*0b57cec5SDimitry Andric       sb_bp_location.SetLocation(bkpt_sp->FindLocationByAddress(address));
137*0b57cec5SDimitry Andric     }
138*0b57cec5SDimitry Andric   }
139*0b57cec5SDimitry Andric   return LLDB_RECORD_RESULT(sb_bp_location);
140*0b57cec5SDimitry Andric }
141*0b57cec5SDimitry Andric 
142*0b57cec5SDimitry Andric break_id_t SBBreakpoint::FindLocationIDByAddress(addr_t vm_addr) {
143*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(lldb::break_id_t, SBBreakpoint, FindLocationIDByAddress,
144*0b57cec5SDimitry Andric                      (lldb::addr_t), vm_addr);
145*0b57cec5SDimitry Andric 
146*0b57cec5SDimitry Andric   break_id_t break_id = LLDB_INVALID_BREAK_ID;
147*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
148*0b57cec5SDimitry Andric 
149*0b57cec5SDimitry Andric   if (bkpt_sp && vm_addr != LLDB_INVALID_ADDRESS) {
150*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
151*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
152*0b57cec5SDimitry Andric     Address address;
153*0b57cec5SDimitry Andric     Target &target = bkpt_sp->GetTarget();
154*0b57cec5SDimitry Andric     if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) {
155*0b57cec5SDimitry Andric       address.SetRawAddress(vm_addr);
156*0b57cec5SDimitry Andric     }
157*0b57cec5SDimitry Andric     break_id = bkpt_sp->FindLocationIDByAddress(address);
158*0b57cec5SDimitry Andric   }
159*0b57cec5SDimitry Andric 
160*0b57cec5SDimitry Andric   return break_id;
161*0b57cec5SDimitry Andric }
162*0b57cec5SDimitry Andric 
163*0b57cec5SDimitry Andric SBBreakpointLocation SBBreakpoint::FindLocationByID(break_id_t bp_loc_id) {
164*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(lldb::SBBreakpointLocation, SBBreakpoint, FindLocationByID,
165*0b57cec5SDimitry Andric                      (lldb::break_id_t), bp_loc_id);
166*0b57cec5SDimitry Andric 
167*0b57cec5SDimitry Andric   SBBreakpointLocation sb_bp_location;
168*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
169*0b57cec5SDimitry Andric 
170*0b57cec5SDimitry Andric   if (bkpt_sp) {
171*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
172*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
173*0b57cec5SDimitry Andric     sb_bp_location.SetLocation(bkpt_sp->FindLocationByID(bp_loc_id));
174*0b57cec5SDimitry Andric   }
175*0b57cec5SDimitry Andric 
176*0b57cec5SDimitry Andric   return LLDB_RECORD_RESULT(sb_bp_location);
177*0b57cec5SDimitry Andric }
178*0b57cec5SDimitry Andric 
179*0b57cec5SDimitry Andric SBBreakpointLocation SBBreakpoint::GetLocationAtIndex(uint32_t index) {
180*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
181*0b57cec5SDimitry Andric                      GetLocationAtIndex, (uint32_t), index);
182*0b57cec5SDimitry Andric 
183*0b57cec5SDimitry Andric   SBBreakpointLocation sb_bp_location;
184*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
185*0b57cec5SDimitry Andric 
186*0b57cec5SDimitry Andric   if (bkpt_sp) {
187*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
188*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
189*0b57cec5SDimitry Andric     sb_bp_location.SetLocation(bkpt_sp->GetLocationAtIndex(index));
190*0b57cec5SDimitry Andric   }
191*0b57cec5SDimitry Andric 
192*0b57cec5SDimitry Andric   return LLDB_RECORD_RESULT(sb_bp_location);
193*0b57cec5SDimitry Andric }
194*0b57cec5SDimitry Andric 
195*0b57cec5SDimitry Andric void SBBreakpoint::SetEnabled(bool enable) {
196*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(void, SBBreakpoint, SetEnabled, (bool), enable);
197*0b57cec5SDimitry Andric 
198*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
199*0b57cec5SDimitry Andric 
200*0b57cec5SDimitry Andric   if (bkpt_sp) {
201*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
202*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
203*0b57cec5SDimitry Andric     bkpt_sp->SetEnabled(enable);
204*0b57cec5SDimitry Andric   }
205*0b57cec5SDimitry Andric }
206*0b57cec5SDimitry Andric 
207*0b57cec5SDimitry Andric bool SBBreakpoint::IsEnabled() {
208*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpoint, IsEnabled);
209*0b57cec5SDimitry Andric 
210*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
211*0b57cec5SDimitry Andric   if (bkpt_sp) {
212*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
213*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
214*0b57cec5SDimitry Andric     return bkpt_sp->IsEnabled();
215*0b57cec5SDimitry Andric   } else
216*0b57cec5SDimitry Andric     return false;
217*0b57cec5SDimitry Andric }
218*0b57cec5SDimitry Andric 
219*0b57cec5SDimitry Andric void SBBreakpoint::SetOneShot(bool one_shot) {
220*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(void, SBBreakpoint, SetOneShot, (bool), one_shot);
221*0b57cec5SDimitry Andric 
222*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
223*0b57cec5SDimitry Andric 
224*0b57cec5SDimitry Andric   if (bkpt_sp) {
225*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
226*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
227*0b57cec5SDimitry Andric     bkpt_sp->SetOneShot(one_shot);
228*0b57cec5SDimitry Andric   }
229*0b57cec5SDimitry Andric }
230*0b57cec5SDimitry Andric 
231*0b57cec5SDimitry Andric bool SBBreakpoint::IsOneShot() const {
232*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, IsOneShot);
233*0b57cec5SDimitry Andric 
234*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
235*0b57cec5SDimitry Andric   if (bkpt_sp) {
236*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
237*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
238*0b57cec5SDimitry Andric     return bkpt_sp->IsOneShot();
239*0b57cec5SDimitry Andric   } else
240*0b57cec5SDimitry Andric     return false;
241*0b57cec5SDimitry Andric }
242*0b57cec5SDimitry Andric 
243*0b57cec5SDimitry Andric bool SBBreakpoint::IsInternal() {
244*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpoint, IsInternal);
245*0b57cec5SDimitry Andric 
246*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
247*0b57cec5SDimitry Andric   if (bkpt_sp) {
248*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
249*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
250*0b57cec5SDimitry Andric     return bkpt_sp->IsInternal();
251*0b57cec5SDimitry Andric   } else
252*0b57cec5SDimitry Andric     return false;
253*0b57cec5SDimitry Andric }
254*0b57cec5SDimitry Andric 
255*0b57cec5SDimitry Andric void SBBreakpoint::SetIgnoreCount(uint32_t count) {
256*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(void, SBBreakpoint, SetIgnoreCount, (uint32_t), count);
257*0b57cec5SDimitry Andric 
258*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
259*0b57cec5SDimitry Andric 
260*0b57cec5SDimitry Andric   if (bkpt_sp) {
261*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
262*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
263*0b57cec5SDimitry Andric     bkpt_sp->SetIgnoreCount(count);
264*0b57cec5SDimitry Andric   }
265*0b57cec5SDimitry Andric }
266*0b57cec5SDimitry Andric 
267*0b57cec5SDimitry Andric void SBBreakpoint::SetCondition(const char *condition) {
268*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(void, SBBreakpoint, SetCondition, (const char *),
269*0b57cec5SDimitry Andric                      condition);
270*0b57cec5SDimitry Andric 
271*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
272*0b57cec5SDimitry Andric   if (bkpt_sp) {
273*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
274*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
275*0b57cec5SDimitry Andric     bkpt_sp->SetCondition(condition);
276*0b57cec5SDimitry Andric   }
277*0b57cec5SDimitry Andric }
278*0b57cec5SDimitry Andric 
279*0b57cec5SDimitry Andric const char *SBBreakpoint::GetCondition() {
280*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD_NO_ARGS(const char *, SBBreakpoint, GetCondition);
281*0b57cec5SDimitry Andric 
282*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
283*0b57cec5SDimitry Andric   if (bkpt_sp) {
284*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
285*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
286*0b57cec5SDimitry Andric     return bkpt_sp->GetConditionText();
287*0b57cec5SDimitry Andric   }
288*0b57cec5SDimitry Andric   return nullptr;
289*0b57cec5SDimitry Andric }
290*0b57cec5SDimitry Andric 
291*0b57cec5SDimitry Andric void SBBreakpoint::SetAutoContinue(bool auto_continue) {
292*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(void, SBBreakpoint, SetAutoContinue, (bool),
293*0b57cec5SDimitry Andric                      auto_continue);
294*0b57cec5SDimitry Andric 
295*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
296*0b57cec5SDimitry Andric   if (bkpt_sp) {
297*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
298*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
299*0b57cec5SDimitry Andric     bkpt_sp->SetAutoContinue(auto_continue);
300*0b57cec5SDimitry Andric   }
301*0b57cec5SDimitry Andric }
302*0b57cec5SDimitry Andric 
303*0b57cec5SDimitry Andric bool SBBreakpoint::GetAutoContinue() {
304*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpoint, GetAutoContinue);
305*0b57cec5SDimitry Andric 
306*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
307*0b57cec5SDimitry Andric   if (bkpt_sp) {
308*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
309*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
310*0b57cec5SDimitry Andric     return bkpt_sp->IsAutoContinue();
311*0b57cec5SDimitry Andric   }
312*0b57cec5SDimitry Andric   return false;
313*0b57cec5SDimitry Andric }
314*0b57cec5SDimitry Andric 
315*0b57cec5SDimitry Andric uint32_t SBBreakpoint::GetHitCount() const {
316*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpoint, GetHitCount);
317*0b57cec5SDimitry Andric 
318*0b57cec5SDimitry Andric   uint32_t count = 0;
319*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
320*0b57cec5SDimitry Andric   if (bkpt_sp) {
321*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
322*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
323*0b57cec5SDimitry Andric     count = bkpt_sp->GetHitCount();
324*0b57cec5SDimitry Andric   }
325*0b57cec5SDimitry Andric 
326*0b57cec5SDimitry Andric   return count;
327*0b57cec5SDimitry Andric }
328*0b57cec5SDimitry Andric 
329*0b57cec5SDimitry Andric uint32_t SBBreakpoint::GetIgnoreCount() const {
330*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpoint, GetIgnoreCount);
331*0b57cec5SDimitry Andric 
332*0b57cec5SDimitry Andric   uint32_t count = 0;
333*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
334*0b57cec5SDimitry Andric   if (bkpt_sp) {
335*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
336*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
337*0b57cec5SDimitry Andric     count = bkpt_sp->GetIgnoreCount();
338*0b57cec5SDimitry Andric   }
339*0b57cec5SDimitry Andric 
340*0b57cec5SDimitry Andric   return count;
341*0b57cec5SDimitry Andric }
342*0b57cec5SDimitry Andric 
343*0b57cec5SDimitry Andric void SBBreakpoint::SetThreadID(tid_t tid) {
344*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(void, SBBreakpoint, SetThreadID, (lldb::tid_t), tid);
345*0b57cec5SDimitry Andric 
346*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
347*0b57cec5SDimitry Andric   if (bkpt_sp) {
348*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
349*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
350*0b57cec5SDimitry Andric     bkpt_sp->SetThreadID(tid);
351*0b57cec5SDimitry Andric   }
352*0b57cec5SDimitry Andric }
353*0b57cec5SDimitry Andric 
354*0b57cec5SDimitry Andric tid_t SBBreakpoint::GetThreadID() {
355*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD_NO_ARGS(lldb::tid_t, SBBreakpoint, GetThreadID);
356*0b57cec5SDimitry Andric 
357*0b57cec5SDimitry Andric   tid_t tid = LLDB_INVALID_THREAD_ID;
358*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
359*0b57cec5SDimitry Andric   if (bkpt_sp) {
360*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
361*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
362*0b57cec5SDimitry Andric     tid = bkpt_sp->GetThreadID();
363*0b57cec5SDimitry Andric   }
364*0b57cec5SDimitry Andric 
365*0b57cec5SDimitry Andric   return tid;
366*0b57cec5SDimitry Andric }
367*0b57cec5SDimitry Andric 
368*0b57cec5SDimitry Andric void SBBreakpoint::SetThreadIndex(uint32_t index) {
369*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(void, SBBreakpoint, SetThreadIndex, (uint32_t), index);
370*0b57cec5SDimitry Andric 
371*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
372*0b57cec5SDimitry Andric   if (bkpt_sp) {
373*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
374*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
375*0b57cec5SDimitry Andric     bkpt_sp->GetOptions()->GetThreadSpec()->SetIndex(index);
376*0b57cec5SDimitry Andric   }
377*0b57cec5SDimitry Andric }
378*0b57cec5SDimitry Andric 
379*0b57cec5SDimitry Andric uint32_t SBBreakpoint::GetThreadIndex() const {
380*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpoint, GetThreadIndex);
381*0b57cec5SDimitry Andric 
382*0b57cec5SDimitry Andric   uint32_t thread_idx = UINT32_MAX;
383*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
384*0b57cec5SDimitry Andric   if (bkpt_sp) {
385*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
386*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
387*0b57cec5SDimitry Andric     const ThreadSpec *thread_spec =
388*0b57cec5SDimitry Andric         bkpt_sp->GetOptions()->GetThreadSpecNoCreate();
389*0b57cec5SDimitry Andric     if (thread_spec != nullptr)
390*0b57cec5SDimitry Andric       thread_idx = thread_spec->GetIndex();
391*0b57cec5SDimitry Andric   }
392*0b57cec5SDimitry Andric 
393*0b57cec5SDimitry Andric   return thread_idx;
394*0b57cec5SDimitry Andric }
395*0b57cec5SDimitry Andric 
396*0b57cec5SDimitry Andric void SBBreakpoint::SetThreadName(const char *thread_name) {
397*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(void, SBBreakpoint, SetThreadName, (const char *),
398*0b57cec5SDimitry Andric                      thread_name);
399*0b57cec5SDimitry Andric 
400*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
401*0b57cec5SDimitry Andric 
402*0b57cec5SDimitry Andric   if (bkpt_sp) {
403*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
404*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
405*0b57cec5SDimitry Andric     bkpt_sp->GetOptions()->GetThreadSpec()->SetName(thread_name);
406*0b57cec5SDimitry Andric   }
407*0b57cec5SDimitry Andric }
408*0b57cec5SDimitry Andric 
409*0b57cec5SDimitry Andric const char *SBBreakpoint::GetThreadName() const {
410*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpoint, GetThreadName);
411*0b57cec5SDimitry Andric 
412*0b57cec5SDimitry Andric   const char *name = nullptr;
413*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
414*0b57cec5SDimitry Andric   if (bkpt_sp) {
415*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
416*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
417*0b57cec5SDimitry Andric     const ThreadSpec *thread_spec =
418*0b57cec5SDimitry Andric         bkpt_sp->GetOptions()->GetThreadSpecNoCreate();
419*0b57cec5SDimitry Andric     if (thread_spec != nullptr)
420*0b57cec5SDimitry Andric       name = thread_spec->GetName();
421*0b57cec5SDimitry Andric   }
422*0b57cec5SDimitry Andric 
423*0b57cec5SDimitry Andric   return name;
424*0b57cec5SDimitry Andric }
425*0b57cec5SDimitry Andric 
426*0b57cec5SDimitry Andric void SBBreakpoint::SetQueueName(const char *queue_name) {
427*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(void, SBBreakpoint, SetQueueName, (const char *),
428*0b57cec5SDimitry Andric                      queue_name);
429*0b57cec5SDimitry Andric 
430*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
431*0b57cec5SDimitry Andric   if (bkpt_sp) {
432*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
433*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
434*0b57cec5SDimitry Andric     bkpt_sp->GetOptions()->GetThreadSpec()->SetQueueName(queue_name);
435*0b57cec5SDimitry Andric   }
436*0b57cec5SDimitry Andric }
437*0b57cec5SDimitry Andric 
438*0b57cec5SDimitry Andric const char *SBBreakpoint::GetQueueName() const {
439*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpoint, GetQueueName);
440*0b57cec5SDimitry Andric 
441*0b57cec5SDimitry Andric   const char *name = nullptr;
442*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
443*0b57cec5SDimitry Andric   if (bkpt_sp) {
444*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
445*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
446*0b57cec5SDimitry Andric     const ThreadSpec *thread_spec =
447*0b57cec5SDimitry Andric         bkpt_sp->GetOptions()->GetThreadSpecNoCreate();
448*0b57cec5SDimitry Andric     if (thread_spec)
449*0b57cec5SDimitry Andric       name = thread_spec->GetQueueName();
450*0b57cec5SDimitry Andric   }
451*0b57cec5SDimitry Andric 
452*0b57cec5SDimitry Andric   return name;
453*0b57cec5SDimitry Andric }
454*0b57cec5SDimitry Andric 
455*0b57cec5SDimitry Andric size_t SBBreakpoint::GetNumResolvedLocations() const {
456*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBBreakpoint,
457*0b57cec5SDimitry Andric                                    GetNumResolvedLocations);
458*0b57cec5SDimitry Andric 
459*0b57cec5SDimitry Andric   size_t num_resolved = 0;
460*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
461*0b57cec5SDimitry Andric   if (bkpt_sp) {
462*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
463*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
464*0b57cec5SDimitry Andric     num_resolved = bkpt_sp->GetNumResolvedLocations();
465*0b57cec5SDimitry Andric   }
466*0b57cec5SDimitry Andric   return num_resolved;
467*0b57cec5SDimitry Andric }
468*0b57cec5SDimitry Andric 
469*0b57cec5SDimitry Andric size_t SBBreakpoint::GetNumLocations() const {
470*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBBreakpoint, GetNumLocations);
471*0b57cec5SDimitry Andric 
472*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
473*0b57cec5SDimitry Andric   size_t num_locs = 0;
474*0b57cec5SDimitry Andric   if (bkpt_sp) {
475*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
476*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
477*0b57cec5SDimitry Andric     num_locs = bkpt_sp->GetNumLocations();
478*0b57cec5SDimitry Andric   }
479*0b57cec5SDimitry Andric   return num_locs;
480*0b57cec5SDimitry Andric }
481*0b57cec5SDimitry Andric 
482*0b57cec5SDimitry Andric void SBBreakpoint::SetCommandLineCommands(SBStringList &commands) {
483*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(void, SBBreakpoint, SetCommandLineCommands,
484*0b57cec5SDimitry Andric                      (lldb::SBStringList &), commands);
485*0b57cec5SDimitry Andric 
486*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
487*0b57cec5SDimitry Andric   if (!bkpt_sp)
488*0b57cec5SDimitry Andric     return;
489*0b57cec5SDimitry Andric   if (commands.GetSize() == 0)
490*0b57cec5SDimitry Andric     return;
491*0b57cec5SDimitry Andric 
492*0b57cec5SDimitry Andric   std::lock_guard<std::recursive_mutex> guard(
493*0b57cec5SDimitry Andric       bkpt_sp->GetTarget().GetAPIMutex());
494*0b57cec5SDimitry Andric   std::unique_ptr<BreakpointOptions::CommandData> cmd_data_up(
495*0b57cec5SDimitry Andric       new BreakpointOptions::CommandData(*commands, eScriptLanguageNone));
496*0b57cec5SDimitry Andric 
497*0b57cec5SDimitry Andric   bkpt_sp->GetOptions()->SetCommandDataCallback(cmd_data_up);
498*0b57cec5SDimitry Andric }
499*0b57cec5SDimitry Andric 
500*0b57cec5SDimitry Andric bool SBBreakpoint::GetCommandLineCommands(SBStringList &commands) {
501*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(bool, SBBreakpoint, GetCommandLineCommands,
502*0b57cec5SDimitry Andric                      (lldb::SBStringList &), commands);
503*0b57cec5SDimitry Andric 
504*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
505*0b57cec5SDimitry Andric   if (!bkpt_sp)
506*0b57cec5SDimitry Andric     return false;
507*0b57cec5SDimitry Andric   StringList command_list;
508*0b57cec5SDimitry Andric   bool has_commands =
509*0b57cec5SDimitry Andric       bkpt_sp->GetOptions()->GetCommandLineCallbacks(command_list);
510*0b57cec5SDimitry Andric   if (has_commands)
511*0b57cec5SDimitry Andric     commands.AppendList(command_list);
512*0b57cec5SDimitry Andric   return has_commands;
513*0b57cec5SDimitry Andric }
514*0b57cec5SDimitry Andric 
515*0b57cec5SDimitry Andric bool SBBreakpoint::GetDescription(SBStream &s) {
516*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(bool, SBBreakpoint, GetDescription, (lldb::SBStream &), s);
517*0b57cec5SDimitry Andric 
518*0b57cec5SDimitry Andric   return GetDescription(s, true);
519*0b57cec5SDimitry Andric }
520*0b57cec5SDimitry Andric 
521*0b57cec5SDimitry Andric bool SBBreakpoint::GetDescription(SBStream &s, bool include_locations) {
522*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(bool, SBBreakpoint, GetDescription,
523*0b57cec5SDimitry Andric                      (lldb::SBStream &, bool), s, include_locations);
524*0b57cec5SDimitry Andric 
525*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
526*0b57cec5SDimitry Andric   if (bkpt_sp) {
527*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
528*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
529*0b57cec5SDimitry Andric     s.Printf("SBBreakpoint: id = %i, ", bkpt_sp->GetID());
530*0b57cec5SDimitry Andric     bkpt_sp->GetResolverDescription(s.get());
531*0b57cec5SDimitry Andric     bkpt_sp->GetFilterDescription(s.get());
532*0b57cec5SDimitry Andric     if (include_locations) {
533*0b57cec5SDimitry Andric       const size_t num_locations = bkpt_sp->GetNumLocations();
534*0b57cec5SDimitry Andric       s.Printf(", locations = %" PRIu64, (uint64_t)num_locations);
535*0b57cec5SDimitry Andric     }
536*0b57cec5SDimitry Andric     return true;
537*0b57cec5SDimitry Andric   }
538*0b57cec5SDimitry Andric   s.Printf("No value");
539*0b57cec5SDimitry Andric   return false;
540*0b57cec5SDimitry Andric }
541*0b57cec5SDimitry Andric 
542*0b57cec5SDimitry Andric SBError SBBreakpoint::AddLocation(SBAddress &address) {
543*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(lldb::SBError, SBBreakpoint, AddLocation,
544*0b57cec5SDimitry Andric                      (lldb::SBAddress &), address);
545*0b57cec5SDimitry Andric 
546*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
547*0b57cec5SDimitry Andric   SBError error;
548*0b57cec5SDimitry Andric 
549*0b57cec5SDimitry Andric   if (!address.IsValid()) {
550*0b57cec5SDimitry Andric     error.SetErrorString("Can't add an invalid address.");
551*0b57cec5SDimitry Andric     return LLDB_RECORD_RESULT(error);
552*0b57cec5SDimitry Andric   }
553*0b57cec5SDimitry Andric 
554*0b57cec5SDimitry Andric   if (!bkpt_sp) {
555*0b57cec5SDimitry Andric     error.SetErrorString("No breakpoint to add a location to.");
556*0b57cec5SDimitry Andric     return LLDB_RECORD_RESULT(error);
557*0b57cec5SDimitry Andric   }
558*0b57cec5SDimitry Andric 
559*0b57cec5SDimitry Andric   if (!llvm::isa<BreakpointResolverScripted>(bkpt_sp->GetResolver().get())) {
560*0b57cec5SDimitry Andric     error.SetErrorString("Only a scripted resolver can add locations.");
561*0b57cec5SDimitry Andric     return LLDB_RECORD_RESULT(error);
562*0b57cec5SDimitry Andric   }
563*0b57cec5SDimitry Andric 
564*0b57cec5SDimitry Andric   if (bkpt_sp->GetSearchFilter()->AddressPasses(address.ref()))
565*0b57cec5SDimitry Andric     bkpt_sp->AddLocation(address.ref());
566*0b57cec5SDimitry Andric   else {
567*0b57cec5SDimitry Andric     StreamString s;
568*0b57cec5SDimitry Andric     address.get()->Dump(&s, &bkpt_sp->GetTarget(),
569*0b57cec5SDimitry Andric                         Address::DumpStyleModuleWithFileAddress);
570*0b57cec5SDimitry Andric     error.SetErrorStringWithFormat("Address: %s didn't pass the filter.",
571*0b57cec5SDimitry Andric                                    s.GetData());
572*0b57cec5SDimitry Andric   }
573*0b57cec5SDimitry Andric   return LLDB_RECORD_RESULT(error);
574*0b57cec5SDimitry Andric }
575*0b57cec5SDimitry Andric 
576*0b57cec5SDimitry Andric void SBBreakpoint ::SetCallback(SBBreakpointHitCallback callback, void *baton) {
577*0b57cec5SDimitry Andric   LLDB_RECORD_DUMMY(void, SBBreakpoint, SetCallback,
578*0b57cec5SDimitry Andric                     (lldb::SBBreakpointHitCallback, void *), callback, baton);
579*0b57cec5SDimitry Andric 
580*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
581*0b57cec5SDimitry Andric 
582*0b57cec5SDimitry Andric   if (bkpt_sp) {
583*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
584*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
585*0b57cec5SDimitry Andric     BatonSP baton_sp(new SBBreakpointCallbackBaton(callback, baton));
586*0b57cec5SDimitry Andric     bkpt_sp->SetCallback(SBBreakpointCallbackBaton
587*0b57cec5SDimitry Andric       ::PrivateBreakpointHitCallback, baton_sp,
588*0b57cec5SDimitry Andric                          false);
589*0b57cec5SDimitry Andric   }
590*0b57cec5SDimitry Andric }
591*0b57cec5SDimitry Andric 
592*0b57cec5SDimitry Andric void SBBreakpoint::SetScriptCallbackFunction(
593*0b57cec5SDimitry Andric     const char *callback_function_name) {
594*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(void, SBBreakpoint, SetScriptCallbackFunction,
595*0b57cec5SDimitry Andric                      (const char *), callback_function_name);
596*0b57cec5SDimitry Andric 
597*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
598*0b57cec5SDimitry Andric 
599*0b57cec5SDimitry Andric   if (bkpt_sp) {
600*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
601*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
602*0b57cec5SDimitry Andric     BreakpointOptions *bp_options = bkpt_sp->GetOptions();
603*0b57cec5SDimitry Andric     bkpt_sp->GetTarget()
604*0b57cec5SDimitry Andric         .GetDebugger()
605*0b57cec5SDimitry Andric         .GetScriptInterpreter()
606*0b57cec5SDimitry Andric         ->SetBreakpointCommandCallbackFunction(bp_options,
607*0b57cec5SDimitry Andric                                                callback_function_name);
608*0b57cec5SDimitry Andric   }
609*0b57cec5SDimitry Andric }
610*0b57cec5SDimitry Andric 
611*0b57cec5SDimitry Andric SBError SBBreakpoint::SetScriptCallbackBody(const char *callback_body_text) {
612*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(lldb::SBError, SBBreakpoint, SetScriptCallbackBody,
613*0b57cec5SDimitry Andric                      (const char *), callback_body_text);
614*0b57cec5SDimitry Andric 
615*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
616*0b57cec5SDimitry Andric 
617*0b57cec5SDimitry Andric   SBError sb_error;
618*0b57cec5SDimitry Andric   if (bkpt_sp) {
619*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
620*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
621*0b57cec5SDimitry Andric     BreakpointOptions *bp_options = bkpt_sp->GetOptions();
622*0b57cec5SDimitry Andric     Status error =
623*0b57cec5SDimitry Andric         bkpt_sp->GetTarget()
624*0b57cec5SDimitry Andric             .GetDebugger()
625*0b57cec5SDimitry Andric             .GetScriptInterpreter()
626*0b57cec5SDimitry Andric             ->SetBreakpointCommandCallback(bp_options, callback_body_text);
627*0b57cec5SDimitry Andric     sb_error.SetError(error);
628*0b57cec5SDimitry Andric   } else
629*0b57cec5SDimitry Andric     sb_error.SetErrorString("invalid breakpoint");
630*0b57cec5SDimitry Andric 
631*0b57cec5SDimitry Andric   return LLDB_RECORD_RESULT(sb_error);
632*0b57cec5SDimitry Andric }
633*0b57cec5SDimitry Andric 
634*0b57cec5SDimitry Andric bool SBBreakpoint::AddName(const char *new_name) {
635*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(bool, SBBreakpoint, AddName, (const char *), new_name);
636*0b57cec5SDimitry Andric 
637*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
638*0b57cec5SDimitry Andric 
639*0b57cec5SDimitry Andric   if (bkpt_sp) {
640*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
641*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
642*0b57cec5SDimitry Andric     Status error; // Think I'm just going to swallow the error here, it's
643*0b57cec5SDimitry Andric                   // probably more annoying to have to provide it.
644*0b57cec5SDimitry Andric     bkpt_sp->GetTarget().AddNameToBreakpoint(bkpt_sp, new_name, error);
645*0b57cec5SDimitry Andric     if (error.Fail())
646*0b57cec5SDimitry Andric       return false;
647*0b57cec5SDimitry Andric   }
648*0b57cec5SDimitry Andric 
649*0b57cec5SDimitry Andric   return true;
650*0b57cec5SDimitry Andric }
651*0b57cec5SDimitry Andric 
652*0b57cec5SDimitry Andric void SBBreakpoint::RemoveName(const char *name_to_remove) {
653*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(void, SBBreakpoint, RemoveName, (const char *),
654*0b57cec5SDimitry Andric                      name_to_remove);
655*0b57cec5SDimitry Andric 
656*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
657*0b57cec5SDimitry Andric 
658*0b57cec5SDimitry Andric   if (bkpt_sp) {
659*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
660*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
661*0b57cec5SDimitry Andric     bkpt_sp->GetTarget().RemoveNameFromBreakpoint(bkpt_sp,
662*0b57cec5SDimitry Andric                                                   ConstString(name_to_remove));
663*0b57cec5SDimitry Andric   }
664*0b57cec5SDimitry Andric }
665*0b57cec5SDimitry Andric 
666*0b57cec5SDimitry Andric bool SBBreakpoint::MatchesName(const char *name) {
667*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(bool, SBBreakpoint, MatchesName, (const char *), name);
668*0b57cec5SDimitry Andric 
669*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
670*0b57cec5SDimitry Andric 
671*0b57cec5SDimitry Andric   if (bkpt_sp) {
672*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
673*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
674*0b57cec5SDimitry Andric     return bkpt_sp->MatchesName(name);
675*0b57cec5SDimitry Andric   }
676*0b57cec5SDimitry Andric 
677*0b57cec5SDimitry Andric   return false;
678*0b57cec5SDimitry Andric }
679*0b57cec5SDimitry Andric 
680*0b57cec5SDimitry Andric void SBBreakpoint::GetNames(SBStringList &names) {
681*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(void, SBBreakpoint, GetNames, (lldb::SBStringList &),
682*0b57cec5SDimitry Andric                      names);
683*0b57cec5SDimitry Andric 
684*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
685*0b57cec5SDimitry Andric 
686*0b57cec5SDimitry Andric   if (bkpt_sp) {
687*0b57cec5SDimitry Andric     std::lock_guard<std::recursive_mutex> guard(
688*0b57cec5SDimitry Andric         bkpt_sp->GetTarget().GetAPIMutex());
689*0b57cec5SDimitry Andric     std::vector<std::string> names_vec;
690*0b57cec5SDimitry Andric     bkpt_sp->GetNames(names_vec);
691*0b57cec5SDimitry Andric     for (std::string name : names_vec) {
692*0b57cec5SDimitry Andric       names.AppendString(name.c_str());
693*0b57cec5SDimitry Andric     }
694*0b57cec5SDimitry Andric   }
695*0b57cec5SDimitry Andric }
696*0b57cec5SDimitry Andric 
697*0b57cec5SDimitry Andric bool SBBreakpoint::EventIsBreakpointEvent(const lldb::SBEvent &event) {
698*0b57cec5SDimitry Andric   LLDB_RECORD_STATIC_METHOD(bool, SBBreakpoint, EventIsBreakpointEvent,
699*0b57cec5SDimitry Andric                             (const lldb::SBEvent &), event);
700*0b57cec5SDimitry Andric 
701*0b57cec5SDimitry Andric   return Breakpoint::BreakpointEventData::GetEventDataFromEvent(event.get()) !=
702*0b57cec5SDimitry Andric          nullptr;
703*0b57cec5SDimitry Andric }
704*0b57cec5SDimitry Andric 
705*0b57cec5SDimitry Andric BreakpointEventType
706*0b57cec5SDimitry Andric SBBreakpoint::GetBreakpointEventTypeFromEvent(const SBEvent &event) {
707*0b57cec5SDimitry Andric   LLDB_RECORD_STATIC_METHOD(lldb::BreakpointEventType, SBBreakpoint,
708*0b57cec5SDimitry Andric                             GetBreakpointEventTypeFromEvent,
709*0b57cec5SDimitry Andric                             (const lldb::SBEvent &), event);
710*0b57cec5SDimitry Andric 
711*0b57cec5SDimitry Andric   if (event.IsValid())
712*0b57cec5SDimitry Andric     return Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent(
713*0b57cec5SDimitry Andric         event.GetSP());
714*0b57cec5SDimitry Andric   return eBreakpointEventTypeInvalidType;
715*0b57cec5SDimitry Andric }
716*0b57cec5SDimitry Andric 
717*0b57cec5SDimitry Andric SBBreakpoint SBBreakpoint::GetBreakpointFromEvent(const lldb::SBEvent &event) {
718*0b57cec5SDimitry Andric   LLDB_RECORD_STATIC_METHOD(lldb::SBBreakpoint, SBBreakpoint,
719*0b57cec5SDimitry Andric                             GetBreakpointFromEvent, (const lldb::SBEvent &),
720*0b57cec5SDimitry Andric                             event);
721*0b57cec5SDimitry Andric 
722*0b57cec5SDimitry Andric   if (event.IsValid())
723*0b57cec5SDimitry Andric     return LLDB_RECORD_RESULT(
724*0b57cec5SDimitry Andric         SBBreakpoint(Breakpoint::BreakpointEventData::GetBreakpointFromEvent(
725*0b57cec5SDimitry Andric             event.GetSP())));
726*0b57cec5SDimitry Andric   return LLDB_RECORD_RESULT(SBBreakpoint());
727*0b57cec5SDimitry Andric }
728*0b57cec5SDimitry Andric 
729*0b57cec5SDimitry Andric SBBreakpointLocation
730*0b57cec5SDimitry Andric SBBreakpoint::GetBreakpointLocationAtIndexFromEvent(const lldb::SBEvent &event,
731*0b57cec5SDimitry Andric                                                     uint32_t loc_idx) {
732*0b57cec5SDimitry Andric   LLDB_RECORD_STATIC_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
733*0b57cec5SDimitry Andric                             GetBreakpointLocationAtIndexFromEvent,
734*0b57cec5SDimitry Andric                             (const lldb::SBEvent &, uint32_t), event, loc_idx);
735*0b57cec5SDimitry Andric 
736*0b57cec5SDimitry Andric   SBBreakpointLocation sb_breakpoint_loc;
737*0b57cec5SDimitry Andric   if (event.IsValid())
738*0b57cec5SDimitry Andric     sb_breakpoint_loc.SetLocation(
739*0b57cec5SDimitry Andric         Breakpoint::BreakpointEventData::GetBreakpointLocationAtIndexFromEvent(
740*0b57cec5SDimitry Andric             event.GetSP(), loc_idx));
741*0b57cec5SDimitry Andric   return LLDB_RECORD_RESULT(sb_breakpoint_loc);
742*0b57cec5SDimitry Andric }
743*0b57cec5SDimitry Andric 
744*0b57cec5SDimitry Andric uint32_t
745*0b57cec5SDimitry Andric SBBreakpoint::GetNumBreakpointLocationsFromEvent(const lldb::SBEvent &event) {
746*0b57cec5SDimitry Andric   LLDB_RECORD_STATIC_METHOD(uint32_t, SBBreakpoint,
747*0b57cec5SDimitry Andric                             GetNumBreakpointLocationsFromEvent,
748*0b57cec5SDimitry Andric                             (const lldb::SBEvent &), event);
749*0b57cec5SDimitry Andric 
750*0b57cec5SDimitry Andric   uint32_t num_locations = 0;
751*0b57cec5SDimitry Andric   if (event.IsValid())
752*0b57cec5SDimitry Andric     num_locations =
753*0b57cec5SDimitry Andric         (Breakpoint::BreakpointEventData::GetNumBreakpointLocationsFromEvent(
754*0b57cec5SDimitry Andric             event.GetSP()));
755*0b57cec5SDimitry Andric   return num_locations;
756*0b57cec5SDimitry Andric }
757*0b57cec5SDimitry Andric 
758*0b57cec5SDimitry Andric bool SBBreakpoint::IsHardware() const {
759*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, IsHardware);
760*0b57cec5SDimitry Andric 
761*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = GetSP();
762*0b57cec5SDimitry Andric   if (bkpt_sp)
763*0b57cec5SDimitry Andric     return bkpt_sp->IsHardware();
764*0b57cec5SDimitry Andric   return false;
765*0b57cec5SDimitry Andric }
766*0b57cec5SDimitry Andric 
767*0b57cec5SDimitry Andric BreakpointSP SBBreakpoint::GetSP() const { return m_opaque_wp.lock(); }
768*0b57cec5SDimitry Andric 
769*0b57cec5SDimitry Andric // This is simple collection of breakpoint id's and their target.
770*0b57cec5SDimitry Andric class SBBreakpointListImpl {
771*0b57cec5SDimitry Andric public:
772*0b57cec5SDimitry Andric   SBBreakpointListImpl(lldb::TargetSP target_sp) : m_target_wp() {
773*0b57cec5SDimitry Andric     if (target_sp && target_sp->IsValid())
774*0b57cec5SDimitry Andric       m_target_wp = target_sp;
775*0b57cec5SDimitry Andric   }
776*0b57cec5SDimitry Andric 
777*0b57cec5SDimitry Andric   ~SBBreakpointListImpl() = default;
778*0b57cec5SDimitry Andric 
779*0b57cec5SDimitry Andric   size_t GetSize() { return m_break_ids.size(); }
780*0b57cec5SDimitry Andric 
781*0b57cec5SDimitry Andric   BreakpointSP GetBreakpointAtIndex(size_t idx) {
782*0b57cec5SDimitry Andric     if (idx >= m_break_ids.size())
783*0b57cec5SDimitry Andric       return BreakpointSP();
784*0b57cec5SDimitry Andric     TargetSP target_sp = m_target_wp.lock();
785*0b57cec5SDimitry Andric     if (!target_sp)
786*0b57cec5SDimitry Andric       return BreakpointSP();
787*0b57cec5SDimitry Andric     lldb::break_id_t bp_id = m_break_ids[idx];
788*0b57cec5SDimitry Andric     return target_sp->GetBreakpointList().FindBreakpointByID(bp_id);
789*0b57cec5SDimitry Andric   }
790*0b57cec5SDimitry Andric 
791*0b57cec5SDimitry Andric   BreakpointSP FindBreakpointByID(lldb::break_id_t desired_id) {
792*0b57cec5SDimitry Andric     TargetSP target_sp = m_target_wp.lock();
793*0b57cec5SDimitry Andric     if (!target_sp)
794*0b57cec5SDimitry Andric       return BreakpointSP();
795*0b57cec5SDimitry Andric 
796*0b57cec5SDimitry Andric     for (lldb::break_id_t &break_id : m_break_ids) {
797*0b57cec5SDimitry Andric       if (break_id == desired_id)
798*0b57cec5SDimitry Andric         return target_sp->GetBreakpointList().FindBreakpointByID(break_id);
799*0b57cec5SDimitry Andric     }
800*0b57cec5SDimitry Andric     return BreakpointSP();
801*0b57cec5SDimitry Andric   }
802*0b57cec5SDimitry Andric 
803*0b57cec5SDimitry Andric   bool Append(BreakpointSP bkpt) {
804*0b57cec5SDimitry Andric     TargetSP target_sp = m_target_wp.lock();
805*0b57cec5SDimitry Andric     if (!target_sp || !bkpt)
806*0b57cec5SDimitry Andric       return false;
807*0b57cec5SDimitry Andric     if (bkpt->GetTargetSP() != target_sp)
808*0b57cec5SDimitry Andric       return false;
809*0b57cec5SDimitry Andric     m_break_ids.push_back(bkpt->GetID());
810*0b57cec5SDimitry Andric     return true;
811*0b57cec5SDimitry Andric   }
812*0b57cec5SDimitry Andric 
813*0b57cec5SDimitry Andric   bool AppendIfUnique(BreakpointSP bkpt) {
814*0b57cec5SDimitry Andric     TargetSP target_sp = m_target_wp.lock();
815*0b57cec5SDimitry Andric     if (!target_sp || !bkpt)
816*0b57cec5SDimitry Andric       return false;
817*0b57cec5SDimitry Andric     if (bkpt->GetTargetSP() != target_sp)
818*0b57cec5SDimitry Andric       return false;
819*0b57cec5SDimitry Andric     lldb::break_id_t bp_id = bkpt->GetID();
820*0b57cec5SDimitry Andric     if (find(m_break_ids.begin(), m_break_ids.end(), bp_id) ==
821*0b57cec5SDimitry Andric         m_break_ids.end())
822*0b57cec5SDimitry Andric       return false;
823*0b57cec5SDimitry Andric 
824*0b57cec5SDimitry Andric     m_break_ids.push_back(bkpt->GetID());
825*0b57cec5SDimitry Andric     return true;
826*0b57cec5SDimitry Andric   }
827*0b57cec5SDimitry Andric 
828*0b57cec5SDimitry Andric   bool AppendByID(lldb::break_id_t id) {
829*0b57cec5SDimitry Andric     TargetSP target_sp = m_target_wp.lock();
830*0b57cec5SDimitry Andric     if (!target_sp)
831*0b57cec5SDimitry Andric       return false;
832*0b57cec5SDimitry Andric     if (id == LLDB_INVALID_BREAK_ID)
833*0b57cec5SDimitry Andric       return false;
834*0b57cec5SDimitry Andric     m_break_ids.push_back(id);
835*0b57cec5SDimitry Andric     return true;
836*0b57cec5SDimitry Andric   }
837*0b57cec5SDimitry Andric 
838*0b57cec5SDimitry Andric   void Clear() { m_break_ids.clear(); }
839*0b57cec5SDimitry Andric 
840*0b57cec5SDimitry Andric   void CopyToBreakpointIDList(lldb_private::BreakpointIDList &bp_list) {
841*0b57cec5SDimitry Andric     for (lldb::break_id_t id : m_break_ids) {
842*0b57cec5SDimitry Andric       bp_list.AddBreakpointID(BreakpointID(id));
843*0b57cec5SDimitry Andric     }
844*0b57cec5SDimitry Andric   }
845*0b57cec5SDimitry Andric 
846*0b57cec5SDimitry Andric   TargetSP GetTarget() { return m_target_wp.lock(); }
847*0b57cec5SDimitry Andric 
848*0b57cec5SDimitry Andric private:
849*0b57cec5SDimitry Andric   std::vector<lldb::break_id_t> m_break_ids;
850*0b57cec5SDimitry Andric   TargetWP m_target_wp;
851*0b57cec5SDimitry Andric };
852*0b57cec5SDimitry Andric 
853*0b57cec5SDimitry Andric SBBreakpointList::SBBreakpointList(SBTarget &target)
854*0b57cec5SDimitry Andric     : m_opaque_sp(new SBBreakpointListImpl(target.GetSP())) {
855*0b57cec5SDimitry Andric   LLDB_RECORD_CONSTRUCTOR(SBBreakpointList, (lldb::SBTarget &), target);
856*0b57cec5SDimitry Andric }
857*0b57cec5SDimitry Andric 
858*0b57cec5SDimitry Andric SBBreakpointList::~SBBreakpointList() {}
859*0b57cec5SDimitry Andric 
860*0b57cec5SDimitry Andric size_t SBBreakpointList::GetSize() const {
861*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBBreakpointList, GetSize);
862*0b57cec5SDimitry Andric 
863*0b57cec5SDimitry Andric   if (!m_opaque_sp)
864*0b57cec5SDimitry Andric     return 0;
865*0b57cec5SDimitry Andric   else
866*0b57cec5SDimitry Andric     return m_opaque_sp->GetSize();
867*0b57cec5SDimitry Andric }
868*0b57cec5SDimitry Andric 
869*0b57cec5SDimitry Andric SBBreakpoint SBBreakpointList::GetBreakpointAtIndex(size_t idx) {
870*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBBreakpointList, GetBreakpointAtIndex,
871*0b57cec5SDimitry Andric                      (size_t), idx);
872*0b57cec5SDimitry Andric 
873*0b57cec5SDimitry Andric   if (!m_opaque_sp)
874*0b57cec5SDimitry Andric     return LLDB_RECORD_RESULT(SBBreakpoint());
875*0b57cec5SDimitry Andric 
876*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = m_opaque_sp->GetBreakpointAtIndex(idx);
877*0b57cec5SDimitry Andric   return LLDB_RECORD_RESULT(SBBreakpoint(bkpt_sp));
878*0b57cec5SDimitry Andric }
879*0b57cec5SDimitry Andric 
880*0b57cec5SDimitry Andric SBBreakpoint SBBreakpointList::FindBreakpointByID(lldb::break_id_t id) {
881*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBBreakpointList, FindBreakpointByID,
882*0b57cec5SDimitry Andric                      (lldb::break_id_t), id);
883*0b57cec5SDimitry Andric 
884*0b57cec5SDimitry Andric   if (!m_opaque_sp)
885*0b57cec5SDimitry Andric     return LLDB_RECORD_RESULT(SBBreakpoint());
886*0b57cec5SDimitry Andric   BreakpointSP bkpt_sp = m_opaque_sp->FindBreakpointByID(id);
887*0b57cec5SDimitry Andric   return LLDB_RECORD_RESULT(SBBreakpoint(bkpt_sp));
888*0b57cec5SDimitry Andric }
889*0b57cec5SDimitry Andric 
890*0b57cec5SDimitry Andric void SBBreakpointList::Append(const SBBreakpoint &sb_bkpt) {
891*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(void, SBBreakpointList, Append,
892*0b57cec5SDimitry Andric                      (const lldb::SBBreakpoint &), sb_bkpt);
893*0b57cec5SDimitry Andric 
894*0b57cec5SDimitry Andric   if (!sb_bkpt.IsValid())
895*0b57cec5SDimitry Andric     return;
896*0b57cec5SDimitry Andric   if (!m_opaque_sp)
897*0b57cec5SDimitry Andric     return;
898*0b57cec5SDimitry Andric   m_opaque_sp->Append(sb_bkpt.m_opaque_wp.lock());
899*0b57cec5SDimitry Andric }
900*0b57cec5SDimitry Andric 
901*0b57cec5SDimitry Andric void SBBreakpointList::AppendByID(lldb::break_id_t id) {
902*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(void, SBBreakpointList, AppendByID, (lldb::break_id_t),
903*0b57cec5SDimitry Andric                      id);
904*0b57cec5SDimitry Andric 
905*0b57cec5SDimitry Andric   if (!m_opaque_sp)
906*0b57cec5SDimitry Andric     return;
907*0b57cec5SDimitry Andric   m_opaque_sp->AppendByID(id);
908*0b57cec5SDimitry Andric }
909*0b57cec5SDimitry Andric 
910*0b57cec5SDimitry Andric bool SBBreakpointList::AppendIfUnique(const SBBreakpoint &sb_bkpt) {
911*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD(bool, SBBreakpointList, AppendIfUnique,
912*0b57cec5SDimitry Andric                      (const lldb::SBBreakpoint &), sb_bkpt);
913*0b57cec5SDimitry Andric 
914*0b57cec5SDimitry Andric   if (!sb_bkpt.IsValid())
915*0b57cec5SDimitry Andric     return false;
916*0b57cec5SDimitry Andric   if (!m_opaque_sp)
917*0b57cec5SDimitry Andric     return false;
918*0b57cec5SDimitry Andric   return m_opaque_sp->AppendIfUnique(sb_bkpt.GetSP());
919*0b57cec5SDimitry Andric }
920*0b57cec5SDimitry Andric 
921*0b57cec5SDimitry Andric void SBBreakpointList::Clear() {
922*0b57cec5SDimitry Andric   LLDB_RECORD_METHOD_NO_ARGS(void, SBBreakpointList, Clear);
923*0b57cec5SDimitry Andric 
924*0b57cec5SDimitry Andric   if (m_opaque_sp)
925*0b57cec5SDimitry Andric     m_opaque_sp->Clear();
926*0b57cec5SDimitry Andric }
927*0b57cec5SDimitry Andric 
928*0b57cec5SDimitry Andric void SBBreakpointList::CopyToBreakpointIDList(
929*0b57cec5SDimitry Andric     lldb_private::BreakpointIDList &bp_id_list) {
930*0b57cec5SDimitry Andric   if (m_opaque_sp)
931*0b57cec5SDimitry Andric     m_opaque_sp->CopyToBreakpointIDList(bp_id_list);
932*0b57cec5SDimitry Andric }
933*0b57cec5SDimitry Andric 
934*0b57cec5SDimitry Andric namespace lldb_private {
935*0b57cec5SDimitry Andric namespace repro {
936*0b57cec5SDimitry Andric 
937*0b57cec5SDimitry Andric template <>
938*0b57cec5SDimitry Andric void RegisterMethods<SBBreakpoint>(Registry &R) {
939*0b57cec5SDimitry Andric   LLDB_REGISTER_CONSTRUCTOR(SBBreakpoint, ());
940*0b57cec5SDimitry Andric   LLDB_REGISTER_CONSTRUCTOR(SBBreakpoint, (const lldb::SBBreakpoint &));
941*0b57cec5SDimitry Andric   LLDB_REGISTER_CONSTRUCTOR(SBBreakpoint, (const lldb::BreakpointSP &));
942*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(const lldb::SBBreakpoint &,
943*0b57cec5SDimitry Andric                        SBBreakpoint, operator=,(const lldb::SBBreakpoint &));
944*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(bool,
945*0b57cec5SDimitry Andric                        SBBreakpoint, operator==,(const lldb::SBBreakpoint &));
946*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(bool,
947*0b57cec5SDimitry Andric                        SBBreakpoint, operator!=,(const lldb::SBBreakpoint &));
948*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD_CONST(lldb::break_id_t, SBBreakpoint, GetID, ());
949*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, IsValid, ());
950*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, operator bool, ());
951*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(void, SBBreakpoint, ClearAllBreakpointSites, ());
952*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
953*0b57cec5SDimitry Andric                        FindLocationByAddress, (lldb::addr_t));
954*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(lldb::break_id_t, SBBreakpoint,
955*0b57cec5SDimitry Andric                        FindLocationIDByAddress, (lldb::addr_t));
956*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
957*0b57cec5SDimitry Andric                        FindLocationByID, (lldb::break_id_t));
958*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
959*0b57cec5SDimitry Andric                        GetLocationAtIndex, (uint32_t));
960*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(void, SBBreakpoint, SetEnabled, (bool));
961*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(bool, SBBreakpoint, IsEnabled, ());
962*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(void, SBBreakpoint, SetOneShot, (bool));
963*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, IsOneShot, ());
964*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(bool, SBBreakpoint, IsInternal, ());
965*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(void, SBBreakpoint, SetIgnoreCount, (uint32_t));
966*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(void, SBBreakpoint, SetCondition, (const char *));
967*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(const char *, SBBreakpoint, GetCondition, ());
968*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(void, SBBreakpoint, SetAutoContinue, (bool));
969*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(bool, SBBreakpoint, GetAutoContinue, ());
970*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpoint, GetHitCount, ());
971*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpoint, GetIgnoreCount, ());
972*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(void, SBBreakpoint, SetThreadID, (lldb::tid_t));
973*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(lldb::tid_t, SBBreakpoint, GetThreadID, ());
974*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(void, SBBreakpoint, SetThreadIndex, (uint32_t));
975*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpoint, GetThreadIndex, ());
976*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(void, SBBreakpoint, SetThreadName, (const char *));
977*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpoint, GetThreadName, ());
978*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(void, SBBreakpoint, SetQueueName, (const char *));
979*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpoint, GetQueueName, ());
980*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD_CONST(size_t, SBBreakpoint, GetNumResolvedLocations,
981*0b57cec5SDimitry Andric                              ());
982*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD_CONST(size_t, SBBreakpoint, GetNumLocations, ());
983*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(void, SBBreakpoint, SetCommandLineCommands,
984*0b57cec5SDimitry Andric                        (lldb::SBStringList &));
985*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(bool, SBBreakpoint, GetCommandLineCommands,
986*0b57cec5SDimitry Andric                        (lldb::SBStringList &));
987*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(bool, SBBreakpoint, GetDescription,
988*0b57cec5SDimitry Andric                        (lldb::SBStream &));
989*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(bool, SBBreakpoint, GetDescription,
990*0b57cec5SDimitry Andric                        (lldb::SBStream &, bool));
991*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, AddLocation,
992*0b57cec5SDimitry Andric                        (lldb::SBAddress &));
993*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(void, SBBreakpoint, SetScriptCallbackFunction,
994*0b57cec5SDimitry Andric                        (const char *));
995*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, SetScriptCallbackBody,
996*0b57cec5SDimitry Andric                        (const char *));
997*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(bool, SBBreakpoint, AddName, (const char *));
998*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(void, SBBreakpoint, RemoveName, (const char *));
999*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(bool, SBBreakpoint, MatchesName, (const char *));
1000*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(void, SBBreakpoint, GetNames, (lldb::SBStringList &));
1001*0b57cec5SDimitry Andric   LLDB_REGISTER_STATIC_METHOD(bool, SBBreakpoint, EventIsBreakpointEvent,
1002*0b57cec5SDimitry Andric                               (const lldb::SBEvent &));
1003*0b57cec5SDimitry Andric   LLDB_REGISTER_STATIC_METHOD(lldb::BreakpointEventType, SBBreakpoint,
1004*0b57cec5SDimitry Andric                               GetBreakpointEventTypeFromEvent,
1005*0b57cec5SDimitry Andric                               (const lldb::SBEvent &));
1006*0b57cec5SDimitry Andric   LLDB_REGISTER_STATIC_METHOD(lldb::SBBreakpoint, SBBreakpoint,
1007*0b57cec5SDimitry Andric                               GetBreakpointFromEvent,
1008*0b57cec5SDimitry Andric                               (const lldb::SBEvent &));
1009*0b57cec5SDimitry Andric   LLDB_REGISTER_STATIC_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
1010*0b57cec5SDimitry Andric                               GetBreakpointLocationAtIndexFromEvent,
1011*0b57cec5SDimitry Andric                               (const lldb::SBEvent &, uint32_t));
1012*0b57cec5SDimitry Andric   LLDB_REGISTER_STATIC_METHOD(uint32_t, SBBreakpoint,
1013*0b57cec5SDimitry Andric                               GetNumBreakpointLocationsFromEvent,
1014*0b57cec5SDimitry Andric                               (const lldb::SBEvent &));
1015*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, IsHardware, ());
1016*0b57cec5SDimitry Andric }
1017*0b57cec5SDimitry Andric 
1018*0b57cec5SDimitry Andric template <>
1019*0b57cec5SDimitry Andric void RegisterMethods<SBBreakpointList>(Registry &R) {
1020*0b57cec5SDimitry Andric   LLDB_REGISTER_CONSTRUCTOR(SBBreakpointList, (lldb::SBTarget &));
1021*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD_CONST(size_t, SBBreakpointList, GetSize, ());
1022*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBBreakpointList,
1023*0b57cec5SDimitry Andric                        GetBreakpointAtIndex, (size_t));
1024*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBBreakpointList,
1025*0b57cec5SDimitry Andric                        FindBreakpointByID, (lldb::break_id_t));
1026*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(void, SBBreakpointList, Append,
1027*0b57cec5SDimitry Andric                        (const lldb::SBBreakpoint &));
1028*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(void, SBBreakpointList, AppendByID,
1029*0b57cec5SDimitry Andric                        (lldb::break_id_t));
1030*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(bool, SBBreakpointList, AppendIfUnique,
1031*0b57cec5SDimitry Andric                        (const lldb::SBBreakpoint &));
1032*0b57cec5SDimitry Andric   LLDB_REGISTER_METHOD(void, SBBreakpointList, Clear, ());
1033*0b57cec5SDimitry Andric }
1034*0b57cec5SDimitry Andric 
1035*0b57cec5SDimitry Andric }
1036*0b57cec5SDimitry Andric }
1037