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_address(addr), m_owner(owner), m_loc_id(loc_id) {
38 if (check_for_resolver) {
39 const Symbol *symbol = m_address.CalculateSymbolContextSymbol();
40 if (symbol && symbol->IsIndirect()) {
41 SetShouldResolveIndirectFunctions(true);
42 }
43 }
44
45 SetThreadIDInternal(tid);
46}
47
49 : m_owner(owner), m_loc_id(loc_id) {
50 SetThreadIDInternal(LLDB_INVALID_THREAD_ID);
51}
52
56
58 return m_address.GetOpcodeLoadAddress(&m_owner.GetTarget());
59}
60
63 if (m_options_up && m_options_up->IsOptionSet(kind))
64 return *m_options_up;
65 return m_owner.GetOptions();
66}
67
69
71
73
75 if (!m_owner.IsEnabled())
76 return false;
77 if (m_options_up != nullptr)
78 return m_options_up->IsEnabled();
79 return true;
80}
81
82llvm::Error BreakpointLocation::SetEnabled(bool enabled) {
84 llvm::Error error = enabled ? ResolveBreakpointSite() : ClearBreakpointSite();
85 SendBreakpointLocationChangedEvent(enabled ? eBreakpointEventTypeEnabled
86 : eBreakpointEventTypeDisabled);
87 return error;
88}
89
91 if (m_options_up &&
93 return m_options_up->IsAutoContinue();
94 return m_owner.IsAutoContinue();
95}
96
97void BreakpointLocation::SetAutoContinue(bool auto_continue) {
98 GetLocationOptions().SetAutoContinue(auto_continue);
99 SendBreakpointLocationChangedEvent(eBreakpointEventTypeAutoContinueChanged);
100}
101
103 SetThreadIDInternal(thread_id);
104 SendBreakpointLocationChangedEvent(eBreakpointEventTypeThreadChanged);
105}
106
108 const ThreadSpec *thread_spec =
111 if (thread_spec)
112 return thread_spec->GetTID();
114}
115
117 if (index != 0)
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(eBreakpointEventTypeThreadChanged);
126}
127
129 const ThreadSpec *thread_spec =
132 if (thread_spec)
133 return thread_spec->GetIndex();
134 return 0;
135}
136
137void BreakpointLocation::SetThreadName(const char *thread_name) {
138 if (thread_name != nullptr)
139 GetLocationOptions().GetThreadSpec()->SetName(thread_name);
140 else {
141 // If we're resetting this to an invalid thread id, then don't make an
142 // options pointer just to do that.
143 if (m_options_up != nullptr)
144 m_options_up->GetThreadSpec()->SetName(thread_name);
145 }
146 SendBreakpointLocationChangedEvent(eBreakpointEventTypeThreadChanged);
147}
148
150 const ThreadSpec *thread_spec =
153 if (thread_spec)
154 return thread_spec->GetName();
155 return nullptr;
156}
157
158void BreakpointLocation::SetQueueName(const char *queue_name) {
159 if (queue_name != nullptr)
161 else {
162 // If we're resetting this to an invalid thread id, then don't make an
163 // options pointer just to do that.
164 if (m_options_up != nullptr)
165 m_options_up->GetThreadSpec()->SetQueueName(queue_name);
166 }
167 SendBreakpointLocationChangedEvent(eBreakpointEventTypeThreadChanged);
168}
169
171 const ThreadSpec *thread_spec =
174 if (thread_spec)
175 return thread_spec->GetQueueName();
176 return nullptr;
177}
178
180 if (m_options_up != nullptr && m_options_up->HasCallback())
181 return m_options_up->InvokeCallback(context, m_owner.GetID(), GetID());
182 return m_owner.InvokeCallback(context, GetID());
183}
184
186 if (m_options_up != nullptr && m_options_up->HasCallback())
187 return m_options_up->IsCallbackSynchronous();
188 return m_owner.GetOptions().IsCallbackSynchronous();
189}
190
192 void *baton, bool is_synchronous) {
193 // The default "Baton" class will keep a copy of "baton" and won't free or
194 // delete it when it goes out of scope.
196 callback, std::make_shared<UntypedBaton>(baton), is_synchronous);
197 SendBreakpointLocationChangedEvent(eBreakpointEventTypeCommandChanged);
198}
199
201 const BatonSP &baton_sp,
202 bool is_synchronous) {
203 GetLocationOptions().SetCallback(callback, baton_sp, is_synchronous);
204 SendBreakpointLocationChangedEvent(eBreakpointEventTypeCommandChanged);
205}
206
210
212 GetLocationOptions().SetCondition(std::move(condition));
213 SendBreakpointLocationChangedEvent(eBreakpointEventTypeConditionChanged);
214}
215
219
221 Status &error) {
223
224 std::lock_guard<std::mutex> guard(m_condition_mutex);
225
226 StopCondition condition = GetCondition();
227
228 if (!condition) {
229 m_user_expression_sp.reset();
230 return false;
231 }
232
233 error.Clear();
234
235 DiagnosticManager diagnostics;
236
237 if (condition.GetHash() != m_condition_hash || !m_user_expression_sp ||
238 !m_user_expression_sp->IsParseCacheable() ||
239 !m_user_expression_sp->MatchesContext(exe_ctx)) {
240 LanguageType language = condition.GetLanguage();
241 if (language == lldb::eLanguageTypeUnknown) {
242 // See if we can figure out the language from the frame, otherwise use the
243 // default language:
244 if (CompileUnit *comp_unit =
245 m_address.CalculateSymbolContextCompileUnit())
246 language = comp_unit->GetLanguage();
247 }
248
249 m_user_expression_sp.reset(GetTarget().GetUserExpressionForLanguage(
250 condition.GetText(), llvm::StringRef(), SourceLanguage{language},
252 error));
253 if (error.Fail()) {
254 LLDB_LOGF(log, "Error getting condition expression: %s.",
255 error.AsCString());
256 m_user_expression_sp.reset();
257 return true;
258 }
259
260 if (!m_user_expression_sp->Parse(diagnostics, exe_ctx,
262 false)) {
265 "Couldn't parse conditional expression:"));
266
267 m_user_expression_sp.reset();
268 return true;
269 }
270
271 m_condition_hash = condition.GetHash();
272 }
273
274 // We need to make sure the user sees any parse errors in their condition, so
275 // we'll hook the constructor errors up to the debugger's Async I/O.
276
277 ValueObjectSP result_value_sp;
278
280 options.SetUnwindOnError(true);
281 options.SetIgnoreBreakpoints(true);
282 options.SetTryAllThreads(true);
284 true); // Don't generate a user variable for condition expressions.
285
286 Status expr_error;
287
288 diagnostics.Clear();
289
290 ExpressionVariableSP result_variable_sp;
291
292 ExpressionResults result_code = m_user_expression_sp->Execute(
293 diagnostics, exe_ctx, options, m_user_expression_sp, result_variable_sp);
294
295 bool ret;
296
297 if (result_code == eExpressionCompleted) {
298 if (!result_variable_sp) {
299 error = Status::FromErrorString("Expression did not return a result");
300 return false;
301 }
302
303 result_value_sp = result_variable_sp->GetValueObject();
304
305 if (result_value_sp) {
306 ret = result_value_sp->IsLogicalTrue(error);
307 if (log) {
308 if (error.Success()) {
309 LLDB_LOGF(log, "Condition successfully evaluated, result is %s.\n",
310 ret ? "true" : "false");
311 } else {
313 "Failed to get an integer result from the expression");
314 ret = false;
315 }
316 }
317 } else {
318 ret = false;
320 "Failed to get any result from the expression");
321 }
322 } else {
323 ret = false;
324 error = Status::FromError(diagnostics.GetAsError(
325 lldb::eExpressionParseError, "Couldn't execute expression:"));
326 }
327
328 return ret;
329}
330
335
338 SendBreakpointLocationChangedEvent(eBreakpointEventTypeIgnoreChanged);
339}
340
342 if (m_options_up != nullptr) {
343 uint32_t loc_ignore = m_options_up->GetIgnoreCount();
344 if (loc_ignore != 0)
345 m_options_up->SetIgnoreCount(loc_ignore - 1);
346 }
347}
348
350 uint32_t owner_ignore = GetBreakpoint().GetIgnoreCount();
351 uint32_t loc_ignore = 0;
352 if (m_options_up != nullptr)
353 loc_ignore = m_options_up->GetIgnoreCount();
354
355 if (loc_ignore != 0 || owner_ignore != 0) {
356 m_owner.DecrementIgnoreCount();
357 DecrementIgnoreCount(); // Have to decrement our owners' ignore count,
358 // since it won't get a chance to.
359 return false;
360 }
361 return true;
362}
363
365 // If we make the copy we don't copy the callbacks because that is
366 // potentially expensive and we don't want to do that for the simple case
367 // where someone is just disabling the location.
368 if (m_options_up == nullptr)
369 m_options_up = std::make_unique<BreakpointOptions>(false);
370
371 return *m_options_up;
372}
373
375 return thread.MatchesSpec(
377 .GetThreadSpecNoCreate());
378}
379
382 // Only the BreakpointResolverScripted provides WasHit.
385 llvm::dyn_cast<BreakpointResolverScripted>(resolver_sp.get());
386 if (!scripted)
387 return shared_from_this();
388
389 StackFrameSP frame_sp = context->exe_ctx_ref.GetFrameSP();
390 if (!frame_sp)
391 return shared_from_this();
392
393 BreakpointLocationSP return_loc_sp =
394 scripted->WasHit(frame_sp, shared_from_this());
395 // If this is a facade location, then we won't have bumped its hit count
396 // while processing the original location hit. Do so here. We don't need
397 // to bump the breakpoint's hit count, however, since hitting the real
398 // location would have already done that.
399 // Also we have to check the enabled state here, since we would never have
400 // gotten here with a real location...
401 if (return_loc_sp && return_loc_sp->IsFacade()) {
402 if (return_loc_sp->IsEnabled())
403 return_loc_sp->m_hit_counter.Increment();
404 else
405 return {};
406 }
407 return return_loc_sp;
408}
409
410// RETURNS - true if we should stop at this breakpoint, false if we
411// should continue. Note, we don't check the thread spec for the breakpoint
412// here, since if the breakpoint is not for this thread, then the event won't
413// even get reported, so the check is redundant.
414
416 lldb::BreakpointLocationSP &facade_loc_sp) {
417 bool should_stop = true;
419
420 // Do this first, if a location is disabled, it shouldn't increment its hit
421 // count.
422 if (!IsEnabled())
423 return false;
424
425 // Next check WasHit:
426 BreakpointLocationSP loc_hit_sp = WasHit(context);
427
428 if (!loc_hit_sp) {
429 // We bump the hit counts in StopInfoBreakpoint::ShouldStopSynchronous,
430 // before we call into each location's ShouldStop. So we need to undo
431 // that here.
433 return false;
434 }
435
436 // If the location hit was not us, it was a facade location, in which case
437 // we should use the facade location's callbacks, etc. Those will all be
438 // run in the asynchronous phase, so for now we just have to record the fact
439 // that we should treat this as a facade hit. This is strictly an out
440 // parameter, so clear it if this isn't a facade hit.
441 if (loc_hit_sp.get() != this)
442 facade_loc_sp = loc_hit_sp;
443 else
444 facade_loc_sp.reset();
445
446 // We only run synchronous callbacks in ShouldStop:
447 context->is_synchronous = true;
448 should_stop = InvokeCallback(context);
449
450 if (log) {
451 StreamString s;
453 LLDB_LOGF(log, "Hit breakpoint location: %s, %s.\n", s.GetData(),
454 should_stop ? "stopping" : "continuing");
455 if (facade_loc_sp) {
456 s.Clear();
457 facade_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
458 LLDB_LOGF(log, "Attributing to facade location: %s.\n", s.GetData());
459 }
460 }
461
462 return should_stop;
463}
464
466 if (IsEnabled()) {
467 // Step our hit count, and also step the hit count of the owner.
468 m_hit_counter.Increment();
469 m_owner.m_hit_counter.Increment();
470 }
471}
472
474 if (IsEnabled()) {
475 // Step our hit count, and also step the hit count of the owner.
476 m_hit_counter.Decrement();
477 m_owner.m_hit_counter.Decrement();
478 }
479}
480
482
483 bool has_site = m_bp_site_sp.get() != nullptr;
484 // Facade locations are currently always considered resolved.
485 return has_site || IsFacade();
486}
487
491
493 // This might be a facade location, which doesn't have an address.
494 // In that case, don't attempt to make a site.
495 if (m_bp_site_sp || IsFacade())
496 return llvm::Error::success();
497
498 Process *process = m_owner.GetTarget().GetProcessSP().get();
499 if (process == nullptr)
500 return llvm::createStringError("no process");
501
502 lldb::break_id_t new_id =
503 process->CreateBreakpointSite(shared_from_this(), m_owner.IsHardware());
504
505 if (new_id == LLDB_INVALID_BREAK_ID)
506 return llvm::createStringError(
507 llvm::formatv("Failed to add breakpoint site at {0:x}",
508 m_address.GetOpcodeLoadAddress(&m_owner.GetTarget())));
509
510 if (!IsResolved())
511 return llvm::createStringError(
512 "breakpoint site created but location is still unresolved");
513
514 return llvm::Error::success();
515}
516
518 m_bp_site_sp = bp_site_sp;
519 SendBreakpointLocationChangedEvent(eBreakpointEventTypeLocationsResolved);
520 return true;
521}
522
524 if (!m_bp_site_sp) {
525 // This might be a Facade Location, which don't have sites or addresses
526 if (IsFacade())
527 return llvm::Error::success();
528 return llvm::createStringError("no breakpoint site to clear");
529 }
530
531 // If the process exists, get it to remove the owner, it will remove the
532 // physical implementation of the breakpoint as well if there are no more
533 // owners. Otherwise just remove this owner.
534 if (ProcessSP process_sp = m_owner.GetTarget().GetProcessSP())
535 process_sp->RemoveConstituentFromBreakpointSite(GetBreakpoint().GetID(),
537 else
538 m_bp_site_sp->RemoveConstituent(GetBreakpoint().GetID(), GetID());
539
540 m_bp_site_sp.reset();
541 return llvm::Error::success();
542}
543
546 SymbolContext sc;
547
548 // If this is a scripted breakpoint, give it a chance to describe its
549 // locations:
550 std::optional<std::string> scripted_opt;
553 llvm::dyn_cast<BreakpointResolverScripted>(resolver_sp.get());
554 if (scripted)
555 scripted_opt = scripted->GetLocationDescription(shared_from_this(), level);
556
557 bool is_scripted_desc = scripted_opt.has_value();
558
559 // If the description level is "initial" then the breakpoint is printing out
560 // our initial state, and we should let it decide how it wants to print our
561 // label.
562 if (level != eDescriptionLevelInitial) {
563 s->Indent();
565 }
566
567 if (level == lldb::eDescriptionLevelBrief)
568 return;
569
570 if (level != eDescriptionLevelInitial)
571 s->PutCString(": ");
572
574 s->IndentMore();
575
576 if (is_scripted_desc) {
577 s->PutCString(scripted_opt->c_str());
578 } else if (m_address.IsSectionOffset()) {
579 m_address.CalculateSymbolContext(&sc);
580
581 if (level == lldb::eDescriptionLevelFull ||
582 level == eDescriptionLevelInitial) {
583 if (IsReExported())
584 s->PutCString("re-exported target = ");
585 else
586 s->PutCString("where = ");
587
588 // If there's a preferred line entry for printing, use that.
589 bool show_function_info = true;
590 if (auto preferred = GetPreferredLineEntry()) {
591 sc.line_entry = *preferred;
592 // FIXME: We're going to get the function name wrong when the preferred
593 // line entry is not the lowest one. For now, just leave the function
594 // out in this case, but we really should also figure out how to easily
595 // fake the function name here.
596 show_function_info = false;
597 }
598 sc.DumpStopContext(s, m_owner.GetTarget().GetProcessSP().get(), m_address,
599 false, true, false, show_function_info,
600 show_function_info, show_function_info);
601 } else {
602 if (sc.module_sp) {
603 s->EOL();
604 s->Indent("module = ");
605 sc.module_sp->GetFileSpec().Dump(s->AsRawOstream());
606 }
607
608 if (sc.comp_unit != nullptr) {
609 s->EOL();
610 s->Indent("compile unit = ");
612
613 if (sc.function != nullptr) {
614 s->EOL();
615 s->Indent("function = ");
616 s->PutCString(sc.function->GetName().AsCString("<unknown>"));
617 if (ConstString mangled_name =
619 s->EOL();
620 s->Indent("mangled function = ");
621 s->PutCString(mangled_name.AsCString());
622 }
623 }
624
625 if (sc.line_entry.line > 0) {
626 s->EOL();
627 s->Indent("location = ");
628 if (auto preferred = GetPreferredLineEntry())
629 preferred->DumpStopContext(s, true);
630 else
631 sc.line_entry.DumpStopContext(s, true);
632 }
633
634 } else {
635 // If we don't have a comp unit, see if we have a symbol we can print.
636 if (sc.symbol) {
637 s->EOL();
638 if (IsReExported())
639 s->Indent("re-exported target = ");
640 else
641 s->Indent("symbol = ");
642 s->PutCString(sc.symbol->GetName().AsCString("<unknown>"));
643 }
644 }
645 }
646 }
647
648 if (level == lldb::eDescriptionLevelVerbose) {
649 s->EOL();
650 s->Indent();
651 }
652
653 if (!is_scripted_desc) {
654 if (m_address.IsSectionOffset() &&
655 (level == eDescriptionLevelFull || level == eDescriptionLevelInitial))
656 s->Printf(", ");
657 s->Printf("address = ");
658
659 ExecutionContextScope *exe_scope = nullptr;
660 Target *target = &m_owner.GetTarget();
661 if (target)
662 exe_scope = target->GetProcessSP().get();
663 if (exe_scope == nullptr)
664 exe_scope = target;
665
666 if (level == eDescriptionLevelInitial)
667 m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress,
669 else
670 m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress,
672
673 if (IsIndirect() && m_bp_site_sp) {
674 Address resolved_address;
675 resolved_address.SetLoadAddress(m_bp_site_sp->GetLoadAddress(), target);
676 const Symbol *resolved_symbol =
677 resolved_address.CalculateSymbolContextSymbol();
678 if (resolved_symbol) {
679 if (level == eDescriptionLevelFull || level == eDescriptionLevelInitial)
680 s->Printf(", ");
681 else if (level == lldb::eDescriptionLevelVerbose) {
682 s->EOL();
683 s->Indent();
684 }
685 s->Printf("indirect target = %s",
686 resolved_symbol->GetName().GetCString());
687 }
688 }
689 }
690
691 // FIXME: scripted breakpoint are currently always resolved. Does this seem
692 // right? If they don't add any scripted locations, we shouldn't consider them
693 // resolved.
694 bool is_resolved = is_scripted_desc || IsResolved();
695 // A scripted breakpoint might be resolved but not have a site. Be sure to
696 // check for that.
697 bool is_hardware = !is_scripted_desc && IsResolved() && m_bp_site_sp &&
698 m_bp_site_sp->IsHardware();
699
700 if (level == lldb::eDescriptionLevelVerbose) {
701 s->EOL();
702 s->Indent();
703 s->Printf("resolved = %s\n", is_resolved ? "true" : "false");
704 s->Indent();
705 s->Printf("hardware = %s\n", is_hardware ? "true" : "false");
706 s->Indent();
707 s->Printf("hit count = %-4u\n", GetHitCount());
708
709 if (m_options_up) {
710 s->Indent();
711 m_options_up->GetDescription(s, level);
712 s->EOL();
713 }
714 s->IndentLess();
715 } else if (level != eDescriptionLevelInitial) {
716 s->Printf(", %sresolved, %shit count = %u ", (is_resolved ? "" : "un"),
717 (is_hardware ? "hardware, " : ""), GetHitCount());
718 if (m_options_up) {
719 m_options_up->GetDescription(s, level);
720 }
721 }
722}
723
725 if (s == nullptr)
726 return;
727
728 bool is_resolved = IsResolved();
729 bool is_hardware = is_resolved && m_bp_site_sp->IsHardware();
730
733 ->GetTID();
734 s->Printf("BreakpointLocation %u: tid = %4.4" PRIx64
735 " load addr = 0x%8.8" PRIx64 " state = %s type = %s breakpoint "
736 "hit_count = %-4u ignore_count = %-4u",
737 GetID(), tid,
738 (uint64_t)m_address.GetOpcodeLoadAddress(&m_owner.GetTarget()),
739 (m_options_up ? m_options_up->IsEnabled() : m_owner.IsEnabled())
740 ? "enabled "
741 : "disabled",
742 is_hardware ? "hardware" : "software", GetHitCount(),
744 .GetIgnoreCount());
745}
746
748 lldb::BreakpointEventType eventKind) {
749 if (!m_owner.IsInternal()) {
750 auto data_sp = std::make_shared<Breakpoint::BreakpointEventData>(
751 eventKind, m_owner.shared_from_this());
752 data_sp->GetBreakpointLocationCollection().Add(shared_from_this());
753 m_owner.GetTarget().NotifyBreakpointChanged(m_owner, data_sp);
754 }
755}
756
758 auto preferred_opt = GetPreferredLineEntry();
759 if (!preferred_opt)
760 return {};
761 LineEntry preferred = *preferred_opt;
762 SymbolContext sc;
763 if (!m_address.CalculateSymbolContext(&sc))
764 return {};
765 // Don't return anything special if frame 0 is the preferred line entry.
766 // We not really telling the stack frame list to do anything special in that
767 // case.
768 if (!LineEntry::Compare(sc.line_entry, preferred))
769 return {};
770
771 if (!sc.block)
772 return {};
773
774 // Blocks have their line info in Declaration form, so make one here:
775 Declaration preferred_decl(preferred.GetFile(), preferred.line,
776 preferred.column);
777
778 uint32_t depth = 0;
779 Block *inlined_block = sc.block->GetContainingInlinedBlock();
780 while (inlined_block) {
781 // If we've moved to a block that this isn't the start of, that's not
782 // our inlining info or call site, so we can stop here.
783 Address start_address;
784 if (!inlined_block->GetStartAddress(start_address) ||
785 start_address != m_address)
786 return {};
787
788 const InlineFunctionInfo *info = inlined_block->GetInlinedFunctionInfo();
789 if (info) {
790 if (preferred_decl == info->GetDeclaration())
791 return depth;
792 if (preferred_decl == info->GetCallSite())
793 return depth + 1;
794 }
795 inlined_block = inlined_block->GetInlinedParent();
796 depth++;
797 }
798 return {};
799}
800
802 m_address = swap_from->m_address;
804 swap_from->m_should_resolve_indirect_functions;
805 m_is_reexported = swap_from->m_is_reexported;
806 m_is_indirect = swap_from->m_is_indirect;
807 m_user_expression_sp.reset();
808}
809
811 if (thread_id != LLDB_INVALID_THREAD_ID) {
812 GetLocationOptions().SetThreadID(thread_id);
813 } else {
814 // If we're resetting this to an invalid thread id, then don't make an
815 // options pointer just to do that.
816 if (m_options_up != nullptr)
817 m_options_up->SetThreadID(thread_id);
818 }
819}
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
Definition Log.h:383
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:1034
@ 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:887
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:373
void SetTryAllThreads(bool try_others=true)
Definition Target.h:406
void SetIgnoreBreakpoints(bool ignore=false)
Definition Target.h:377
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:250
Declaration & GetDeclaration()
Get accessor for the declaration information.
Definition Function.cpp:54
ConstString GetName() const
Definition Function.cpp:709
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:109
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:1584
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:136
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:418
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:204
void IndentMore(unsigned amount=2)
Increment the current indentation level.
Definition Stream.cpp:201
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
const lldb::ProcessSP & GetProcessSP() const
Definition Target.cpp:313
void SetIndex(uint32_t index)
Definition ThreadSpec.h:47
void SetName(llvm::StringRef name)
Definition ThreadSpec.h:51
uint32_t GetIndex() const
Definition ThreadSpec.h:57
const char * GetName() const
void SetQueueName(llvm::StringRef queue_name)
Definition ThreadSpec.h:53
const char * GetQueueName() const
lldb::tid_t GetTID() const
Definition ThreadSpec.h:59
#define LLDB_INVALID_BREAK_ID
#define LLDB_INVALID_THREAD_ID
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:87
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:155
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:151
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:40
const FileSpec & GetFile() const
Helper to access the file.
Definition LineEntry.h:134
A type-erased pair of llvm::dwarf::SourceLanguageName and version.