Go to the documentation of this file.
32 #include "llvm/ADT/StringRef.h"
38 llvm::ArrayRef<CompilerContext> pattern) {
39 auto ctx = context_chain.begin();
40 auto ctx_end = context_chain.end();
47 if (pat.kind == CompilerContextKind::AnyModule) {
50 return ctx.
kind != CompilerContextKind::Module;
58 if (pat.kind != CompilerContextKind::AnyModule && ctx->name != pat.name)
66 void CompilerContext::Dump()
const {
71 case CompilerContextKind::TranslationUnit:
72 printf(
"TranslationUnit");
74 case CompilerContextKind::Module:
77 case CompilerContextKind::Namespace:
80 case CompilerContextKind::Class:
83 case CompilerContextKind::Struct:
86 case CompilerContextKind::Union:
89 case CompilerContextKind::Function:
92 case CompilerContextKind::Variable:
95 case CompilerContextKind::Enum:
96 printf(
"Enumeration");
98 case CompilerContextKind::Typedef:
101 case CompilerContextKind::AnyModule:
104 case CompilerContextKind::AnyType:
108 printf(
"(\"%s\")\n", name.GetCString());
116 m_type_list.Append(TypeImplSP(
new TypeImpl(type)));
130 const lldb::TypeSP &type_sp)
132 m_symbol_file(symbol_file), m_type_sp(type_sp) {}
138 m_type_sp = resolved_type->shared_from_this();
148 : std::enable_shared_from_this<
Type>(),
UserID(uid), m_name(name),
149 m_symbol_file(symbol_file), m_context(context),
150 m_encoding_uid(encoding_uid), m_encoding_uid_type(encoding_uid_type),
151 m_decl(decl), m_compiler_type(compiler_type),
152 m_compiler_type_resolve_state(compiler_type ? compiler_type_resolve_state
154 m_payload(opaque_payload) {
165 : std::enable_shared_from_this<
Type>(),
UserID(0),
166 m_name(
"<INVALID TYPE>") {
173 *s <<
"id = " << (
const UserID &)*
this;
179 *s <<
", name = \"" << type_name <<
'"';
181 if (qualified_type_name != type_name) {
182 *s <<
", qualified = \"" << qualified_type_name <<
'"';
194 *s <<
", compiler_type = \"";
224 s->
PutCString(
" (unresolved L value reference)");
227 s->
PutCString(
" (unresolved R value reference)");
237 s->
Printf(
"%p: ",
static_cast<void *
>(
this));
239 *s <<
"Type" <<
static_cast<const UserID &
>(*this) <<
' ';
241 *s <<
", name = \"" <<
m_name <<
"\"";
246 if (show_context &&
m_context !=
nullptr) {
252 bool show_fullpaths =
false;
285 s->
PutCString(
" (unresolved L value reference)");
288 s->
PutCString(
" (unresolved R value reference)");
312 bool show_types,
bool show_summary,
bool verbose,
330 show_types, show_summary, verbose, 0);
356 if (llvm::Optional<uint64_t> size = encoding_type->
GetByteSize(exe_scope)) {
362 if (llvm::Optional<uint64_t> size =
393 lldb::TypeSP type_sp;
397 type_sp = typedef_type->shared_from_this();
411 bool show_types,
bool show_summary,
bool verbose) {
420 DumpValue(exe_ctx, s, data, 0, show_types, show_summary, verbose);
435 const uint64_t byte_size =
443 uint8_t *dst =
const_cast<uint8_t *
>(data.
PeekData(0, byte_size));
444 if (dst !=
nullptr) {
449 memcpy(dst,
reinterpret_cast<uint8_t *
>(addr), byte_size);
474 Type *encoding_type =
nullptr;
482 if (encoding_compiler_type.
IsValid()) {
532 llvm_unreachable(
"Unhandled encoding_data_type.");
536 auto type_system_or_err =
538 if (
auto err = type_system_or_err.takeError()) {
540 "Unable to construct void type from TypeSystemClang");
584 llvm_unreachable(
"Unhandled encoding_data_type.");
614 if (encoding_type ==
nullptr)
618 compiler_type_resolve_state;
639 assert(encoding_type !=
this);
642 return encoding_mask;
665 llvm::StringRef &scope,
666 llvm::StringRef &basename,
667 TypeClass &type_class) {
668 type_class = eTypeClassAny;
674 if (basename.consume_front(
"struct "))
675 type_class = eTypeClassStruct;
676 else if (basename.consume_front(
"class "))
677 type_class = eTypeClassClass;
678 else if (basename.consume_front(
"union "))
679 type_class = eTypeClassUnion;
680 else if (basename.consume_front(
"enum "))
681 type_class = eTypeClassEnumeration;
682 else if (basename.consume_front(
"typedef "))
683 type_class = eTypeClassTypedef;
685 size_t namespace_separator = basename.find(
"::");
686 if (namespace_separator == llvm::StringRef::npos)
689 size_t template_begin = basename.find(
'<');
690 while (namespace_separator != llvm::StringRef::npos) {
691 if (template_begin != llvm::StringRef::npos &&
692 namespace_separator > template_begin) {
693 size_t template_depth = 1;
694 llvm::StringRef template_arg =
695 basename.drop_front(template_begin + 1);
696 while (template_depth > 0 && !template_arg.empty()) {
697 if (template_arg.front() ==
'<')
699 else if (template_arg.front() ==
'>')
701 template_arg = template_arg.drop_front(1);
703 if (template_depth != 0)
705 if (template_arg.empty())
707 basename = template_arg;
709 basename = basename.drop_front(namespace_separator + 2);
711 template_begin = basename.find(
'<');
712 namespace_separator = basename.find(
"::");
714 if (basename.size() < name.size()) {
715 scope = name.take_front(name.size() - basename.size());
744 : m_type_name(in_type_str) {}
747 : m_type_name(in_type_const_string) {}
758 return !(*
this == other);
807 : m_module_wp(), m_static_type(), m_dynamic_type() {
812 : m_module_wp(), m_static_type(), m_dynamic_type() {
817 : m_module_wp(), m_static_type(), m_dynamic_type(dynamic) {
823 : m_module_wp(), m_static_type(), m_dynamic_type() {
824 SetType(static_type, dynamic_type);
865 lldb::ModuleSP &module_sp)
const {
874 module_sp = input_module_wp.lock();
876 lldb::ModuleWP empty_module_wp;
882 if (empty_module_wp.owner_before(input_module_wp) ||
883 input_module_wp.owner_before(empty_module_wp)) {
899 return !(*
this == rhs);
910 TypeImpl::operator bool()
const {
return IsValid(); }
919 lldb::ModuleSP module_sp;
1032 if (prefer_dynamic) {
1044 if (prefer_dynamic) {
1058 strm.
Printf(
"Dynamic:\n");
1060 strm.
Printf(
"\nStatic:\n");
1064 strm.
PutCString(
"Invalid TypeImpl module for type has been deleted\n");
1090 stream.
Printf(
"constructor for %s",
1094 stream.
Printf(
"destructor for %s",
1131 const llvm::APSInt &value)
1132 : m_integer_type_sp(integer_type_sp), m_name(name), m_value(value),
1133 m_valid((bool)name && (bool)integer_type_sp)
CompilerType GetNonReferenceType() const
If this type is a reference to a type (L value or R value reference), return a new type with the refe...
lldb::MemberFunctionKind m_kind
@ eMemberFunctionKindDestructor
A function used to tear down existing instances.
void Format(const char *format, Args &&... args)
virtual ArchSpec GetArchitecture()=0
Get the ArchSpec for this object file.
Provides public interface for all SymbolFiles.
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
bool CheckModuleCommon(const lldb::ModuleWP &input_module_wp, lldb::ModuleSP &module_sp) const
TypeImpl GetCanonicalType() const
void DumpValue(ExecutionContext *exe_ctx, Stream *s, const DataExtractor &data, uint32_t data_offset, bool show_type, bool show_summary, bool verbose, lldb::Format format=lldb::eFormatDefault)
@ eEncodingIsSyntheticUID
This type is the synthetic type whose UID is m_encoding_uid.
bool operator==(const TypeImpl &rhs) const
virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
Format
Display format definitions.
@ eEncodingIsConstUID
This type is the type whose UID is m_encoding_uid with the const qualifier added.
size_t GetNumFunctionArguments() const
void SetName(ConstString type_name)
Process * GetProcessPtr() const
Returns a pointer to the process object.
@ eEncodingIsTypedefUID
This type is alias to a type whose UID is m_encoding_uid.
bool contextMatches(llvm::ArrayRef< CompilerContext > context_chain, llvm::ArrayRef< CompilerContext > pattern)
Match context_chain against pattern, which may contain "Any" kinds.
void SetCompilerType(CompilerType compiler_type)
bool CheckModule(lldb::ModuleSP &module_sp) const
CompilerType GetLayoutCompilerType()
ResolveState m_compiler_type_resolve_state
lldb::ModuleSP GetModule() const
@ eMemberFunctionKindUnknown
Not sure what the type of this is.
Payload m_payload
Language-specific flags.
lldb::ModuleSP GetModule()
Since Type instances only keep a "SymbolFile *" internally, other classes like TypeImpl need make sur...
@ eAddressTypeHost
Address is an address in the process that is running this code.
uint64_t m_byte_size_has_value
ConstString GetMangledName() const
void SetCString(const char *cstr)
Set the C string value.
ConstString GetDisplayTypeName() const
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
virtual llvm::Expected< lldb_private::TypeSystem & > GetTypeSystemForLanguage(lldb::LanguageType language)=0
lldb::opaque_compiler_type_t GetOpaqueQualType() const
CompilerType AddVolatileModifier() const
Return a new CompilerType adds a volatile modifier to this type if this type is valid and the type sy...
EncodingDataType m_encoding_uid_type
bool IsAggregateType() const
void ForEach(std::function< bool(const lldb::TypeSP &type_sp)> const &callback) const
void Dump(Stream *s, bool show_context, lldb::DescriptionLevel level=lldb::eDescriptionLevelFull)
lldb::Encoding GetEncoding(uint64_t &count)
@ eEncodingIsRValueReferenceUID
This type is R value reference to a type whose UID is m_encoding_uid.
CompilerType GetFunctionArgumentAtIndex(const size_t index) const
bool ResolveCompilerType(ResolveState compiler_type_resolve_state)
CompilerType m_dynamic_type
ConstString GetName() const
llvm::Optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope)
@ eEncodingInvalid
Invalid encoding.
CompilerType GetPointeeType() const
If this type is a pointer type, return the type that the pointer points to, else return an invalid ty...
void Dump(Stream *s, bool show_fullpaths) const
Dump a description of this object to a Stream.
static llvm::raw_ostream & error(Stream &strm)
lldb::MemberFunctionKind GetKind() const
CompilerContext allows an array of these items to be passed to perform detailed lookups in SymbolVend...
SymbolFile * m_symbol_file
ConstString GetDisplayTypeName() const
ConstString GetName() const
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
CompilerType GetFunctionReturnType() const
virtual Type * ResolveTypeUID(lldb::user_id_t type_uid)=0
@ eEncodingIsRestrictUID
This type is the type whose UID is m_encoding_uid with the restrict qualifier added.
CompilerType CreateTypedef(const char *name, const CompilerDeclContext &decl_ctx, uint32_t payload) const
Create a typedef to this type using "name" as the name of the typedef this type is valid and the type...
CompilerType GetType() const
bool HasCompilerType() const
lldb::Format GetFormat() const
@ eEncodingIsVolatileUID
This type is the type whose UID is m_encoding_uid with the volatile qualifier added.
lldb::TypeSP GetTypedefType()
CompilerType GetAtomicType() const
Return a new CompilerType that is the atomic type of this type.
void DumpValue(ExecutionContext *exe_ctx, Stream *s, lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, bool show_types, bool show_summary, bool verbose, uint32_t depth)
CompilerType AddConstModifier() const
Return a new CompilerType adds a const modifier to this type if this type is valid and the type syste...
size_t GetNumberOfFunctionArguments() const
void DumpTypeName(Stream *s)
lldb::ModuleSP GetExeModule()
GetModule may return module for compile unit's object file.
CompilerDeclContext GetDeclContext() const
const lldb_private::Declaration & GetDeclaration() const
SymbolFile * GetSymbolFile()
bool operator()(const lldb::TypeSP &type)
TypeImpl GetPointeeType() const
TypeImpl GetDereferencedType() const
bool WriteToMemory(ExecutionContext *exe_ctx, lldb::addr_t address, AddressType address_type, DataExtractor &data)
lldb::Encoding GetEncoding(uint64_t &count) const
ConstString GetName() const
CompilerType GetFunctionReturnType() const
void Dump(Stream *s, const char *value_if_empty=nullptr) const
Dump the object description to a stream.
CompilerType GetLValueReferenceType() const
Return a new CompilerType that is a L value reference to this type if this type is valid and the type...
SymbolContextScope * m_context
The symbol context in which this type is defined.
lldb::user_id_t GetID() const
Get accessor for the user ID.
uint32_t GetNumChildren(bool omit_empty_base_classes, const ExecutionContext *exe_ctx) const
ConstString GetName() const
uint32_t GetEncodingMask()
@ eEncodingIsPointerUID
This type is pointer to a type whose UID is m_encoding_uid.
void GetDescription(Stream *s, lldb::DescriptionLevel level, bool show_name, ExecutionContextScope *exe_scope)
virtual bool CompleteType(CompilerType &compiler_type)=0
void Clear()
Clear this object's state.
lldb::user_id_t m_encoding_uid
TypeAppendVisitor(TypeListImpl &type_list)
const ArchSpec & GetArchitecture() const
CompilerType GetFunctionArgumentType(size_t arg_idx) const
@ eMemberFunctionKindStaticMethod
A function that applies to a type rather than any instance.
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
TypeImpl GetUnqualifiedType() const
ConstString GetQualifiedName()
@ eMemberFunctionKindConstructor
A function used to create instances.
@ eEncodingIsLValueReferenceUID
This type is L value reference to a type whose UID is m_encoding_uid.
ExecutionContextScope * GetBestExecutionContextScope() const
CompilerType GetArgumentAtIndex(size_t idx) const
CompilerType GetReturnType() const
void SetType(const lldb::TypeSP &type_sp)
void SetTypeSP(lldb::TypeSP type_sp)
TypeSystem * GetTypeSystem() const
Accessors.
size_t EOL()
Output and End of Line character to the stream.
bool GetDescription(lldb_private::Stream &strm, lldb::DescriptionLevel description_level)
bool ReadFromMemory(ExecutionContext *exe_ctx, lldb::addr_t address, AddressType address_type, DataExtractor &data)
ConstString GetTypeName() const
lldb::ModuleWP m_exe_module_wp
@ eAddressTypeFile
Address is an address as found in an object or symbol file.
bool DumpValueInMemory(ExecutionContext *exe_ctx, Stream *s, lldb::addr_t address, AddressType address_type, bool show_types, bool show_summary, bool verbose)
CompilerType GetCanonicalType() const
bool operator!=(const TypeAndOrName &other) const
CompilerType GetCompilerType(bool prefer_dynamic)
CompilerType GetForwardCompilerType()
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
CompilerType AddRestrictModifier() const
Return a new CompilerType adds a restrict modifier to this type if this type is valid and the type sy...
bool operator==(const TypeAndOrName &other) const
ConstString GetMangledName() const
TypeSystem * GetTypeSystem(bool prefer_dynamic)
Encoding
Register encoding definitions.
#define LLDB_INVALID_ADDRESS
CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) const
Create related types using the current type's AST.
CompilerType GetTypedefedType() const
If the current object represents a typedef type, get the underlying type.
Generic representation of a type in a programming language.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t GetNumArguments() const
@ eLanguageTypeC
Non-standardized C, such as K&R.
TypeListImpl & m_type_list
A class that represents a running process on the host machine.
@ eDescriptionLevelVerbose
TypeImpl GetPointerType() const
Interface for representing a type system.
TypeImpl GetTypedefedType() const
virtual void DumpSymbolContext(Stream *s)=0
Dump the object's symbol context to the stream s.
MemberFunctionKind
Kind of member function.
TypeImpl GetReferenceType() const
SymbolFile & m_symbol_file
lldb::ModuleWP m_module_wp
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
virtual SymbolFile * GetSymbolFile() const
@ eEncodingIsAtomicUID
This type is the type whose UID is m_encoding_uid as an atomic type.
Sometimes you can find the name of the type corresponding to an object, but we don't have debug infor...
bool CheckExeModule(lldb::ModuleSP &module_sp) const
@ eMemberFunctionKindInstanceMethod
A function that applies to a specific instance.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
virtual ObjectFile * GetObjectFile()=0
bool GetDescription(Stream &stream)
bool operator!=(const TypeImpl &rhs) const
CompilerType m_compiler_type
#define LLDB_LOG_ERROR(log, error,...)
CompilerType GetFullCompilerType()
Target * GetTargetPtr() const
Returns a pointer to the target object.
CompilerType GetRValueReferenceType() const
Return a new CompilerType that is a R value reference to this type if this type is valid and the type...
CompilerType GetFullyUnqualifiedType() const
void DumpTypeDescription(lldb::DescriptionLevel level=lldb::eDescriptionLevelFull) const
Dump to stdout.
@ eEncodingIsUID
This type is the type whose UID is m_encoding_uid.
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
CompilerType m_compiler_type
CompilerType m_static_type
uint32_t GetNumChildren(bool omit_empty_base_classes)
static bool GetTypeScopeAndBasename(llvm::StringRef name, llvm::StringRef &scope, llvm::StringRef &basename, lldb::TypeClass &type_class)