LLDB mainline
BreakpointLocation.cpp
Go to the documentation of this file.
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
14#include "lldb/Core/Debugger.h"
15#include "lldb/Core/Module.h"
20#include "lldb/Symbol/Symbol.h"
22#include "lldb/Target/Process.h"
23#include "lldb/Target/Target.h"
24#include "lldb/Target/Thread.h"
27#include "lldb/Utility/Log.h"
30
31using namespace lldb;
32using namespace lldb_private;
33
35 const Address &addr, lldb::tid_t tid,
36 bool check_for_resolver)
37 : m_should_resolve_indirect_functions(false), m_is_reexported(false),
38 m_is_indirect(false), m_address(addr), m_owner(owner),
39 m_condition_hash(0), m_loc_id(loc_id), m_hit_counter() {
40 if (check_for_resolver) {
41 Symbol *symbol = m_address.CalculateSymbolContextSymbol();
42 if (symbol && symbol->IsIndirect()) {
43 SetShouldResolveIndirectFunctions(true);
44 }
45 }
46
47 SetThreadIDInternal(tid);
48}
49
51 : m_should_resolve_indirect_functions(false), m_is_reexported(false),
52 m_is_indirect(false), m_address(LLDB_INVALID_ADDRESS), m_owner(owner),
53 m_condition_hash(0), m_loc_id(loc_id), m_hit_counter() {
54 SetThreadIDInternal(LLDB_INVALID_THREAD_ID);
55}
56
60
62 return m_address.GetOpcodeLoadAddress(&m_owner.GetTarget());
63}
64
67 if (m_options_up && m_options_up->IsOptionSet(kind))
68 return *m_options_up;
69 return m_owner.GetOptions();
70}
71
73
75
77
79 if (!m_owner.IsEnabled())
80 return false;
81 if (m_options_up != nullptr)
82 return m_options_up->IsEnabled();
83 return true;
84}
85
86llvm::Error BreakpointLocation::SetEnabled(bool enabled) {
88 llvm::Error error = enabled ? ResolveBreakpointSite() : ClearBreakpointSite();
89 SendBreakpointLocationChangedEvent(enabled ? eBreakpointEventTypeEnabled
90 : eBreakpointEventTypeDisabled);
91 return error;
92}
93
95 if (m_options_up &&
97 return m_options_up->IsAutoContinue();
98 return m_owner.IsAutoContinue();
99}
100
101void BreakpointLocation::SetAutoContinue(bool auto_continue) {
102 GetLocationOptions().SetAutoContinue(auto_continue);
103 SendBreakpointLocationChangedEvent(eBreakpointEventTypeAutoContinueChanged);
104}
105
107 SetThreadIDInternal(thread_id);
108 SendBreakpointLocationChangedEvent(eBreakpointEventTypeThreadChanged);
109}
110
112 const ThreadSpec *thread_spec =
115 if (thread_spec)
116 return thread_spec->GetTID();
118}
119
121 if (index != 0)
123 else {
124 // If we're resetting this to an invalid thread id, then don't make an
125 // options pointer just to do that.
126 if (m_options_up != nullptr)
127 m_options_up->GetThreadSpec()->SetIndex(index);
128 }
129 SendBreakpointLocationChangedEvent(eBreakpointEventTypeThreadChanged);
130}
131
133 const ThreadSpec *thread_spec =
136 if (thread_spec)
137 return thread_spec->GetIndex();
138 return 0;
139}
140
141void BreakpointLocation::SetThreadName(const char *thread_name) {
142 if (thread_name != nullptr)
143 GetLocationOptions().GetThreadSpec()->SetName(thread_name);
144 else {
145 // If we're resetting this to an invalid thread id, then don't make an
146 // options pointer just to do that.
147 if (m_options_up != nullptr)
148 m_options_up->GetThreadSpec()->SetName(thread_name);
149 }
150 SendBreakpointLocationChangedEvent(eBreakpointEventTypeThreadChanged);
151}
152
154 const ThreadSpec *thread_spec =
157 if (thread_spec)
158 return thread_spec->GetName();
159 return nullptr;
160}
161
162void BreakpointLocation::SetQueueName(const char *queue_name) {
163 if (queue_name != nullptr)
165 else {
166 // If we're resetting this to an invalid thread id, then don't make an
167 // options pointer just to do that.
168 if (m_options_up != nullptr)
169 m_options_up->GetThreadSpec()->SetQueueName(queue_name);
170 }
171 SendBreakpointLocationChangedEvent(eBreakpointEventTypeThreadChanged);
172}
173
175 const ThreadSpec *thread_spec =
178 if (thread_spec)
179 return thread_spec->GetQueueName();
180 return nullptr;
181}
182
184 if (m_options_up != nullptr && m_options_up->HasCallback())
185 return m_options_up->InvokeCallback(context, m_owner.GetID(), GetID());
186 return m_owner.InvokeCallback(context, GetID());
187}
188
190 if (m_options_up != nullptr && m_options_up->HasCallback())
191 return m_options_up->IsCallbackSynchronous();
192 return m_owner.GetOptions().IsCallbackSynchronous();
193}
194
196 void *baton, bool is_synchronous) {
197 // The default "Baton" class will keep a copy of "baton" and won't free or
198 // delete it when it goes out of scope.
200 callback, std::make_shared<UntypedBaton>(baton), is_synchronous);
201 SendBreakpointLocationChangedEvent(eBreakpointEventTypeCommandChanged);
202}
203
205 const BatonSP &baton_sp,
206 bool is_synchronous) {
207 GetLocationOptions().SetCallback(callback, baton_sp, is_synchronous);
208 SendBreakpointLocationChangedEvent(eBreakpointEventTypeCommandChanged);
209}
210
214
216 GetLocationOptions().SetCondition(std::move(condition));
217 SendBreakpointLocationChangedEvent(eBreakpointEventTypeConditionChanged);
218}
219
223
225 Status &error) {
227
228 std::lock_guard<std::mutex> guard(m_condition_mutex);
229
230 StopCondition condition = GetCondition();
231
232 if (!condition) {
233 m_user_expression_sp.reset();
234 return false;
235 }
236
237 error.Clear();
238
239 DiagnosticManager diagnostics;
240
241 if (condition.GetHash() != m_condition_hash || !m_user_expression_sp ||
242 !m_user_expression_sp->IsParseCacheable() ||
243 !m_user_expression_sp->MatchesContext(exe_ctx)) {
244 LanguageType language = condition.GetLanguage();
245 if (language == lldb::eLanguageTypeUnknown) {
246 // See if we can figure out the language from the frame, otherwise use the
247 // default language:
248 if (CompileUnit *comp_unit =
249 m_address.CalculateSymbolContextCompileUnit())
250 language = comp_unit->GetLanguage();
251 }
252
253 m_user_expression_sp.reset(GetTarget().GetUserExpressionForLanguage(
254 condition.GetText(), llvm::StringRef(), language,
256 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(diagnostics, exe_ctx,
266 false)) {
269 "Couldn't parse conditional expression:"));
270
271 m_user_expression_sp.reset();
272 return true;
273 }
274
275 m_condition_hash = condition.GetHash();
276 }
277
278 // We need to make sure the user sees any parse errors in their condition, so
279 // we'll hook the constructor errors up to the debugger's Async I/O.
280
281 ValueObjectSP result_value_sp;
282
284 options.SetUnwindOnError(true);
285 options.SetIgnoreBreakpoints(true);
286 options.SetTryAllThreads(true);
288 true); // Don't generate a user variable for condition expressions.
289
290 Status expr_error;
291
292 diagnostics.Clear();
293
294 ExpressionVariableSP result_variable_sp;
295
296 ExpressionResults result_code = m_user_expression_sp->Execute(
297 diagnostics, exe_ctx, options, m_user_expression_sp, result_variable_sp);
298
299 bool ret;
300
301 if (result_code == eExpressionCompleted) {
302 if (!result_variable_sp) {
303 error = Status::FromErrorString("Expression did not return a result");
304 return false;
305 }
306
307 result_value_sp = result_variable_sp->GetValueObject();
308
309 if (result_value_sp) {
310 ret = result_value_sp->IsLogicalTrue(error);
311 if (log) {
312 if (error.Success()) {
313 LLDB_LOGF(log, "Condition successfully evaluated, result is %s.\n",
314 ret ? "true" : "false");
315 } else {
317 "Failed to get an integer result from the expression");
318 ret = false;
319 }
320 }
321 } else {
322 ret = false;
324 "Failed to get any result from the expression");
325 }
326 } else {
327 ret = false;
328 error = Status::FromError(diagnostics.GetAsError(
329 lldb::eExpressionParseError, "Couldn't execute expression:"));
330 }
331
332 return ret;
333}
334
339
342 SendBreakpointLocationChangedEvent(eBreakpointEventTypeIgnoreChanged);
343}
344
346 if (m_options_up != nullptr) {
347 uint32_t loc_ignore = m_options_up->GetIgnoreCount();
348 if (loc_ignore != 0)
349 m_options_up->SetIgnoreCount(loc_ignore - 1);
350 }
351}
352
354 uint32_t owner_ignore = GetBreakpoint().GetIgnoreCount();
355 uint32_t loc_ignore = 0;
356 if (m_options_up != nullptr)
357 loc_ignore = m_options_up->GetIgnoreCount();
358
359 if (loc_ignore != 0 || owner_ignore != 0) {
360 m_owner.DecrementIgnoreCount();
361 DecrementIgnoreCount(); // Have to decrement our owners' ignore count,
362 // since it won't get a chance to.
363 return false;
364 }
365 return true;
366}
367
369 // If we make the copy we don't copy the callbacks because that is
370 // potentially expensive and we don't want to do that for the simple case
371 // where someone is just disabling the location.
372 if (m_options_up == nullptr)
373 m_options_up = std::make_unique<BreakpointOptions>(false);
374
375 return *m_options_up;
376}
377
379 return thread.MatchesSpec(
381 .GetThreadSpecNoCreate());
382}
383
386 // Only the BreakpointResolverScripted provides WasHit.
389 llvm::dyn_cast<BreakpointResolverScripted>(resolver_sp.get());
390 if (!scripted)
391 return shared_from_this();
392
393 StackFrameSP frame_sp = context->exe_ctx_ref.GetFrameSP();
394 if (!frame_sp)
395 return shared_from_this();
396
397 BreakpointLocationSP return_loc_sp =
398 scripted->WasHit(frame_sp, shared_from_this());
399 // If this is a facade location, then we won't have bumped its hit count
400 // while processing the original location hit. Do so here. We don't need
401 // to bump the breakpoint's hit count, however, since hitting the real
402 // location would have already done that.
403 // Also we have to check the enabled state here, since we would never have
404 // gotten here with a real location...
405 if (return_loc_sp && return_loc_sp->IsFacade()) {
406 if (return_loc_sp->IsEnabled())
407 return_loc_sp->m_hit_counter.Increment();
408 else
409 return {};
410 }
411 return return_loc_sp;
412}
413
414// RETURNS - true if we should stop at this breakpoint, false if we
415// should continue. Note, we don't check the thread spec for the breakpoint
416// here, since if the breakpoint is not for this thread, then the event won't
417// even get reported, so the check is redundant.
418
420 lldb::BreakpointLocationSP &facade_loc_sp) {
421 bool should_stop = true;
423
424 // Do this first, if a location is disabled, it shouldn't increment its hit
425 // count.
426 if (!IsEnabled())
427 return false;
428
429 // Next check WasHit:
430 BreakpointLocationSP loc_hit_sp = WasHit(context);
431
432 if (!loc_hit_sp) {
433 // We bump the hit counts in StopInfoBreakpoint::ShouldStopSynchronous,
434 // before we call into each location's ShouldStop. So we need to undo
435 // that here.
437 return false;
438 }
439
440 // If the location hit was not us, it was a facade location, in which case
441 // we should use the facade location's callbacks, etc. Those will all be
442 // run in the asynchronous phase, so for now we just have to record the fact
443 // that we should treat this as a facade hit. This is strictly an out
444 // parameter, so clear it if this isn't a facade hit.
445 if (loc_hit_sp.get() != this)
446 facade_loc_sp = loc_hit_sp;
447 else
448 facade_loc_sp.reset();
449
450 // We only run synchronous callbacks in ShouldStop:
451 context->is_synchronous = true;
452 should_stop = InvokeCallback(context);
453
454 if (log) {
455 StreamString s;
457 LLDB_LOGF(log, "Hit breakpoint location: %s, %s.\n", s.GetData(),
458 should_stop ? "stopping" : "continuing");
459 if (facade_loc_sp) {
460 s.Clear();
461 facade_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
462 LLDB_LOGF(log, "Attributing to facade location: %s.\n", s.GetData());
463 }
464 }
465
466 return should_stop;
467}
468
470 if (IsEnabled()) {
471 // Step our hit count, and also step the hit count of the owner.
472 m_hit_counter.Increment();
473 m_owner.m_hit_counter.Increment();
474 }
475}
476
478 if (IsEnabled()) {
479 // Step our hit count, and also step the hit count of the owner.
480 m_hit_counter.Decrement();
481 m_owner.m_hit_counter.Decrement();
482 }
483}
484
486
487 bool has_site = m_bp_site_sp.get() != nullptr;
488 // Facade locations are currently always considered resolved.
489 return has_site || IsFacade();
490}
491
495
497 // This might be a facade location, which doesn't have an address.
498 // In that case, don't attempt to make a site.
499 if (m_bp_site_sp || IsFacade())
500 return llvm::Error::success();
501
502 Process *process = m_owner.GetTarget().GetProcessSP().get();
503 if (process == nullptr)
504 return llvm::createStringError("no process");
505
506 lldb::break_id_t new_id =
507 process->CreateBreakpointSite(shared_from_this(), m_owner.IsHardware());
508
509 if (new_id == LLDB_INVALID_BREAK_ID)
510 return llvm::createStringError(
511 llvm::formatv("Failed to add breakpoint site at {0:x}",
512 m_address.GetOpcodeLoadAddress(&m_owner.GetTarget())));
513
514 if (!IsResolved())
515 return llvm::createStringError(
516 "breakpoint site created but location is still unresolved");
517
518 return llvm::Error::success();
519}
520
522 m_bp_site_sp = bp_site_sp;
523 SendBreakpointLocationChangedEvent(eBreakpointEventTypeLocationsResolved);
524 return true;
525}
526
528 if (!m_bp_site_sp) {
529 // This might be a Facade Location, which don't have sites or addresses
530 if (IsFacade())
531 return llvm::Error::success();
532 return llvm::createStringError("no breakpoint site to clear");
533 }
534
535 // If the process exists, get it to remove the owner, it will remove the
536 // physical implementation of the breakpoint as well if there are no more
537 // owners. Otherwise just remove this owner.
538 if (ProcessSP process_sp = m_owner.GetTarget().GetProcessSP())
539 process_sp->RemoveConstituentFromBreakpointSite(GetBreakpoint().GetID(),
541 else
542 m_bp_site_sp->RemoveConstituent(GetBreakpoint().GetID(), GetID());
543
544 m_bp_site_sp.reset();
545 return llvm::Error::success();
546}
547
550 SymbolContext sc;
551
552 // If this is a scripted breakpoint, give it a chance to describe its
553 // locations:
554 std::optional<std::string> scripted_opt;
557 llvm::dyn_cast<BreakpointResolverScripted>(resolver_sp.get());
558 if (scripted)
559 scripted_opt = scripted->GetLocationDescription(shared_from_this(), level);
560
561 bool is_scripted_desc = scripted_opt.has_value();
562
563 // If the description level is "initial" then the breakpoint is printing out
564 // our initial state, and we should let it decide how it wants to print our
565 // label.
566 if (level != eDescriptionLevelInitial) {
567 s->Indent();
569 }
570
571 if (level == lldb::eDescriptionLevelBrief)
572 return;
573
574 if (level != eDescriptionLevelInitial)
575 s->PutCString(": ");
576
578 s->IndentMore();
579
580 if (is_scripted_desc) {
581 s->PutCString(scripted_opt->c_str());
582 } else if (m_address.IsSectionOffset()) {
583 m_address.CalculateSymbolContext(&sc);
584
585 if (level == lldb::eDescriptionLevelFull ||
586 level == eDescriptionLevelInitial) {
587 if (IsReExported())
588 s->PutCString("re-exported target = ");
589 else
590 s->PutCString("where = ");
591
592 // If there's a preferred line entry for printing, use that.
593 bool show_function_info = true;
594 if (auto preferred = GetPreferredLineEntry()) {
595 sc.line_entry = *preferred;
596 // FIXME: We're going to get the function name wrong when the preferred
597 // line entry is not the lowest one. For now, just leave the function
598 // out in this case, but we really should also figure out how to easily
599 // fake the function name here.
600 show_function_info = false;
601 }
602 sc.DumpStopContext(s, m_owner.GetTarget().GetProcessSP().get(), m_address,
603 false, true, false, show_function_info,
604 show_function_info, show_function_info);
605 } else {
606 if (sc.module_sp) {
607 s->EOL();
608 s->Indent("module = ");
609 sc.module_sp->GetFileSpec().Dump(s->AsRawOstream());
610 }
611
612 if (sc.comp_unit != nullptr) {
613 s->EOL();
614 s->Indent("compile unit = ");
616
617 if (sc.function != nullptr) {
618 s->EOL();
619 s->Indent("function = ");
620 s->PutCString(sc.function->GetName().AsCString("<unknown>"));
621 if (ConstString mangled_name =
623 s->EOL();
624 s->Indent("mangled function = ");
625 s->PutCString(mangled_name.AsCString());
626 }
627 }
628
629 if (sc.line_entry.line > 0) {
630 s->EOL();
631 s->Indent("location = ");
632 if (auto preferred = GetPreferredLineEntry())
633 preferred->DumpStopContext(s, true);
634 else
635 sc.line_entry.DumpStopContext(s, true);
636 }
637
638 } else {
639 // If we don't have a comp unit, see if we have a symbol we can print.
640 if (sc.symbol) {
641 s->EOL();
642 if (IsReExported())
643 s->Indent("re-exported target = ");
644 else
645 s->Indent("symbol = ");
646 s->PutCString(sc.symbol->GetName().AsCString("<unknown>"));
647 }
648 }
649 }
650 }
651
652 if (level == lldb::eDescriptionLevelVerbose) {
653 s->EOL();
654 s->Indent();
655 }
656
657 if (!is_scripted_desc) {
658 if (m_address.IsSectionOffset() &&
659 (level == eDescriptionLevelFull || level == eDescriptionLevelInitial))
660 s->Printf(", ");
661 s->Printf("address = ");
662
663 ExecutionContextScope *exe_scope = nullptr;
664 Target *target = &m_owner.GetTarget();
665 if (target)
666 exe_scope = target->GetProcessSP().get();
667 if (exe_scope == nullptr)
668 exe_scope = target;
669
670 if (level == eDescriptionLevelInitial)
671 m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress,
673 else
674 m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress,
676
677 if (IsIndirect() && m_bp_site_sp) {
678 Address resolved_address;
679 resolved_address.SetLoadAddress(m_bp_site_sp->GetLoadAddress(), target);
680 Symbol *resolved_symbol = resolved_address.CalculateSymbolContextSymbol();
681 if (resolved_symbol) {
682 if (level == eDescriptionLevelFull || level == eDescriptionLevelInitial)
683 s->Printf(", ");
684 else if (level == lldb::eDescriptionLevelVerbose) {
685 s->EOL();
686 s->Indent();
687 }
688 s->Printf("indirect target = %s",
689 resolved_symbol->GetName().GetCString());
690 }
691 }
692 }
693
694 // FIXME: scripted breakpoint are currently always resolved. Does this seem
695 // right? If they don't add any scripted locations, we shouldn't consider them
696 // resolved.
697 bool is_resolved = is_scripted_desc || IsResolved();
698 // A scripted breakpoint might be resolved but not have a site. Be sure to
699 // check for that.
700 bool is_hardware = !is_scripted_desc && IsResolved() && m_bp_site_sp &&
701 m_bp_site_sp->IsHardware();
702
703 if (level == lldb::eDescriptionLevelVerbose) {
704 s->EOL();
705 s->Indent();
706 s->Printf("resolved = %s\n", is_resolved ? "true" : "false");
707 s->Indent();
708 s->Printf("hardware = %s\n", is_hardware ? "true" : "false");
709 s->Indent();
710 s->Printf("hit count = %-4u\n", GetHitCount());
711
712 if (m_options_up) {
713 s->Indent();
714 m_options_up->GetDescription(s, level);
715 s->EOL();
716 }
717 s->IndentLess();
718 } else if (level != eDescriptionLevelInitial) {
719 s->Printf(", %sresolved, %shit count = %u ", (is_resolved ? "" : "un"),
720 (is_hardware ? "hardware, " : ""), GetHitCount());
721 if (m_options_up) {
722 m_options_up->GetDescription(s, level);
723 }
724 }
725}
726
728 if (s == nullptr)
729 return;
730
731 bool is_resolved = IsResolved();
732 bool is_hardware = is_resolved && m_bp_site_sp->IsHardware();
733
736 ->GetTID();
737 s->Printf("BreakpointLocation %u: tid = %4.4" PRIx64
738 " load addr = 0x%8.8" PRIx64 " state = %s type = %s breakpoint "
739 "hit_count = %-4u ignore_count = %-4u",
740 GetID(), tid,
741 (uint64_t)m_address.GetOpcodeLoadAddress(&m_owner.GetTarget()),
742 (m_options_up ? m_options_up->IsEnabled() : m_owner.IsEnabled())
743 ? "enabled "
744 : "disabled",
745 is_hardware ? "hardware" : "software", GetHitCount(),
747 .GetIgnoreCount());
748}
749
751 lldb::BreakpointEventType eventKind) {
752 if (!m_owner.IsInternal() && m_owner.GetTarget().EventTypeHasListeners(
754 auto data_sp = std::make_shared<Breakpoint::BreakpointEventData>(
755 eventKind, m_owner.shared_from_this());
756 data_sp->GetBreakpointLocationCollection().Add(shared_from_this());
757 m_owner.GetTarget().BroadcastEvent(Target::eBroadcastBitBreakpointChanged,
758 data_sp);
759 }
760}
761
763 auto preferred_opt = GetPreferredLineEntry();
764 if (!preferred_opt)
765 return {};
766 LineEntry preferred = *preferred_opt;
767 SymbolContext sc;
768 if (!m_address.CalculateSymbolContext(&sc))
769 return {};
770 // Don't return anything special if frame 0 is the preferred line entry.
771 // We not really telling the stack frame list to do anything special in that
772 // case.
773 if (!LineEntry::Compare(sc.line_entry, preferred))
774 return {};
775
776 if (!sc.block)
777 return {};
778
779 // Blocks have their line info in Declaration form, so make one here:
780 Declaration preferred_decl(preferred.GetFile(), preferred.line,
781 preferred.column);
782
783 uint32_t depth = 0;
784 Block *inlined_block = sc.block->GetContainingInlinedBlock();
785 while (inlined_block) {
786 // If we've moved to a block that this isn't the start of, that's not
787 // our inlining info or call site, so we can stop here.
788 Address start_address;
789 if (!inlined_block->GetStartAddress(start_address) ||
790 start_address != m_address)
791 return {};
792
793 const InlineFunctionInfo *info = inlined_block->GetInlinedFunctionInfo();
794 if (info) {
795 if (preferred_decl == info->GetDeclaration())
796 return depth;
797 if (preferred_decl == info->GetCallSite())
798 return depth + 1;
799 }
800 inlined_block = inlined_block->GetInlinedParent();
801 depth++;
802 }
803 return {};
804}
805
807 m_address = swap_from->m_address;
809 swap_from->m_should_resolve_indirect_functions;
810 m_is_reexported = swap_from->m_is_reexported;
811 m_is_indirect = swap_from->m_is_indirect;
812 m_user_expression_sp.reset();
813}
814
816 if (thread_id != LLDB_INVALID_THREAD_ID) {
817 GetLocationOptions().SetThreadID(thread_id);
818 } else {
819 // If we're resetting this to an invalid thread id, then don't make an
820 // options pointer just to do that.
821 if (m_options_up != nullptr)
822 m_options_up->SetThreadID(thread_id);
823 }
824}
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
Definition Log.h:376
A section + offset based address class.
Definition Address.h:62
bool SetLoadAddress(lldb::addr_t load_addr, Target *target, bool allow_section_end=false)
Set the address to represent load_addr.
Definition Address.cpp:1035
@ DumpStyleFileAddress
Display as the file address (if any).
Definition Address.h:87
@ DumpStyleModuleWithFileAddress
Display as the file address with the module name prepended (if any).
Definition Address.h:93
@ DumpStyleLoadAddress
Display as the load address (if resolved).
Definition Address.h:99
Symbol * CalculateSymbolContextSymbol() const
Definition Address.cpp:888
A class that describes a single lexical block.
Definition Block.h:41
Block * GetContainingInlinedBlock()
Get the inlined block that contains this block.
Definition Block.cpp:206
const InlineFunctionInfo * GetInlinedFunctionInfo() const
Get const accessor for any inlined function information.
Definition Block.h:268
bool GetStartAddress(Address &addr)
Definition Block.cpp:317
Block * GetInlinedParent()
Get the inlined parent block for this block.
Definition Block.cpp:212
static void GetCanonicalReference(Stream *s, lldb::break_id_t break_id, lldb::break_id_t break_loc_id)
Takes a breakpoint ID and the breakpoint location id and returns a string containing the canonical de...
size_t m_condition_hash
Breakpoint location ID.
void SetCondition(StopCondition condition)
Set the breakpoint location's condition.
const std::optional< LineEntry > GetPreferredLineEntry()
void SwapLocation(lldb::BreakpointLocationSP swap_from)
BreakpointLocation(lldb::break_id_t loc_id, Breakpoint &owner, const Address &addr, lldb::tid_t tid, bool check_for_resolver=true)
Constructor.
bool IsIndirect()
Returns whether the address set in the breakpoint site for this location was found by resolving an in...
uint32_t GetHitCount() const
Return the current Hit Count.
std::mutex m_condition_mutex
For testing whether the condition source code changed.
lldb::BreakpointSiteSP m_bp_site_sp
The compiled expression to use in testing our condition.
llvm::Error ClearBreakpointSite()
Clear this breakpoint location's breakpoint site - for instance when disabling the breakpoint.
Breakpoint & m_owner
Breakpoint options pointer, nullptr if we're using our breakpoint's options.
bool SetBreakpointSite(lldb::BreakpointSiteSP &bp_site_sp)
Set the breakpoint site for this location to bp_site_sp.
void SetIgnoreCount(uint32_t n)
Set the breakpoint to ignore the next count breakpoint hits.
void SetThreadIDInternal(lldb::tid_t thread_id)
Updates the thread ID internally.
void SetQueueName(const char *queue_name)
llvm::Error SetEnabled(bool enabled)
If enabled is true, enable the breakpoint, if false disable it.
bool IsReExported()
Returns whether the address set in the breakpoint location was re-routed to the target of a re-export...
lldb::addr_t GetLoadAddress() const
Gets the load address for this breakpoint location.
BreakpointOptions & GetLocationOptions()
Use this to set location specific breakpoint options.
bool InvokeCallback(StoppointCallbackContext *context)
Invoke the callback action when the breakpoint is hit.
void GetDescription(Stream *s, lldb::DescriptionLevel level)
Print a description of this breakpoint location to the stream s.
Address m_address
The breakpoint that produced this object.
bool IsEnabled() const
Check the Enable/Disable state.
bool IgnoreCountShouldStop()
BreakpointLocation::IgnoreCountShouldStop can only be called once per stop.
const StopCondition & GetCondition() const
Return the breakpoint condition.
bool IsResolved() const
Return whether this breakpoint location has a breakpoint site.
lldb::break_id_t GetID() const
Returns the breakpoint location ID.
void Dump(Stream *s) const
Standard "Dump" method. At present it does nothing.
bool IsCallbackSynchronous()
Report whether the callback for this location is synchronous or not.
void SendBreakpointLocationChangedEvent(lldb::BreakpointEventType eventKind)
void SetAutoContinue(bool auto_continue)
If auto_continue is true, set the breakpoint to continue when hit.
void SetThreadID(lldb::tid_t thread_id)
Set the valid thread to be checked when the breakpoint is hit.
lldb::UserExpressionSP m_user_expression_sp
Guards parsing and evaluation of the condition, which could be evaluated by multiple processes.
void SetCallback(BreakpointHitCallback callback, const lldb::BatonSP &callback_baton_sp, bool is_synchronous)
Set the callback action invoked when the breakpoint is hit.
uint32_t GetIgnoreCount() const
Return the current Ignore Count.
bool m_is_indirect
The address defining this location.
bool ConditionSaysStop(ExecutionContext &exe_ctx, Status &error)
std::unique_ptr< BreakpointOptions > m_options_up
Our breakpoint site (it may be shared by more than one location.)
Address & GetAddress()
Gets the Address for this breakpoint location.
bool IsAutoContinue() const
Check the AutoContinue state.
std::optional< uint32_t > GetSuggestedStackFrameIndex()
If this location knows that the virtual stack frame it represents is not frame 0, return the suggeste...
void SetThreadName(const char *thread_name)
Breakpoint & GetBreakpoint()
Gets the Breakpoint that created this breakpoint location.
const BreakpointOptions & GetOptionsSpecifyingKind(BreakpointOptions::OptionKind kind) const
Use this to access breakpoint options from this breakpoint location.
llvm::Error ResolveBreakpointSite()
Try to resolve the breakpoint site for this location.
lldb::BreakpointLocationSP WasHit(StoppointCallbackContext *context)
This is a programmatic version of a breakpoint "condition".
lldb::BreakpointSiteSP GetBreakpointSite() const
bool ShouldStop(StoppointCallbackContext *context, lldb::BreakpointLocationSP &facade_loc_sp)
Determines whether we should stop due to a hit at this breakpoint location.
"lldb/Breakpoint/BreakpointOptions.h" Class that manages the options on a breakpoint or breakpoint lo...
void ClearCallback()
Remove the callback from this option set.
void SetIgnoreCount(uint32_t n)
Set the breakpoint to ignore the next count breakpoint hits.
void SetCondition(StopCondition condition)
Set the breakpoint stop condition.
void SetEnabled(bool enabled)
If enable is true, enable the breakpoint, if false disable it.
const StopCondition & GetCondition() const
Return the breakpoint condition.
uint32_t GetIgnoreCount() const
Return the current Ignore Count.
ThreadSpec * GetThreadSpec()
Returns a pointer to the ThreadSpec for this option, creating it.
const ThreadSpec * GetThreadSpecNoCreate() const
Return the current thread spec for this option.
void SetAutoContinue(bool auto_continue)
Set the auto-continue state.
void SetThreadID(lldb::tid_t thread_id)
void SetCallback(BreakpointHitCallback callback, const lldb::BatonSP &baton_sp, bool synchronous=false)
Adds a callback to the breakpoint option set.
"lldb/Breakpoint/BreakpointResolverScripted.h" This class sets breakpoints on a given Address.
std::optional< std::string > GetLocationDescription(lldb::BreakpointLocationSP bp_loc_sp, lldb::DescriptionLevel level)
lldb::BreakpointLocationSP WasHit(lldb::StackFrameSP frame_sp, lldb::BreakpointLocationSP bp_loc_sp)
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
Definition Breakpoint.h:81
uint32_t GetIgnoreCount() const
Return the current ignore count/.
lldb::BreakpointResolverSP GetResolver()
Definition Breakpoint.h:554
A class that describes a compilation unit.
Definition CompileUnit.h:43
const FileSpec & GetPrimaryFile() const
Return the primary source spec associated with this compile unit.
A uniqued constant string class.
Definition ConstString.h:40
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
void Dump(Stream *s, const char *value_if_empty=nullptr) const
Dump the object description to a stream.
const char * GetCString() const
Get the string value as a C string.
A class that describes the declaration location of a lldb object.
Definition Declaration.h:24
llvm::Error GetAsError(lldb::ExpressionResults result, llvm::Twine message={}) const
Returns an ExpressionError with arg as error code.
void SetUnwindOnError(bool unwind=false)
Definition Target.h:371
void SetTryAllThreads(bool try_others=true)
Definition Target.h:404
void SetIgnoreBreakpoints(bool ignore=false)
Definition Target.h:375
lldb::StackFrameSP GetFrameSP() const
Get accessor that creates a strong reference from the weak frame reference contained in this object.
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
const ConstString & GetFilename() const
Filename string const get accessor.
Definition FileSpec.h:251
Declaration & GetDeclaration()
Get accessor for the declaration information.
Definition Function.cpp:53
ConstString GetName() const
Definition Function.cpp:708
const Mangled & GetMangled() const
Definition Function.h:534
A class that describes information for an inlined function.
Definition Function.h:126
Declaration & GetCallSite()
Get accessor for the call site declaration information.
Definition Function.cpp:108
ConstString GetMangledName() const
Mangled name get accessor.
Definition Mangled.h:152
lldb::break_id_t CreateBreakpointSite(const lldb::BreakpointLocationSP &owner, bool use_hardware)
Definition Process.cpp:1613
An error handling class.
Definition Status.h:118
static Status FromErrorString(const char *str)
Definition Status.h:141
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
Definition Status.cpp:137
lldb::LanguageType GetLanguage() const
llvm::StringRef GetText() const
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
const char * GetData() const
A stream class that can stream formatted output to a file.
Definition Stream.h:28
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
Definition Stream.h:392
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
Definition Stream.cpp:157
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition Stream.cpp:134
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition Stream.cpp:65
size_t EOL()
Output and End of Line character to the stream.
Definition Stream.cpp:155
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
Definition Stream.cpp:198
void IndentMore(unsigned amount=2)
Increment the current indentation level.
Definition Stream.cpp:195
Defines a symbol context baton that can be handed other debug core functions.
Function * function
The Function for a given query.
Block * block
The Block for a given query.
lldb::ModuleSP module_sp
The Module for a given query.
CompileUnit * comp_unit
The CompileUnit for a given query.
bool DumpStopContext(Stream *s, ExecutionContextScope *exe_scope, const Address &so_addr, bool show_fullpaths, bool show_module, bool show_inlined_frames, bool show_function_arguments, bool show_function_name, bool show_function_display_name=false, std::optional< Stream::HighlightSettings > settings=std::nullopt) const
Dump the stop context in this object to a Stream.
Symbol * symbol
The Symbol for a given query.
LineEntry line_entry
The LineEntry for a given query.
bool IsIndirect() const
Definition Symbol.cpp:223
ConstString GetName() const
Definition Symbol.cpp:511
Symbol * CalculateSymbolContextSymbol() override
Definition Symbol.cpp:414
@ eBroadcastBitBreakpointChanged
Definition Target.h:534
const lldb::ProcessSP & GetProcessSP() const
Definition Target.cpp:309
void SetIndex(uint32_t index)
Definition ThreadSpec.h:45
void SetName(llvm::StringRef name)
Definition ThreadSpec.h:49
uint32_t GetIndex() const
Definition ThreadSpec.h:55
const char * GetName() const
void SetQueueName(llvm::StringRef queue_name)
Definition ThreadSpec.h:51
const char * GetQueueName() const
lldb::tid_t GetTID() const
Definition ThreadSpec.h:57
#define LLDB_INVALID_BREAK_ID
#define LLDB_INVALID_THREAD_ID
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition Log.h:332
std::function< bool(void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)> BreakpointHitCallback
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::BreakpointSite > BreakpointSiteSP
std::shared_ptr< lldb_private::BreakpointResolver > BreakpointResolverSP
std::shared_ptr< lldb_private::BreakpointLocation > BreakpointLocationSP
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eDescriptionLevelBrief
@ eDescriptionLevelInitial
@ eDescriptionLevelFull
@ eDescriptionLevelVerbose
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::ExpressionVariable > ExpressionVariableSP
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
ExpressionResults
The results of expression evaluation.
@ eExpressionCompleted
@ eExpressionParseError
int32_t break_id_t
Definition lldb-types.h:86
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::Baton > BatonSP
uint64_t addr_t
Definition lldb-types.h:80
uint64_t tid_t
Definition lldb-types.h:84
A line table entry class.
Definition LineEntry.h:21
uint16_t column
The column number of the source line, or zero if there is no column information.
Definition LineEntry.h:151
static int Compare(const LineEntry &lhs, const LineEntry &rhs)
Compare two LineEntry objects.
uint32_t line
The source line number, or LLDB_INVALID_LINE_NUMBER if there is no line number information.
Definition LineEntry.h:147
bool DumpStopContext(Stream *s, bool show_fullpaths) const
Dumps information specific to a process that stops at this line entry to the supplied stream s.
Definition LineEntry.cpp:39
const FileSpec & GetFile() const
Helper to access the file.
Definition LineEntry.h:134