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",
76 llvm::StringRef class_name = symbol_name;
80 std::string lookup_name(
"::");
81 lookup_name.append(class_name.data(), class_name.size());
91 TypeQueryOptions::e_exact_match |
92 TypeQueryOptions::e_strict_namespaces |
93 TypeQueryOptions::e_find_one);
95 module_sp->FindTypes(query, results);
98 class_types.
Insert(type_sp);
103 if (class_types.
Empty()) {
105 m_process->GetTarget().GetImages().FindTypes(
nullptr, query, results);
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())) {
123 ": static-type = '%s' has dynamic type: uid={0x%" PRIx64
124 "}, type-name='%s'\n",
127 type_sp->GetName().GetCString());
134 for (i = 0; i < class_types.
GetSize(); i++) {
139 ": static-type = '%s' has multiple matching dynamic "
140 "types: uid={0x%" PRIx64
"}, type-name='%s'\n",
143 type_sp->GetName().GetCString());
148 for (i = 0; i < class_types.
GetSize(); i++) {
152 type_sp->GetForwardCompilerType())) {
154 "0x%16.16" PRIx64
": static-type = '%s' has multiple "
155 "matching dynamic types, picking "
156 "this one: uid={0x%" PRIx64
"}, type-name='%s'\n",
159 type_sp->GetName().GetCString());
168 ": static-type = '%s' has multiple matching dynamic "
169 "types, didn't find a C++ match\n",
193 if ((type.
GetTypeClass() & (eTypeClassStruct | eTypeClassClass)) == 0) {
194 return llvm::createStringError(std::errc::invalid_argument,
195 "type \"%s\" is not a class or struct or a pointer to one",
201 return llvm::createStringError(std::errc::invalid_argument,
202 "type \"%s\" doesn't have a vtable",
205 return llvm::Error::success();
215llvm::Expected<LanguageRuntime::VTableInfo>
222 return std::move(err);
226 if (process ==
nullptr)
227 return llvm::createStringError(std::errc::invalid_argument,
230 auto [original_ptr, address_type] =
235 return llvm::createStringError(std::errc::invalid_argument,
236 "failed to get the address of the value");
243 return llvm::createStringError(std::errc::invalid_argument,
244 "failed to read vtable pointer from memory at 0x%" PRIx64,
254 return llvm::createStringError(std::errc::invalid_argument,
255 "failed to resolve vtable pointer 0x%"
256 PRIx64
"to a section", vtable_load_addr);
260 std::lock_guard<std::mutex> locker(
m_mutex);
267 if (symbol ==
nullptr)
268 return llvm::createStringError(std::errc::invalid_argument,
269 "no symbol found for 0x%" PRIx64,
274 std::lock_guard<std::mutex> locker(
m_mutex);
278 return llvm::createStringError(std::errc::invalid_argument,
279 "symbol found that contains 0x%" PRIx64
" is not a vtable symbol",
296 class_type_or_name.
Clear();
307 llvm::Expected<VTableInfo> vtable_info_or_err =
309 if (!vtable_info_or_err) {
310 llvm::consumeError(vtable_info_or_err.takeError());
314 const VTableInfo &vtable_info = vtable_info_or_err.get();
315 class_type_or_name =
GetTypeInfo(in_value, vtable_info);
317 if (!class_type_or_name)
339 const uint32_t addr_byte_size =
m_process->GetAddressByteSize();
341 vtable_load_addr - 2 * addr_byte_size;
344 if (offset_to_top_location >= vtable_load_addr)
348 offset_to_top_location, addr_byte_size, INT64_MIN,
error);
350 if (offset_to_top == INT64_MIN)
356 if (!
m_process->GetTarget().ResolveLoadAddress(
357 dynamic_addr, dynamic_address)) {
369 if (type_and_or_name.
HasType()) {
376 if (static_type_flags.
AllSet(eTypeIsPointer))
378 else if (static_type_flags.
AllSet(eTypeIsReference))
385 if (static_type_flags.
AllSet(eTypeIsPointer))
386 corrected_name.append(
" *");
387 else if (static_type_flags.
AllSet(eTypeIsReference))
388 corrected_name.append(
" &");
391 ret.
SetName(corrected_name.c_str());
416 interpreter,
"demangle",
"Demangle a C++ mangled name.",
417 "language cplusplus demangle [<mangled-name> ...]") {
425 bool demangled_any =
false;
426 bool error_any =
false;
427 for (
auto &entry : command.
entries()) {
428 if (entry.ref().empty())
436 auto name = entry.ref();
437 if (name.starts_with(
"__Z"))
438 name = name.drop_front();
443 demangled_any =
true;
449 entry.ref().str().c_str());
464 interpreter,
"cplusplus",
465 "Commands for operating on the C++ language runtime.",
466 "cplusplus <subcommand> [<subcommand-options>]") {
490 const BreakpointSP &bkpt,
bool catch_bp,
bool throw_bp) {
496 bool for_expressions) {
504 static const char *g_catch_name =
"__cxa_begin_catch";
505 static const char *g_throw_name1 =
"__cxa_throw";
506 static const char *g_throw_name2 =
"__cxa_rethrow";
507 static const char *g_exception_throw_name =
"__cxa_allocate_exception";
508 std::vector<const char *> exception_names;
509 exception_names.reserve(4);
511 exception_names.push_back(g_catch_name);
514 exception_names.push_back(g_throw_name1);
515 exception_names.push_back(g_throw_name2);
519 exception_names.push_back(g_exception_throw_name);
522 bkpt, exception_names.data(), exception_names.size(),
544 bool catch_bp,
bool throw_bp,
bool for_expressions,
bool is_internal) {
550 const bool hardware =
false;
551 const bool resolve_indirect_functions =
false;
552 return target.
CreateBreakpoint(filter_sp, exception_resolver_sp, is_internal,
553 hardware, resolve_indirect_functions);
560 const bool catch_bp =
false;
561 const bool throw_bp =
true;
562 const bool is_internal =
true;
563 const bool for_expressions =
true;
572 catch_bp, throw_bp, for_expressions, is_internal);
599 uint64_t break_site_id = stop_reason->GetValue();
600 return m_process->GetBreakpointSiteList().StopPointSiteContainsBreakpoint(
606 if (!thread_sp->SafeToCallFunctions())
626 thread_sp->CalculateExecutionContext(exe_ctx);
642 m_process->GetTarget().GetFunctionCallerForLanguage(
647 func_call_ret = function_caller->
ExecuteFunction(exe_ctx,
nullptr, options,
648 diagnostics, results);
653 size_t ptr_size =
m_process->GetAddressByteSize();
658 if (!
error.Success()) {
671 return dyn_exception;
678 std::lock_guard<std::mutex> locker(
m_mutex);
688 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,...
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
CommandObjectMultiword(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
friend class CommandInterpreter
CommandObjectParsed(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
void AddSimpleArgumentList(lldb::CommandArgumentType arg_type, ArgumentRepetitionType repetition_type=eArgRepeatPlain)
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.
bool GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic, TypeAndOrName &class_type_or_name, Address &address, Value::ValueType &value_type, llvm::ArrayRef< uint8_t > &local_buffer) override
This call should return true if it could set the name and/or the type Sets address to the address of ...
void ClearExceptionBreakpoints() override
llvm::Error TypeHasVTable(CompilerType compiler_type)
ItaniumABILanguageRuntime(Process *process)
bool ExceptionBreakpointsAreSet() 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 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)
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
lldb::SearchFilterSP GetSearchFilterForModuleList(const FileSpecList *containingModuleList)
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)
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)
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)
CompilerType GetCompilerType()
virtual ConstString GetTypeName()
static lldb::ValueObjectSP CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data, const ExecutionContext &exe_ctx, CompilerType type)
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.
@ 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.