1//===-- BreakpointLocation.cpp --------------------------------------------===//
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/Breakpoint/BreakpointLocation.h"
10#include "lldb/Breakpoint/BreakpointID.h"
11#include "lldb/Breakpoint/StoppointCallbackContext.h"
12#include "lldb/Core/Debugger.h"
13#include "lldb/Core/Module.h"
14#include "lldb/Core/ValueObject.h"
15#include "lldb/Expression/DiagnosticManager.h"
16#include "lldb/Expression/ExpressionVariable.h"
17#include "lldb/Expression/UserExpression.h"
18#include "lldb/Symbol/CompileUnit.h"
19#include "lldb/Symbol/Symbol.h"
20#include "lldb/Symbol/TypeSystem.h"
21#include "lldb/Target/Process.h"
22#include "lldb/Target/Target.h"
23#include "lldb/Target/Thread.h"
24#include "lldb/Target/ThreadSpec.h"
25#include "lldb/Utility/LLDBLog.h"
26#include "lldb/Utility/Log.h"
27#include "lldb/Utility/StreamString.h"
28
29using namespace lldb;
30using namespace lldb_private;
31
32BreakpointLocation::BreakpointLocation(break_id_t loc_id, Breakpoint &owner,
33 const Address &addr, lldb::tid_t tid,
34 bool hardware, bool check_for_resolver)
35 : m_should_resolve_indirect_functions(false), m_is_reexported(false),
36 m_is_indirect(false), m_address(addr), m_owner(owner),
37 m_condition_hash(0), m_loc_id(loc_id), m_hit_counter() {
38 if (check_for_resolver) {
39 Symbol *symbol = m_address.CalculateSymbolContextSymbol();
40 if (symbol && symbol->IsIndirect()) {
41 SetShouldResolveIndirectFunctions(true);
42 }
43 }
44
45 SetThreadIDInternal(tid);
46}
47
48BreakpointLocation::~BreakpointLocation() { ClearBreakpointSite(); }
49
50lldb::addr_t BreakpointLocation::GetLoadAddress() const {
51 return m_address.GetOpcodeLoadAddress(target: &m_owner.GetTarget());
52}
53
54const BreakpointOptions &BreakpointLocation::GetOptionsSpecifyingKind(
55 BreakpointOptions::OptionKind kind) const {
56 if (m_options_up && m_options_up->IsOptionSet(kind))
57 return *m_options_up;
58 else
59 return m_owner.GetOptions();
60}
61
62Address &BreakpointLocation::GetAddress() { return m_address; }
63
64Breakpoint &BreakpointLocation::GetBreakpoint() { return m_owner; }
65
66Target &BreakpointLocation::GetTarget() { return m_owner.GetTarget(); }
67
68bool BreakpointLocation::IsEnabled() const {
69 if (!m_owner.IsEnabled())
70 return false;
71 else if (m_options_up != nullptr)
72 return m_options_up->IsEnabled();
73 else
74 return true;
75}
76
77void BreakpointLocation::SetEnabled(bool enabled) {
78 GetLocationOptions().SetEnabled(enabled);
79 if (enabled) {
80 ResolveBreakpointSite();
81 } else {
82 ClearBreakpointSite();
83 }
84 SendBreakpointLocationChangedEvent(eventKind: enabled ? eBreakpointEventTypeEnabled
85 : eBreakpointEventTypeDisabled);
86}
87
88bool BreakpointLocation::IsAutoContinue() const {
89 if (m_options_up &&
90 m_options_up->IsOptionSet(kind: BreakpointOptions::eAutoContinue))
91 return m_options_up->IsAutoContinue();
92 else
93 return m_owner.IsAutoContinue();
94}
95
96void BreakpointLocation::SetAutoContinue(bool auto_continue) {
97 GetLocationOptions().SetAutoContinue(auto_continue);
98 SendBreakpointLocationChangedEvent(eventKind: eBreakpointEventTypeAutoContinueChanged);
99}
100
101void BreakpointLocation::SetThreadID(lldb::tid_t thread_id) {
102 SetThreadIDInternal(thread_id);
103 SendBreakpointLocationChangedEvent(eventKind: eBreakpointEventTypeThreadChanged);
104}
105
106lldb::tid_t BreakpointLocation::GetThreadID() {
107 const ThreadSpec *thread_spec =
108 GetOptionsSpecifyingKind(kind: BreakpointOptions::eThreadSpec)
109 .GetThreadSpecNoCreate();
110 if (thread_spec)
111 return thread_spec->GetTID();
112 else
113 return LLDB_INVALID_THREAD_ID;
114}
115
116void BreakpointLocation::SetThreadIndex(uint32_t index) {
117 if (index != 0)
118 GetLocationOptions().GetThreadSpec()->SetIndex(index);
119 else {
120 // If we're resetting this to an invalid thread id, then don't make an
121 // options pointer just to do that.
122 if (m_options_up != nullptr)
123 m_options_up->GetThreadSpec()->SetIndex(index);
124 }
125 SendBreakpointLocationChangedEvent(eventKind: eBreakpointEventTypeThreadChanged);
126}
127
128uint32_t BreakpointLocation::GetThreadIndex() const {
129 const ThreadSpec *thread_spec =
130 GetOptionsSpecifyingKind(kind: BreakpointOptions::eThreadSpec)
131 .GetThreadSpecNoCreate();
132 if (thread_spec)
133 return thread_spec->GetIndex();
134 else
135 return 0;
136}
137
138void BreakpointLocation::SetThreadName(const char *thread_name) {
139 if (thread_name != nullptr)
140 GetLocationOptions().GetThreadSpec()->SetName(thread_name);
141 else {
142 // If we're resetting this to an invalid thread id, then don't make an
143 // options pointer just to do that.
144 if (m_options_up != nullptr)
145 m_options_up->GetThreadSpec()->SetName(thread_name);
146 }
147 SendBreakpointLocationChangedEvent(eventKind: eBreakpointEventTypeThreadChanged);
148}
149
150const char *BreakpointLocation::GetThreadName() const {
151 const ThreadSpec *thread_spec =
152 GetOptionsSpecifyingKind(kind: BreakpointOptions::eThreadSpec)
153 .GetThreadSpecNoCreate();
154 if (thread_spec)
155 return thread_spec->GetName();
156 else
157 return nullptr;
158}
159
160void BreakpointLocation::SetQueueName(const char *queue_name) {
161 if (queue_name != nullptr)
162 GetLocationOptions().GetThreadSpec()->SetQueueName(queue_name);
163 else {
164 // If we're resetting this to an invalid thread id, then don't make an
165 // options pointer just to do that.
166 if (m_options_up != nullptr)
167 m_options_up->GetThreadSpec()->SetQueueName(queue_name);
168 }
169 SendBreakpointLocationChangedEvent(eventKind: eBreakpointEventTypeThreadChanged);
170}
171
172const char *BreakpointLocation::GetQueueName() const {
173 const ThreadSpec *thread_spec =
174 GetOptionsSpecifyingKind(kind: BreakpointOptions::eThreadSpec)
175 .GetThreadSpecNoCreate();
176 if (thread_spec)
177 return thread_spec->GetQueueName();
178 else
179 return nullptr;
180}
181
182bool BreakpointLocation::InvokeCallback(StoppointCallbackContext *context) {
183 if (m_options_up != nullptr && m_options_up->HasCallback())
184 return m_options_up->InvokeCallback(context, break_id: m_owner.GetID(), break_loc_id: GetID());
185 else
186 return m_owner.InvokeCallback(context, bp_loc_id: GetID());
187}
188
189bool BreakpointLocation::IsCallbackSynchronous() {
190 if (m_options_up != nullptr && m_options_up->HasCallback())
191 return m_options_up->IsCallbackSynchronous();
192 else
193 return m_owner.GetOptions().IsCallbackSynchronous();
194}
195
196void BreakpointLocation::SetCallback(BreakpointHitCallback callback,
197 void *baton, bool is_synchronous) {
198 // The default "Baton" class will keep a copy of "baton" and won't free or
199 // delete it when it goes out of scope.
200 GetLocationOptions().SetCallback(
201 callback, baton_sp: std::make_shared<UntypedBaton>(args&: baton), synchronous: is_synchronous);
202 SendBreakpointLocationChangedEvent(eventKind: eBreakpointEventTypeCommandChanged);
203}
204
205void BreakpointLocation::SetCallback(BreakpointHitCallback callback,
206 const BatonSP &baton_sp,
207 bool is_synchronous) {
208 GetLocationOptions().SetCallback(callback, baton_sp, synchronous: is_synchronous);
209 SendBreakpointLocationChangedEvent(eventKind: eBreakpointEventTypeCommandChanged);
210}
211
212void BreakpointLocation::ClearCallback() {
213 GetLocationOptions().ClearCallback();
214}
215
216void BreakpointLocation::SetCondition(const char *condition) {
217 GetLocationOptions().SetCondition(condition);
218 SendBreakpointLocationChangedEvent(eventKind: eBreakpointEventTypeConditionChanged);
219}
220
221const char *BreakpointLocation::GetConditionText(size_t *hash) const {
222 return GetOptionsSpecifyingKind(kind: BreakpointOptions::eCondition)
223 .GetConditionText(hash);
224}
225
226bool BreakpointLocation::ConditionSaysStop(ExecutionContext &exe_ctx,
227 Status &error) {
228 Log *log = GetLog(mask: LLDBLog::Breakpoints);
229
230 std::lock_guard<std::mutex> guard(m_condition_mutex);
231
232 size_t condition_hash;
233 const char *condition_text = GetConditionText(hash: &condition_hash);
234
235 if (!condition_text) {
236 m_user_expression_sp.reset();
237 return false;
238 }
239
240 error.Clear();
241
242 DiagnosticManager diagnostics;
243
244 if (condition_hash != m_condition_hash || !m_user_expression_sp ||
245 !m_user_expression_sp->IsParseCacheable() ||
246 !m_user_expression_sp->MatchesContext(exe_ctx)) {
247 LanguageType language = eLanguageTypeUnknown;
248 // See if we can figure out the language from the frame, otherwise use the
249 // default language:
250 CompileUnit *comp_unit = m_address.CalculateSymbolContextCompileUnit();
251 if (comp_unit)
252 language = comp_unit->GetLanguage();
253
254 m_user_expression_sp.reset(p: GetTarget().GetUserExpressionForLanguage(
255 expr: condition_text, prefix: llvm::StringRef(), language, desired_type: Expression::eResultTypeAny,
256 options: EvaluateExpressionOptions(), ctx_obj: nullptr, error));
257 if (error.Fail()) {
258 LLDB_LOGF(log, "Error getting condition expression: %s.",
259 error.AsCString());
260 m_user_expression_sp.reset();
261 return true;
262 }
263
264 if (!m_user_expression_sp->Parse(diagnostic_manager&: diagnostics, exe_ctx,
265 execution_policy: eExecutionPolicyOnlyWhenNeeded, keep_result_in_memory: true,
266 generate_debug_info: false)) {
267 error.SetErrorStringWithFormat(
268 "Couldn't parse conditional expression:\n%s",
269 diagnostics.GetString().c_str());
270 m_user_expression_sp.reset();
271 return true;
272 }
273
274 m_condition_hash = condition_hash;
275 }
276
277 // We need to make sure the user sees any parse errors in their condition, so
278 // we'll hook the constructor errors up to the debugger's Async I/O.
279
280 ValueObjectSP result_value_sp;
281
282 EvaluateExpressionOptions options;
283 options.SetUnwindOnError(true);
284 options.SetIgnoreBreakpoints(true);
285 options.SetTryAllThreads(true);
286 options.SetSuppressPersistentResult(
287 true); // Don't generate a user variable for condition expressions.
288
289 Status expr_error;
290
291 diagnostics.Clear();
292
293 ExpressionVariableSP result_variable_sp;
294
295 ExpressionResults result_code = m_user_expression_sp->Execute(
296 diagnostic_manager&: diagnostics, exe_ctx, options, shared_ptr_to_me&: m_user_expression_sp, result&: result_variable_sp);
297
298 bool ret;
299
300 if (result_code == eExpressionCompleted) {
301 if (!result_variable_sp) {
302 error.SetErrorString("Expression did not return a result");
303 return false;
304 }
305
306 result_value_sp = result_variable_sp->GetValueObject();
307
308 if (result_value_sp) {
309 ret = result_value_sp->IsLogicalTrue(error);
310 if (log) {
311 if (error.Success()) {
312 LLDB_LOGF(log, "Condition successfully evaluated, result is %s.\n",
313 ret ? "true" : "false");
314 } else {
315 error.SetErrorString(
316 "Failed to get an integer result from the expression");
317 ret = false;
318 }
319 }
320 } else {
321 ret = false;
322 error.SetErrorString("Failed to get any result from the expression");
323 }
324 } else {
325 ret = false;
326 error.SetErrorStringWithFormat("Couldn't execute expression:\n%s",
327 diagnostics.GetString().c_str());
328 }
329
330 return ret;
331}
332
333uint32_t BreakpointLocation::GetIgnoreCount() const {
334 return GetOptionsSpecifyingKind(kind: BreakpointOptions::eIgnoreCount)
335 .GetIgnoreCount();
336}
337
338void BreakpointLocation::SetIgnoreCount(uint32_t n) {
339 GetLocationOptions().SetIgnoreCount(n);
340 SendBreakpointLocationChangedEvent(eventKind: eBreakpointEventTypeIgnoreChanged);
341}
342
343void BreakpointLocation::DecrementIgnoreCount() {
344 if (m_options_up != nullptr) {
345 uint32_t loc_ignore = m_options_up->GetIgnoreCount();
346 if (loc_ignore != 0)
347 m_options_up->SetIgnoreCount(loc_ignore - 1);
348 }
349}
350
351bool BreakpointLocation::IgnoreCountShouldStop() {
352 uint32_t owner_ignore = GetBreakpoint().GetIgnoreCount();
353 uint32_t loc_ignore = 0;
354 if (m_options_up != nullptr)
355 loc_ignore = m_options_up->GetIgnoreCount();
356
357 if (loc_ignore != 0 || owner_ignore != 0) {
358 m_owner.DecrementIgnoreCount();
359 DecrementIgnoreCount(); // Have to decrement our owners' ignore count,
360 // since it won't get a chance to.
361 return false;
362 }
363 return true;
364}
365
366BreakpointOptions &BreakpointLocation::GetLocationOptions() {
367 // If we make the copy we don't copy the callbacks because that is
368 // potentially expensive and we don't want to do that for the simple case
369 // where someone is just disabling the location.
370 if (m_options_up == nullptr)
371 m_options_up = std::make_unique<BreakpointOptions>(args: false);
372
373 return *m_options_up;
374}
375
376bool BreakpointLocation::ValidForThisThread(Thread &thread) {
377 return thread.MatchesSpec(
378 spec: GetOptionsSpecifyingKind(kind: BreakpointOptions::eThreadSpec)
379 .GetThreadSpecNoCreate());
380}
381
382// RETURNS - true if we should stop at this breakpoint, false if we
383// should continue. Note, we don't check the thread spec for the breakpoint
384// here, since if the breakpoint is not for this thread, then the event won't
385// even get reported, so the check is redundant.
386
387bool BreakpointLocation::ShouldStop(StoppointCallbackContext *context) {
388 bool should_stop = true;
389 Log *log = GetLog(mask: LLDBLog::Breakpoints);
390
391 // Do this first, if a location is disabled, it shouldn't increment its hit
392 // count.
393 if (!IsEnabled())
394 return false;
395
396 // We only run synchronous callbacks in ShouldStop:
397 context->is_synchronous = true;
398 should_stop = InvokeCallback(context);
399
400 if (log) {
401 StreamString s;
402 GetDescription(s: &s, level: lldb::eDescriptionLevelVerbose);
403 LLDB_LOGF(log, "Hit breakpoint location: %s, %s.\n", s.GetData(),
404 should_stop ? "stopping" : "continuing");
405 }
406
407 return should_stop;
408}
409
410void BreakpointLocation::BumpHitCount() {
411 if (IsEnabled()) {
412 // Step our hit count, and also step the hit count of the owner.
413 m_hit_counter.Increment();
414 m_owner.m_hit_counter.Increment();
415 }
416}
417
418void BreakpointLocation::UndoBumpHitCount() {
419 if (IsEnabled()) {
420 // Step our hit count, and also step the hit count of the owner.
421 m_hit_counter.Decrement();
422 m_owner.m_hit_counter.Decrement();
423 }
424}
425
426bool BreakpointLocation::IsResolved() const {
427 return m_bp_site_sp.get() != nullptr;
428}
429
430lldb::BreakpointSiteSP BreakpointLocation::GetBreakpointSite() const {
431 return m_bp_site_sp;
432}
433
434bool BreakpointLocation::ResolveBreakpointSite() {
435 if (m_bp_site_sp)
436 return true;
437
438 Process *process = m_owner.GetTarget().GetProcessSP().get();
439 if (process == nullptr)
440 return false;
441
442 lldb::break_id_t new_id =
443 process->CreateBreakpointSite(owner: shared_from_this(), use_hardware: m_owner.IsHardware());
444
445 if (new_id == LLDB_INVALID_BREAK_ID) {
446 Log *log = GetLog(mask: LLDBLog::Breakpoints);
447 if (log)
448 log->Warning(fmt: "Failed to add breakpoint site at 0x%" PRIx64,
449 m_address.GetOpcodeLoadAddress(target: &m_owner.GetTarget()));
450 }
451
452 return IsResolved();
453}
454
455bool BreakpointLocation::SetBreakpointSite(BreakpointSiteSP &bp_site_sp) {
456 m_bp_site_sp = bp_site_sp;
457 SendBreakpointLocationChangedEvent(eventKind: eBreakpointEventTypeLocationsResolved);
458 return true;
459}
460
461bool BreakpointLocation::ClearBreakpointSite() {
462 if (m_bp_site_sp.get()) {
463 ProcessSP process_sp(m_owner.GetTarget().GetProcessSP());
464 // If the process exists, get it to remove the owner, it will remove the
465 // physical implementation of the breakpoint as well if there are no more
466 // owners. Otherwise just remove this owner.
467 if (process_sp)
468 process_sp->RemoveConstituentFromBreakpointSite(site_id: GetBreakpoint().GetID(),
469 constituent_id: GetID(), bp_site_sp&: m_bp_site_sp);
470 else
471 m_bp_site_sp->RemoveConstituent(break_id: GetBreakpoint().GetID(), break_loc_id: GetID());
472
473 m_bp_site_sp.reset();
474 return true;
475 }
476 return false;
477}
478
479void BreakpointLocation::GetDescription(Stream *s,
480 lldb::DescriptionLevel level) {
481 SymbolContext sc;
482
483 // If the description level is "initial" then the breakpoint is printing out
484 // our initial state, and we should let it decide how it wants to print our
485 // label.
486 if (level != eDescriptionLevelInitial) {
487 s->Indent();
488 BreakpointID::GetCanonicalReference(s, break_id: m_owner.GetID(), break_loc_id: GetID());
489 }
490
491 if (level == lldb::eDescriptionLevelBrief)
492 return;
493
494 if (level != eDescriptionLevelInitial)
495 s->PutCString(cstr: ": ");
496
497 if (level == lldb::eDescriptionLevelVerbose)
498 s->IndentMore();
499
500 if (m_address.IsSectionOffset()) {
501 m_address.CalculateSymbolContext(sc: &sc);
502
503 if (level == lldb::eDescriptionLevelFull ||
504 level == eDescriptionLevelInitial) {
505 if (IsReExported())
506 s->PutCString(cstr: "re-exported target = ");
507 else
508 s->PutCString(cstr: "where = ");
509 sc.DumpStopContext(s, exe_scope: m_owner.GetTarget().GetProcessSP().get(), so_addr: m_address,
510 show_fullpaths: false, show_module: true, show_inlined_frames: false, show_function_arguments: true, show_function_name: true);
511 } else {
512 if (sc.module_sp) {
513 s->EOL();
514 s->Indent(s: "module = ");
515 sc.module_sp->GetFileSpec().Dump(s&: s->AsRawOstream());
516 }
517
518 if (sc.comp_unit != nullptr) {
519 s->EOL();
520 s->Indent(s: "compile unit = ");
521 sc.comp_unit->GetPrimaryFile().GetFilename().Dump(s);
522
523 if (sc.function != nullptr) {
524 s->EOL();
525 s->Indent(s: "function = ");
526 s->PutCString(cstr: sc.function->GetName().AsCString(value_if_empty: "<unknown>"));
527 }
528
529 if (sc.line_entry.line > 0) {
530 s->EOL();
531 s->Indent(s: "location = ");
532 sc.line_entry.DumpStopContext(s, show_fullpaths: true);
533 }
534
535 } else {
536 // If we don't have a comp unit, see if we have a symbol we can print.
537 if (sc.symbol) {
538 s->EOL();
539 if (IsReExported())
540 s->Indent(s: "re-exported target = ");
541 else
542 s->Indent(s: "symbol = ");
543 s->PutCString(cstr: sc.symbol->GetName().AsCString(value_if_empty: "<unknown>"));
544 }
545 }
546 }
547 }
548
549 if (level == lldb::eDescriptionLevelVerbose) {
550 s->EOL();
551 s->Indent();
552 }
553
554 if (m_address.IsSectionOffset() &&
555 (level == eDescriptionLevelFull || level == eDescriptionLevelInitial))
556 s->Printf(format: ", ");
557 s->Printf(format: "address = ");
558
559 ExecutionContextScope *exe_scope = nullptr;
560 Target *target = &m_owner.GetTarget();
561 if (target)
562 exe_scope = target->GetProcessSP().get();
563 if (exe_scope == nullptr)
564 exe_scope = target;
565
566 if (level == eDescriptionLevelInitial)
567 m_address.Dump(s, exe_scope, style: Address::DumpStyleLoadAddress,
568 fallback_style: Address::DumpStyleFileAddress);
569 else
570 m_address.Dump(s, exe_scope, style: Address::DumpStyleLoadAddress,
571 fallback_style: Address::DumpStyleModuleWithFileAddress);
572
573 if (IsIndirect() && m_bp_site_sp) {
574 Address resolved_address;
575 resolved_address.SetLoadAddress(load_addr: m_bp_site_sp->GetLoadAddress(), target);
576 Symbol *resolved_symbol = resolved_address.CalculateSymbolContextSymbol();
577 if (resolved_symbol) {
578 if (level == eDescriptionLevelFull || level == eDescriptionLevelInitial)
579 s->Printf(format: ", ");
580 else if (level == lldb::eDescriptionLevelVerbose) {
581 s->EOL();
582 s->Indent();
583 }
584 s->Printf(format: "indirect target = %s",
585 resolved_symbol->GetName().GetCString());
586 }
587 }
588
589 bool is_resolved = IsResolved();
590 bool is_hardware = is_resolved && m_bp_site_sp->IsHardware();
591
592 if (level == lldb::eDescriptionLevelVerbose) {
593 s->EOL();
594 s->Indent();
595 s->Printf(format: "resolved = %s\n", is_resolved ? "true" : "false");
596 s->Indent();
597 s->Printf(format: "hardware = %s\n", is_hardware ? "true" : "false");
598 s->Indent();
599 s->Printf(format: "hit count = %-4u\n", GetHitCount());
600
601 if (m_options_up) {
602 s->Indent();
603 m_options_up->GetDescription(s, level);
604 s->EOL();
605 }
606 s->IndentLess();
607 } else if (level != eDescriptionLevelInitial) {
608 s->Printf(format: ", %sresolved, %shit count = %u ", (is_resolved ? "" : "un"),
609 (is_hardware ? "hardware, " : ""), GetHitCount());
610 if (m_options_up) {
611 m_options_up->GetDescription(s, level);
612 }
613 }
614}
615
616void BreakpointLocation::Dump(Stream *s) const {
617 if (s == nullptr)
618 return;
619
620 bool is_resolved = IsResolved();
621 bool is_hardware = is_resolved && m_bp_site_sp->IsHardware();
622
623 lldb::tid_t tid = GetOptionsSpecifyingKind(kind: BreakpointOptions::eThreadSpec)
624 .GetThreadSpecNoCreate()
625 ->GetTID();
626 s->Printf(format: "BreakpointLocation %u: tid = %4.4" PRIx64
627 " load addr = 0x%8.8" PRIx64 " state = %s type = %s breakpoint "
628 "hit_count = %-4u ignore_count = %-4u",
629 GetID(), tid,
630 (uint64_t)m_address.GetOpcodeLoadAddress(target: &m_owner.GetTarget()),
631 (m_options_up ? m_options_up->IsEnabled() : m_owner.IsEnabled())
632 ? "enabled "
633 : "disabled",
634 is_hardware ? "hardware" : "software", GetHitCount(),
635 GetOptionsSpecifyingKind(kind: BreakpointOptions::eIgnoreCount)
636 .GetIgnoreCount());
637}
638
639void BreakpointLocation::SendBreakpointLocationChangedEvent(
640 lldb::BreakpointEventType eventKind) {
641 if (!m_owner.IsInternal() && m_owner.GetTarget().EventTypeHasListeners(
642 event_type: Target::eBroadcastBitBreakpointChanged)) {
643 auto data_sp = std::make_shared<Breakpoint::BreakpointEventData>(
644 args&: eventKind, args: m_owner.shared_from_this());
645 data_sp->GetBreakpointLocationCollection().Add(bp_loc_sp: shared_from_this());
646 m_owner.GetTarget().BroadcastEvent(event_type: Target::eBroadcastBitBreakpointChanged,
647 event_data_sp: data_sp);
648 }
649}
650
651void BreakpointLocation::SwapLocation(BreakpointLocationSP swap_from) {
652 m_address = swap_from->m_address;
653 m_should_resolve_indirect_functions =
654 swap_from->m_should_resolve_indirect_functions;
655 m_is_reexported = swap_from->m_is_reexported;
656 m_is_indirect = swap_from->m_is_indirect;
657 m_user_expression_sp.reset();
658}
659
660void BreakpointLocation::SetThreadIDInternal(lldb::tid_t thread_id) {
661 if (thread_id != LLDB_INVALID_THREAD_ID)
662 GetLocationOptions().SetThreadID(thread_id);
663 else {
664 // If we're resetting this to an invalid thread id, then don't make an
665 // options pointer just to do that.
666 if (m_options_up != nullptr)
667 m_options_up->SetThreadID(thread_id);
668 }
669}
670

source code of lldb/source/Breakpoint/BreakpointLocation.cpp