Go to the documentation of this file.
8 #include "clang/AST/Type.h"
26 #include "llvm/ADT/StringRef.h"
27 #include "llvm/Support/DJB.h"
35 ObjCLanguageRuntime::~ObjCLanguageRuntime() {}
37 ObjCLanguageRuntime::ObjCLanguageRuntime(
Process *process)
40 m_isa_to_descriptor(), m_hash_to_isa_map(), m_type_size_cache(),
41 m_isa_to_descriptor_stop_id(
UINT32_MAX), m_complete_class_cache(),
42 m_negative_complete_class_cache() {}
47 return name == g_self || name == g_cmd;
52 const char *class_name) {
68 "Caching: class 0x%" PRIx64
" selector 0x%" PRIx64
69 " implementation 0x%" PRIx64
".",
70 class_addr, selector, impl_addr);
72 m_impl_cache.insert(std::pair<ClassAndSel, lldb::addr_t>(
87 CompleteClassMap::iterator complete_class_iter =
92 TypeSP complete_type_sp(complete_class_iter->second.lock());
95 return complete_type_sp;
107 const size_t matching_symbols = sc_list.
GetSize();
109 if (matching_symbols) {
119 const bool exact_match =
true;
123 llvm::DenseSet<SymbolFile *> searched_symbol_files;
124 module_sp->
FindTypes(name, exact_match, max_matches, searched_symbol_files,
131 type_sp->GetForwardCompilerType())) {
144 const char *ivar_name) {
150 bool check_version_specific)
const {
153 if ((value % 2) == 1 && allow_tagged)
155 if ((value % ptr_size) == 0)
156 return (check_version_specific ?
CheckPointer(value, ptr_size) :
true);
180 if (pos->second->GetClassName() == name)
187 std::pair<HashToISAIterator, HashToISAIterator> range =
194 if (pos->second->GetClassName() == name)
206 if (update_if_needed)
219 if (objc_super_class_sp)
220 return objc_super_class_sp->GetISA();
254 return objc_class_sp;
262 if (!objc_class_sp->IsKVO())
263 return objc_class_sp;
266 if (non_kvo_objc_class_sp && non_kvo_objc_class_sp->IsValid())
267 return non_kvo_objc_class_sp;
288 if (objc_class_sp && objc_class_sp->IsValid()) {
289 if (!objc_class_sp->IsKVO())
290 return objc_class_sp;
293 if (non_kvo_objc_class_sp && non_kvo_objc_class_sp->IsValid())
294 return non_kvo_objc_class_sp;
302 bool for_expression) {
303 if (m_scratch_ast_ctx_up)
304 return RealizeType(*m_scratch_ast_ctx_up, name, for_expression);
324 if (!class_descriptor_sp)
327 int32_t max_offset = INT32_MIN;
328 uint64_t sizeof_max = 0;
331 for (
size_t idx = 0; idx < class_descriptor_sp->GetNumIVars(); idx++) {
332 const auto &ivar = class_descriptor_sp->GetIVarAtIndex(idx);
333 int32_t cur_offset = ivar.m_offset;
334 if (cur_offset > max_offset) {
335 max_offset = cur_offset;
336 sizeof_max = ivar.m_size;
341 size = 8 * (max_offset + sizeof_max);
348 lldb::BreakpointPreconditionSP
352 return lldb::BreakpointPreconditionSP();
354 return lldb::BreakpointPreconditionSP();
355 BreakpointPreconditionSP precondition_sp(
357 return precondition_sp;
362 const char *class_name) {
363 m_class_names.insert(class_name);
380 error.SetErrorString(
381 "The ObjC Exception breakpoint doesn't support extra options.");
385 llvm::Optional<CompilerType>
388 bool is_pointer_type =
false;
391 is_pointer_type =
true;
393 class_type = base_type;
405 if (!complete_objc_class_type_sp)
409 complete_objc_class_type_sp->GetFullCompilerType());
414 return complete_class;
virtual size_t GetByteOffsetForIvar(CompilerType &parent_qual_type, const char *ivar_name)
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
ClassDescriptorSP GetNonKVOClassDescriptor(ValueObject &in_value)
CompleteClassMap m_complete_class_cache
ISAToDescriptorIterator GetDescriptorIterator(ConstString name)
std::shared_ptr< ClassDescriptor > ClassDescriptorSP
Process * GetProcessPtr() const
Returns a pointer to the process object.
ObjCExceptionPrecondition()
virtual ClassDescriptorSP GetClassDescriptorFromClassName(ConstString class_name)
virtual ClassDescriptorSP GetClassDescriptorFromISA(ObjCISA isa)
HashToISAMap::iterator HashToISAIterator
#define LLDB_LOGF(log,...)
std::shared_ptr< EncodingToType > EncodingToTypeSP
Target & GetTarget()
Get the target object pointer for this module.
bool IsPointerValid(lldb::addr_t value, uint32_t ptr_size, bool allow_NULLs=false, bool allow_tagged=false, bool check_version_specific=false) const
lldb::addr_t GetPointerValue(AddressType *address_type=nullptr)
LanguageType
Programming language type.
virtual ObjCISA GetISA(ConstString name)
static lldb::BreakpointPreconditionSP GetBreakpointExceptionPrecondition(lldb::LanguageType language, bool throw_bp)
bool GetContextAtIndex(size_t idx, SymbolContext &sc) const
Get accessor for a symbol context at index idx.
lldb::opaque_compiler_type_t GetOpaqueQualType() const
bool GetTypeBitSize(const CompilerType &compiler_type, uint64_t &size) override
static bool IsObjCObjectPointerType(const CompilerType &type, CompilerType *target_type=nullptr)
The implementation of lldb::Type's m_payload field for TypeSystemClang.
lldb::TypeSP GetTypeAtIndex(uint32_t idx)
const ModuleList & GetImages() const
Get accessor for the images for this process.
_ValueType Lookup(_KeyType k)
virtual ObjCISA GetParentClass(ObjCISA isa)
HashToISAMap m_hash_to_isa_map
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
Status ConfigurePrecondition(Args &args) override
static llvm::raw_ostream & error(Stream &strm)
lldb::TypeSP LookupInCompleteClassCache(ConstString &name)
llvm::Optional< CompilerType > GetRuntimeType(CompilerType base_type) override
void UpdateISAToDescriptorMap()
void GetDescription(Stream &stream, lldb::DescriptionLevel level) override
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
static bool IsObjCObjectOrInterfaceType(const CompilerType &type)
void Insert(_KeyType k, _ValueType v)
virtual ClassDescriptorSP GetClassDescriptor(ValueObject &in_value)
virtual ~EncodingToType()
std::pair< ISAToDescriptorIterator, ISAToDescriptorIterator > GetDescriptorIteratorPair(bool update_if_needed=true)
bool EvaluatePrecondition(StoppointCallbackContext &context) override
uint32_t GetSize() const
Get accessor for a symbol context list size.
bool IsAllowedRuntimeValue(ConstString name) override
Check whether the name is "self" or "_cmd" and should show up in "frame variable".
Log * GetLogIfAllCategoriesSet(uint32_t mask)
const ExecutionContextRef & GetExecutionContextRef() const
CompleteClassSet m_negative_complete_class_cache
@ eLanguageTypeObjC
Objective-C.
#define LLDB_INVALID_IVAR_OFFSET
bool AddClass(ObjCISA isa, const ClassDescriptorSP &descriptor_sp)
ISAToDescriptorMap m_isa_to_descriptor
virtual void UpdateISAToDescriptorMapIfNeeded()=0
virtual CompilerType RealizeType(TypeSystemClang &ast_ctx, const char *name, bool for_expression)=0
bool GetCompleteType() const
Type Completion.
virtual EncodingToTypeSP GetEncodingToType()
void AddToMethodCache(lldb::addr_t class_addr, lldb::addr_t sel, lldb::addr_t impl_addr)
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
ISAToDescriptorMap::iterator ISAToDescriptorIterator
TypeList FindTypes(ConstString name)
bool IsCompleteObjCClass()
ConstString GetTypeName() const
CompilerType GetCompilerType()
lldb::ModuleSP module_sp
The Module for a given query.
#define LLDB_INVALID_ADDRESS
Invalid value definitions.
Generic representation of a type in a programming language.
A class that represents a running process on the host machine.
TypeSizeCache m_type_size_cache
lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status &error)
void AddClassName(const char *class_name)
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
lldb::addr_t LookupInMethodCache(lldb::addr_t class_addr, lldb::addr_t sel)
virtual bool CheckPointer(lldb::addr_t value, uint32_t ptr_size) const
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.