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());
92 TypeQueryOptions::e_exact_match |
93 TypeQueryOptions::e_find_one);
95 module_sp->FindTypes(query, results);
98 class_types.
Insert(type_sp);
103 if (class_types.
Empty()) {
107 class_types.
Insert(type_sp);
111 if (class_types.
Empty()) {
112 LLDB_LOGF(log,
"0x%16.16" PRIx64
": is not dynamic\n",
116 if (class_types.
GetSize() == 1) {
120 type_sp->GetForwardCompilerType())) {
124 ": static-type = '%s' has dynamic type: uid={0x%" PRIx64
125 "}, type-name='%s'\n",
127 type_sp->GetID(), type_sp->GetName().GetCString());
134 for (i = 0; i < class_types.
GetSize(); i++) {
140 ": static-type = '%s' has multiple matching dynamic "
141 "types: uid={0x%" PRIx64
"}, type-name='%s'\n",
144 type_sp->GetID(), type_sp->GetName().GetCString());
149 for (i = 0; i < class_types.
GetSize(); i++) {
153 type_sp->GetForwardCompilerType())) {
156 "0x%16.16" PRIx64
": static-type = '%s' has multiple "
157 "matching dynamic types, picking "
158 "this one: uid={0x%" PRIx64
"}, type-name='%s'\n",
161 type_sp->GetID(), type_sp->GetName().GetCString());
170 ": static-type = '%s' has multiple matching dynamic "
171 "types, didn't find a C++ match\n",
195 if ((type.
GetTypeClass() & (eTypeClassStruct | eTypeClassClass)) == 0) {
196 return llvm::createStringError(std::errc::invalid_argument,
197 "type \"%s\" is not a class or struct or a pointer to one",
203 return llvm::createStringError(std::errc::invalid_argument,
204 "type \"%s\" doesn't have a vtable",
207 return llvm::Error::success();
217llvm::Expected<LanguageRuntime::VTableInfo>
224 return std::move(err);
228 if (process ==
nullptr)
229 return llvm::createStringError(std::errc::invalid_argument,
240 return llvm::createStringError(std::errc::invalid_argument,
241 "failed to get the address of the value");
248 return llvm::createStringError(std::errc::invalid_argument,
249 "failed to read vtable pointer from memory at 0x%" PRIx64,
259 return llvm::createStringError(std::errc::invalid_argument,
260 "failed to resolve vtable pointer 0x%"
261 PRIx64
"to a section", vtable_load_addr);
265 std::lock_guard<std::mutex> locker(
m_mutex);
272 if (symbol ==
nullptr)
273 return llvm::createStringError(std::errc::invalid_argument,
274 "no symbol found for 0x%" PRIx64,
279 std::lock_guard<std::mutex> locker(
m_mutex);
283 return llvm::createStringError(std::errc::invalid_argument,
284 "symbol found that contains 0x%" PRIx64
" is not a vtable symbol",
301 class_type_or_name.
Clear();
312 llvm::Expected<VTableInfo> vtable_info_or_err =
314 if (!vtable_info_or_err) {
315 llvm::consumeError(vtable_info_or_err.takeError());
319 const VTableInfo &vtable_info = vtable_info_or_err.get();
320 class_type_or_name =
GetTypeInfo(in_value, vtable_info);
322 if (!class_type_or_name)
346 vtable_load_addr - 2 * addr_byte_size;
349 if (offset_to_top_location >= vtable_load_addr)
353 offset_to_top_location, addr_byte_size, INT64_MIN,
error);
355 if (offset_to_top == INT64_MIN)
361 dynamic_addr, dynamic_address)) {
373 if (type_and_or_name.
HasType()) {
380 if (static_type_flags.
AllSet(eTypeIsPointer))
382 else if (static_type_flags.
AllSet(eTypeIsReference))
389 if (static_type_flags.
AllSet(eTypeIsPointer))
390 corrected_name.append(
" *");
391 else if (static_type_flags.
AllSet(eTypeIsReference))
392 corrected_name.append(
" &");
395 ret.
SetName(corrected_name.c_str());
420 interpreter,
"demangle",
"Demangle a C++ mangled name.",
421 "language cplusplus demangle [<mangled-name> ...]") {
429 bool demangled_any =
false;
430 bool error_any =
false;
431 for (
auto &entry : command.
entries()) {
432 if (entry.ref().empty())
440 auto name = entry.ref();
441 if (name.starts_with(
"__Z"))
442 name = name.drop_front();
447 demangled_any =
true;
453 entry.ref().str().c_str());
468 interpreter,
"cplusplus",
469 "Commands for operating on the C++ language runtime.",
470 "cplusplus <subcommand> [<subcommand-options>]") {
494 const BreakpointSP &bkpt,
bool catch_bp,
bool throw_bp) {
500 bool for_expressions) {
508 static const char *g_catch_name =
"__cxa_begin_catch";
509 static const char *g_throw_name1 =
"__cxa_throw";
510 static const char *g_throw_name2 =
"__cxa_rethrow";
511 static const char *g_exception_throw_name =
"__cxa_allocate_exception";
512 std::vector<const char *> exception_names;
513 exception_names.reserve(4);
515 exception_names.push_back(g_catch_name);
518 exception_names.push_back(g_throw_name1);
519 exception_names.push_back(g_throw_name2);
523 exception_names.push_back(g_exception_throw_name);
526 bkpt, exception_names.data(), exception_names.size(),
548 bool catch_bp,
bool throw_bp,
bool for_expressions,
bool is_internal) {
554 const bool hardware =
false;
555 const bool resolve_indirect_functions =
false;
556 return target.
CreateBreakpoint(filter_sp, exception_resolver_sp, is_internal,
557 hardware, resolve_indirect_functions);
564 const bool catch_bp =
false;
565 const bool throw_bp =
true;
566 const bool is_internal =
true;
567 const bool for_expressions =
true;
576 catch_bp, throw_bp, for_expressions, is_internal);
603 uint64_t break_site_id = stop_reason->GetValue();
610 if (!thread_sp->SafeToCallFunctions())
630 thread_sp->CalculateExecutionContext(exe_ctx);
651 func_call_ret = function_caller->
ExecuteFunction(exe_ctx,
nullptr, options,
652 diagnostics, results);
662 if (!
error.Success()) {
675 return dyn_exception;
682 std::lock_guard<std::mutex> locker(
m_mutex);
692 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,...
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, const TypeQuery &query, lldb_private::TypeResults &results) const
Find types using a type-matching object that contains all search parameters.
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)
void Insert(const lldb::TypeSP &type)
TypeIterable Types() const
A class that contains all state required for type lookups.
This class tracks the state and results of a TypeQuery.
lldb::TypeSP GetFirstType() const
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
Symbol * symbol
Address of the vtable's virtual function table.