180814287SRaphael Isemann //===-- SBBreakpoint.cpp --------------------------------------------------===//
230fdc8d8SChris Lattner //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
630fdc8d8SChris Lattner //
730fdc8d8SChris Lattner //===----------------------------------------------------------------------===//
830fdc8d8SChris Lattner 
930fdc8d8SChris Lattner #include "lldb/API/SBBreakpoint.h"
10baf5664fSJonas Devlieghere #include "SBReproducerPrivate.h"
1130fdc8d8SChris Lattner #include "lldb/API/SBBreakpointLocation.h"
1230fdc8d8SChris Lattner #include "lldb/API/SBDebugger.h"
139fed0d85SGreg Clayton #include "lldb/API/SBEvent.h"
1430fdc8d8SChris Lattner #include "lldb/API/SBProcess.h"
15dde9cff3SCaroline Tice #include "lldb/API/SBStream.h"
165e09c8c3SJim Ingham #include "lldb/API/SBStringList.h"
17738af7a6SJim Ingham #include "lldb/API/SBStructuredData.h"
1830fdc8d8SChris Lattner #include "lldb/API/SBThread.h"
1930fdc8d8SChris Lattner 
2030fdc8d8SChris Lattner #include "lldb/Breakpoint/Breakpoint.h"
2101f16664SJim Ingham #include "lldb/Breakpoint/BreakpointIDList.h"
2230fdc8d8SChris Lattner #include "lldb/Breakpoint/BreakpointLocation.h"
233815e702SJim Ingham #include "lldb/Breakpoint/BreakpointResolver.h"
243815e702SJim Ingham #include "lldb/Breakpoint/BreakpointResolverScripted.h"
2530fdc8d8SChris Lattner #include "lldb/Breakpoint/StoppointCallbackContext.h"
2630fdc8d8SChris Lattner #include "lldb/Core/Address.h"
27d80102e4SJim Ingham #include "lldb/Core/Debugger.h"
2830fdc8d8SChris Lattner #include "lldb/Core/StreamFile.h"
29738af7a6SJim Ingham #include "lldb/Core/StructuredDataImpl.h"
30d80102e4SJim Ingham #include "lldb/Interpreter/CommandInterpreter.h"
31d80102e4SJim Ingham #include "lldb/Interpreter/ScriptInterpreter.h"
3230fdc8d8SChris Lattner #include "lldb/Target/Process.h"
33d5944cd1SGreg Clayton #include "lldb/Target/SectionLoadList.h"
3430fdc8d8SChris Lattner #include "lldb/Target/Target.h"
3562b02c61SJim Ingham #include "lldb/Target/Thread.h"
3662b02c61SJim Ingham #include "lldb/Target/ThreadSpec.h"
37bf9a7730SZachary Turner #include "lldb/Utility/Stream.h"
3830fdc8d8SChris Lattner 
39b842f2ecSJim Ingham #include "SBBreakpointOptionCommon.h"
40b842f2ecSJim Ingham 
4130fdc8d8SChris Lattner #include "lldb/lldb-enumerations.h"
4230fdc8d8SChris Lattner 
434e4fbe82SZachary Turner #include "llvm/ADT/STLExtras.h"
444e4fbe82SZachary Turner 
4530fdc8d8SChris Lattner using namespace lldb;
4630fdc8d8SChris Lattner using namespace lldb_private;
4730fdc8d8SChris Lattner 
48baf5664fSJonas Devlieghere SBBreakpoint::SBBreakpoint() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBreakpoint); }
4930fdc8d8SChris Lattner 
50b9c1b51eSKate Stone SBBreakpoint::SBBreakpoint(const SBBreakpoint &rhs)
51baf5664fSJonas Devlieghere     : m_opaque_wp(rhs.m_opaque_wp) {
52baf5664fSJonas Devlieghere   LLDB_RECORD_CONSTRUCTOR(SBBreakpoint, (const lldb::SBBreakpoint &), rhs);
53baf5664fSJonas Devlieghere }
5430fdc8d8SChris Lattner 
55b9c1b51eSKate Stone SBBreakpoint::SBBreakpoint(const lldb::BreakpointSP &bp_sp)
56baf5664fSJonas Devlieghere     : m_opaque_wp(bp_sp) {
57baf5664fSJonas Devlieghere   LLDB_RECORD_CONSTRUCTOR(SBBreakpoint, (const lldb::BreakpointSP &), bp_sp);
58baf5664fSJonas Devlieghere }
5930fdc8d8SChris Lattner 
60dbb0abbfSEugene Zelenko SBBreakpoint::~SBBreakpoint() = default;
6130fdc8d8SChris Lattner 
62b9c1b51eSKate Stone const SBBreakpoint &SBBreakpoint::operator=(const SBBreakpoint &rhs) {
63baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(const lldb::SBBreakpoint &,
64baf5664fSJonas Devlieghere                      SBBreakpoint, operator=,(const lldb::SBBreakpoint &), rhs);
65baf5664fSJonas Devlieghere 
666ac84034SPavel Labath   m_opaque_wp = rhs.m_opaque_wp;
67306809f2SJonas Devlieghere   return LLDB_RECORD_RESULT(*this);
6830fdc8d8SChris Lattner }
6930fdc8d8SChris Lattner 
70b9c1b51eSKate Stone bool SBBreakpoint::operator==(const lldb::SBBreakpoint &rhs) {
71baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(
72baf5664fSJonas Devlieghere       bool, SBBreakpoint, operator==,(const lldb::SBBreakpoint &), rhs);
73baf5664fSJonas Devlieghere 
746ac84034SPavel Labath   return m_opaque_wp.lock() == rhs.m_opaque_wp.lock();
75ac2eb9b1SGreg Clayton }
76ac2eb9b1SGreg Clayton 
77b9c1b51eSKate Stone bool SBBreakpoint::operator!=(const lldb::SBBreakpoint &rhs) {
78baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(
79baf5664fSJonas Devlieghere       bool, SBBreakpoint, operator!=,(const lldb::SBBreakpoint &), rhs);
80baf5664fSJonas Devlieghere 
816ac84034SPavel Labath   return m_opaque_wp.lock() != rhs.m_opaque_wp.lock();
82c3387333SEnrico Granata }
83c3387333SEnrico Granata 
846754caa9SJim Ingham SBTarget SBBreakpoint::GetTarget() const {
856754caa9SJim Ingham   LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBTarget, SBBreakpoint, GetTarget);
866754caa9SJim Ingham 
876754caa9SJim Ingham   BreakpointSP bkpt_sp = GetSP();
886754caa9SJim Ingham   if (bkpt_sp)
896754caa9SJim Ingham     return LLDB_RECORD_RESULT(SBTarget(bkpt_sp->GetTargetSP()));
906754caa9SJim Ingham 
916754caa9SJim Ingham   return LLDB_RECORD_RESULT(SBTarget());
926754caa9SJim Ingham }
936754caa9SJim Ingham 
94b9c1b51eSKate Stone break_id_t SBBreakpoint::GetID() const {
95baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::break_id_t, SBBreakpoint, GetID);
96baf5664fSJonas Devlieghere 
97af67cecdSGreg Clayton   break_id_t break_id = LLDB_INVALID_BREAK_ID;
986ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
996ac84034SPavel Labath   if (bkpt_sp)
1006ac84034SPavel Labath     break_id = bkpt_sp->GetID();
101af67cecdSGreg Clayton 
102af67cecdSGreg Clayton   return break_id;
10330fdc8d8SChris Lattner }
10430fdc8d8SChris Lattner 
105b9c1b51eSKate Stone bool SBBreakpoint::IsValid() const {
106baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, IsValid);
1077f5237bcSPavel Labath   return this->operator bool();
1087f5237bcSPavel Labath }
1097f5237bcSPavel Labath SBBreakpoint::operator bool() const {
1107f5237bcSPavel Labath   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, operator bool);
111baf5664fSJonas Devlieghere 
1126ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
1136ac84034SPavel Labath   if (!bkpt_sp)
114e029fa57SJim Ingham     return false;
1156ac84034SPavel Labath   else if (bkpt_sp->GetTarget().GetBreakpointByID(bkpt_sp->GetID()))
116e029fa57SJim Ingham     return true;
117e029fa57SJim Ingham   else
118e029fa57SJim Ingham     return false;
11930fdc8d8SChris Lattner }
12030fdc8d8SChris Lattner 
121b9c1b51eSKate Stone void SBBreakpoint::ClearAllBreakpointSites() {
122baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_NO_ARGS(void, SBBreakpoint, ClearAllBreakpointSites);
123baf5664fSJonas Devlieghere 
1246ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
1256ac84034SPavel Labath   if (bkpt_sp) {
126b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
1276ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
1286ac84034SPavel Labath     bkpt_sp->ClearAllBreakpointSites();
12930fdc8d8SChris Lattner   }
130af67cecdSGreg Clayton }
13130fdc8d8SChris Lattner 
132b9c1b51eSKate Stone SBBreakpointLocation SBBreakpoint::FindLocationByAddress(addr_t vm_addr) {
133baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
134baf5664fSJonas Devlieghere                      FindLocationByAddress, (lldb::addr_t), vm_addr);
135baf5664fSJonas Devlieghere 
13630fdc8d8SChris Lattner   SBBreakpointLocation sb_bp_location;
13730fdc8d8SChris Lattner 
1386ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
1396ac84034SPavel Labath   if (bkpt_sp) {
140b9c1b51eSKate Stone     if (vm_addr != LLDB_INVALID_ADDRESS) {
141b9c1b51eSKate Stone       std::lock_guard<std::recursive_mutex> guard(
1426ac84034SPavel Labath           bkpt_sp->GetTarget().GetAPIMutex());
14330fdc8d8SChris Lattner       Address address;
1446ac84034SPavel Labath       Target &target = bkpt_sp->GetTarget();
145b9c1b51eSKate Stone       if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) {
146e72dfb32SGreg Clayton         address.SetRawAddress(vm_addr);
14730fdc8d8SChris Lattner       }
1486ac84034SPavel Labath       sb_bp_location.SetLocation(bkpt_sp->FindLocationByAddress(address));
14930fdc8d8SChris Lattner     }
15030fdc8d8SChris Lattner   }
151baf5664fSJonas Devlieghere   return LLDB_RECORD_RESULT(sb_bp_location);
15230fdc8d8SChris Lattner }
15330fdc8d8SChris Lattner 
154b9c1b51eSKate Stone break_id_t SBBreakpoint::FindLocationIDByAddress(addr_t vm_addr) {
155baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::break_id_t, SBBreakpoint, FindLocationIDByAddress,
156baf5664fSJonas Devlieghere                      (lldb::addr_t), vm_addr);
157baf5664fSJonas Devlieghere 
158af67cecdSGreg Clayton   break_id_t break_id = LLDB_INVALID_BREAK_ID;
1596ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
16030fdc8d8SChris Lattner 
1616ac84034SPavel Labath   if (bkpt_sp && vm_addr != LLDB_INVALID_ADDRESS) {
162b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
1636ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
16430fdc8d8SChris Lattner     Address address;
1656ac84034SPavel Labath     Target &target = bkpt_sp->GetTarget();
166b9c1b51eSKate Stone     if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) {
167e72dfb32SGreg Clayton       address.SetRawAddress(vm_addr);
16830fdc8d8SChris Lattner     }
1696ac84034SPavel Labath     break_id = bkpt_sp->FindLocationIDByAddress(address);
17030fdc8d8SChris Lattner   }
17130fdc8d8SChris Lattner 
172af67cecdSGreg Clayton   return break_id;
17330fdc8d8SChris Lattner }
17430fdc8d8SChris Lattner 
175b9c1b51eSKate Stone SBBreakpointLocation SBBreakpoint::FindLocationByID(break_id_t bp_loc_id) {
176baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBBreakpointLocation, SBBreakpoint, FindLocationByID,
177baf5664fSJonas Devlieghere                      (lldb::break_id_t), bp_loc_id);
178baf5664fSJonas Devlieghere 
17930fdc8d8SChris Lattner   SBBreakpointLocation sb_bp_location;
1806ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
18130fdc8d8SChris Lattner 
1826ac84034SPavel Labath   if (bkpt_sp) {
183b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
1846ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
1856ac84034SPavel Labath     sb_bp_location.SetLocation(bkpt_sp->FindLocationByID(bp_loc_id));
186af67cecdSGreg Clayton   }
18730fdc8d8SChris Lattner 
188baf5664fSJonas Devlieghere   return LLDB_RECORD_RESULT(sb_bp_location);
18930fdc8d8SChris Lattner }
19030fdc8d8SChris Lattner 
191b9c1b51eSKate Stone SBBreakpointLocation SBBreakpoint::GetLocationAtIndex(uint32_t index) {
192baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
193baf5664fSJonas Devlieghere                      GetLocationAtIndex, (uint32_t), index);
194baf5664fSJonas Devlieghere 
19530fdc8d8SChris Lattner   SBBreakpointLocation sb_bp_location;
1966ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
19730fdc8d8SChris Lattner 
1986ac84034SPavel Labath   if (bkpt_sp) {
199b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
2006ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
2016ac84034SPavel Labath     sb_bp_location.SetLocation(bkpt_sp->GetLocationAtIndex(index));
202af67cecdSGreg Clayton   }
20330fdc8d8SChris Lattner 
204baf5664fSJonas Devlieghere   return LLDB_RECORD_RESULT(sb_bp_location);
20530fdc8d8SChris Lattner }
20630fdc8d8SChris Lattner 
207b9c1b51eSKate Stone void SBBreakpoint::SetEnabled(bool enable) {
208baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(void, SBBreakpoint, SetEnabled, (bool), enable);
209baf5664fSJonas Devlieghere 
2106ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
211ceb6b139SCaroline Tice 
2126ac84034SPavel Labath   if (bkpt_sp) {
213b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
2146ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
2156ac84034SPavel Labath     bkpt_sp->SetEnabled(enable);
21630fdc8d8SChris Lattner   }
217af67cecdSGreg Clayton }
21830fdc8d8SChris Lattner 
219b9c1b51eSKate Stone bool SBBreakpoint::IsEnabled() {
220baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpoint, IsEnabled);
221baf5664fSJonas Devlieghere 
2226ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
2236ac84034SPavel Labath   if (bkpt_sp) {
224b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
2256ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
2266ac84034SPavel Labath     return bkpt_sp->IsEnabled();
227b9c1b51eSKate Stone   } else
22830fdc8d8SChris Lattner     return false;
22930fdc8d8SChris Lattner }
23030fdc8d8SChris Lattner 
231b9c1b51eSKate Stone void SBBreakpoint::SetOneShot(bool one_shot) {
232baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(void, SBBreakpoint, SetOneShot, (bool), one_shot);
233baf5664fSJonas Devlieghere 
2346ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
235ca36cd16SJim Ingham 
2366ac84034SPavel Labath   if (bkpt_sp) {
237b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
2386ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
2396ac84034SPavel Labath     bkpt_sp->SetOneShot(one_shot);
240ca36cd16SJim Ingham   }
241ca36cd16SJim Ingham }
242ca36cd16SJim Ingham 
243b9c1b51eSKate Stone bool SBBreakpoint::IsOneShot() const {
244baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, IsOneShot);
245baf5664fSJonas Devlieghere 
2466ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
2476ac84034SPavel Labath   if (bkpt_sp) {
248b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
2496ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
2506ac84034SPavel Labath     return bkpt_sp->IsOneShot();
251b9c1b51eSKate Stone   } else
252ca36cd16SJim Ingham     return false;
253ca36cd16SJim Ingham }
254ca36cd16SJim Ingham 
255b9c1b51eSKate Stone bool SBBreakpoint::IsInternal() {
256baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpoint, IsInternal);
257baf5664fSJonas Devlieghere 
2586ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
2596ac84034SPavel Labath   if (bkpt_sp) {
260b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
2616ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
2626ac84034SPavel Labath     return bkpt_sp->IsInternal();
263b9c1b51eSKate Stone   } else
26411c8108dSJim Ingham     return false;
26511c8108dSJim Ingham }
26611c8108dSJim Ingham 
267b9c1b51eSKate Stone void SBBreakpoint::SetIgnoreCount(uint32_t count) {
268baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(void, SBBreakpoint, SetIgnoreCount, (uint32_t), count);
269baf5664fSJonas Devlieghere 
2706ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
271ceb6b139SCaroline Tice 
2726ac84034SPavel Labath   if (bkpt_sp) {
273b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
2746ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
2756ac84034SPavel Labath     bkpt_sp->SetIgnoreCount(count);
27630fdc8d8SChris Lattner   }
277af67cecdSGreg Clayton }
27830fdc8d8SChris Lattner 
279b9c1b51eSKate Stone void SBBreakpoint::SetCondition(const char *condition) {
280baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(void, SBBreakpoint, SetCondition, (const char *),
281baf5664fSJonas Devlieghere                      condition);
282baf5664fSJonas Devlieghere 
2836ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
2846ac84034SPavel Labath   if (bkpt_sp) {
285b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
2866ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
2876ac84034SPavel Labath     bkpt_sp->SetCondition(condition);
288041a12fcSJim Ingham   }
289af67cecdSGreg Clayton }
290041a12fcSJim Ingham 
291b9c1b51eSKate Stone const char *SBBreakpoint::GetCondition() {
292baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_NO_ARGS(const char *, SBBreakpoint, GetCondition);
293baf5664fSJonas Devlieghere 
2946ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
2956ac84034SPavel Labath   if (bkpt_sp) {
296b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
2976ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
2986ac84034SPavel Labath     return bkpt_sp->GetConditionText();
299041a12fcSJim Ingham   }
300dbb0abbfSEugene Zelenko   return nullptr;
301af67cecdSGreg Clayton }
302041a12fcSJim Ingham 
303f08f5c99SJim Ingham void SBBreakpoint::SetAutoContinue(bool auto_continue) {
304baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(void, SBBreakpoint, SetAutoContinue, (bool),
305baf5664fSJonas Devlieghere                      auto_continue);
306baf5664fSJonas Devlieghere 
307f08f5c99SJim Ingham   BreakpointSP bkpt_sp = GetSP();
308f08f5c99SJim Ingham   if (bkpt_sp) {
309f08f5c99SJim Ingham     std::lock_guard<std::recursive_mutex> guard(
310f08f5c99SJim Ingham         bkpt_sp->GetTarget().GetAPIMutex());
311f08f5c99SJim Ingham     bkpt_sp->SetAutoContinue(auto_continue);
312f08f5c99SJim Ingham   }
313f08f5c99SJim Ingham }
314f08f5c99SJim Ingham 
315f08f5c99SJim Ingham bool SBBreakpoint::GetAutoContinue() {
316baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpoint, GetAutoContinue);
317baf5664fSJonas Devlieghere 
318f08f5c99SJim Ingham   BreakpointSP bkpt_sp = GetSP();
319f08f5c99SJim Ingham   if (bkpt_sp) {
320f08f5c99SJim Ingham     std::lock_guard<std::recursive_mutex> guard(
321f08f5c99SJim Ingham         bkpt_sp->GetTarget().GetAPIMutex());
322f08f5c99SJim Ingham     return bkpt_sp->IsAutoContinue();
323f08f5c99SJim Ingham   }
3241c7dc829SJim Ingham   return false;
325f08f5c99SJim Ingham }
326f08f5c99SJim Ingham 
327b9c1b51eSKate Stone uint32_t SBBreakpoint::GetHitCount() const {
328baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpoint, GetHitCount);
329baf5664fSJonas Devlieghere 
3304838131bSGreg Clayton   uint32_t count = 0;
3316ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
3326ac84034SPavel Labath   if (bkpt_sp) {
333b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
3346ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
3356ac84034SPavel Labath     count = bkpt_sp->GetHitCount();
336af67cecdSGreg Clayton   }
3374838131bSGreg Clayton 
3384838131bSGreg Clayton   return count;
339ceb6b139SCaroline Tice }
3409fed0d85SGreg Clayton 
341b9c1b51eSKate Stone uint32_t SBBreakpoint::GetIgnoreCount() const {
342baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpoint, GetIgnoreCount);
343baf5664fSJonas Devlieghere 
3444838131bSGreg Clayton   uint32_t count = 0;
3456ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
3466ac84034SPavel Labath   if (bkpt_sp) {
347b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
3486ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
3496ac84034SPavel Labath     count = bkpt_sp->GetIgnoreCount();
350af67cecdSGreg Clayton   }
3514838131bSGreg Clayton 
3524838131bSGreg Clayton   return count;
35330fdc8d8SChris Lattner }
35430fdc8d8SChris Lattner 
355b9c1b51eSKate Stone void SBBreakpoint::SetThreadID(tid_t tid) {
356baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(void, SBBreakpoint, SetThreadID, (lldb::tid_t), tid);
357baf5664fSJonas Devlieghere 
3586ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
3596ac84034SPavel Labath   if (bkpt_sp) {
360b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
3616ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
3626ac84034SPavel Labath     bkpt_sp->SetThreadID(tid);
363af67cecdSGreg Clayton   }
36430fdc8d8SChris Lattner }
36530fdc8d8SChris Lattner 
366b9c1b51eSKate Stone tid_t SBBreakpoint::GetThreadID() {
367baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_NO_ARGS(lldb::tid_t, SBBreakpoint, GetThreadID);
368baf5664fSJonas Devlieghere 
3694838131bSGreg Clayton   tid_t tid = LLDB_INVALID_THREAD_ID;
3706ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
3716ac84034SPavel Labath   if (bkpt_sp) {
372b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
3736ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
3746ac84034SPavel Labath     tid = bkpt_sp->GetThreadID();
375af67cecdSGreg Clayton   }
37630fdc8d8SChris Lattner 
3774838131bSGreg Clayton   return tid;
37830fdc8d8SChris Lattner }
37930fdc8d8SChris Lattner 
380b9c1b51eSKate Stone void SBBreakpoint::SetThreadIndex(uint32_t index) {
381baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(void, SBBreakpoint, SetThreadIndex, (uint32_t), index);
382baf5664fSJonas Devlieghere 
3836ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
3846ac84034SPavel Labath   if (bkpt_sp) {
385b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
3866ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
387*cfb96d84SJim Ingham     bkpt_sp->GetOptions().GetThreadSpec()->SetIndex(index);
38862b02c61SJim Ingham   }
389af67cecdSGreg Clayton }
39062b02c61SJim Ingham 
391b9c1b51eSKate Stone uint32_t SBBreakpoint::GetThreadIndex() const {
392baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpoint, GetThreadIndex);
393baf5664fSJonas Devlieghere 
394bdf4c6acSGreg Clayton   uint32_t thread_idx = UINT32_MAX;
3956ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
3966ac84034SPavel Labath   if (bkpt_sp) {
397b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
3986ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
399b9c1b51eSKate Stone     const ThreadSpec *thread_spec =
400*cfb96d84SJim Ingham         bkpt_sp->GetOptions().GetThreadSpecNoCreate();
401dbb0abbfSEugene Zelenko     if (thread_spec != nullptr)
4024838131bSGreg Clayton       thread_idx = thread_spec->GetIndex();
40362b02c61SJim Ingham   }
4044838131bSGreg Clayton 
405763d1a17SJohnny Chen   return thread_idx;
40662b02c61SJim Ingham }
40762b02c61SJim Ingham 
408b9c1b51eSKate Stone void SBBreakpoint::SetThreadName(const char *thread_name) {
409baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(void, SBBreakpoint, SetThreadName, (const char *),
410baf5664fSJonas Devlieghere                      thread_name);
411baf5664fSJonas Devlieghere 
4126ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
4134838131bSGreg Clayton 
4146ac84034SPavel Labath   if (bkpt_sp) {
415b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
4166ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
417*cfb96d84SJim Ingham     bkpt_sp->GetOptions().GetThreadSpec()->SetName(thread_name);
41862b02c61SJim Ingham   }
419af67cecdSGreg Clayton }
42062b02c61SJim Ingham 
421b9c1b51eSKate Stone const char *SBBreakpoint::GetThreadName() const {
422baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpoint, GetThreadName);
423baf5664fSJonas Devlieghere 
424dbb0abbfSEugene Zelenko   const char *name = nullptr;
4256ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
4266ac84034SPavel Labath   if (bkpt_sp) {
427b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
4286ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
429b9c1b51eSKate Stone     const ThreadSpec *thread_spec =
430*cfb96d84SJim Ingham         bkpt_sp->GetOptions().GetThreadSpecNoCreate();
431dbb0abbfSEugene Zelenko     if (thread_spec != nullptr)
4324838131bSGreg Clayton       name = thread_spec->GetName();
43362b02c61SJim Ingham   }
4344838131bSGreg Clayton 
4354838131bSGreg Clayton   return name;
43662b02c61SJim Ingham }
43762b02c61SJim Ingham 
438b9c1b51eSKate Stone void SBBreakpoint::SetQueueName(const char *queue_name) {
439baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(void, SBBreakpoint, SetQueueName, (const char *),
440baf5664fSJonas Devlieghere                      queue_name);
441baf5664fSJonas Devlieghere 
4426ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
4436ac84034SPavel Labath   if (bkpt_sp) {
444b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
4456ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
446*cfb96d84SJim Ingham     bkpt_sp->GetOptions().GetThreadSpec()->SetQueueName(queue_name);
44762b02c61SJim Ingham   }
448af67cecdSGreg Clayton }
44962b02c61SJim Ingham 
450b9c1b51eSKate Stone const char *SBBreakpoint::GetQueueName() const {
451baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpoint, GetQueueName);
452baf5664fSJonas Devlieghere 
453dbb0abbfSEugene Zelenko   const char *name = nullptr;
4546ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
4556ac84034SPavel Labath   if (bkpt_sp) {
456b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
4576ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
458b9c1b51eSKate Stone     const ThreadSpec *thread_spec =
459*cfb96d84SJim Ingham         bkpt_sp->GetOptions().GetThreadSpecNoCreate();
460af67cecdSGreg Clayton     if (thread_spec)
4614838131bSGreg Clayton       name = thread_spec->GetQueueName();
46262b02c61SJim Ingham   }
4634838131bSGreg Clayton 
4644838131bSGreg Clayton   return name;
46562b02c61SJim Ingham }
46662b02c61SJim Ingham 
467b9c1b51eSKate Stone size_t SBBreakpoint::GetNumResolvedLocations() const {
468baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBBreakpoint,
469baf5664fSJonas Devlieghere                                    GetNumResolvedLocations);
470baf5664fSJonas Devlieghere 
4714838131bSGreg Clayton   size_t num_resolved = 0;
4726ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
4736ac84034SPavel Labath   if (bkpt_sp) {
474b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
4756ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
4766ac84034SPavel Labath     num_resolved = bkpt_sp->GetNumResolvedLocations();
477af67cecdSGreg Clayton   }
4784838131bSGreg Clayton   return num_resolved;
47930fdc8d8SChris Lattner }
48030fdc8d8SChris Lattner 
481b9c1b51eSKate Stone size_t SBBreakpoint::GetNumLocations() const {
482baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBBreakpoint, GetNumLocations);
483baf5664fSJonas Devlieghere 
4846ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
4854838131bSGreg Clayton   size_t num_locs = 0;
4866ac84034SPavel Labath   if (bkpt_sp) {
487b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
4886ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
4896ac84034SPavel Labath     num_locs = bkpt_sp->GetNumLocations();
490af67cecdSGreg Clayton   }
4914838131bSGreg Clayton   return num_locs;
49230fdc8d8SChris Lattner }
49330fdc8d8SChris Lattner 
49492d1960eSJim Ingham void SBBreakpoint::SetCommandLineCommands(SBStringList &commands) {
495baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(void, SBBreakpoint, SetCommandLineCommands,
496baf5664fSJonas Devlieghere                      (lldb::SBStringList &), commands);
497baf5664fSJonas Devlieghere 
4986ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
4996ac84034SPavel Labath   if (!bkpt_sp)
50092d1960eSJim Ingham     return;
50192d1960eSJim Ingham   if (commands.GetSize() == 0)
50292d1960eSJim Ingham     return;
50392d1960eSJim Ingham 
50492d1960eSJim Ingham   std::lock_guard<std::recursive_mutex> guard(
5056ac84034SPavel Labath       bkpt_sp->GetTarget().GetAPIMutex());
50692d1960eSJim Ingham   std::unique_ptr<BreakpointOptions::CommandData> cmd_data_up(
507f7e07256SJim Ingham       new BreakpointOptions::CommandData(*commands, eScriptLanguageNone));
50892d1960eSJim Ingham 
509*cfb96d84SJim Ingham   bkpt_sp->GetOptions().SetCommandDataCallback(cmd_data_up);
51092d1960eSJim Ingham }
51192d1960eSJim Ingham 
51292d1960eSJim Ingham bool SBBreakpoint::GetCommandLineCommands(SBStringList &commands) {
513baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(bool, SBBreakpoint, GetCommandLineCommands,
514baf5664fSJonas Devlieghere                      (lldb::SBStringList &), commands);
515baf5664fSJonas Devlieghere 
5166ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
5176ac84034SPavel Labath   if (!bkpt_sp)
51892d1960eSJim Ingham     return false;
51992d1960eSJim Ingham   StringList command_list;
52092d1960eSJim Ingham   bool has_commands =
521*cfb96d84SJim Ingham       bkpt_sp->GetOptions().GetCommandLineCallbacks(command_list);
52292d1960eSJim Ingham   if (has_commands)
52392d1960eSJim Ingham     commands.AppendList(command_list);
52492d1960eSJim Ingham   return has_commands;
52592d1960eSJim Ingham }
52692d1960eSJim Ingham 
527b9c1b51eSKate Stone bool SBBreakpoint::GetDescription(SBStream &s) {
528baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(bool, SBBreakpoint, GetDescription, (lldb::SBStream &), s);
529baf5664fSJonas Devlieghere 
5306d1e4696SJim Ingham   return GetDescription(s, true);
5316d1e4696SJim Ingham }
5326d1e4696SJim Ingham 
5336d1e4696SJim Ingham bool SBBreakpoint::GetDescription(SBStream &s, bool include_locations) {
534baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(bool, SBBreakpoint, GetDescription,
535baf5664fSJonas Devlieghere                      (lldb::SBStream &, bool), s, include_locations);
536baf5664fSJonas Devlieghere 
5376ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
5386ac84034SPavel Labath   if (bkpt_sp) {
539b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
5406ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
5416ac84034SPavel Labath     s.Printf("SBBreakpoint: id = %i, ", bkpt_sp->GetID());
5426ac84034SPavel Labath     bkpt_sp->GetResolverDescription(s.get());
5436ac84034SPavel Labath     bkpt_sp->GetFilterDescription(s.get());
5446d1e4696SJim Ingham     if (include_locations) {
5456ac84034SPavel Labath       const size_t num_locations = bkpt_sp->GetNumLocations();
546d01b2953SDaniel Malea       s.Printf(", locations = %" PRIu64, (uint64_t)num_locations);
5476d1e4696SJim Ingham     }
548dde9cff3SCaroline Tice     return true;
549dde9cff3SCaroline Tice   }
55005faeb71SGreg Clayton   s.Printf("No value");
55105faeb71SGreg Clayton   return false;
55205faeb71SGreg Clayton }
553dde9cff3SCaroline Tice 
554baf5664fSJonas Devlieghere SBError SBBreakpoint::AddLocation(SBAddress &address) {
555baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBError, SBBreakpoint, AddLocation,
556baf5664fSJonas Devlieghere                      (lldb::SBAddress &), address);
557baf5664fSJonas Devlieghere 
5583815e702SJim Ingham   BreakpointSP bkpt_sp = GetSP();
5593815e702SJim Ingham   SBError error;
5603815e702SJim Ingham 
5613815e702SJim Ingham   if (!address.IsValid()) {
5623815e702SJim Ingham     error.SetErrorString("Can't add an invalid address.");
563baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(error);
5643815e702SJim Ingham   }
5653815e702SJim Ingham 
5663815e702SJim Ingham   if (!bkpt_sp) {
5673815e702SJim Ingham     error.SetErrorString("No breakpoint to add a location to.");
568baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(error);
5693815e702SJim Ingham   }
5703815e702SJim Ingham 
5713815e702SJim Ingham   if (!llvm::isa<BreakpointResolverScripted>(bkpt_sp->GetResolver().get())) {
5723815e702SJim Ingham     error.SetErrorString("Only a scripted resolver can add locations.");
573baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(error);
5743815e702SJim Ingham   }
5753815e702SJim Ingham 
5763815e702SJim Ingham   if (bkpt_sp->GetSearchFilter()->AddressPasses(address.ref()))
5773815e702SJim Ingham     bkpt_sp->AddLocation(address.ref());
578baf5664fSJonas Devlieghere   else {
5793815e702SJim Ingham     StreamString s;
5803815e702SJim Ingham     address.get()->Dump(&s, &bkpt_sp->GetTarget(),
5813815e702SJim Ingham                         Address::DumpStyleModuleWithFileAddress);
5823815e702SJim Ingham     error.SetErrorStringWithFormat("Address: %s didn't pass the filter.",
5833815e702SJim Ingham                                    s.GetData());
5843815e702SJim Ingham   }
585baf5664fSJonas Devlieghere   return LLDB_RECORD_RESULT(error);
5863815e702SJim Ingham }
5873815e702SJim Ingham 
5884da8fa45SMed Ismail Bennani SBStructuredData SBBreakpoint::SerializeToStructuredData() {
5894da8fa45SMed Ismail Bennani   LLDB_RECORD_METHOD_NO_ARGS(lldb::SBStructuredData, SBBreakpoint,
5904da8fa45SMed Ismail Bennani                              SerializeToStructuredData);
5914da8fa45SMed Ismail Bennani 
5924da8fa45SMed Ismail Bennani   SBStructuredData data;
5934da8fa45SMed Ismail Bennani   BreakpointSP bkpt_sp = GetSP();
5944da8fa45SMed Ismail Bennani 
5954da8fa45SMed Ismail Bennani   if (!bkpt_sp)
5964da8fa45SMed Ismail Bennani     return LLDB_RECORD_RESULT(data);
5974da8fa45SMed Ismail Bennani 
5984da8fa45SMed Ismail Bennani   StructuredData::ObjectSP bkpt_dict = bkpt_sp->SerializeToStructuredData();
5994da8fa45SMed Ismail Bennani   data.m_impl_up->SetObjectSP(bkpt_dict);
6004da8fa45SMed Ismail Bennani   return LLDB_RECORD_RESULT(data);
6014da8fa45SMed Ismail Bennani }
6024da8fa45SMed Ismail Bennani 
6030d7b0c96SJonas Devlieghere void SBBreakpoint::SetCallback(SBBreakpointHitCallback callback, void *baton) {
6040d7b0c96SJonas Devlieghere   LLDB_RECORD_DUMMY(void, SBBreakpoint, SetCallback,
6050d7b0c96SJonas Devlieghere                     (lldb::SBBreakpointHitCallback, void *), callback, baton);
6060d7b0c96SJonas Devlieghere 
6076ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
608ceb6b139SCaroline Tice 
6096ac84034SPavel Labath   if (bkpt_sp) {
610b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
6116ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
61230fdc8d8SChris Lattner     BatonSP baton_sp(new SBBreakpointCallbackBaton(callback, baton));
613b842f2ecSJim Ingham     bkpt_sp->SetCallback(SBBreakpointCallbackBaton
614b842f2ecSJim Ingham       ::PrivateBreakpointHitCallback, baton_sp,
6156ac84034SPavel Labath                          false);
61630fdc8d8SChris Lattner   }
61730fdc8d8SChris Lattner }
61830fdc8d8SChris Lattner 
619b9c1b51eSKate Stone void SBBreakpoint::SetScriptCallbackFunction(
620b9c1b51eSKate Stone   const char *callback_function_name) {
621baf5664fSJonas Devlieghere LLDB_RECORD_METHOD(void, SBBreakpoint, SetScriptCallbackFunction,
622baf5664fSJonas Devlieghere                    (const char *), callback_function_name);
623738af7a6SJim Ingham   SBStructuredData empty_args;
624738af7a6SJim Ingham   SetScriptCallbackFunction(callback_function_name, empty_args);
625738af7a6SJim Ingham }
626baf5664fSJonas Devlieghere 
627738af7a6SJim Ingham SBError SBBreakpoint::SetScriptCallbackFunction(
628738af7a6SJim Ingham     const char *callback_function_name,
629738af7a6SJim Ingham     SBStructuredData &extra_args) {
630738af7a6SJim Ingham   LLDB_RECORD_METHOD(SBError, SBBreakpoint, SetScriptCallbackFunction,
631738af7a6SJim Ingham   (const char *, SBStructuredData &), callback_function_name, extra_args);
632738af7a6SJim Ingham   SBError sb_error;
6336ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
634d80102e4SJim Ingham 
6356ac84034SPavel Labath   if (bkpt_sp) {
636738af7a6SJim Ingham     Status error;
637b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
6386ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
639*cfb96d84SJim Ingham     BreakpointOptions &bp_options = bkpt_sp->GetOptions();
640738af7a6SJim Ingham     error = bkpt_sp->GetTarget()
641b9c1b51eSKate Stone         .GetDebugger()
642b9c1b51eSKate Stone         .GetScriptInterpreter()
643b9c1b51eSKate Stone         ->SetBreakpointCommandCallbackFunction(bp_options,
644738af7a6SJim Ingham                                                callback_function_name,
645738af7a6SJim Ingham                                                extra_args.m_impl_up
646738af7a6SJim Ingham                                                    ->GetObjectSP());
647738af7a6SJim Ingham     sb_error.SetError(error);
648738af7a6SJim Ingham   } else
649738af7a6SJim Ingham     sb_error.SetErrorString("invalid breakpoint");
650738af7a6SJim Ingham 
651738af7a6SJim Ingham   return LLDB_RECORD_RESULT(sb_error);
652d80102e4SJim Ingham }
653d80102e4SJim Ingham 
654b9c1b51eSKate Stone SBError SBBreakpoint::SetScriptCallbackBody(const char *callback_body_text) {
655baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBError, SBBreakpoint, SetScriptCallbackBody,
656baf5664fSJonas Devlieghere                      (const char *), callback_body_text);
657baf5664fSJonas Devlieghere 
6586ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
659d80102e4SJim Ingham 
660d80102e4SJim Ingham   SBError sb_error;
6616ac84034SPavel Labath   if (bkpt_sp) {
662b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
6636ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
664*cfb96d84SJim Ingham     BreakpointOptions &bp_options = bkpt_sp->GetOptions();
66597206d57SZachary Turner     Status error =
6666ac84034SPavel Labath         bkpt_sp->GetTarget()
667b9c1b51eSKate Stone             .GetDebugger()
668b9c1b51eSKate Stone             .GetScriptInterpreter()
669b9c1b51eSKate Stone             ->SetBreakpointCommandCallback(bp_options, callback_body_text);
670d80102e4SJim Ingham     sb_error.SetError(error);
671b9c1b51eSKate Stone   } else
672d80102e4SJim Ingham     sb_error.SetErrorString("invalid breakpoint");
673d80102e4SJim Ingham 
674baf5664fSJonas Devlieghere   return LLDB_RECORD_RESULT(sb_error);
675d80102e4SJim Ingham }
67630fdc8d8SChris Lattner 
677b9c1b51eSKate Stone bool SBBreakpoint::AddName(const char *new_name) {
678baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(bool, SBBreakpoint, AddName, (const char *), new_name);
679baf5664fSJonas Devlieghere 
680f70cad26SMed Ismail Bennani   SBError status = AddNameWithErrorHandling(new_name);
681f70cad26SMed Ismail Bennani   return status.Success();
682f70cad26SMed Ismail Bennani }
683f70cad26SMed Ismail Bennani 
684f70cad26SMed Ismail Bennani SBError SBBreakpoint::AddNameWithErrorHandling(const char *new_name) {
685f70cad26SMed Ismail Bennani   LLDB_RECORD_METHOD(SBError, SBBreakpoint, AddNameWithErrorHandling,
686f70cad26SMed Ismail Bennani                      (const char *), new_name);
687f70cad26SMed Ismail Bennani 
6886ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
6895e09c8c3SJim Ingham 
690f70cad26SMed Ismail Bennani   SBError status;
6916ac84034SPavel Labath   if (bkpt_sp) {
692b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
6936ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
694f70cad26SMed Ismail Bennani     Status error;
695b842f2ecSJim Ingham     bkpt_sp->GetTarget().AddNameToBreakpoint(bkpt_sp, new_name, error);
696f70cad26SMed Ismail Bennani     status.SetError(error);
697f70cad26SMed Ismail Bennani   } else {
698f70cad26SMed Ismail Bennani     status.SetErrorString("invalid breakpoint");
699b842f2ecSJim Ingham   }
7005e09c8c3SJim Ingham 
701d9d992bbSJonas Devlieghere   return LLDB_RECORD_RESULT(status);
7025e09c8c3SJim Ingham }
7035e09c8c3SJim Ingham 
704b9c1b51eSKate Stone void SBBreakpoint::RemoveName(const char *name_to_remove) {
705baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(void, SBBreakpoint, RemoveName, (const char *),
706baf5664fSJonas Devlieghere                      name_to_remove);
707baf5664fSJonas Devlieghere 
7086ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
7095e09c8c3SJim Ingham 
7106ac84034SPavel Labath   if (bkpt_sp) {
711b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
7126ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
713b842f2ecSJim Ingham     bkpt_sp->GetTarget().RemoveNameFromBreakpoint(bkpt_sp,
714b842f2ecSJim Ingham                                                   ConstString(name_to_remove));
7155e09c8c3SJim Ingham   }
7165e09c8c3SJim Ingham }
7175e09c8c3SJim Ingham 
718b9c1b51eSKate Stone bool SBBreakpoint::MatchesName(const char *name) {
719baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(bool, SBBreakpoint, MatchesName, (const char *), name);
720baf5664fSJonas Devlieghere 
7216ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
7225e09c8c3SJim Ingham 
7236ac84034SPavel Labath   if (bkpt_sp) {
724b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
7256ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
7266ac84034SPavel Labath     return bkpt_sp->MatchesName(name);
7275e09c8c3SJim Ingham   }
7285e09c8c3SJim Ingham 
7295e09c8c3SJim Ingham   return false;
7305e09c8c3SJim Ingham }
7315e09c8c3SJim Ingham 
732b9c1b51eSKate Stone void SBBreakpoint::GetNames(SBStringList &names) {
733baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(void, SBBreakpoint, GetNames, (lldb::SBStringList &),
734baf5664fSJonas Devlieghere                      names);
735baf5664fSJonas Devlieghere 
7366ac84034SPavel Labath   BreakpointSP bkpt_sp = GetSP();
7375e09c8c3SJim Ingham 
7386ac84034SPavel Labath   if (bkpt_sp) {
739b9c1b51eSKate Stone     std::lock_guard<std::recursive_mutex> guard(
7406ac84034SPavel Labath         bkpt_sp->GetTarget().GetAPIMutex());
7415e09c8c3SJim Ingham     std::vector<std::string> names_vec;
7426ac84034SPavel Labath     bkpt_sp->GetNames(names_vec);
743b9c1b51eSKate Stone     for (std::string name : names_vec) {
7445e09c8c3SJim Ingham       names.AppendString(name.c_str());
7455e09c8c3SJim Ingham     }
7465e09c8c3SJim Ingham   }
7475e09c8c3SJim Ingham }
7485e09c8c3SJim Ingham 
749b9c1b51eSKate Stone bool SBBreakpoint::EventIsBreakpointEvent(const lldb::SBEvent &event) {
750baf5664fSJonas Devlieghere   LLDB_RECORD_STATIC_METHOD(bool, SBBreakpoint, EventIsBreakpointEvent,
751baf5664fSJonas Devlieghere                             (const lldb::SBEvent &), event);
752baf5664fSJonas Devlieghere 
753b9c1b51eSKate Stone   return Breakpoint::BreakpointEventData::GetEventDataFromEvent(event.get()) !=
754b9c1b51eSKate Stone          nullptr;
755e6bc6cb9SJim Ingham }
756e6bc6cb9SJim Ingham 
7579fed0d85SGreg Clayton BreakpointEventType
758b9c1b51eSKate Stone SBBreakpoint::GetBreakpointEventTypeFromEvent(const SBEvent &event) {
759baf5664fSJonas Devlieghere   LLDB_RECORD_STATIC_METHOD(lldb::BreakpointEventType, SBBreakpoint,
760baf5664fSJonas Devlieghere                             GetBreakpointEventTypeFromEvent,
761baf5664fSJonas Devlieghere                             (const lldb::SBEvent &), event);
762baf5664fSJonas Devlieghere 
7639fed0d85SGreg Clayton   if (event.IsValid())
764b9c1b51eSKate Stone     return Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent(
765b9c1b51eSKate Stone         event.GetSP());
7669fed0d85SGreg Clayton   return eBreakpointEventTypeInvalidType;
7679fed0d85SGreg Clayton }
7689fed0d85SGreg Clayton 
769b9c1b51eSKate Stone SBBreakpoint SBBreakpoint::GetBreakpointFromEvent(const lldb::SBEvent &event) {
770baf5664fSJonas Devlieghere   LLDB_RECORD_STATIC_METHOD(lldb::SBBreakpoint, SBBreakpoint,
771baf5664fSJonas Devlieghere                             GetBreakpointFromEvent, (const lldb::SBEvent &),
772baf5664fSJonas Devlieghere                             event);
773baf5664fSJonas Devlieghere 
7749fed0d85SGreg Clayton   if (event.IsValid())
775baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(
776baf5664fSJonas Devlieghere         SBBreakpoint(Breakpoint::BreakpointEventData::GetBreakpointFromEvent(
777baf5664fSJonas Devlieghere             event.GetSP())));
778baf5664fSJonas Devlieghere   return LLDB_RECORD_RESULT(SBBreakpoint());
7799fed0d85SGreg Clayton }
7809fed0d85SGreg Clayton 
7819fed0d85SGreg Clayton SBBreakpointLocation
782b9c1b51eSKate Stone SBBreakpoint::GetBreakpointLocationAtIndexFromEvent(const lldb::SBEvent &event,
783b9c1b51eSKate Stone                                                     uint32_t loc_idx) {
784baf5664fSJonas Devlieghere   LLDB_RECORD_STATIC_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
785baf5664fSJonas Devlieghere                             GetBreakpointLocationAtIndexFromEvent,
786baf5664fSJonas Devlieghere                             (const lldb::SBEvent &, uint32_t), event, loc_idx);
787baf5664fSJonas Devlieghere 
7889fed0d85SGreg Clayton   SBBreakpointLocation sb_breakpoint_loc;
7899fed0d85SGreg Clayton   if (event.IsValid())
790b9c1b51eSKate Stone     sb_breakpoint_loc.SetLocation(
791b9c1b51eSKate Stone         Breakpoint::BreakpointEventData::GetBreakpointLocationAtIndexFromEvent(
792b9c1b51eSKate Stone             event.GetSP(), loc_idx));
793baf5664fSJonas Devlieghere   return LLDB_RECORD_RESULT(sb_breakpoint_loc);
7949fed0d85SGreg Clayton }
7959fed0d85SGreg Clayton 
796e6bc6cb9SJim Ingham uint32_t
797b9c1b51eSKate Stone SBBreakpoint::GetNumBreakpointLocationsFromEvent(const lldb::SBEvent &event) {
798baf5664fSJonas Devlieghere   LLDB_RECORD_STATIC_METHOD(uint32_t, SBBreakpoint,
799baf5664fSJonas Devlieghere                             GetNumBreakpointLocationsFromEvent,
800baf5664fSJonas Devlieghere                             (const lldb::SBEvent &), event);
801baf5664fSJonas Devlieghere 
802e6bc6cb9SJim Ingham   uint32_t num_locations = 0;
803e6bc6cb9SJim Ingham   if (event.IsValid())
804b9c1b51eSKate Stone     num_locations =
805b9c1b51eSKate Stone         (Breakpoint::BreakpointEventData::GetNumBreakpointLocationsFromEvent(
806b9c1b51eSKate Stone             event.GetSP()));
807e6bc6cb9SJim Ingham   return num_locations;
808e6bc6cb9SJim Ingham }
80901f16664SJim Ingham 
810e103ae92SJonas Devlieghere bool SBBreakpoint::IsHardware() const {
811baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, IsHardware);
812baf5664fSJonas Devlieghere 
813e103ae92SJonas Devlieghere   BreakpointSP bkpt_sp = GetSP();
814e103ae92SJonas Devlieghere   if (bkpt_sp)
815e103ae92SJonas Devlieghere     return bkpt_sp->IsHardware();
816e103ae92SJonas Devlieghere   return false;
817e103ae92SJonas Devlieghere }
818e103ae92SJonas Devlieghere 
8196ac84034SPavel Labath BreakpointSP SBBreakpoint::GetSP() const { return m_opaque_wp.lock(); }
8206ac84034SPavel Labath 
82101f16664SJim Ingham // This is simple collection of breakpoint id's and their target.
822653e3f4eSTodd Fiala class SBBreakpointListImpl {
82301f16664SJim Ingham public:
824653e3f4eSTodd Fiala   SBBreakpointListImpl(lldb::TargetSP target_sp) : m_target_wp() {
825653e3f4eSTodd Fiala     if (target_sp && target_sp->IsValid())
826653e3f4eSTodd Fiala       m_target_wp = target_sp;
82701f16664SJim Ingham   }
82801f16664SJim Ingham 
82901f16664SJim Ingham   ~SBBreakpointListImpl() = default;
83001f16664SJim Ingham 
83101f16664SJim Ingham   size_t GetSize() { return m_break_ids.size(); }
83201f16664SJim Ingham 
83301f16664SJim Ingham   BreakpointSP GetBreakpointAtIndex(size_t idx) {
83401f16664SJim Ingham     if (idx >= m_break_ids.size())
83501f16664SJim Ingham       return BreakpointSP();
83601f16664SJim Ingham     TargetSP target_sp = m_target_wp.lock();
83701f16664SJim Ingham     if (!target_sp)
83801f16664SJim Ingham       return BreakpointSP();
83901f16664SJim Ingham     lldb::break_id_t bp_id = m_break_ids[idx];
84001f16664SJim Ingham     return target_sp->GetBreakpointList().FindBreakpointByID(bp_id);
84101f16664SJim Ingham   }
84201f16664SJim Ingham 
8436d1e4696SJim Ingham   BreakpointSP FindBreakpointByID(lldb::break_id_t desired_id) {
8446d1e4696SJim Ingham     TargetSP target_sp = m_target_wp.lock();
8456d1e4696SJim Ingham     if (!target_sp)
8466d1e4696SJim Ingham       return BreakpointSP();
8476d1e4696SJim Ingham 
8486d1e4696SJim Ingham     for (lldb::break_id_t &break_id : m_break_ids) {
8496d1e4696SJim Ingham       if (break_id == desired_id)
8506d1e4696SJim Ingham         return target_sp->GetBreakpointList().FindBreakpointByID(break_id);
8516d1e4696SJim Ingham     }
8526d1e4696SJim Ingham     return BreakpointSP();
8536d1e4696SJim Ingham   }
8546d1e4696SJim Ingham 
8556ac84034SPavel Labath   bool Append(BreakpointSP bkpt) {
85601f16664SJim Ingham     TargetSP target_sp = m_target_wp.lock();
8576ac84034SPavel Labath     if (!target_sp || !bkpt)
85801f16664SJim Ingham       return false;
8596ac84034SPavel Labath     if (bkpt->GetTargetSP() != target_sp)
86001f16664SJim Ingham       return false;
8616ac84034SPavel Labath     m_break_ids.push_back(bkpt->GetID());
86201f16664SJim Ingham     return true;
86301f16664SJim Ingham   }
86401f16664SJim Ingham 
8656ac84034SPavel Labath   bool AppendIfUnique(BreakpointSP bkpt) {
86601f16664SJim Ingham     TargetSP target_sp = m_target_wp.lock();
8676ac84034SPavel Labath     if (!target_sp || !bkpt)
86801f16664SJim Ingham       return false;
8696ac84034SPavel Labath     if (bkpt->GetTargetSP() != target_sp)
87001f16664SJim Ingham       return false;
8716ac84034SPavel Labath     lldb::break_id_t bp_id = bkpt->GetID();
87201f16664SJim Ingham     if (find(m_break_ids.begin(), m_break_ids.end(), bp_id) ==
87301f16664SJim Ingham         m_break_ids.end())
87401f16664SJim Ingham       return false;
87501f16664SJim Ingham 
8766ac84034SPavel Labath     m_break_ids.push_back(bkpt->GetID());
87701f16664SJim Ingham     return true;
87801f16664SJim Ingham   }
87901f16664SJim Ingham 
88001f16664SJim Ingham   bool AppendByID(lldb::break_id_t id) {
88101f16664SJim Ingham     TargetSP target_sp = m_target_wp.lock();
88201f16664SJim Ingham     if (!target_sp)
88301f16664SJim Ingham       return false;
88401f16664SJim Ingham     if (id == LLDB_INVALID_BREAK_ID)
88501f16664SJim Ingham       return false;
88601f16664SJim Ingham     m_break_ids.push_back(id);
88701f16664SJim Ingham     return true;
88801f16664SJim Ingham   }
88901f16664SJim Ingham 
89001f16664SJim Ingham   void Clear() { m_break_ids.clear(); }
89101f16664SJim Ingham 
89201f16664SJim Ingham   void CopyToBreakpointIDList(lldb_private::BreakpointIDList &bp_list) {
89301f16664SJim Ingham     for (lldb::break_id_t id : m_break_ids) {
89401f16664SJim Ingham       bp_list.AddBreakpointID(BreakpointID(id));
89501f16664SJim Ingham     }
89601f16664SJim Ingham   }
89701f16664SJim Ingham 
89801f16664SJim Ingham   TargetSP GetTarget() { return m_target_wp.lock(); }
89901f16664SJim Ingham 
90001f16664SJim Ingham private:
90101f16664SJim Ingham   std::vector<lldb::break_id_t> m_break_ids;
90201f16664SJim Ingham   TargetWP m_target_wp;
90301f16664SJim Ingham };
90401f16664SJim Ingham 
90501f16664SJim Ingham SBBreakpointList::SBBreakpointList(SBTarget &target)
906baf5664fSJonas Devlieghere     : m_opaque_sp(new SBBreakpointListImpl(target.GetSP())) {
907baf5664fSJonas Devlieghere   LLDB_RECORD_CONSTRUCTOR(SBBreakpointList, (lldb::SBTarget &), target);
908baf5664fSJonas Devlieghere }
90901f16664SJim Ingham 
910866b7a65SJonas Devlieghere SBBreakpointList::~SBBreakpointList() = default;
91101f16664SJim Ingham 
91201f16664SJim Ingham size_t SBBreakpointList::GetSize() const {
913baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBBreakpointList, GetSize);
914baf5664fSJonas Devlieghere 
91501f16664SJim Ingham   if (!m_opaque_sp)
91601f16664SJim Ingham     return 0;
91701f16664SJim Ingham   else
91801f16664SJim Ingham     return m_opaque_sp->GetSize();
91901f16664SJim Ingham }
92001f16664SJim Ingham 
92101f16664SJim Ingham SBBreakpoint SBBreakpointList::GetBreakpointAtIndex(size_t idx) {
922baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBBreakpointList, GetBreakpointAtIndex,
923baf5664fSJonas Devlieghere                      (size_t), idx);
924baf5664fSJonas Devlieghere 
92501f16664SJim Ingham   if (!m_opaque_sp)
926baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(SBBreakpoint());
92701f16664SJim Ingham 
92801f16664SJim Ingham   BreakpointSP bkpt_sp = m_opaque_sp->GetBreakpointAtIndex(idx);
929baf5664fSJonas Devlieghere   return LLDB_RECORD_RESULT(SBBreakpoint(bkpt_sp));
93001f16664SJim Ingham }
93101f16664SJim Ingham 
9326d1e4696SJim Ingham SBBreakpoint SBBreakpointList::FindBreakpointByID(lldb::break_id_t id) {
933baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBBreakpointList, FindBreakpointByID,
934baf5664fSJonas Devlieghere                      (lldb::break_id_t), id);
935baf5664fSJonas Devlieghere 
9366d1e4696SJim Ingham   if (!m_opaque_sp)
937baf5664fSJonas Devlieghere     return LLDB_RECORD_RESULT(SBBreakpoint());
9386d1e4696SJim Ingham   BreakpointSP bkpt_sp = m_opaque_sp->FindBreakpointByID(id);
939baf5664fSJonas Devlieghere   return LLDB_RECORD_RESULT(SBBreakpoint(bkpt_sp));
9406d1e4696SJim Ingham }
9416d1e4696SJim Ingham 
94201f16664SJim Ingham void SBBreakpointList::Append(const SBBreakpoint &sb_bkpt) {
943baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(void, SBBreakpointList, Append,
944baf5664fSJonas Devlieghere                      (const lldb::SBBreakpoint &), sb_bkpt);
945baf5664fSJonas Devlieghere 
94601f16664SJim Ingham   if (!sb_bkpt.IsValid())
94701f16664SJim Ingham     return;
94801f16664SJim Ingham   if (!m_opaque_sp)
94901f16664SJim Ingham     return;
9506ac84034SPavel Labath   m_opaque_sp->Append(sb_bkpt.m_opaque_wp.lock());
95101f16664SJim Ingham }
95201f16664SJim Ingham 
95301f16664SJim Ingham void SBBreakpointList::AppendByID(lldb::break_id_t id) {
954baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(void, SBBreakpointList, AppendByID, (lldb::break_id_t),
955baf5664fSJonas Devlieghere                      id);
956baf5664fSJonas Devlieghere 
95701f16664SJim Ingham   if (!m_opaque_sp)
95801f16664SJim Ingham     return;
95901f16664SJim Ingham   m_opaque_sp->AppendByID(id);
96001f16664SJim Ingham }
96101f16664SJim Ingham 
96201f16664SJim Ingham bool SBBreakpointList::AppendIfUnique(const SBBreakpoint &sb_bkpt) {
963baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD(bool, SBBreakpointList, AppendIfUnique,
964baf5664fSJonas Devlieghere                      (const lldb::SBBreakpoint &), sb_bkpt);
965baf5664fSJonas Devlieghere 
96601f16664SJim Ingham   if (!sb_bkpt.IsValid())
96701f16664SJim Ingham     return false;
96801f16664SJim Ingham   if (!m_opaque_sp)
96901f16664SJim Ingham     return false;
9706ac84034SPavel Labath   return m_opaque_sp->AppendIfUnique(sb_bkpt.GetSP());
97101f16664SJim Ingham }
97201f16664SJim Ingham 
97301f16664SJim Ingham void SBBreakpointList::Clear() {
974baf5664fSJonas Devlieghere   LLDB_RECORD_METHOD_NO_ARGS(void, SBBreakpointList, Clear);
975baf5664fSJonas Devlieghere 
97601f16664SJim Ingham   if (m_opaque_sp)
97701f16664SJim Ingham     m_opaque_sp->Clear();
97801f16664SJim Ingham }
97901f16664SJim Ingham 
98001f16664SJim Ingham void SBBreakpointList::CopyToBreakpointIDList(
98101f16664SJim Ingham     lldb_private::BreakpointIDList &bp_id_list) {
98201f16664SJim Ingham   if (m_opaque_sp)
98301f16664SJim Ingham     m_opaque_sp->CopyToBreakpointIDList(bp_id_list);
98401f16664SJim Ingham }
985ae211eceSMichal Gorny 
986ae211eceSMichal Gorny namespace lldb_private {
987ae211eceSMichal Gorny namespace repro {
988ae211eceSMichal Gorny 
989ae211eceSMichal Gorny template <>
990ae211eceSMichal Gorny void RegisterMethods<SBBreakpoint>(Registry &R) {
991ae211eceSMichal Gorny   LLDB_REGISTER_CONSTRUCTOR(SBBreakpoint, ());
992ae211eceSMichal Gorny   LLDB_REGISTER_CONSTRUCTOR(SBBreakpoint, (const lldb::SBBreakpoint &));
993ae211eceSMichal Gorny   LLDB_REGISTER_CONSTRUCTOR(SBBreakpoint, (const lldb::BreakpointSP &));
994ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(const lldb::SBBreakpoint &,
995ae211eceSMichal Gorny                        SBBreakpoint, operator=,(const lldb::SBBreakpoint &));
996ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(bool,
997ae211eceSMichal Gorny                        SBBreakpoint, operator==,(const lldb::SBBreakpoint &));
998ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(bool,
999ae211eceSMichal Gorny                        SBBreakpoint, operator!=,(const lldb::SBBreakpoint &));
10006754caa9SJim Ingham   LLDB_REGISTER_METHOD_CONST(lldb::SBTarget, SBBreakpoint, GetTarget, ());
1001ae211eceSMichal Gorny   LLDB_REGISTER_METHOD_CONST(lldb::break_id_t, SBBreakpoint, GetID, ());
1002ae211eceSMichal Gorny   LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, IsValid, ());
1003ae211eceSMichal Gorny   LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, operator bool, ());
1004ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(void, SBBreakpoint, ClearAllBreakpointSites, ());
1005ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
1006ae211eceSMichal Gorny                        FindLocationByAddress, (lldb::addr_t));
1007ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::break_id_t, SBBreakpoint,
1008ae211eceSMichal Gorny                        FindLocationIDByAddress, (lldb::addr_t));
1009ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
1010ae211eceSMichal Gorny                        FindLocationByID, (lldb::break_id_t));
1011ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
1012ae211eceSMichal Gorny                        GetLocationAtIndex, (uint32_t));
1013ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(void, SBBreakpoint, SetEnabled, (bool));
1014ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(bool, SBBreakpoint, IsEnabled, ());
1015ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(void, SBBreakpoint, SetOneShot, (bool));
1016ae211eceSMichal Gorny   LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, IsOneShot, ());
1017ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(bool, SBBreakpoint, IsInternal, ());
1018ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(void, SBBreakpoint, SetIgnoreCount, (uint32_t));
1019ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(void, SBBreakpoint, SetCondition, (const char *));
1020ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(const char *, SBBreakpoint, GetCondition, ());
1021ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(void, SBBreakpoint, SetAutoContinue, (bool));
1022ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(bool, SBBreakpoint, GetAutoContinue, ());
1023ae211eceSMichal Gorny   LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpoint, GetHitCount, ());
1024ae211eceSMichal Gorny   LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpoint, GetIgnoreCount, ());
1025ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(void, SBBreakpoint, SetThreadID, (lldb::tid_t));
1026ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::tid_t, SBBreakpoint, GetThreadID, ());
1027ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(void, SBBreakpoint, SetThreadIndex, (uint32_t));
1028ae211eceSMichal Gorny   LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpoint, GetThreadIndex, ());
1029ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(void, SBBreakpoint, SetThreadName, (const char *));
1030ae211eceSMichal Gorny   LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpoint, GetThreadName, ());
1031ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(void, SBBreakpoint, SetQueueName, (const char *));
1032ae211eceSMichal Gorny   LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpoint, GetQueueName, ());
1033ae211eceSMichal Gorny   LLDB_REGISTER_METHOD_CONST(size_t, SBBreakpoint, GetNumResolvedLocations,
1034ae211eceSMichal Gorny                              ());
1035ae211eceSMichal Gorny   LLDB_REGISTER_METHOD_CONST(size_t, SBBreakpoint, GetNumLocations, ());
1036ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(void, SBBreakpoint, SetCommandLineCommands,
1037ae211eceSMichal Gorny                        (lldb::SBStringList &));
1038ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(bool, SBBreakpoint, GetCommandLineCommands,
1039ae211eceSMichal Gorny                        (lldb::SBStringList &));
1040ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(bool, SBBreakpoint, GetDescription,
1041ae211eceSMichal Gorny                        (lldb::SBStream &));
1042ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(bool, SBBreakpoint, GetDescription,
1043ae211eceSMichal Gorny                        (lldb::SBStream &, bool));
1044ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, AddLocation,
1045ae211eceSMichal Gorny                        (lldb::SBAddress &));
10464da8fa45SMed Ismail Bennani   LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBBreakpoint,
10474da8fa45SMed Ismail Bennani                        SerializeToStructuredData, ());
1048ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(void, SBBreakpoint, SetScriptCallbackFunction,
1049ae211eceSMichal Gorny                        (const char *));
1050738af7a6SJim Ingham   LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, SetScriptCallbackFunction,
1051738af7a6SJim Ingham                        (const char *, SBStructuredData &));
1052ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, SetScriptCallbackBody,
1053ae211eceSMichal Gorny                        (const char *));
1054ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(bool, SBBreakpoint, AddName, (const char *));
1055f70cad26SMed Ismail Bennani   LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, AddNameWithErrorHandling,
1056f70cad26SMed Ismail Bennani                        (const char *));
1057ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(void, SBBreakpoint, RemoveName, (const char *));
1058ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(bool, SBBreakpoint, MatchesName, (const char *));
1059ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(void, SBBreakpoint, GetNames, (lldb::SBStringList &));
1060ae211eceSMichal Gorny   LLDB_REGISTER_STATIC_METHOD(bool, SBBreakpoint, EventIsBreakpointEvent,
1061ae211eceSMichal Gorny                               (const lldb::SBEvent &));
1062ae211eceSMichal Gorny   LLDB_REGISTER_STATIC_METHOD(lldb::BreakpointEventType, SBBreakpoint,
1063ae211eceSMichal Gorny                               GetBreakpointEventTypeFromEvent,
1064ae211eceSMichal Gorny                               (const lldb::SBEvent &));
1065ae211eceSMichal Gorny   LLDB_REGISTER_STATIC_METHOD(lldb::SBBreakpoint, SBBreakpoint,
1066ae211eceSMichal Gorny                               GetBreakpointFromEvent,
1067ae211eceSMichal Gorny                               (const lldb::SBEvent &));
1068ae211eceSMichal Gorny   LLDB_REGISTER_STATIC_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
1069ae211eceSMichal Gorny                               GetBreakpointLocationAtIndexFromEvent,
1070ae211eceSMichal Gorny                               (const lldb::SBEvent &, uint32_t));
1071ae211eceSMichal Gorny   LLDB_REGISTER_STATIC_METHOD(uint32_t, SBBreakpoint,
1072ae211eceSMichal Gorny                               GetNumBreakpointLocationsFromEvent,
1073ae211eceSMichal Gorny                               (const lldb::SBEvent &));
1074ae211eceSMichal Gorny   LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, IsHardware, ());
1075ae211eceSMichal Gorny }
1076ae211eceSMichal Gorny 
1077ae211eceSMichal Gorny template <>
1078ae211eceSMichal Gorny void RegisterMethods<SBBreakpointList>(Registry &R) {
1079ae211eceSMichal Gorny   LLDB_REGISTER_CONSTRUCTOR(SBBreakpointList, (lldb::SBTarget &));
1080ae211eceSMichal Gorny   LLDB_REGISTER_METHOD_CONST(size_t, SBBreakpointList, GetSize, ());
1081ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBBreakpointList,
1082ae211eceSMichal Gorny                        GetBreakpointAtIndex, (size_t));
1083ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBBreakpointList,
1084ae211eceSMichal Gorny                        FindBreakpointByID, (lldb::break_id_t));
1085ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(void, SBBreakpointList, Append,
1086ae211eceSMichal Gorny                        (const lldb::SBBreakpoint &));
1087ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(void, SBBreakpointList, AppendByID,
1088ae211eceSMichal Gorny                        (lldb::break_id_t));
1089ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(bool, SBBreakpointList, AppendIfUnique,
1090ae211eceSMichal Gorny                        (const lldb::SBBreakpoint &));
1091ae211eceSMichal Gorny   LLDB_REGISTER_METHOD(void, SBBreakpointList, Clear, ());
1092ae211eceSMichal Gorny }
1093ae211eceSMichal Gorny 
1094ae211eceSMichal Gorny }
1095ae211eceSMichal Gorny }
1096