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) {
142 const bool exact_match =
true;
146 llvm::DenseSet<SymbolFile *> searched_symbol_files;
147 module_sp->
FindTypes(name, exact_match, max_matches, searched_symbol_files,
150 for (uint32_t i = 0; i < types.
GetSize(); ++i) {
154 type_sp->GetForwardCompilerType())) {
167 const char *ivar_name) {
172 lldb::addr_t value, uint32_t ptr_size,
bool allow_NULLs,
bool allow_tagged,
173 bool check_version_specific)
const {
176 if ((value % 2) == 1 && allow_tagged)
178 if ((value % ptr_size) == 0)
179 return (check_version_specific ?
CheckPointer(value, ptr_size) :
true);
203 if (pos->second->GetClassName() == name)
209 const uint32_t name_hash = llvm::djbHash(name.
GetStringRef());
210 std::pair<HashToISAIterator, HashToISAIterator> range =
217 if (pos->second->GetClassName() == name)
229 if (update_if_needed)
240 std::lock_guard<std::recursive_mutex> guard(module_list.
GetMutex());
242 size_t num_modules = module_list.
GetSize();
243 for (
size_t i = 0; i < num_modules; i++) {
258 if (objc_super_class_sp)
259 return objc_super_class_sp->GetISA();
293 return objc_class_sp;
301 if (!objc_class_sp->IsKVO())
302 return objc_class_sp;
305 if (non_kvo_objc_class_sp && non_kvo_objc_class_sp->IsValid())
306 return non_kvo_objc_class_sp;
334 if (objc_class_sp && objc_class_sp->IsValid()) {
335 if (!objc_class_sp->IsKVO())
336 return objc_class_sp;
339 if (non_kvo_objc_class_sp && non_kvo_objc_class_sp->IsValid())
340 return non_kvo_objc_class_sp;
348 bool for_expression) {
349 if (m_scratch_ast_ctx_sp)
350 return RealizeType(*m_scratch_ast_ctx_sp, name, for_expression);
370 if (!class_descriptor_sp)
373 int32_t max_offset = INT32_MIN;
374 uint64_t sizeof_max = 0;
377 for (
size_t idx = 0; idx < class_descriptor_sp->GetNumIVars(); idx++) {
378 const auto &ivar = class_descriptor_sp->GetIVarAtIndex(idx);
379 int32_t cur_offset = ivar.m_offset;
380 if (cur_offset > max_offset) {
381 max_offset = cur_offset;
382 sizeof_max = ivar.m_size;
387 size = 8 * (max_offset + sizeof_max);
403 return precondition_sp;
408 const char *class_name) {
409 m_class_names.insert(class_name);
427 error.SetErrorString(
428 "The ObjC Exception breakpoint doesn't support extra options.");
432std::optional<CompilerType>
435 bool is_pointer_type =
false;
438 is_pointer_type =
true;
440 class_type = base_type;
452 if (!complete_objc_class_type_sp)
456 complete_objc_class_type_sp->GetFullCompilerType());
461 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::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
bool GetTypeBitSize(const CompilerType &compiler_type, uint64_t &size) override
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)
TypeList FindTypes(ConstString name)
lldb::TypeSP GetTypeAtIndex(uint32_t idx)
The implementation of lldb::Type's m_payload field for TypeSystemClang.
bool IsCompleteObjCClass()
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