1 //===-- SBBreakpointName.cpp ----------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "lldb/API/SBBreakpointName.h"
10 #include "SBReproducerPrivate.h"
11 #include "lldb/API/SBDebugger.h"
12 #include "lldb/API/SBError.h"
13 #include "lldb/API/SBStream.h"
14 #include "lldb/API/SBStringList.h"
15 #include "lldb/API/SBStructuredData.h"
16 #include "lldb/API/SBTarget.h"
17
18 #include "lldb/Breakpoint/BreakpointName.h"
19 #include "lldb/Breakpoint/StoppointCallbackContext.h"
20 #include "lldb/Core/Debugger.h"
21 #include "lldb/Core/StructuredDataImpl.h"
22 #include "lldb/Interpreter/CommandInterpreter.h"
23 #include "lldb/Interpreter/ScriptInterpreter.h"
24 #include "lldb/Target/Target.h"
25 #include "lldb/Target/ThreadSpec.h"
26 #include "lldb/Utility/Stream.h"
27
28 #include "SBBreakpointOptionCommon.h"
29
30 using namespace lldb;
31 using namespace lldb_private;
32
33 namespace lldb
34 {
35 class SBBreakpointNameImpl {
36 public:
SBBreakpointNameImpl(TargetSP target_sp,const char * name)37 SBBreakpointNameImpl(TargetSP target_sp, const char *name) {
38 if (!name || name[0] == '\0')
39 return;
40 m_name.assign(name);
41
42 if (!target_sp)
43 return;
44
45 m_target_wp = target_sp;
46 }
47
48 SBBreakpointNameImpl(SBTarget &sb_target, const char *name);
49 bool operator==(const SBBreakpointNameImpl &rhs);
50 bool operator!=(const SBBreakpointNameImpl &rhs);
51
52 // For now we take a simple approach and only keep the name, and relook up
53 // the location when we need it.
54
GetTarget() const55 TargetSP GetTarget() const {
56 return m_target_wp.lock();
57 }
58
GetName() const59 const char *GetName() const {
60 return m_name.c_str();
61 }
62
IsValid() const63 bool IsValid() const {
64 return !m_name.empty() && m_target_wp.lock();
65 }
66
67 lldb_private::BreakpointName *GetBreakpointName() const;
68
69 private:
70 TargetWP m_target_wp;
71 std::string m_name;
72 };
73
SBBreakpointNameImpl(SBTarget & sb_target,const char * name)74 SBBreakpointNameImpl::SBBreakpointNameImpl(SBTarget &sb_target,
75 const char *name) {
76 if (!name || name[0] == '\0')
77 return;
78 m_name.assign(name);
79
80 if (!sb_target.IsValid())
81 return;
82
83 TargetSP target_sp = sb_target.GetSP();
84 if (!target_sp)
85 return;
86
87 m_target_wp = target_sp;
88 }
89
operator ==(const SBBreakpointNameImpl & rhs)90 bool SBBreakpointNameImpl::operator==(const SBBreakpointNameImpl &rhs) {
91 return m_name == rhs.m_name && m_target_wp.lock() == rhs.m_target_wp.lock();
92 }
93
operator !=(const SBBreakpointNameImpl & rhs)94 bool SBBreakpointNameImpl::operator!=(const SBBreakpointNameImpl &rhs) {
95 return m_name != rhs.m_name || m_target_wp.lock() != rhs.m_target_wp.lock();
96 }
97
GetBreakpointName() const98 lldb_private::BreakpointName *SBBreakpointNameImpl::GetBreakpointName() const {
99 if (!IsValid())
100 return nullptr;
101 TargetSP target_sp = GetTarget();
102 if (!target_sp)
103 return nullptr;
104 Status error;
105 return target_sp->FindBreakpointName(ConstString(m_name), true, error);
106 }
107
108 } // namespace lldb
109
SBBreakpointName()110 SBBreakpointName::SBBreakpointName() {
111 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBreakpointName);
112 }
113
SBBreakpointName(SBTarget & sb_target,const char * name)114 SBBreakpointName::SBBreakpointName(SBTarget &sb_target, const char *name) {
115 LLDB_RECORD_CONSTRUCTOR(SBBreakpointName, (lldb::SBTarget &, const char *),
116 sb_target, name);
117
118 m_impl_up.reset(new SBBreakpointNameImpl(sb_target, name));
119 // Call FindBreakpointName here to make sure the name is valid, reset if not:
120 BreakpointName *bp_name = GetBreakpointName();
121 if (!bp_name)
122 m_impl_up.reset();
123 }
124
SBBreakpointName(SBBreakpoint & sb_bkpt,const char * name)125 SBBreakpointName::SBBreakpointName(SBBreakpoint &sb_bkpt, const char *name) {
126 LLDB_RECORD_CONSTRUCTOR(SBBreakpointName,
127 (lldb::SBBreakpoint &, const char *), sb_bkpt, name);
128
129 if (!sb_bkpt.IsValid()) {
130 m_impl_up.reset();
131 return;
132 }
133 BreakpointSP bkpt_sp = sb_bkpt.GetSP();
134 Target &target = bkpt_sp->GetTarget();
135
136 m_impl_up.reset(new SBBreakpointNameImpl(target.shared_from_this(), name));
137
138 // Call FindBreakpointName here to make sure the name is valid, reset if not:
139 BreakpointName *bp_name = GetBreakpointName();
140 if (!bp_name) {
141 m_impl_up.reset();
142 return;
143 }
144
145 // Now copy over the breakpoint's options:
146 target.ConfigureBreakpointName(*bp_name, *bkpt_sp->GetOptions(),
147 BreakpointName::Permissions());
148 }
149
SBBreakpointName(const SBBreakpointName & rhs)150 SBBreakpointName::SBBreakpointName(const SBBreakpointName &rhs) {
151 LLDB_RECORD_CONSTRUCTOR(SBBreakpointName, (const lldb::SBBreakpointName &),
152 rhs);
153
154 if (!rhs.m_impl_up)
155 return;
156 else
157 m_impl_up.reset(new SBBreakpointNameImpl(rhs.m_impl_up->GetTarget(),
158 rhs.m_impl_up->GetName()));
159 }
160
161 SBBreakpointName::~SBBreakpointName() = default;
162
163 const SBBreakpointName &SBBreakpointName::
operator =(const SBBreakpointName & rhs)164 operator=(const SBBreakpointName &rhs) {
165 LLDB_RECORD_METHOD(
166 const lldb::SBBreakpointName &,
167 SBBreakpointName, operator=,(const lldb::SBBreakpointName &), rhs);
168
169 if (!rhs.m_impl_up) {
170 m_impl_up.reset();
171 return LLDB_RECORD_RESULT(*this);
172 }
173
174 m_impl_up.reset(new SBBreakpointNameImpl(rhs.m_impl_up->GetTarget(),
175 rhs.m_impl_up->GetName()));
176 return LLDB_RECORD_RESULT(*this);
177 }
178
operator ==(const lldb::SBBreakpointName & rhs)179 bool SBBreakpointName::operator==(const lldb::SBBreakpointName &rhs) {
180 LLDB_RECORD_METHOD(
181 bool, SBBreakpointName, operator==,(const lldb::SBBreakpointName &), rhs);
182
183 return *m_impl_up == *rhs.m_impl_up;
184 }
185
operator !=(const lldb::SBBreakpointName & rhs)186 bool SBBreakpointName::operator!=(const lldb::SBBreakpointName &rhs) {
187 LLDB_RECORD_METHOD(
188 bool, SBBreakpointName, operator!=,(const lldb::SBBreakpointName &), rhs);
189
190 return *m_impl_up != *rhs.m_impl_up;
191 }
192
IsValid() const193 bool SBBreakpointName::IsValid() const {
194 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpointName, IsValid);
195 return this->operator bool();
196 }
operator bool() const197 SBBreakpointName::operator bool() const {
198 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpointName, operator bool);
199
200 if (!m_impl_up)
201 return false;
202 return m_impl_up->IsValid();
203 }
204
GetName() const205 const char *SBBreakpointName::GetName() const {
206 LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpointName, GetName);
207
208 if (!m_impl_up)
209 return "<Invalid Breakpoint Name Object>";
210 return m_impl_up->GetName();
211 }
212
SetEnabled(bool enable)213 void SBBreakpointName::SetEnabled(bool enable) {
214 LLDB_RECORD_METHOD(void, SBBreakpointName, SetEnabled, (bool), enable);
215
216 BreakpointName *bp_name = GetBreakpointName();
217 if (!bp_name)
218 return;
219
220 std::lock_guard<std::recursive_mutex> guard(
221 m_impl_up->GetTarget()->GetAPIMutex());
222
223 bp_name->GetOptions().SetEnabled(enable);
224 }
225
UpdateName(BreakpointName & bp_name)226 void SBBreakpointName::UpdateName(BreakpointName &bp_name) {
227 if (!IsValid())
228 return;
229
230 TargetSP target_sp = m_impl_up->GetTarget();
231 if (!target_sp)
232 return;
233 target_sp->ApplyNameToBreakpoints(bp_name);
234
235 }
236
IsEnabled()237 bool SBBreakpointName::IsEnabled() {
238 LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointName, IsEnabled);
239
240 BreakpointName *bp_name = GetBreakpointName();
241 if (!bp_name)
242 return false;
243
244 std::lock_guard<std::recursive_mutex> guard(
245 m_impl_up->GetTarget()->GetAPIMutex());
246
247 return bp_name->GetOptions().IsEnabled();
248 }
249
SetOneShot(bool one_shot)250 void SBBreakpointName::SetOneShot(bool one_shot) {
251 LLDB_RECORD_METHOD(void, SBBreakpointName, SetOneShot, (bool), one_shot);
252
253 BreakpointName *bp_name = GetBreakpointName();
254 if (!bp_name)
255 return;
256
257 std::lock_guard<std::recursive_mutex> guard(
258 m_impl_up->GetTarget()->GetAPIMutex());
259
260 bp_name->GetOptions().SetOneShot(one_shot);
261 UpdateName(*bp_name);
262 }
263
IsOneShot() const264 bool SBBreakpointName::IsOneShot() const {
265 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpointName, IsOneShot);
266
267 const BreakpointName *bp_name = GetBreakpointName();
268 if (!bp_name)
269 return false;
270
271 std::lock_guard<std::recursive_mutex> guard(
272 m_impl_up->GetTarget()->GetAPIMutex());
273
274 return bp_name->GetOptions().IsOneShot();
275 }
276
SetIgnoreCount(uint32_t count)277 void SBBreakpointName::SetIgnoreCount(uint32_t count) {
278 LLDB_RECORD_METHOD(void, SBBreakpointName, SetIgnoreCount, (uint32_t), count);
279
280 BreakpointName *bp_name = GetBreakpointName();
281 if (!bp_name)
282 return;
283
284 std::lock_guard<std::recursive_mutex> guard(
285 m_impl_up->GetTarget()->GetAPIMutex());
286
287 bp_name->GetOptions().SetIgnoreCount(count);
288 UpdateName(*bp_name);
289 }
290
GetIgnoreCount() const291 uint32_t SBBreakpointName::GetIgnoreCount() const {
292 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpointName, GetIgnoreCount);
293
294 BreakpointName *bp_name = GetBreakpointName();
295 if (!bp_name)
296 return false;
297
298 std::lock_guard<std::recursive_mutex> guard(
299 m_impl_up->GetTarget()->GetAPIMutex());
300
301 return bp_name->GetOptions().GetIgnoreCount();
302 }
303
SetCondition(const char * condition)304 void SBBreakpointName::SetCondition(const char *condition) {
305 LLDB_RECORD_METHOD(void, SBBreakpointName, SetCondition, (const char *),
306 condition);
307
308 BreakpointName *bp_name = GetBreakpointName();
309 if (!bp_name)
310 return;
311
312 std::lock_guard<std::recursive_mutex> guard(
313 m_impl_up->GetTarget()->GetAPIMutex());
314
315 bp_name->GetOptions().SetCondition(condition);
316 UpdateName(*bp_name);
317 }
318
GetCondition()319 const char *SBBreakpointName::GetCondition() {
320 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBBreakpointName, GetCondition);
321
322 BreakpointName *bp_name = GetBreakpointName();
323 if (!bp_name)
324 return nullptr;
325
326 std::lock_guard<std::recursive_mutex> guard(
327 m_impl_up->GetTarget()->GetAPIMutex());
328
329 return bp_name->GetOptions().GetConditionText();
330 }
331
SetAutoContinue(bool auto_continue)332 void SBBreakpointName::SetAutoContinue(bool auto_continue) {
333 LLDB_RECORD_METHOD(void, SBBreakpointName, SetAutoContinue, (bool),
334 auto_continue);
335
336 BreakpointName *bp_name = GetBreakpointName();
337 if (!bp_name)
338 return;
339
340 std::lock_guard<std::recursive_mutex> guard(
341 m_impl_up->GetTarget()->GetAPIMutex());
342
343 bp_name->GetOptions().SetAutoContinue(auto_continue);
344 UpdateName(*bp_name);
345 }
346
GetAutoContinue()347 bool SBBreakpointName::GetAutoContinue() {
348 LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointName, GetAutoContinue);
349
350 BreakpointName *bp_name = GetBreakpointName();
351 if (!bp_name)
352 return false;
353
354 std::lock_guard<std::recursive_mutex> guard(
355 m_impl_up->GetTarget()->GetAPIMutex());
356
357 return bp_name->GetOptions().IsAutoContinue();
358 }
359
SetThreadID(tid_t tid)360 void SBBreakpointName::SetThreadID(tid_t tid) {
361 LLDB_RECORD_METHOD(void, SBBreakpointName, SetThreadID, (lldb::tid_t), tid);
362
363 BreakpointName *bp_name = GetBreakpointName();
364 if (!bp_name)
365 return;
366
367 std::lock_guard<std::recursive_mutex> guard(
368 m_impl_up->GetTarget()->GetAPIMutex());
369
370 bp_name->GetOptions().SetThreadID(tid);
371 UpdateName(*bp_name);
372 }
373
GetThreadID()374 tid_t SBBreakpointName::GetThreadID() {
375 LLDB_RECORD_METHOD_NO_ARGS(lldb::tid_t, SBBreakpointName, GetThreadID);
376
377 BreakpointName *bp_name = GetBreakpointName();
378 if (!bp_name)
379 return LLDB_INVALID_THREAD_ID;
380
381 std::lock_guard<std::recursive_mutex> guard(
382 m_impl_up->GetTarget()->GetAPIMutex());
383
384 return bp_name->GetOptions().GetThreadSpec()->GetTID();
385 }
386
SetThreadIndex(uint32_t index)387 void SBBreakpointName::SetThreadIndex(uint32_t index) {
388 LLDB_RECORD_METHOD(void, SBBreakpointName, SetThreadIndex, (uint32_t), index);
389
390 BreakpointName *bp_name = GetBreakpointName();
391 if (!bp_name)
392 return;
393
394 std::lock_guard<std::recursive_mutex> guard(
395 m_impl_up->GetTarget()->GetAPIMutex());
396
397 bp_name->GetOptions().GetThreadSpec()->SetIndex(index);
398 UpdateName(*bp_name);
399 }
400
GetThreadIndex() const401 uint32_t SBBreakpointName::GetThreadIndex() const {
402 LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpointName, GetThreadIndex);
403
404 BreakpointName *bp_name = GetBreakpointName();
405 if (!bp_name)
406 return LLDB_INVALID_THREAD_ID;
407
408 std::lock_guard<std::recursive_mutex> guard(
409 m_impl_up->GetTarget()->GetAPIMutex());
410
411 return bp_name->GetOptions().GetThreadSpec()->GetIndex();
412 }
413
SetThreadName(const char * thread_name)414 void SBBreakpointName::SetThreadName(const char *thread_name) {
415 LLDB_RECORD_METHOD(void, SBBreakpointName, SetThreadName, (const char *),
416 thread_name);
417
418 BreakpointName *bp_name = GetBreakpointName();
419 if (!bp_name)
420 return;
421
422 std::lock_guard<std::recursive_mutex> guard(
423 m_impl_up->GetTarget()->GetAPIMutex());
424
425 bp_name->GetOptions().GetThreadSpec()->SetName(thread_name);
426 UpdateName(*bp_name);
427 }
428
GetThreadName() const429 const char *SBBreakpointName::GetThreadName() const {
430 LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpointName,
431 GetThreadName);
432
433 BreakpointName *bp_name = GetBreakpointName();
434 if (!bp_name)
435 return nullptr;
436
437 std::lock_guard<std::recursive_mutex> guard(
438 m_impl_up->GetTarget()->GetAPIMutex());
439
440 return bp_name->GetOptions().GetThreadSpec()->GetName();
441 }
442
SetQueueName(const char * queue_name)443 void SBBreakpointName::SetQueueName(const char *queue_name) {
444 LLDB_RECORD_METHOD(void, SBBreakpointName, SetQueueName, (const char *),
445 queue_name);
446
447 BreakpointName *bp_name = GetBreakpointName();
448 if (!bp_name)
449 return;
450
451 std::lock_guard<std::recursive_mutex> guard(
452 m_impl_up->GetTarget()->GetAPIMutex());
453
454 bp_name->GetOptions().GetThreadSpec()->SetQueueName(queue_name);
455 UpdateName(*bp_name);
456 }
457
GetQueueName() const458 const char *SBBreakpointName::GetQueueName() const {
459 LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpointName,
460 GetQueueName);
461
462 BreakpointName *bp_name = GetBreakpointName();
463 if (!bp_name)
464 return nullptr;
465
466 std::lock_guard<std::recursive_mutex> guard(
467 m_impl_up->GetTarget()->GetAPIMutex());
468
469 return bp_name->GetOptions().GetThreadSpec()->GetQueueName();
470 }
471
SetCommandLineCommands(SBStringList & commands)472 void SBBreakpointName::SetCommandLineCommands(SBStringList &commands) {
473 LLDB_RECORD_METHOD(void, SBBreakpointName, SetCommandLineCommands,
474 (lldb::SBStringList &), commands);
475
476 BreakpointName *bp_name = GetBreakpointName();
477 if (!bp_name)
478 return;
479 if (commands.GetSize() == 0)
480 return;
481
482
483 std::lock_guard<std::recursive_mutex> guard(
484 m_impl_up->GetTarget()->GetAPIMutex());
485 std::unique_ptr<BreakpointOptions::CommandData> cmd_data_up(
486 new BreakpointOptions::CommandData(*commands, eScriptLanguageNone));
487
488 bp_name->GetOptions().SetCommandDataCallback(cmd_data_up);
489 UpdateName(*bp_name);
490 }
491
GetCommandLineCommands(SBStringList & commands)492 bool SBBreakpointName::GetCommandLineCommands(SBStringList &commands) {
493 LLDB_RECORD_METHOD(bool, SBBreakpointName, GetCommandLineCommands,
494 (lldb::SBStringList &), commands);
495
496 BreakpointName *bp_name = GetBreakpointName();
497 if (!bp_name)
498 return false;
499
500 StringList command_list;
501 bool has_commands =
502 bp_name->GetOptions().GetCommandLineCallbacks(command_list);
503 if (has_commands)
504 commands.AppendList(command_list);
505 return has_commands;
506 }
507
GetHelpString() const508 const char *SBBreakpointName::GetHelpString() const {
509 LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpointName,
510 GetHelpString);
511
512 BreakpointName *bp_name = GetBreakpointName();
513 if (!bp_name)
514 return "";
515
516 return bp_name->GetHelp();
517 }
518
SetHelpString(const char * help_string)519 void SBBreakpointName::SetHelpString(const char *help_string) {
520 LLDB_RECORD_METHOD(void, SBBreakpointName, SetHelpString, (const char *),
521 help_string);
522
523 BreakpointName *bp_name = GetBreakpointName();
524 if (!bp_name)
525 return;
526
527
528 std::lock_guard<std::recursive_mutex> guard(
529 m_impl_up->GetTarget()->GetAPIMutex());
530 bp_name->SetHelp(help_string);
531 }
532
GetDescription(SBStream & s)533 bool SBBreakpointName::GetDescription(SBStream &s) {
534 LLDB_RECORD_METHOD(bool, SBBreakpointName, GetDescription, (lldb::SBStream &),
535 s);
536
537 BreakpointName *bp_name = GetBreakpointName();
538 if (!bp_name)
539 {
540 s.Printf("No value");
541 return false;
542 }
543
544 std::lock_guard<std::recursive_mutex> guard(
545 m_impl_up->GetTarget()->GetAPIMutex());
546 bp_name->GetDescription(s.get(), eDescriptionLevelFull);
547 return true;
548 }
549
SetCallback(SBBreakpointHitCallback callback,void * baton)550 void SBBreakpointName::SetCallback(SBBreakpointHitCallback callback,
551 void *baton) {
552 LLDB_RECORD_DUMMY(void, SBBreakpointName, SetCallback,
553 (lldb::SBBreakpointHitCallback, void *), callback, baton);
554
555 BreakpointName *bp_name = GetBreakpointName();
556 if (!bp_name)
557 return;
558 std::lock_guard<std::recursive_mutex> guard(
559 m_impl_up->GetTarget()->GetAPIMutex());
560
561 BatonSP baton_sp(new SBBreakpointCallbackBaton(callback, baton));
562 bp_name->GetOptions().SetCallback(SBBreakpointCallbackBaton
563 ::PrivateBreakpointHitCallback,
564 baton_sp,
565 false);
566 UpdateName(*bp_name);
567 }
568
SetScriptCallbackFunction(const char * callback_function_name)569 void SBBreakpointName::SetScriptCallbackFunction(
570 const char *callback_function_name) {
571 LLDB_RECORD_METHOD(void, SBBreakpointName, SetScriptCallbackFunction,
572 (const char *), callback_function_name);
573 SBStructuredData empty_args;
574 SetScriptCallbackFunction(callback_function_name, empty_args);
575 }
576
SetScriptCallbackFunction(const char * callback_function_name,SBStructuredData & extra_args)577 SBError SBBreakpointName::SetScriptCallbackFunction(
578 const char *callback_function_name,
579 SBStructuredData &extra_args) {
580 LLDB_RECORD_METHOD(SBError, SBBreakpointName, SetScriptCallbackFunction,
581 (const char *, SBStructuredData &),
582 callback_function_name, extra_args);
583 SBError sb_error;
584 BreakpointName *bp_name = GetBreakpointName();
585 if (!bp_name) {
586 sb_error.SetErrorString("unrecognized breakpoint name");
587 return LLDB_RECORD_RESULT(sb_error);
588 }
589
590 std::lock_guard<std::recursive_mutex> guard(
591 m_impl_up->GetTarget()->GetAPIMutex());
592
593 BreakpointOptions &bp_options = bp_name->GetOptions();
594 Status error;
595 error = m_impl_up->GetTarget()
596 ->GetDebugger()
597 .GetScriptInterpreter()
598 ->SetBreakpointCommandCallbackFunction(&bp_options,
599 callback_function_name,
600 extra_args.m_impl_up
601 ->GetObjectSP());
602 sb_error.SetError(error);
603 UpdateName(*bp_name);
604 return LLDB_RECORD_RESULT(sb_error);
605 }
606
607 SBError
SetScriptCallbackBody(const char * callback_body_text)608 SBBreakpointName::SetScriptCallbackBody(const char *callback_body_text) {
609 LLDB_RECORD_METHOD(lldb::SBError, SBBreakpointName, SetScriptCallbackBody,
610 (const char *), callback_body_text);
611
612 SBError sb_error;
613 BreakpointName *bp_name = GetBreakpointName();
614 if (!bp_name)
615 return LLDB_RECORD_RESULT(sb_error);
616
617 std::lock_guard<std::recursive_mutex> guard(
618 m_impl_up->GetTarget()->GetAPIMutex());
619
620 BreakpointOptions &bp_options = bp_name->GetOptions();
621 Status error =
622 m_impl_up->GetTarget()
623 ->GetDebugger()
624 .GetScriptInterpreter()
625 ->SetBreakpointCommandCallback(&bp_options, callback_body_text);
626 sb_error.SetError(error);
627 if (!sb_error.Fail())
628 UpdateName(*bp_name);
629
630 return LLDB_RECORD_RESULT(sb_error);
631 }
632
GetAllowList() const633 bool SBBreakpointName::GetAllowList() const {
634 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpointName, GetAllowList);
635
636 BreakpointName *bp_name = GetBreakpointName();
637 if (!bp_name)
638 return false;
639 return bp_name->GetPermissions().GetAllowList();
640 }
641
SetAllowList(bool value)642 void SBBreakpointName::SetAllowList(bool value) {
643 LLDB_RECORD_METHOD(void, SBBreakpointName, SetAllowList, (bool), value);
644
645
646 BreakpointName *bp_name = GetBreakpointName();
647 if (!bp_name)
648 return;
649 bp_name->GetPermissions().SetAllowList(value);
650 }
651
GetAllowDelete()652 bool SBBreakpointName::GetAllowDelete() {
653 LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointName, GetAllowDelete);
654
655 BreakpointName *bp_name = GetBreakpointName();
656 if (!bp_name)
657 return false;
658 return bp_name->GetPermissions().GetAllowDelete();
659 }
660
SetAllowDelete(bool value)661 void SBBreakpointName::SetAllowDelete(bool value) {
662 LLDB_RECORD_METHOD(void, SBBreakpointName, SetAllowDelete, (bool), value);
663
664
665 BreakpointName *bp_name = GetBreakpointName();
666 if (!bp_name)
667 return;
668 bp_name->GetPermissions().SetAllowDelete(value);
669 }
670
GetAllowDisable()671 bool SBBreakpointName::GetAllowDisable() {
672 LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointName, GetAllowDisable);
673
674 BreakpointName *bp_name = GetBreakpointName();
675 if (!bp_name)
676 return false;
677 return bp_name->GetPermissions().GetAllowDisable();
678 }
679
SetAllowDisable(bool value)680 void SBBreakpointName::SetAllowDisable(bool value) {
681 LLDB_RECORD_METHOD(void, SBBreakpointName, SetAllowDisable, (bool), value);
682
683 BreakpointName *bp_name = GetBreakpointName();
684 if (!bp_name)
685 return;
686 bp_name->GetPermissions().SetAllowDisable(value);
687 }
688
GetBreakpointName() const689 lldb_private::BreakpointName *SBBreakpointName::GetBreakpointName() const
690 {
691 if (!IsValid())
692 return nullptr;
693 return m_impl_up->GetBreakpointName();
694 }
695
696
697 namespace lldb_private {
698 namespace repro {
699
700 template <>
RegisterMethods(Registry & R)701 void RegisterMethods<SBBreakpointName>(Registry &R) {
702 LLDB_REGISTER_CONSTRUCTOR(SBBreakpointName, ());
703 LLDB_REGISTER_CONSTRUCTOR(SBBreakpointName,
704 (lldb::SBTarget &, const char *));
705 LLDB_REGISTER_CONSTRUCTOR(SBBreakpointName,
706 (lldb::SBBreakpoint &, const char *));
707 LLDB_REGISTER_CONSTRUCTOR(SBBreakpointName,
708 (const lldb::SBBreakpointName &));
709 LLDB_REGISTER_METHOD(
710 const lldb::SBBreakpointName &,
711 SBBreakpointName, operator=,(const lldb::SBBreakpointName &));
712 LLDB_REGISTER_METHOD(
713 bool, SBBreakpointName, operator==,(const lldb::SBBreakpointName &));
714 LLDB_REGISTER_METHOD(
715 bool, SBBreakpointName, operator!=,(const lldb::SBBreakpointName &));
716 LLDB_REGISTER_METHOD_CONST(bool, SBBreakpointName, IsValid, ());
717 LLDB_REGISTER_METHOD_CONST(bool, SBBreakpointName, operator bool, ());
718 LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpointName, GetName, ());
719 LLDB_REGISTER_METHOD(void, SBBreakpointName, SetEnabled, (bool));
720 LLDB_REGISTER_METHOD(bool, SBBreakpointName, IsEnabled, ());
721 LLDB_REGISTER_METHOD(void, SBBreakpointName, SetOneShot, (bool));
722 LLDB_REGISTER_METHOD_CONST(bool, SBBreakpointName, IsOneShot, ());
723 LLDB_REGISTER_METHOD(void, SBBreakpointName, SetIgnoreCount, (uint32_t));
724 LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpointName, GetIgnoreCount, ());
725 LLDB_REGISTER_METHOD(void, SBBreakpointName, SetCondition, (const char *));
726 LLDB_REGISTER_METHOD(const char *, SBBreakpointName, GetCondition, ());
727 LLDB_REGISTER_METHOD(void, SBBreakpointName, SetAutoContinue, (bool));
728 LLDB_REGISTER_METHOD(bool, SBBreakpointName, GetAutoContinue, ());
729 LLDB_REGISTER_METHOD(void, SBBreakpointName, SetThreadID, (lldb::tid_t));
730 LLDB_REGISTER_METHOD(lldb::tid_t, SBBreakpointName, GetThreadID, ());
731 LLDB_REGISTER_METHOD(void, SBBreakpointName, SetThreadIndex, (uint32_t));
732 LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpointName, GetThreadIndex, ());
733 LLDB_REGISTER_METHOD(void, SBBreakpointName, SetThreadName, (const char *));
734 LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpointName, GetThreadName,
735 ());
736 LLDB_REGISTER_METHOD(void, SBBreakpointName, SetQueueName, (const char *));
737 LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpointName, GetQueueName,
738 ());
739 LLDB_REGISTER_METHOD(void, SBBreakpointName, SetCommandLineCommands,
740 (lldb::SBStringList &));
741 LLDB_REGISTER_METHOD(bool, SBBreakpointName, GetCommandLineCommands,
742 (lldb::SBStringList &));
743 LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpointName, GetHelpString,
744 ());
745 LLDB_REGISTER_METHOD(void, SBBreakpointName, SetHelpString, (const char *));
746 LLDB_REGISTER_METHOD(bool, SBBreakpointName, GetDescription,
747 (lldb::SBStream &));
748 LLDB_REGISTER_METHOD(void, SBBreakpointName, SetScriptCallbackFunction,
749 (const char *));
750 LLDB_REGISTER_METHOD(SBError, SBBreakpointName, SetScriptCallbackFunction,
751 (const char *, SBStructuredData &));
752 LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpointName, SetScriptCallbackBody,
753 (const char *));
754 LLDB_REGISTER_METHOD_CONST(bool, SBBreakpointName, GetAllowList, ());
755 LLDB_REGISTER_METHOD(void, SBBreakpointName, SetAllowList, (bool));
756 LLDB_REGISTER_METHOD(bool, SBBreakpointName, GetAllowDelete, ());
757 LLDB_REGISTER_METHOD(void, SBBreakpointName, SetAllowDelete, (bool));
758 LLDB_REGISTER_METHOD(bool, SBBreakpointName, GetAllowDisable, ());
759 LLDB_REGISTER_METHOD(void, SBBreakpointName, SetAllowDisable, (bool));
760 }
761
762 }
763 }
764