16#include "llvm/ADT/StringRef.h"
72 std::string GetName() override {
return "libc++ frame recognizer"; }
78 const auto &sc = frame_sp->GetSymbolContext(lldb::eSymbolContextFunction);
84 if (!r.Execute(sc.function->GetNameNoArguments()))
92 thread_sp->GetStackFrameAtIndex(frame_sp->GetFrameIndex() + 1);
95 const auto &parent_sc =
96 parent_frame_sp->GetSymbolContext(lldb::eSymbolContextFunction);
97 if (!parent_sc.function)
99 if (parent_sc.function->GetNameNoArguments().GetStringRef().starts_with(
113 std::make_shared<RegularExpression>(
"^std::__[^:]*::"),
125 return llvm::createStringError(
"C++ does not support object descriptions");
132 return llvm::createStringError(
"C++ does not support object descriptions");
136 return str_ref.contains(
"$_") || str_ref.contains(
"'lambda'");
141 llvm::StringRef first_template_param_sref,
bool has_invoke) {
155 optional_info.
callable_case = lldb_private::CPPLanguageRuntime::
156 LibCppStdFunctionCallableCase::Lambda;
159 optional_info.
callable_case = lldb_private::CPPLanguageRuntime::
160 LibCppStdFunctionCallableCase::CallableObject;
168 return optional_info;
179 return optional_info;
213 ValueObjectSP member_f_(valobj_sp->GetChildMemberWithName(
"__f_"));
216 ValueObjectSP sub_member_f_(member_f_->GetChildMemberWithName(
"__f_"));
219 member_f_ = sub_member_f_;
223 return optional_info;
225 lldb::addr_t member_f_pointer_value = member_f_->GetValueAsUnsigned(0);
229 if (!member_f_pointer_value)
230 return optional_info;
235 if (process ==
nullptr)
236 return optional_info;
247 return optional_info;
253 return optional_info;
255 lldb::addr_t address_after_vtable = member_f_pointer_value + address_size;
262 return optional_info;
267 return optional_info;
269 Address vtable_first_entry_resolved;
272 vtable_first_entry_resolved))
273 return optional_info;
280 return optional_info;
283 vtable_addr_resolved, eSymbolContextEverything, sc);
286 if (symbol ==
nullptr)
287 return optional_info;
290 bool found_expected_start_string =
291 vtable_name.starts_with(
"vtable for std::__1::__function::__func<");
293 if (!found_expected_start_string)
294 return optional_info;
310 size_t first_open_angle_bracket = vtable_name.find(
'<') + 1;
311 size_t first_comma = vtable_name.find(
',');
313 llvm::StringRef first_template_parameter =
314 vtable_name.slice(first_open_angle_bracket, first_comma);
316 Address function_address_resolved;
322 function_address_resolved)) {
324 function_address_resolved, eSymbolContextEverything, sc);
330 (symbol ? symbol->
GetName().GetStringRef().contains(
"__invoke") :
false);
331 auto calculate_symbol_context_helper = [](
auto &t,
334 t->CalculateSymbolContext(&sc);
341 calculate_symbol_context_helper(symbol, scl);
355 return optional_info;
358 std::string func_to_match = first_template_parameter.str();
368 llvm::StringRef name_to_use = func_to_match;
377 return optional_info;
379 if (vtable_cu && !has_invoke) {
382 auto name = f->GetName().GetStringRef();
383 if (name.starts_with(name_to_use) && name.contains(
"operator"))
390 calculate_symbol_context_helper(func_sp, scl);
394 if (symbol ==
nullptr)
395 return optional_info;
400 first_template_parameter, has_invoke);
405 return optional_info;
413 lldb::addr_t curr_pc = thread.GetRegisterContext()->GetPC();
415 TargetSP target_sp(thread.CalculateTarget());
417 if (!target_sp->HasLoadedSections())
424 if (!target_sp->ResolveLoadAddress(curr_pc, pc_addr_resolved))
427 target_sp->GetImages().ResolveSymbolContextForAddress(
428 pc_addr_resolved, eSymbolContextEverything, sc);
431 if (symbol ==
nullptr)
442 bool found_expected_start_string =
443 function_name.starts_with(
"std::__1::function<");
445 if (!found_expected_start_string)
449 sc.
GetAddressRange(eSymbolContextEverything, 0,
false, range_of_curr_func);
460 value_sp->GetValueIsValid()) {
463 ret_plan_sp = std::make_shared<ThreadPlanRunToAddress>(
470 ret_plan_sp = std::make_shared<ThreadPlanStepInRange>(
481 llvm::StringRef mangled_name =
487 return mangled_name.starts_with(
"_ZTh") || mangled_name.starts_with(
"_ZTv") ||
488 mangled_name.starts_with(
"_ZTc");
static ConstString g_promise
static ConstString g_coro_frame
bool contains_lambda_identifier(llvm::StringRef &str_ref)
static ConstString g_this
CPPLanguageRuntime::LibCppStdFunctionCallableInfo line_entry_helper(Target &target, const SymbolContext &sc, Symbol *symbol, llvm::StringRef first_template_param_sref, bool has_invoke)
#define LLDB_SCOPED_TIMER()
A frame recognizer that is installed to hide libc++ implementation details from the backtrace.
lldb::RecognizedStackFrameSP RecognizeFrame(lldb::StackFrameSP frame_sp) override
RecognizedStackFrameSP m_hidden_frame
std::array< RegularExpression, 2 > m_hidden_regex
std::string GetName() override
A section + offset based address range class.
A section + offset based address class.
lldb::addr_t GetCallableLoadAddress(Target *target, bool is_indirect=false) const
Get the load address as a callable code load address.
bool CalculateSymbolContextLineEntry(LineEntry &line_entry) const
CompileUnit * CalculateSymbolContextCompileUnit() const
llvm::Error GetObjectDescription(Stream &str, ValueObject &object) override
bool IsSymbolARuntimeThunk(const Symbol &symbol) override
bool IsAllowedRuntimeValue(ConstString name) override
Identify whether a name is a runtime value that should not be hidden by from the user interface.
LibCppStdFunctionCallableInfo FindLibCppStdFunctionCallableInfo(lldb::ValueObjectSP &valobj_sp)
lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, bool stop_others) override
Obtain a ThreadPlan to get us into C++ constructs such as std::function.
OperatorStringToCallableInfoMap CallableLookupCache
CPPLanguageRuntime(Process *process)
A class that describes a compilation unit.
lldb::FunctionSP FindFunction(llvm::function_ref< bool(const lldb::FunctionSP &)> matching_lambda)
Find a function in the compile unit based on the predicate matching_lambda.
A uniqued constant string class.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
const char * GetCString() const
Get the string value as a C string.
"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.
Process * GetProcessPtr() const
Returns a pointer to the process object.
LanguageRuntime(Process *process)
@ ePreferDemangledWithoutArguments
ConstString & GetMangledName()
Mangled name get accessor.
uint32_t ResolveSymbolContextForAddress(const Address &so_addr, lldb::SymbolContextItem resolve_scope, SymbolContext &sc) const
Resolve the symbol context for the given address. (const Address&,uint32_t,SymbolContext&)
A plug-in interface definition class for debugging a process.
lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status &error)
uint32_t GetAddressByteSize() const
Target & GetTarget()
Get the target object pointer for this module.
This class provides extra information about a stack frame that was provided by a specific stack frame...
void AddRecognizer(lldb::StackFrameRecognizerSP recognizer, ConstString module, llvm::ArrayRef< ConstString > symbols, Mangled::NamePreference symbol_mangling, bool first_instruction_only=true)
Add a new recognizer that triggers on a given symbol name.
A base class for frame recognizers.
bool Fail() const
Test for error condition.
A stream class that can stream formatted output to a file.
Defines a list of symbol context objects.
uint32_t GetSize() const
Get accessor for a symbol context list size.
Defines a symbol context baton that can be handed other debug core functions.
bool GetAddressRange(uint32_t scope, uint32_t range_idx, bool use_inline_block_range, AddressRange &range) const
Get the address range contained within a symbol context.
Symbol * symbol
The Symbol for a given query.
Address GetFunctionOrSymbolAddress() const
Get the address of the function or symbol represented by this symbol context.
ConstString GetName() const
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, uint32_t stop_id=SectionLoadHistory::eStopIDNow, bool allow_section_end=false)
StackFrameRecognizerManager & GetFrameRecognizerManager()
const ModuleList & GetImages() const
Get accessor for the images for this process.
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::Function > FunctionSP
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::RecognizedStackFrame > RecognizedStackFrameSP
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::StackFrameRecognizer > StackFrameRecognizerSP
std::shared_ptr< lldb_private::Target > TargetSP
bool ShouldHide() override
Controls whether this frame should be filtered out when displaying backtraces, for example.
lldb::addr_t member_f_pointer_value
LineEntry callable_line_entry
LibCppStdFunctionCallableCase callable_case
A line table entry class.