35 llvm::StringRef symbol_name =
39 ": static-type = '%s' has vtable symbol '%s'\n",
44 llvm::StringRef class_name = symbol_name;
48 std::string lookup_name(
"::");
49 lookup_name.append(class_name.data(), class_name.size());
59 TypeQueryOptions::e_exact_match |
60 TypeQueryOptions::e_strict_namespaces |
61 TypeQueryOptions::e_find_one);
63 module_sp->FindTypes(query, results);
66 class_types.
Insert(type_sp);
71 if (class_types.
Empty()) {
73 m_process->GetTarget().GetImages().FindTypes(
nullptr, query, results);
75 class_types.
Insert(type_sp);
79 if (class_types.
Empty()) {
80 LLDB_LOGF(log,
"0x%16.16" PRIx64
": is not dynamic\n",
84 if (class_types.
GetSize() == 1) {
88 type_sp->GetForwardCompilerType())) {
91 ": static-type = '%s' has dynamic type: uid={0x%" PRIx64
92 "}, type-name='%s'\n",
95 type_sp->GetName().GetCString());
102 for (i = 0; i < class_types.
GetSize(); i++) {
107 ": static-type = '%s' has multiple matching dynamic "
108 "types: uid={0x%" PRIx64
"}, type-name='%s'\n",
111 type_sp->GetName().GetCString());
116 for (i = 0; i < class_types.
GetSize(); i++) {
120 type_sp->GetForwardCompilerType())) {
122 "0x%16.16" PRIx64
": static-type = '%s' has multiple "
123 "matching dynamic types, picking "
124 "this one: uid={0x%" PRIx64
"}, type-name='%s'\n",
127 type_sp->GetName().GetCString());
136 ": static-type = '%s' has multiple matching dynamic "
137 "types, didn't find a C++ match\n",
161 if ((type.
GetTypeClass() & (eTypeClassStruct | eTypeClassClass)) == 0) {
162 return llvm::createStringError(
163 std::errc::invalid_argument,
164 "type \"%s\" is not a class or struct or a pointer to one",
170 return llvm::createStringError(std::errc::invalid_argument,
171 "type \"%s\" doesn't have a vtable",
174 return llvm::Error::success();
184llvm::Expected<LanguageRuntime::VTableInfo>
190 return std::move(err);
194 if (process ==
nullptr)
195 return llvm::createStringError(std::errc::invalid_argument,
198 auto [original_ptr, address_type] =
203 return llvm::createStringError(std::errc::invalid_argument,
204 "failed to get the address of the value");
211 return llvm::createStringError(
212 std::errc::invalid_argument,
213 "failed to read vtable pointer from memory at 0x%" PRIx64,
223 return llvm::createStringError(std::errc::invalid_argument,
224 "failed to resolve vtable pointer 0x%" PRIx64
230 std::lock_guard<std::mutex> locker(
m_mutex);
237 if (symbol ==
nullptr)
238 return llvm::createStringError(std::errc::invalid_argument,
239 "no symbol found for 0x%" PRIx64,
244 std::lock_guard<std::mutex> locker(
m_mutex);
248 return llvm::createStringError(std::errc::invalid_argument,
249 "symbol found that contains 0x%" PRIx64
250 " is not a vtable symbol",
271 llvm::Expected<LanguageRuntime::VTableInfo> vtable_info_or_err =
273 if (!vtable_info_or_err) {
274 llvm::consumeError(vtable_info_or_err.takeError());
279 class_type_or_name =
GetTypeInfo(in_value, vtable_info);
281 if (!class_type_or_name)
303 const uint32_t addr_byte_size =
m_process->GetAddressByteSize();
305 vtable_load_addr - 2 * addr_byte_size;
308 if (offset_to_top_location >= vtable_load_addr)
312 offset_to_top_location, addr_byte_size, INT64_MIN,
error);
314 if (offset_to_top == INT64_MIN)
320 if (!
m_process->GetTarget().ResolveLoadAddress(dynamic_addr,
328 std::vector<const char *> &names,
bool catch_bp,
bool throw_bp,
329 bool for_expressions) {
337 static const char *g_catch_name =
"__cxa_begin_catch";
338 static const char *g_throw_name1 =
"__cxa_throw";
339 static const char *g_throw_name2 =
"__cxa_rethrow";
340 static const char *g_exception_throw_name =
"__cxa_allocate_exception";
343 names.push_back(g_catch_name);
346 names.push_back(g_throw_name1);
347 names.push_back(g_throw_name2);
351 names.push_back(g_exception_throw_name);
368 if (!thread_sp->SafeToCallFunctions())
388 thread_sp->CalculateExecutionContext(exe_ctx);
404 m_process->GetTarget().GetFunctionCallerForLanguage(
409 func_call_ret = function_caller->
ExecuteFunction(exe_ctx,
nullptr, options,
410 diagnostics, results);
415 size_t ptr_size =
m_process->GetAddressByteSize();
420 if (!
error.Success()) {
433 return dyn_exception;
440 std::lock_guard<std::mutex> locker(
m_mutex);
450 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,...)
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.
Generic representation of a type in a programming language.
lldb::TypeClass GetTypeClass() const
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...
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.
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.
TypeAndOrName GetDynamicTypeInfo(const lldb_private::Address &vtable_addr)
ItaniumABIRuntime(Process *process)
lldb::ValueObjectSP GetExceptionObjectForThread(lldb::ThreadSP thread_sp)
void AppendExceptionBreakpointFilterModules(FileSpecList &list, const Target &target)
void AppendExceptionBreakpointFunctions(std::vector< const char * > &names, bool catch_bp, bool throw_bp, bool for_expressions)
DynamicTypeCache m_dynamic_type_map
llvm::Expected< LanguageRuntime::VTableInfo > GetVTableInfo(ValueObject &in_value, bool check_type)
bool GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic, TypeAndOrName &class_type_or_name, Address &dynamic_address, Value::ValueType &value_type)
void SetDynamicTypeInfo(const lldb_private::Address &vtable_addr, const TypeAndOrName &type_info)
llvm::Error TypeHasVTable(CompilerType type)
TypeAndOrName GetTypeInfo(ValueObject &in_value, const LanguageRuntime::VTableInfo &vtable_info)
VTableInfoCache m_vtable_info_map
ConstString GetDemangledName() const
Demangled name get accessor.
A collection class for Module objects.
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
A plug-in interface definition class for debugging a process.
lldb::addr_t FixDataAddress(lldb::addr_t pc)
lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status &error)
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.
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
int64_t ReadSignedIntegerFromMemory(const Address &addr, size_t integer_byte_size, int64_t fail_value, Status &error, bool force_live_memory=false)
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, uint32_t stop_id=SectionLoadHistory::eStopIDNow, bool allow_section_end=false)
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
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)
virtual ConstString GetTypeName()
static lldb::ValueObjectSP CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data, const ExecutionContext &exe_ctx, CompilerType type)
CompilerType GetCompilerType()
AddrAndType GetPointerValue()
const ExecutionContextRef & GetExecutionContextRef() const
virtual AddrAndType GetAddressOf(bool scalar_is_load_address=true)
const Scalar & GetScalar() const
See comment on m_scalar to understand what GetScalar returns.
ValueType
Type that describes Value::m_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::Thread > ThreadSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
@ eLanguageTypeC
Non-standardized C, such as K&R.
ExpressionResults
The results of expression evaluation.
std::shared_ptr< lldb_private::Type > TypeSP
std::shared_ptr< lldb_private::TypeSystemClang > TypeSystemClangSP
std::shared_ptr< lldb_private::Module > ModuleSP
Symbol * symbol
Address of the vtable's virtual function table.