8#include "clang/AST/Type.h"
27#include "llvm/ADT/StringRef.h"
28#include "llvm/Support/DJB.h"
42 m_isa_to_descriptor(), m_hash_to_isa_map(), m_type_size_cache(),
43 m_isa_to_descriptor_stop_id(
UINT32_MAX), m_complete_class_cache(),
44 m_negative_complete_class_cache() {}
49 return name == g_self || name == g_cmd;
54 const char *class_name) {
70 "Caching: class 0x%" PRIx64
" selector 0x%" PRIx64
71 " implementation 0x%" PRIx64
".",
72 class_addr, selector, impl_addr);
74 m_impl_cache.insert(std::pair<ClassAndSel, lldb::addr_t>(
79 llvm::StringRef sel_str,
83 LLDB_LOG(log,
"Caching: class {0} selector {1} implementation {2}.",
84 class_addr, sel_str, impl_addr);
100 llvm::StringRef sel_str) {
104 return (*pos).second;
110 CompleteClassMap::iterator complete_class_iter =
115 TypeSP complete_type_sp(complete_class_iter->second.lock());
117 if (complete_type_sp)
118 return complete_type_sp;
130 const size_t matching_symbols = sc_list.
GetSize();
132 if (matching_symbols) {
144 module_sp->FindTypes(query, results);
147 type_sp->GetForwardCompilerType())) {
160 const char *ivar_name) {
165 lldb::addr_t value, uint32_t ptr_size,
bool allow_NULLs,
bool allow_tagged,
166 bool check_version_specific)
const {
169 if ((value % 2) == 1 && allow_tagged)
171 if ((value % ptr_size) == 0)
172 return (check_version_specific ?
CheckPointer(value, ptr_size) :
true);
196 if (pos->second->GetClassName() == name)
202 const uint32_t name_hash = llvm::djbHash(name.
GetStringRef());
203 std::pair<HashToISAIterator, HashToISAIterator> range =
210 if (pos->second->GetClassName() == name)
222 if (update_if_needed)
233 std::lock_guard<std::recursive_mutex> guard(module_list.
GetMutex());
235 size_t num_modules = module_list.
GetSize();
236 for (
size_t i = 0; i < num_modules; i++) {
251 if (objc_super_class_sp)
252 return objc_super_class_sp->GetISA();
286 return objc_class_sp;
294 if (!objc_class_sp->IsKVO())
295 return objc_class_sp;
298 if (non_kvo_objc_class_sp && non_kvo_objc_class_sp->IsValid())
299 return non_kvo_objc_class_sp;
327 if (objc_class_sp && objc_class_sp->IsValid()) {
328 if (!objc_class_sp->IsKVO())
329 return objc_class_sp;
332 if (non_kvo_objc_class_sp && non_kvo_objc_class_sp->IsValid())
333 return non_kvo_objc_class_sp;
341 bool for_expression) {
342 if (m_scratch_ast_ctx_sp)
343 return RealizeType(*m_scratch_ast_ctx_sp, name, for_expression);
353std::optional<uint64_t>
362 if (!class_descriptor_sp)
365 int32_t max_offset = INT32_MIN;
366 uint64_t sizeof_max = 0;
369 for (
size_t idx = 0; idx < class_descriptor_sp->GetNumIVars(); idx++) {
370 const auto &ivar = class_descriptor_sp->GetIVarAtIndex(idx);
371 int32_t cur_offset = ivar.m_offset;
372 if (cur_offset > max_offset) {
373 max_offset = cur_offset;
374 sizeof_max = ivar.m_size;
379 uint64_t size = 8 * (max_offset + sizeof_max);
380 if (found && size > 0) {
397 return precondition_sp;
402 const char *class_name) {
403 m_class_names.insert(class_name);
421 error.SetErrorString(
422 "The ObjC Exception breakpoint doesn't support extra options.");
426std::optional<CompilerType>
429 bool is_pointer_type =
false;
432 is_pointer_type =
true;
434 class_type = base_type;
446 if (!complete_objc_class_type_sp)
450 complete_objc_class_type_sp->GetFullCompilerType());
455 return complete_class;
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOGF(log,...)
A command line argument class.
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
Generic representation of a type in a programming language.
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
lldb::opaque_compiler_type_t GetOpaqueQualType() const
ConstString GetTypeName(bool BaseOnly=false) const
bool GetCompleteType() const
Type Completion.
A uniqued constant string class.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Process * GetProcessPtr() const
Returns a pointer to the process object.
A collection class for Module objects.
std::recursive_mutex & GetMutex() const
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
lldb::ModuleSP GetModuleAtIndex(size_t idx) const
Get the module shared pointer for the module at index idx.
size_t GetSize() const
Gets the size of the module list.
bool IsPointerValid(lldb::addr_t value, uint32_t ptr_size, bool allow_NULLs=false, bool allow_tagged=false, bool check_version_specific=false) const
virtual bool CheckPointer(lldb::addr_t value, uint32_t ptr_size) const
virtual CompilerType RealizeType(TypeSystemClang &ast_ctx, const char *name, bool for_expression)=0
virtual ~EncodingToType()
Status ConfigurePrecondition(Args &args) override
void GetDescription(Stream &stream, lldb::DescriptionLevel level) override
ObjCExceptionPrecondition()
bool EvaluatePrecondition(StoppointCallbackContext &context) override
void AddClassName(const char *class_name)
virtual bool HasReadObjCLibrary()=0
HashToISAMap::iterator HashToISAIterator
ObjCLanguageRuntime(Process *process)
virtual ObjCISA GetISA(ConstString name)
HashToISAMap m_hash_to_isa_map
CompleteClassSet m_negative_complete_class_cache
virtual EncodingToTypeSP GetEncodingToType()
std::shared_ptr< ClassDescriptor > ClassDescriptorSP
bool AddClass(ObjCISA isa, const ClassDescriptorSP &descriptor_sp)
virtual bool ReadObjCLibrary(const lldb::ModuleSP &module_sp)=0
ISAToDescriptorMap::iterator ISAToDescriptorIterator
std::optional< uint64_t > GetTypeBitSize(const CompilerType &compiler_type) override
std::pair< ISAToDescriptorIterator, ISAToDescriptorIterator > GetDescriptorIteratorPair(bool update_if_needed=true)
virtual size_t GetByteOffsetForIvar(CompilerType &parent_qual_type, const char *ivar_name)
ISAToDescriptorIterator GetDescriptorIterator(ConstString name)
CompleteClassMap m_complete_class_cache
~ObjCLanguageRuntime() override
TypeSizeCache m_type_size_cache
lldb::addr_t LookupInMethodCache(lldb::addr_t class_addr, lldb::addr_t sel)
void UpdateISAToDescriptorMap()
lldb::TypeSP LookupInCompleteClassCache(ConstString &name)
virtual bool IsModuleObjCLibrary(const lldb::ModuleSP &module_sp)=0
MsgImplStrMap m_impl_str_cache
ClassDescriptorSP GetNonKVOClassDescriptor(ValueObject &in_value)
virtual void UpdateISAToDescriptorMapIfNeeded()=0
std::optional< CompilerType > GetRuntimeType(CompilerType base_type) override
void ReadObjCLibraryIfNeeded(const ModuleList &module_list)
virtual ClassDescriptorSP GetClassDescriptorFromISA(ObjCISA isa)
bool IsAllowedRuntimeValue(ConstString name) override
Check whether the name is "self" or "_cmd" and should show up in "frame variable".
ISAToDescriptorMap m_isa_to_descriptor
virtual ClassDescriptorSP GetClassDescriptor(ValueObject &in_value)
virtual ClassDescriptorSP GetClassDescriptorFromClassName(ConstString class_name)
void AddToMethodCache(lldb::addr_t class_addr, lldb::addr_t sel, lldb::addr_t impl_addr)
static lldb::BreakpointPreconditionSP GetBreakpointExceptionPrecondition(lldb::LanguageType language, bool throw_bp)
virtual ObjCISA GetParentClass(ObjCISA isa)
std::shared_ptr< EncodingToType > EncodingToTypeSP
A plug-in interface definition class for debugging a process.
lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status &error)
const lldb::ABISP & GetABI()
Target & GetTarget()
Get the target object pointer for this module.
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
A stream class that can stream formatted output to a file.
Defines a list of symbol context objects.
bool GetContextAtIndex(size_t idx, SymbolContext &sc) const
Get accessor for a symbol context at index idx.
uint32_t GetSize() const
Get accessor for a symbol context list size.
Defines a symbol context baton that can be handed other debug core functions.
lldb::ModuleSP module_sp
The Module for a given query.
const ModuleList & GetImages() const
Get accessor for the images for this process.
void Insert(_KeyType k, _ValueType v)
_ValueType Lookup(_KeyType k)
TypeIterable Types() const
The implementation of lldb::Type's m_payload field for TypeSystemClang.
bool IsCompleteObjCClass()
A class that contains all state required for type lookups.
This class tracks the state and results of a TypeQuery.
static bool IsObjCObjectOrInterfaceType(const CompilerType &type)
static bool IsObjCObjectPointerType(const CompilerType &type, CompilerType *target_type=nullptr)
lldb::addr_t GetPointerValue(AddressType *address_type=nullptr)
CompilerType GetCompilerType()
const ExecutionContextRef & GetExecutionContextRef() const
#define LLDB_INVALID_ADDRESS
#define LLDB_INVALID_IVAR_OFFSET
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.
std::shared_ptr< lldb_private::ABI > ABISP
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
LanguageType
Programming language type.
@ eLanguageTypeObjC
Objective-C.
std::shared_ptr< lldb_private::Type > TypeSP
std::shared_ptr< lldb_private::BreakpointPrecondition > BreakpointPreconditionSP
std::shared_ptr< lldb_private::Module > ModuleSP