180814287SRaphael Isemann //===-- SBBreakpointLocation.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/SBBreakpointLocation.h"
10f644ddf4SGreg Clayton #include "lldb/API/SBAddress.h"
1130fdc8d8SChris Lattner #include "lldb/API/SBDebugger.h"
12b9c1b51eSKate Stone #include "lldb/API/SBDefines.h"
13dde9cff3SCaroline Tice #include "lldb/API/SBStream.h"
14af26b22cSJim Ingham #include "lldb/API/SBStringList.h"
15*1755f5b1SJonas Devlieghere #include "lldb/API/SBStructuredData.h"
16*1755f5b1SJonas Devlieghere #include "lldb/Utility/Instrumentation.h"
1730fdc8d8SChris Lattner
184e78f606SGreg Clayton #include "lldb/Breakpoint/Breakpoint.h"
1930fdc8d8SChris Lattner #include "lldb/Breakpoint/BreakpointLocation.h"
20d80102e4SJim Ingham #include "lldb/Core/Debugger.h"
2130fdc8d8SChris Lattner #include "lldb/Core/StreamFile.h"
22738af7a6SJim Ingham #include "lldb/Core/StructuredDataImpl.h"
23d80102e4SJim Ingham #include "lldb/Interpreter/CommandInterpreter.h"
24d80102e4SJim Ingham #include "lldb/Interpreter/ScriptInterpreter.h"
25af67cecdSGreg Clayton #include "lldb/Target/Target.h"
2662b02c61SJim Ingham #include "lldb/Target/ThreadSpec.h"
27bf9a7730SZachary Turner #include "lldb/Utility/Stream.h"
28b9c1b51eSKate Stone #include "lldb/lldb-defines.h"
29b9c1b51eSKate Stone #include "lldb/lldb-types.h"
3030fdc8d8SChris Lattner
3130fdc8d8SChris Lattner using namespace lldb;
3230fdc8d8SChris Lattner using namespace lldb_private;
3330fdc8d8SChris Lattner
SBBreakpointLocation()34*1755f5b1SJonas Devlieghere SBBreakpointLocation::SBBreakpointLocation() { LLDB_INSTRUMENT_VA(this); }
3530fdc8d8SChris Lattner
SBBreakpointLocation(const lldb::BreakpointLocationSP & break_loc_sp)36b9c1b51eSKate Stone SBBreakpointLocation::SBBreakpointLocation(
37b9c1b51eSKate Stone const lldb::BreakpointLocationSP &break_loc_sp)
38c5789434SPavel Labath : m_opaque_wp(break_loc_sp) {
39*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, break_loc_sp);
4030fdc8d8SChris Lattner }
4130fdc8d8SChris Lattner
SBBreakpointLocation(const SBBreakpointLocation & rhs)42b9c1b51eSKate Stone SBBreakpointLocation::SBBreakpointLocation(const SBBreakpointLocation &rhs)
43baf5664fSJonas Devlieghere : m_opaque_wp(rhs.m_opaque_wp) {
44*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, rhs);
45baf5664fSJonas Devlieghere }
46efabb123SGreg Clayton
47b9c1b51eSKate Stone const SBBreakpointLocation &SBBreakpointLocation::
operator =(const SBBreakpointLocation & rhs)48b9c1b51eSKate Stone operator=(const SBBreakpointLocation &rhs) {
49*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, rhs);
50baf5664fSJonas Devlieghere
51c5789434SPavel Labath m_opaque_wp = rhs.m_opaque_wp;
52d232abc3SJonas Devlieghere return *this;
53efabb123SGreg Clayton }
54efabb123SGreg Clayton
55866b7a65SJonas Devlieghere SBBreakpointLocation::~SBBreakpointLocation() = default;
56efabb123SGreg Clayton
GetSP() const57c5789434SPavel Labath BreakpointLocationSP SBBreakpointLocation::GetSP() const {
58c5789434SPavel Labath return m_opaque_wp.lock();
59c5789434SPavel Labath }
60c5789434SPavel Labath
IsValid() const61baf5664fSJonas Devlieghere bool SBBreakpointLocation::IsValid() const {
62*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
637f5237bcSPavel Labath return this->operator bool();
647f5237bcSPavel Labath }
operator bool() const657f5237bcSPavel Labath SBBreakpointLocation::operator bool() const {
66*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
67baf5664fSJonas Devlieghere
68baf5664fSJonas Devlieghere return bool(GetSP());
69baf5664fSJonas Devlieghere }
7030fdc8d8SChris Lattner
GetAddress()71b9c1b51eSKate Stone SBAddress SBBreakpointLocation::GetAddress() {
72*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
73baf5664fSJonas Devlieghere
74c5789434SPavel Labath BreakpointLocationSP loc_sp = GetSP();
75baf5664fSJonas Devlieghere if (loc_sp) {
76d232abc3SJonas Devlieghere return SBAddress(loc_sp->GetAddress());
77baf5664fSJonas Devlieghere }
78baf5664fSJonas Devlieghere
79d232abc3SJonas Devlieghere return SBAddress();
80810bf85eSJim Ingham }
81810bf85eSJim Ingham
GetLoadAddress()82b9c1b51eSKate Stone addr_t SBBreakpointLocation::GetLoadAddress() {
83*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
84baf5664fSJonas Devlieghere
8530fdc8d8SChris Lattner addr_t ret_addr = LLDB_INVALID_ADDRESS;
86c5789434SPavel Labath BreakpointLocationSP loc_sp = GetSP();
8730fdc8d8SChris Lattner
88c5789434SPavel Labath if (loc_sp) {
89b9c1b51eSKate Stone std::lock_guard<std::recursive_mutex> guard(
90c5789434SPavel Labath loc_sp->GetTarget().GetAPIMutex());
91c5789434SPavel Labath ret_addr = loc_sp->GetLoadAddress();
9230fdc8d8SChris Lattner }
9330fdc8d8SChris Lattner
9430fdc8d8SChris Lattner return ret_addr;
9530fdc8d8SChris Lattner }
9630fdc8d8SChris Lattner
SetEnabled(bool enabled)97b9c1b51eSKate Stone void SBBreakpointLocation::SetEnabled(bool enabled) {
98*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, enabled);
99baf5664fSJonas Devlieghere
100c5789434SPavel Labath BreakpointLocationSP loc_sp = GetSP();
101c5789434SPavel Labath if (loc_sp) {
102b9c1b51eSKate Stone std::lock_guard<std::recursive_mutex> guard(
103c5789434SPavel Labath loc_sp->GetTarget().GetAPIMutex());
104c5789434SPavel Labath loc_sp->SetEnabled(enabled);
10530fdc8d8SChris Lattner }
10630fdc8d8SChris Lattner }
10730fdc8d8SChris Lattner
IsEnabled()108b9c1b51eSKate Stone bool SBBreakpointLocation::IsEnabled() {
109*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
110baf5664fSJonas Devlieghere
111c5789434SPavel Labath BreakpointLocationSP loc_sp = GetSP();
112c5789434SPavel Labath if (loc_sp) {
113b9c1b51eSKate Stone std::lock_guard<std::recursive_mutex> guard(
114c5789434SPavel Labath loc_sp->GetTarget().GetAPIMutex());
115c5789434SPavel Labath return loc_sp->IsEnabled();
116b9c1b51eSKate Stone } else
11730fdc8d8SChris Lattner return false;
11830fdc8d8SChris Lattner }
11930fdc8d8SChris Lattner
GetHitCount()120ccbf7987SBruce Mitchener uint32_t SBBreakpointLocation::GetHitCount() {
121*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
122baf5664fSJonas Devlieghere
123ccbf7987SBruce Mitchener BreakpointLocationSP loc_sp = GetSP();
124ccbf7987SBruce Mitchener if (loc_sp) {
125ccbf7987SBruce Mitchener std::lock_guard<std::recursive_mutex> guard(
126ccbf7987SBruce Mitchener loc_sp->GetTarget().GetAPIMutex());
127ccbf7987SBruce Mitchener return loc_sp->GetHitCount();
128ccbf7987SBruce Mitchener } else
129ccbf7987SBruce Mitchener return 0;
130ccbf7987SBruce Mitchener }
131ccbf7987SBruce Mitchener
GetIgnoreCount()132b9c1b51eSKate Stone uint32_t SBBreakpointLocation::GetIgnoreCount() {
133*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
134baf5664fSJonas Devlieghere
135c5789434SPavel Labath BreakpointLocationSP loc_sp = GetSP();
136c5789434SPavel Labath if (loc_sp) {
137b9c1b51eSKate Stone std::lock_guard<std::recursive_mutex> guard(
138c5789434SPavel Labath loc_sp->GetTarget().GetAPIMutex());
139c5789434SPavel Labath return loc_sp->GetIgnoreCount();
140b9c1b51eSKate Stone } else
14130fdc8d8SChris Lattner return 0;
14230fdc8d8SChris Lattner }
14330fdc8d8SChris Lattner
SetIgnoreCount(uint32_t n)144b9c1b51eSKate Stone void SBBreakpointLocation::SetIgnoreCount(uint32_t n) {
145*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, n);
146baf5664fSJonas Devlieghere
147c5789434SPavel Labath BreakpointLocationSP loc_sp = GetSP();
148c5789434SPavel Labath if (loc_sp) {
149b9c1b51eSKate Stone std::lock_guard<std::recursive_mutex> guard(
150c5789434SPavel Labath loc_sp->GetTarget().GetAPIMutex());
151c5789434SPavel Labath loc_sp->SetIgnoreCount(n);
15230fdc8d8SChris Lattner }
153af67cecdSGreg Clayton }
15430fdc8d8SChris Lattner
SetCondition(const char * condition)155b9c1b51eSKate Stone void SBBreakpointLocation::SetCondition(const char *condition) {
156*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, condition);
157baf5664fSJonas Devlieghere
158c5789434SPavel Labath BreakpointLocationSP loc_sp = GetSP();
159c5789434SPavel Labath if (loc_sp) {
160b9c1b51eSKate Stone std::lock_guard<std::recursive_mutex> guard(
161c5789434SPavel Labath loc_sp->GetTarget().GetAPIMutex());
162c5789434SPavel Labath loc_sp->SetCondition(condition);
163041a12fcSJim Ingham }
164af67cecdSGreg Clayton }
165041a12fcSJim Ingham
GetCondition()166b9c1b51eSKate Stone const char *SBBreakpointLocation::GetCondition() {
167*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
168baf5664fSJonas Devlieghere
169c5789434SPavel Labath BreakpointLocationSP loc_sp = GetSP();
170c5789434SPavel Labath if (loc_sp) {
171b9c1b51eSKate Stone std::lock_guard<std::recursive_mutex> guard(
172c5789434SPavel Labath loc_sp->GetTarget().GetAPIMutex());
173c5789434SPavel Labath return loc_sp->GetConditionText();
174041a12fcSJim Ingham }
175248a1305SKonrad Kleine return nullptr;
176af67cecdSGreg Clayton }
177041a12fcSJim Ingham
SetAutoContinue(bool auto_continue)178f08f5c99SJim Ingham void SBBreakpointLocation::SetAutoContinue(bool auto_continue) {
179*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, auto_continue);
180baf5664fSJonas Devlieghere
181f08f5c99SJim Ingham BreakpointLocationSP loc_sp = GetSP();
182f08f5c99SJim Ingham if (loc_sp) {
183f08f5c99SJim Ingham std::lock_guard<std::recursive_mutex> guard(
184f08f5c99SJim Ingham loc_sp->GetTarget().GetAPIMutex());
185f08f5c99SJim Ingham loc_sp->SetAutoContinue(auto_continue);
186f08f5c99SJim Ingham }
187f08f5c99SJim Ingham }
188f08f5c99SJim Ingham
GetAutoContinue()189f08f5c99SJim Ingham bool SBBreakpointLocation::GetAutoContinue() {
190*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
191baf5664fSJonas Devlieghere
192f08f5c99SJim Ingham BreakpointLocationSP loc_sp = GetSP();
193f08f5c99SJim Ingham if (loc_sp) {
194f08f5c99SJim Ingham std::lock_guard<std::recursive_mutex> guard(
195f08f5c99SJim Ingham loc_sp->GetTarget().GetAPIMutex());
196f08f5c99SJim Ingham return loc_sp->IsAutoContinue();
197f08f5c99SJim Ingham }
1981c7dc829SJim Ingham return false;
199f08f5c99SJim Ingham }
200f08f5c99SJim Ingham
SetScriptCallbackFunction(const char * callback_function_name)201b9c1b51eSKate Stone void SBBreakpointLocation::SetScriptCallbackFunction(
202b9c1b51eSKate Stone const char *callback_function_name) {
203*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, callback_function_name);
204738af7a6SJim Ingham }
205baf5664fSJonas Devlieghere
SetScriptCallbackFunction(const char * callback_function_name,SBStructuredData & extra_args)206738af7a6SJim Ingham SBError SBBreakpointLocation::SetScriptCallbackFunction(
207738af7a6SJim Ingham const char *callback_function_name,
208738af7a6SJim Ingham SBStructuredData &extra_args) {
209*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, callback_function_name, extra_args);
210738af7a6SJim Ingham SBError sb_error;
211c5789434SPavel Labath BreakpointLocationSP loc_sp = GetSP();
212d80102e4SJim Ingham
213c5789434SPavel Labath if (loc_sp) {
214738af7a6SJim Ingham Status error;
215b9c1b51eSKate Stone std::lock_guard<std::recursive_mutex> guard(
216c5789434SPavel Labath loc_sp->GetTarget().GetAPIMutex());
217cfb96d84SJim Ingham BreakpointOptions &bp_options = loc_sp->GetLocationOptions();
218738af7a6SJim Ingham error = loc_sp->GetBreakpoint()
219b9c1b51eSKate Stone .GetTarget()
220b9c1b51eSKate Stone .GetDebugger()
221b9c1b51eSKate Stone .GetScriptInterpreter()
222b9c1b51eSKate Stone ->SetBreakpointCommandCallbackFunction(bp_options,
223738af7a6SJim Ingham callback_function_name,
224738af7a6SJim Ingham extra_args.m_impl_up
225738af7a6SJim Ingham ->GetObjectSP());
226738af7a6SJim Ingham sb_error.SetError(error);
227738af7a6SJim Ingham } else
228738af7a6SJim Ingham sb_error.SetErrorString("invalid breakpoint");
229738af7a6SJim Ingham
230d232abc3SJonas Devlieghere return sb_error;
231d80102e4SJim Ingham }
232d80102e4SJim Ingham
233d80102e4SJim Ingham SBError
SetScriptCallbackBody(const char * callback_body_text)234b9c1b51eSKate Stone SBBreakpointLocation::SetScriptCallbackBody(const char *callback_body_text) {
235*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, callback_body_text);
236baf5664fSJonas Devlieghere
237c5789434SPavel Labath BreakpointLocationSP loc_sp = GetSP();
238d80102e4SJim Ingham
239d80102e4SJim Ingham SBError sb_error;
240c5789434SPavel Labath if (loc_sp) {
241b9c1b51eSKate Stone std::lock_guard<std::recursive_mutex> guard(
242c5789434SPavel Labath loc_sp->GetTarget().GetAPIMutex());
243cfb96d84SJim Ingham BreakpointOptions &bp_options = loc_sp->GetLocationOptions();
24497206d57SZachary Turner Status error =
245c5789434SPavel Labath loc_sp->GetBreakpoint()
246b9c1b51eSKate Stone .GetTarget()
247b9c1b51eSKate Stone .GetDebugger()
248b9c1b51eSKate Stone .GetScriptInterpreter()
249b9c1b51eSKate Stone ->SetBreakpointCommandCallback(bp_options, callback_body_text);
250d80102e4SJim Ingham sb_error.SetError(error);
251b9c1b51eSKate Stone } else
252d80102e4SJim Ingham sb_error.SetErrorString("invalid breakpoint");
253d80102e4SJim Ingham
254d232abc3SJonas Devlieghere return sb_error;
255d80102e4SJim Ingham }
256d80102e4SJim Ingham
SetCommandLineCommands(SBStringList & commands)257af26b22cSJim Ingham void SBBreakpointLocation::SetCommandLineCommands(SBStringList &commands) {
258*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, commands);
259baf5664fSJonas Devlieghere
260af26b22cSJim Ingham BreakpointLocationSP loc_sp = GetSP();
261af26b22cSJim Ingham if (!loc_sp)
262af26b22cSJim Ingham return;
263af26b22cSJim Ingham if (commands.GetSize() == 0)
264af26b22cSJim Ingham return;
265af26b22cSJim Ingham
266af26b22cSJim Ingham std::lock_guard<std::recursive_mutex> guard(
267af26b22cSJim Ingham loc_sp->GetTarget().GetAPIMutex());
268af26b22cSJim Ingham std::unique_ptr<BreakpointOptions::CommandData> cmd_data_up(
269af26b22cSJim Ingham new BreakpointOptions::CommandData(*commands, eScriptLanguageNone));
270af26b22cSJim Ingham
271cfb96d84SJim Ingham loc_sp->GetLocationOptions().SetCommandDataCallback(cmd_data_up);
272af26b22cSJim Ingham }
273af26b22cSJim Ingham
GetCommandLineCommands(SBStringList & commands)274af26b22cSJim Ingham bool SBBreakpointLocation::GetCommandLineCommands(SBStringList &commands) {
275*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, commands);
276baf5664fSJonas Devlieghere
277af26b22cSJim Ingham BreakpointLocationSP loc_sp = GetSP();
278af26b22cSJim Ingham if (!loc_sp)
279af26b22cSJim Ingham return false;
280af26b22cSJim Ingham StringList command_list;
281af26b22cSJim Ingham bool has_commands =
282cfb96d84SJim Ingham loc_sp->GetLocationOptions().GetCommandLineCallbacks(command_list);
283af26b22cSJim Ingham if (has_commands)
284af26b22cSJim Ingham commands.AppendList(command_list);
285af26b22cSJim Ingham return has_commands;
286af26b22cSJim Ingham }
287af26b22cSJim Ingham
SetThreadID(tid_t thread_id)288b9c1b51eSKate Stone void SBBreakpointLocation::SetThreadID(tid_t thread_id) {
289*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, thread_id);
290baf5664fSJonas Devlieghere
291c5789434SPavel Labath BreakpointLocationSP loc_sp = GetSP();
292c5789434SPavel Labath if (loc_sp) {
293b9c1b51eSKate Stone std::lock_guard<std::recursive_mutex> guard(
294c5789434SPavel Labath loc_sp->GetTarget().GetAPIMutex());
295c5789434SPavel Labath loc_sp->SetThreadID(thread_id);
29630fdc8d8SChris Lattner }
297af67cecdSGreg Clayton }
29830fdc8d8SChris Lattner
GetThreadID()299b9c1b51eSKate Stone tid_t SBBreakpointLocation::GetThreadID() {
300*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
301baf5664fSJonas Devlieghere
302af67cecdSGreg Clayton tid_t tid = LLDB_INVALID_THREAD_ID;
303c5789434SPavel Labath BreakpointLocationSP loc_sp = GetSP();
304c5789434SPavel Labath if (loc_sp) {
305b9c1b51eSKate Stone std::lock_guard<std::recursive_mutex> guard(
306c5789434SPavel Labath loc_sp->GetTarget().GetAPIMutex());
307c5789434SPavel Labath return loc_sp->GetThreadID();
308af67cecdSGreg Clayton }
309af67cecdSGreg Clayton return tid;
31030fdc8d8SChris Lattner }
31130fdc8d8SChris Lattner
SetThreadIndex(uint32_t index)312b9c1b51eSKate Stone void SBBreakpointLocation::SetThreadIndex(uint32_t index) {
313*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, index);
314baf5664fSJonas Devlieghere
315c5789434SPavel Labath BreakpointLocationSP loc_sp = GetSP();
316c5789434SPavel Labath if (loc_sp) {
317b9c1b51eSKate Stone std::lock_guard<std::recursive_mutex> guard(
318c5789434SPavel Labath loc_sp->GetTarget().GetAPIMutex());
319c5789434SPavel Labath loc_sp->SetThreadIndex(index);
32062b02c61SJim Ingham }
321af67cecdSGreg Clayton }
32262b02c61SJim Ingham
GetThreadIndex() const323b9c1b51eSKate Stone uint32_t SBBreakpointLocation::GetThreadIndex() const {
324*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
325baf5664fSJonas Devlieghere
326af67cecdSGreg Clayton uint32_t thread_idx = UINT32_MAX;
327c5789434SPavel Labath BreakpointLocationSP loc_sp = GetSP();
328c5789434SPavel Labath if (loc_sp) {
329b9c1b51eSKate Stone std::lock_guard<std::recursive_mutex> guard(
330c5789434SPavel Labath loc_sp->GetTarget().GetAPIMutex());
331c5789434SPavel Labath return loc_sp->GetThreadIndex();
33262b02c61SJim Ingham }
333af67cecdSGreg Clayton return thread_idx;
33462b02c61SJim Ingham }
33562b02c61SJim Ingham
SetThreadName(const char * thread_name)336b9c1b51eSKate Stone void SBBreakpointLocation::SetThreadName(const char *thread_name) {
337*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, thread_name);
338baf5664fSJonas Devlieghere
339c5789434SPavel Labath BreakpointLocationSP loc_sp = GetSP();
340c5789434SPavel Labath if (loc_sp) {
341b9c1b51eSKate Stone std::lock_guard<std::recursive_mutex> guard(
342c5789434SPavel Labath loc_sp->GetTarget().GetAPIMutex());
343c5789434SPavel Labath loc_sp->SetThreadName(thread_name);
34462b02c61SJim Ingham }
345af67cecdSGreg Clayton }
34662b02c61SJim Ingham
GetThreadName() const347b9c1b51eSKate Stone const char *SBBreakpointLocation::GetThreadName() const {
348*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
349baf5664fSJonas Devlieghere
350c5789434SPavel Labath BreakpointLocationSP loc_sp = GetSP();
351c5789434SPavel Labath if (loc_sp) {
352b9c1b51eSKate Stone std::lock_guard<std::recursive_mutex> guard(
353c5789434SPavel Labath loc_sp->GetTarget().GetAPIMutex());
354c5789434SPavel Labath return loc_sp->GetThreadName();
35562b02c61SJim Ingham }
356248a1305SKonrad Kleine return nullptr;
35762b02c61SJim Ingham }
35862b02c61SJim Ingham
SetQueueName(const char * queue_name)359b9c1b51eSKate Stone void SBBreakpointLocation::SetQueueName(const char *queue_name) {
360*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, queue_name);
361baf5664fSJonas Devlieghere
362c5789434SPavel Labath BreakpointLocationSP loc_sp = GetSP();
363c5789434SPavel Labath if (loc_sp) {
364b9c1b51eSKate Stone std::lock_guard<std::recursive_mutex> guard(
365c5789434SPavel Labath loc_sp->GetTarget().GetAPIMutex());
366c5789434SPavel Labath loc_sp->SetQueueName(queue_name);
36762b02c61SJim Ingham }
368af67cecdSGreg Clayton }
36962b02c61SJim Ingham
GetQueueName() const370b9c1b51eSKate Stone const char *SBBreakpointLocation::GetQueueName() const {
371*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
372baf5664fSJonas Devlieghere
373c5789434SPavel Labath BreakpointLocationSP loc_sp = GetSP();
374c5789434SPavel Labath if (loc_sp) {
375b9c1b51eSKate Stone std::lock_guard<std::recursive_mutex> guard(
376c5789434SPavel Labath loc_sp->GetTarget().GetAPIMutex());
377c5789434SPavel Labath loc_sp->GetQueueName();
37862b02c61SJim Ingham }
379248a1305SKonrad Kleine return nullptr;
38062b02c61SJim Ingham }
38162b02c61SJim Ingham
IsResolved()382b9c1b51eSKate Stone bool SBBreakpointLocation::IsResolved() {
383*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
384baf5664fSJonas Devlieghere
385c5789434SPavel Labath BreakpointLocationSP loc_sp = GetSP();
386c5789434SPavel Labath if (loc_sp) {
387b9c1b51eSKate Stone std::lock_guard<std::recursive_mutex> guard(
388c5789434SPavel Labath loc_sp->GetTarget().GetAPIMutex());
389c5789434SPavel Labath return loc_sp->IsResolved();
390af67cecdSGreg Clayton }
39130fdc8d8SChris Lattner return false;
39230fdc8d8SChris Lattner }
39330fdc8d8SChris Lattner
SetLocation(const lldb::BreakpointLocationSP & break_loc_sp)394b9c1b51eSKate Stone void SBBreakpointLocation::SetLocation(
395b9c1b51eSKate Stone const lldb::BreakpointLocationSP &break_loc_sp) {
39630fdc8d8SChris Lattner // Uninstall the callbacks?
397c5789434SPavel Labath m_opaque_wp = break_loc_sp;
39830fdc8d8SChris Lattner }
39930fdc8d8SChris Lattner
GetDescription(SBStream & description,DescriptionLevel level)400b9c1b51eSKate Stone bool SBBreakpointLocation::GetDescription(SBStream &description,
401b9c1b51eSKate Stone DescriptionLevel level) {
402*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this, description, level);
403baf5664fSJonas Devlieghere
404da7bc7d0SGreg Clayton Stream &strm = description.ref();
405c5789434SPavel Labath BreakpointLocationSP loc_sp = GetSP();
406da7bc7d0SGreg Clayton
407c5789434SPavel Labath if (loc_sp) {
408b9c1b51eSKate Stone std::lock_guard<std::recursive_mutex> guard(
409c5789434SPavel Labath loc_sp->GetTarget().GetAPIMutex());
410c5789434SPavel Labath loc_sp->GetDescription(&strm, level);
411da7bc7d0SGreg Clayton strm.EOL();
412b9c1b51eSKate Stone } else
413da7bc7d0SGreg Clayton strm.PutCString("No value");
414dde9cff3SCaroline Tice
415dde9cff3SCaroline Tice return true;
416dde9cff3SCaroline Tice }
417dde9cff3SCaroline Tice
GetID()418b9c1b51eSKate Stone break_id_t SBBreakpointLocation::GetID() {
419*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
420baf5664fSJonas Devlieghere
421c5789434SPavel Labath BreakpointLocationSP loc_sp = GetSP();
422c5789434SPavel Labath if (loc_sp) {
423b9c1b51eSKate Stone std::lock_guard<std::recursive_mutex> guard(
424c5789434SPavel Labath loc_sp->GetTarget().GetAPIMutex());
425c5789434SPavel Labath return loc_sp->GetID();
426b9c1b51eSKate Stone } else
427b08a9442SJim Ingham return LLDB_INVALID_BREAK_ID;
428b08a9442SJim Ingham }
429b08a9442SJim Ingham
GetBreakpoint()430b9c1b51eSKate Stone SBBreakpoint SBBreakpointLocation::GetBreakpoint() {
431*1755f5b1SJonas Devlieghere LLDB_INSTRUMENT_VA(this);
432baf5664fSJonas Devlieghere
433c5789434SPavel Labath BreakpointLocationSP loc_sp = GetSP();
434ceb6b139SCaroline Tice
43530fdc8d8SChris Lattner SBBreakpoint sb_bp;
436c5789434SPavel Labath if (loc_sp) {
437b9c1b51eSKate Stone std::lock_guard<std::recursive_mutex> guard(
438c5789434SPavel Labath loc_sp->GetTarget().GetAPIMutex());
439c5789434SPavel Labath sb_bp = loc_sp->GetBreakpoint().shared_from_this();
440af67cecdSGreg Clayton }
441ceb6b139SCaroline Tice
442d232abc3SJonas Devlieghere return sb_bp;
44330fdc8d8SChris Lattner }
444