51 const bool check_cxx =
true;
52 const bool check_objc =
false;
53 return in_value.GetCompilerType().IsPossibleDynamicType(
nullptr, check_cxx,
67 llvm::StringRef symbol_name =
71 ": static-type = '%s' has vtable symbol '%s'\n",
74 symbol_name.str().c_str());
77 llvm::StringRef class_name = symbol_name;
81 std::string lookup_name(
"::");
82 lookup_name.append(class_name.data(), class_name.size());
85 const bool exact_match =
true;
90 llvm::DenseSet<SymbolFile *> searched_symbol_files;
93 module_sp->FindTypes(
ConstString(lookup_name), exact_match, 1,
94 searched_symbol_files, class_types);
99 if (class_types.
Empty())
102 searched_symbol_files, class_types);
105 if (class_types.
Empty()) {
106 LLDB_LOGF(log,
"0x%16.16" PRIx64
": is not dynamic\n",
110 if (class_types.
GetSize() == 1) {
114 type_sp->GetForwardCompilerType())) {
118 ": static-type = '%s' has dynamic type: uid={0x%" PRIx64
119 "}, type-name='%s'\n",
121 type_sp->GetID(), type_sp->GetName().GetCString());
128 for (i = 0; i < class_types.
GetSize(); i++) {
134 ": static-type = '%s' has multiple matching dynamic "
135 "types: uid={0x%" PRIx64
"}, type-name='%s'\n",
138 type_sp->GetID(), type_sp->GetName().GetCString());
143 for (i = 0; i < class_types.
GetSize(); i++) {
147 type_sp->GetForwardCompilerType())) {
150 "0x%16.16" PRIx64
": static-type = '%s' has multiple "
151 "matching dynamic types, picking "
152 "this one: uid={0x%" PRIx64
"}, type-name='%s'\n",
155 type_sp->GetID(), type_sp->GetName().GetCString());
164 ": static-type = '%s' has multiple matching dynamic "
165 "types, didn't find a C++ match\n",
189 if ((type.
GetTypeClass() & (eTypeClassStruct | eTypeClassClass)) == 0) {
190 return llvm::createStringError(std::errc::invalid_argument,
191 "type \"%s\" is not a class or struct or a pointer to one",
197 return llvm::createStringError(std::errc::invalid_argument,
198 "type \"%s\" doesn't have a vtable",
201 return llvm::Error::success();
211llvm::Expected<LanguageRuntime::VTableInfo>
218 return std::move(err);
222 if (process ==
nullptr)
223 return llvm::createStringError(std::errc::invalid_argument,
234 return llvm::createStringError(std::errc::invalid_argument,
235 "failed to get the address of the value");
242 return llvm::createStringError(std::errc::invalid_argument,
243 "failed to read vtable pointer from memory at 0x%" PRIx64,
253 return llvm::createStringError(std::errc::invalid_argument,
254 "failed to resolve vtable pointer 0x%"
255 PRIx64
"to a section", vtable_load_addr);
259 std::lock_guard<std::mutex> locker(
m_mutex);
266 if (symbol ==
nullptr)
267 return llvm::createStringError(std::errc::invalid_argument,
268 "no symbol found for 0x%" PRIx64,
273 std::lock_guard<std::mutex> locker(
m_mutex);
277 return llvm::createStringError(std::errc::invalid_argument,
278 "symbol found that contains 0x%" PRIx64
" is not a vtable symbol",
295 class_type_or_name.
Clear();
306 llvm::Expected<VTableInfo> vtable_info_or_err =
308 if (!vtable_info_or_err) {
309 llvm::consumeError(vtable_info_or_err.takeError());
313 const VTableInfo &vtable_info = vtable_info_or_err.get();
314 class_type_or_name =
GetTypeInfo(in_value, vtable_info);
316 if (!class_type_or_name)
340 vtable_load_addr - 2 * addr_byte_size;
343 if (offset_to_top_location >= vtable_load_addr)
347 offset_to_top_location, addr_byte_size, INT64_MIN,
error);
349 if (offset_to_top == INT64_MIN)
355 dynamic_addr, dynamic_address)) {
367 if (type_and_or_name.
HasType()) {
374 if (static_type_flags.
AllSet(eTypeIsPointer))
376 else if (static_type_flags.
AllSet(eTypeIsReference))
383 if (static_type_flags.
AllSet(eTypeIsPointer))
384 corrected_name.append(
" *");
385 else if (static_type_flags.
AllSet(eTypeIsReference))
386 corrected_name.append(
" &");
389 ret.
SetName(corrected_name.c_str());
414 interpreter,
"demangle",
"Demangle a C++ mangled name.",
415 "language cplusplus demangle [<mangled-name> ...]") {
425 arg.push_back(index_arg);
428 m_arguments.push_back(arg);
435 bool demangled_any =
false;
436 bool error_any =
false;
437 for (
auto &entry : command.
entries()) {
438 if (entry.ref().empty())
446 auto name = entry.ref();
447 if (name.startswith(
"__Z"))
448 name = name.drop_front();
453 demangled_any =
true;
459 entry.ref().str().c_str());
474 interpreter,
"cplusplus",
475 "Commands for operating on the C++ language runtime.",
476 "cplusplus <subcommand> [<subcommand-options>]") {
500 const BreakpointSP &bkpt,
bool catch_bp,
bool throw_bp) {
506 bool for_expressions) {
514 static const char *g_catch_name =
"__cxa_begin_catch";
515 static const char *g_throw_name1 =
"__cxa_throw";
516 static const char *g_throw_name2 =
"__cxa_rethrow";
517 static const char *g_exception_throw_name =
"__cxa_allocate_exception";
518 std::vector<const char *> exception_names;
519 exception_names.reserve(4);
521 exception_names.push_back(g_catch_name);
524 exception_names.push_back(g_throw_name1);
525 exception_names.push_back(g_throw_name2);
529 exception_names.push_back(g_exception_throw_name);
532 bkpt, exception_names.data(), exception_names.size(),
554 bool catch_bp,
bool throw_bp,
bool for_expressions,
bool is_internal) {
560 const bool hardware =
false;
561 const bool resolve_indirect_functions =
false;
562 return target.
CreateBreakpoint(filter_sp, exception_resolver_sp, is_internal,
563 hardware, resolve_indirect_functions);
570 const bool catch_bp =
false;
571 const bool throw_bp =
true;
572 const bool is_internal =
true;
573 const bool for_expressions =
true;
582 catch_bp, throw_bp, for_expressions, is_internal);
609 uint64_t break_site_id = stop_reason->GetValue();
616 if (!thread_sp->SafeToCallFunctions())
636 thread_sp->CalculateExecutionContext(exe_ctx);
657 func_call_ret = function_caller->
ExecuteFunction(exe_ctx,
nullptr, options,
658 diagnostics, results);
668 if (!
error.Success()) {
681 return dyn_exception;
688 std::lock_guard<std::mutex> locker(
m_mutex);
698 std::lock_guard<std::mutex> locker(
m_mutex);
static llvm::raw_ostream & error(Stream &strm)
static const char * vtable_demangled_prefix
#define LLDB_LOGF(log,...)
#define LLDB_PLUGIN_DEFINE_ADV(ClassName, PluginName)
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectMultiwordItaniumABI_Demangle(CommandInterpreter &interpreter)
~CommandObjectMultiwordItaniumABI_Demangle() override=default
~CommandObjectMultiwordItaniumABI() override=default
CommandObjectMultiwordItaniumABI(CommandInterpreter &interpreter)
A section + offset based address class.
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
void SetRawAddress(lldb::addr_t addr)
bool IsSectionOffset() const
Check if an address is section offset.
Symbol * CalculateSymbolContextSymbol() const
llvm::Triple & GetTriple()
Architecture triple accessor.
A command line argument class.
llvm::ArrayRef< ArgEntry > entries() const
"lldb/Breakpoint/BreakpointResolverName.h" This class sets breakpoints on a given function name,...
std::vector< CommandArgumentData > CommandArgumentEntry
void SetStatus(lldb::ReturnStatus status)
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
void AppendMessageWithFormat(const char *format,...) __attribute__((format(printf
Generic representation of a type in a programming language.
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
lldb::TypeClass GetTypeClass() const
CompilerType GetLValueReferenceType() const
Return a new CompilerType that is a L value reference to this type if this type is valid and the type...
ConstString GetTypeName(bool BaseOnly=false) const
CompilerType GetPointeeType() const
If this type is a pointer type, return the type that the pointer points to, else return an invalid ty...
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr) const
bool IsPolymorphicClass() const
bool IsPointerOrReferenceType(CompilerType *pointee_type=nullptr) const
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
const char * GetCString() const
Get the string value as a C string.
void SetUnwindOnError(bool unwind=false)
void SetTryAllThreads(bool try_others=true)
void SetTimeout(const Timeout< std::micro > &timeout)
void SetStopOthers(bool stop_others=true)
void SetIgnoreBreakpoints(bool ignore=false)
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Process * GetProcessPtr() const
Returns a pointer to the process object.
void EmplaceBack(Args &&...args)
Inserts a new FileSpec into the FileSpecList constructed in-place with the given arguments.
bool AllSet(ValueType mask) const
Test if all bits in mask are 1 in the current flags.
Encapsulates a function that can be called.
lldb::ExpressionResults ExecuteFunction(ExecutionContext &exe_ctx, lldb::addr_t *args_addr_ptr, const EvaluateExpressionOptions &options, DiagnosticManager &diagnostic_manager, Value &results)
Run the function this FunctionCaller was created with.
void ClearExceptionBreakpoints() override
llvm::Error TypeHasVTable(CompilerType compiler_type)
bool ExceptionBreakpointsAreSet() override
bool GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic, TypeAndOrName &class_type_or_name, Address &address, Value::ValueType &value_type) override
lldb::BreakpointSP CreateExceptionBreakpoint(bool catch_bp, bool throw_bp, bool for_expressions, bool is_internal)
DynamicTypeCache m_dynamic_type_map
TypeAndOrName GetTypeInfo(ValueObject &in_value, const VTableInfo &vtable_info)
static lldb_private::LanguageRuntime * CreateInstance(Process *process, lldb::LanguageType language)
lldb::SearchFilterSP CreateExceptionSearchFilter() override
TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name, ValueObject &static_value) override
static llvm::StringRef GetPluginNameStatic()
lldb::BreakpointResolverSP CreateExceptionResolver(const lldb::BreakpointSP &bkpt, bool catch_bp, bool throw_bp) override
VTableInfoCache m_vtable_info_map
void SetDynamicTypeInfo(const lldb_private::Address &vtable_addr, const TypeAndOrName &type_info)
bool CouldHaveDynamicValue(ValueObject &in_value) override
void SetExceptionBreakpoints() override
bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) override
lldb::BreakpointSP m_cxx_exception_bp_sp
TypeAndOrName GetDynamicTypeInfo(const lldb_private::Address &vtable_addr)
llvm::Expected< LanguageRuntime::VTableInfo > GetVTableInfo(ValueObject &in_value, bool check_type) override
Get the vtable information for a given value.
lldb::ValueObjectSP GetExceptionObjectForThread(lldb::ThreadSP thread_sp) override
A class that handles mangled names.
ConstString GetDemangledName() const
Demangled name get accessor.
lldb::LanguageType GuessLanguage() const
Try to guess the language from the mangling.
ConstString GetDisplayDemangledName() const
Display demangled name get accessor.
A collection class for Module objects.
void FindTypes(Module *search_first, ConstString name, bool name_is_fully_qualified, size_t max_matches, llvm::DenseSet< SymbolFile * > &searched_symbol_files, TypeList &types) const
Find types by name.
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
std::chrono::seconds GetUtilityExpressionTimeout() const
A plug-in interface definition class for debugging a process.
StopPointSiteList< lldb_private::BreakpointSite > & GetBreakpointSiteList()
int64_t ReadSignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, int64_t fail_value, Status &error)
lldb::addr_t FixDataAddress(lldb::addr_t pc)
lldb::ByteOrder GetByteOrder() const
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.
unsigned long long ULongLong(unsigned long long fail_value=0) const
static lldb::TypeSystemClangSP GetForTarget(Target &target, std::optional< IsolatedASTKind > ast_kind=DefaultAST, bool create_on_demand=true)
Returns the scratch TypeSystemClang for the given target.
bool StopPointSiteContainsBreakpoint(typename StopPointSite::SiteID, lldb::break_id_t bp_id)
Returns whether the BreakpointSite site_id has a BreakpointLocation that is part of Breakpoint bp_id.
Defines a list of symbol context objects.
bool GetContextAtIndex(size_t idx, SymbolContext &sc) const
Get accessor for a symbol context at index idx.
Defines a symbol context baton that can be handed other debug core functions.
Symbol * symbol
The Symbol for a given query.
lldb::ModuleSP CalculateSymbolContextModule() override
Address GetAddress() const
lldb::SearchFilterSP GetSearchFilterForModuleList(const FileSpecList *containingModuleList)
FunctionCaller * GetFunctionCallerForLanguage(lldb::LanguageType language, const CompilerType &return_type, const Address &function_address, const ValueList &arg_value_list, const char *name, Status &error)
lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules, const FileSpec &file, uint32_t line_no, uint32_t column, lldb::addr_t offset, LazyBool check_inlines, LazyBool skip_prologue, bool internal, bool request_hardware, LazyBool move_to_nearest_code)
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, uint32_t stop_id=SectionLoadHistory::eStopIDNow)
const ModuleList & GetImages() const
Get accessor for the images for this process.
const ArchSpec & GetArchitecture() const
Sometimes you can find the name of the type corresponding to an object, but we don't have debug infor...
void SetName(ConstString type_name)
CompilerType GetCompilerType() const
ConstString GetName() const
void SetCompilerType(CompilerType compiler_type)
void SetTypeSP(lldb::TypeSP type_sp)
lldb::TypeSP GetTypeAtIndex(uint32_t idx)
static bool AreTypesSame(CompilerType type1, CompilerType type2, bool ignore_qualifiers=false)
static bool IsCXXClassType(const CompilerType &type)
lldb::addr_t GetPointerValue(AddressType *address_type=nullptr)
CompilerType GetCompilerType()
virtual ConstString GetTypeName()
static lldb::ValueObjectSP CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data, const ExecutionContext &exe_ctx, CompilerType type)
virtual lldb::addr_t GetAddressOf(bool scalar_is_load_address=true, AddressType *address_type=nullptr)
const ExecutionContextRef & GetExecutionContextRef() const
const Scalar & GetScalar() const
ValueType
Type that describes Value::m_value.
@ Scalar
A raw scalar value.
#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.
@ eAddressTypeLoad
Address is an address as in the current target inferior process.
std::shared_ptr< lldb_private::SearchFilter > SearchFilterSP
std::shared_ptr< lldb_private::BreakpointResolver > BreakpointResolverSP
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
LanguageType
Programming language type.
@ eLanguageTypeC_plus_plus_14
ISO C++:2014.
@ eLanguageTypeC_plus_plus_03
ISO C++:2003.
@ eLanguageTypeUnknown
Unknown or invalid language value.
@ eLanguageTypeC_plus_plus_11
ISO C++:2011.
@ eLanguageTypeC
Non-standardized C, such as K&R.
@ eLanguageTypeC_plus_plus
ISO C++:1998.
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
ExpressionResults
The results of expression evaluation.
std::shared_ptr< lldb_private::Type > TypeSP
@ eReturnStatusSuccessFinishResult
@ eReturnStatusSuccessFinishNoResult
std::shared_ptr< lldb_private::TypeSystemClang > TypeSystemClangSP
std::shared_ptr< lldb_private::StopInfo > StopInfoSP
std::shared_ptr< lldb_private::Module > ModuleSP
Used to build individual command argument lists.
ArgumentRepetitionType arg_repetition
lldb::CommandArgumentType arg_type
Symbol * symbol
Address of the vtable's virtual function table.