39 bool check_for_resolver)
40 : m_address(addr), m_owner(owner), m_loc_id(loc_id) {
41 if (check_for_resolver) {
44 SetShouldResolveIndirectFunctions(
true);
48 SetThreadIDInternal(tid);
52 : m_owner(owner), m_loc_id(loc_id) {
89 : eBreakpointEventTypeDisabled);
97 return m_owner.IsAutoContinue();
115 return thread_spec->
GetTID();
141 if (thread_name !=
nullptr)
162 if (queue_name !=
nullptr)
168 m_options_up->GetThreadSpec()->SetQueueName(queue_name);
191 return m_owner.GetOptions().IsCallbackSynchronous();
195 void *baton,
bool is_synchronous) {
199 callback, std::make_shared<UntypedBaton>(baton), is_synchronous);
205 bool is_synchronous) {
257 LLDB_LOG(log,
"DIL successfully parsed the condition: {0}.",
262 LLDB_LOG(log,
"Parsing condition with DIL failed:\n{0}.",
error);
267 LLDB_LOG(log,
"Lexing condition with DIL failed:\n{0}.",
error);
278 if (valobj_or_error) {
280 if (value_sp && value_sp->GetError().Success()) {
281 llvm::Expected<bool> bool_result = value_sp->GetValueAsBool();
284 "Condition successfully evaluated by DIL, result is {0}.\n",
285 *bool_result ?
"true" :
"false");
294 LLDB_LOG(log,
"Evaluating condition with DIL failed:\n{0}.",
error);
315 m_address.CalculateSymbolContextCompileUnit())
316 language = comp_unit->GetLanguage();
324 LLDB_LOGF(log,
"Error getting condition expression: %s.",
335 "Couldn't parse conditional expression:"));
368 if (!result_variable_sp) {
373 result_value_sp = result_variable_sp->GetValueObject();
375 if (result_value_sp) {
376 ret = result_value_sp->IsLogicalTrue(
error);
378 if (
error.Success()) {
380 "Condition successfully evaluated by UserExpression, "
382 ret ?
"true" :
"false");
385 "Failed to get an integer result from the expression");
392 "Failed to get any result from the expression");
423 uint32_t loc_ignore = 0;
427 if (loc_ignore != 0 || owner_ignore != 0) {
428 m_owner.DecrementIgnoreCount();
441 m_options_up = std::make_unique<BreakpointOptions>(
false);
447 return thread.MatchesSpec(
449 .GetThreadSpecNoCreate());
457 llvm::dyn_cast<BreakpointResolverScripted>(resolver_sp.get());
459 return shared_from_this();
463 return shared_from_this();
466 scripted->
WasHit(frame_sp, shared_from_this());
473 if (return_loc_sp && return_loc_sp->IsFacade()) {
474 if (return_loc_sp->IsEnabled())
475 return_loc_sp->m_hit_counter.Increment();
479 return return_loc_sp;
489 bool should_stop =
true;
513 if (loc_hit_sp.get() !=
this)
514 facade_loc_sp = loc_hit_sp;
516 facade_loc_sp.reset();
526 should_stop ?
"stopping" :
"continuing");
541 m_owner.m_hit_counter.Increment();
549 m_owner.m_hit_counter.Decrement();
568 return llvm::Error::success();
571 if (process ==
nullptr)
572 return llvm::createStringError(
"no process");
578 return llvm::createStringError(
579 llvm::formatv(
"Failed to add breakpoint site at {0:x}",
583 return llvm::createStringError(
584 "breakpoint site created but location is still unresolved");
586 return llvm::Error::success();
599 return llvm::Error::success();
600 return llvm::createStringError(
"no breakpoint site to clear");
613 return llvm::Error::success();
622 std::optional<std::string> scripted_opt;
625 llvm::dyn_cast<BreakpointResolverScripted>(resolver_sp.get());
629 bool is_scripted_desc = scripted_opt.has_value();
648 if (is_scripted_desc) {
650 }
else if (
m_address.IsSectionOffset()) {
661 bool show_function_info =
true;
668 show_function_info =
false;
671 false,
true,
false, show_function_info,
672 show_function_info, show_function_info);
682 s->
Indent(
"compile unit = ");
692 s->
Indent(
"mangled function = ");
701 preferred->DumpStopContext(s,
true);
711 s->
Indent(
"re-exported target = ");
725 if (!is_scripted_desc) {
735 if (exe_scope ==
nullptr)
748 const Symbol *resolved_symbol =
750 if (resolved_symbol) {
757 s->
Printf(
"indirect target = %s",
766 bool is_resolved = is_scripted_desc ||
IsResolved();
775 s->
Printf(
"resolved = %s\n", is_resolved ?
"true" :
"false");
777 s->
Printf(
"hardware = %s\n", is_hardware ?
"true" :
"false");
788 s->
Printf(
", %sresolved, %shit count = %u ", (is_resolved ?
"" :
"un"),
801 bool is_hardware = is_resolved &&
m_bp_site_sp->IsHardware();
806 s->
Printf(
"BreakpointLocation %u: tid = %4.4" PRIx64
807 " load addr = 0x%8.8" PRIx64
" state = %s type = %s breakpoint "
808 "hit_count = %-4u ignore_count = %-4u",
814 is_hardware ?
"hardware" :
"software",
GetHitCount(),
820 lldb::BreakpointEventType eventKind) {
822 auto data_sp = std::make_shared<Breakpoint::BreakpointEventData>(
823 eventKind,
m_owner.shared_from_this());
824 data_sp->GetBreakpointLocationCollection().Add(shared_from_this());
835 if (!
m_address.CalculateSymbolContext(&sc))
852 while (inlined_block) {
876 swap_from->m_should_resolve_indirect_functions;
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOGF(log,...)
A section + offset based address class.
bool SetLoadAddress(lldb::addr_t load_addr, Target *target, bool allow_section_end=false)
Set the address to represent load_addr.
@ DumpStyleFileAddress
Display as the file address (if any).
@ DumpStyleModuleWithFileAddress
Display as the file address with the module name prepended (if any).
@ DumpStyleLoadAddress
Display as the load address (if resolved).
Symbol * CalculateSymbolContextSymbol() const
A class that describes a single lexical block.
Block * GetContainingInlinedBlock()
Get the inlined block that contains this block.
const InlineFunctionInfo * GetInlinedFunctionInfo() const
Get const accessor for any inlined function information.
bool GetStartAddress(Address &addr)
Block * GetInlinedParent()
Get the inlined parent block for this block.
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.
void DecrementIgnoreCount()
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...
bool ValidForThisThread(Thread &thread)
uint32_t GetHitCount() const
Return the current Hit Count.
std::mutex m_condition_mutex
For testing whether the condition source code changed.
StoppointHitCounter m_hit_counter
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)
lldb::tid_t GetThreadID()
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.
uint32_t GetThreadIndex() const
Address m_address
The breakpoint that produced this object.
const char * GetQueueName() const
bool IsEnabled() const
Check the Enable/Disable state.
bool IgnoreCountShouldStop()
BreakpointLocation::IgnoreCountShouldStop can only be called once per stop.
const char * GetThreadName() const
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
The expression parsed by Data Inspection Language (DIL).
void SetThreadIndex(uint32_t index)
dil::ASTNodeUP m_dil_expr_tree
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...
bool m_should_resolve_indirect_functions
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...
uint32_t GetIgnoreCount() const
Return the current ignore count/.
lldb::BreakpointResolverSP GetResolver()
A class that describes a compilation unit.
const FileSpec & GetPrimaryFile() const
Return the primary source spec associated with this compile unit.
A uniqued constant string class.
const char * GetCString() const
Get the string value as a C string.
const char * AsCString(const char *value_if_empty) const
Get the string value as a C string.
A class that describes the declaration location of a lldb object.
llvm::Error GetAsError(lldb::ExpressionResults result, llvm::Twine message={}) const
Returns an ExpressionError with arg as error code.
void SetUnwindOnError(bool unwind=false)
void SetTryAllThreads(bool try_others=true)
void SetSuppressPersistentResult(bool b)
void SetIgnoreBreakpoints(bool ignore=false)
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 lldb::TargetSP & GetTargetSP() const
Get accessor to get the target shared pointer.
StackFrame & GetFrameRef() const
Returns a reference to the thread object.
bool HasFrameScope() const
Returns true the ExecutionContext object contains a valid target, process, thread and frame.
llvm::StringRef GetFilename() const
Filename string const get accessor.
Declaration & GetDeclaration()
Get accessor for the declaration information.
ConstString GetName() const
const Mangled & GetMangled() const
A class that describes information for an inlined function.
Declaration & GetCallSite()
Get accessor for the call site declaration information.
ConstString GetMangledName() const
Mangled name get accessor.
lldb::break_id_t CreateBreakpointSite(const lldb::BreakpointLocationSP &owner, bool use_hardware)
static Status FromErrorString(const char *str)
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
lldb::LanguageType GetLanguage() const
lldb::BreakpointConditionMode GetMode() const
llvm::StringRef GetText() const
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
ExecutionContextRef exe_ctx_ref
const char * GetData() const
A stream class that can stream formatted output to a file.
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
size_t EOL()
Output and End of Line character to the stream.
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
void IndentMore(unsigned amount=2)
Increment the current indentation level.
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.
ConstString GetName() const
Symbol * CalculateSymbolContextSymbol() override
lldb::BreakpointConditionMode GetBreakpointsConditionMode() const
const lldb::ProcessSP & GetProcessSP() const
void SetIndex(uint32_t index)
void SetName(llvm::StringRef name)
uint32_t GetIndex() const
const char * GetName() const
void SetQueueName(llvm::StringRef queue_name)
const char * GetQueueName() const
lldb::tid_t GetTID() const
static llvm::Expected< DILLexer > Create(llvm::StringRef expr, lldb::DILMode mode=lldb::eDILModeFull)
Lexes all the tokens in expr and calls the private constructor with the lexed tokens.
static llvm::Expected< ASTNodeUP > Parse(llvm::StringRef dil_input_expr, DILLexer lexer, StackFrame &stack_frame, lldb::DynamicValueType use_dynamic, lldb::DILMode mode)
Parse the lexed tokens.
llvm::Expected< lldb::ValueObjectSP > EvaluateTree(const ASTNodeUP &tree)
Evaluate an ASTNode tree.
#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.
@ eExecutionPolicyOnlyWhenNeeded
std::function< bool(void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)> BreakpointHitCallback
BreakpointConditionMode
Modes for evaluating breakpoint conditions.
@ eBreakpointConditionModeExpr
Use UserExpression to evaluate the condition.
@ eBreakpointConditionModeDIL
Use Data Inspection Language (DIL) to evaluate the condition.
@ eBreakpointConditionModeDefault
Use the mode specified by the target.breakpoints-condition-mode setting.
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.
@ eDescriptionLevelInitial
@ 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.
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::Baton > BatonSP
@ eDILModeFull
Allowed: everything supported by DIL.
A line table entry class.
uint16_t column
The column number of the source line, or zero if there is no column information.
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.
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.
const FileSpec & GetFile() const
Helper to access the file.
A type-erased pair of llvm::dwarf::SourceLanguageName and version.