8#include "clang/AST/Type.h"
28#include "llvm/ADT/StringRef.h"
29#include "llvm/Support/DJB.h"
43 switch (arch.
GetTriple().getObjectFormat()) {
44 case llvm::Triple::MachO:
45 case llvm::Triple::ELF:
46 case llvm::Triple::COFF:
63 return name == g_self || name == g_cmd;
68 const char *class_name) {
69 return AddClass(isa, descriptor_sp, llvm::djbHash(class_name));
77 "Caching: class 0x%" PRIx64
" selector 0x%" PRIx64
78 " implementation 0x%" PRIx64
".",
79 class_addr, selector, impl_addr);
80 m_impl_cache.insert(std::pair<ClassAndSel, lldb::addr_t>(
85 llvm::StringRef sel_str,
89 LLDB_LOG(log,
"Caching: class {0} selector {1} implementation {2}.",
90 class_addr, sel_str, impl_addr);
101 return (*pos).second;
106 llvm::StringRef sel_str) {
110 return (*pos).second;
116 CompleteClassMap::iterator complete_class_iter =
121 TypeSP complete_type_sp(complete_class_iter->second.lock());
123 if (complete_type_sp)
124 return complete_type_sp;
136 const size_t matching_symbols = sc_list.
GetSize();
138 if (matching_symbols) {
150 module_sp->FindTypes(query, results);
153 type_sp->GetForwardCompilerType())) {
166 const char *ivar_name) {
171 lldb::addr_t value, uint32_t ptr_size,
bool allow_NULLs,
bool allow_tagged,
172 bool check_version_specific)
const {
175 if ((value % 2) == 1 && allow_tagged)
177 if ((value % ptr_size) == 0)
178 return (check_version_specific ?
CheckPointer(value, ptr_size) :
true);
203 if (it->second->GetClassName() == name)
210 const uint32_t name_hash = llvm::djbHash(name.
GetStringRef());
215 for (
auto isa : matches_it->second)
226 if (update_if_needed)
237 std::lock_guard<std::recursive_mutex> guard(module_list.
GetMutex());
239 size_t num_modules = module_list.
GetSize();
240 for (
size_t i = 0; i < num_modules; i++) {
255 if (objc_super_class_sp)
256 return objc_super_class_sp->GetISA();
290 return objc_class_sp;
298 if (!objc_class_sp->IsKVO())
299 return objc_class_sp;
302 if (non_kvo_objc_class_sp && non_kvo_objc_class_sp->IsValid())
303 return non_kvo_objc_class_sp;
331 if (objc_class_sp && objc_class_sp->IsValid()) {
332 if (!objc_class_sp->IsKVO())
333 return objc_class_sp;
336 if (non_kvo_objc_class_sp && non_kvo_objc_class_sp->IsValid())
337 return non_kvo_objc_class_sp;
345 bool for_expression) {
357std::optional<uint64_t>
366 if (!class_descriptor_sp)
369 int32_t max_offset = INT32_MIN;
370 uint64_t sizeof_max = 0;
373 for (
size_t idx = 0; idx < class_descriptor_sp->GetNumIVars(); idx++) {
374 const auto &ivar = class_descriptor_sp->GetIVarAtIndex(idx);
375 int32_t cur_offset = ivar.m_offset;
376 if (cur_offset > max_offset) {
377 max_offset = cur_offset;
378 sizeof_max = ivar.m_size;
383 uint64_t size = 8 * (max_offset + sizeof_max);
384 if (found && size > 0) {
401 return precondition_sp;
406 const char *class_name) {
426 "The ObjC Exception breakpoint doesn't support extra options.");
434 auto *persistent_state = llvm::cast<ClangPersistentVariables>(
436 if (!persistent_state)
439 auto clang_modules_decl_vendor_sp =
440 persistent_state->GetClangModulesDeclVendor();
441 if (!clang_modules_decl_vendor_sp)
444 auto types = clang_modules_decl_vendor_sp->FindTypes(
449 return types.front();
457 std::vector<CompilerDecl> compiler_decls;
458 runtime_vendor->FindDecls(class_name,
false,
UINT32_MAX, compiler_decls);
459 if (compiler_decls.empty())
463 llvm::dyn_cast<TypeSystemClang>(compiler_decls[0].GetTypeSystem());
467 return ctx->GetTypeForDecl(compiler_decls[0].GetOpaqueDecl());
470std::optional<CompilerType>
473 bool is_pointer_type =
false;
476 is_pointer_type =
true;
478 class_type = base_type;
489 if (
TypeSP complete_objc_class_type_sp =
492 complete_objc_class_type_sp->GetFullCompilerType();
494 return is_pointer_type ? complete_class.GetPointerType() : complete_class;
500 return is_pointer_type ? found.GetPointerType() : found;
503 return is_pointer_type ? found.GetPointerType() : found;
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,...)
An architecture specification class.
llvm::Triple & GetTriple()
Architecture triple accessor.
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.
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.
LanguageRuntime(Process *process)
virtual DeclVendor * GetDeclVendor()
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()
std::shared_ptr< TypeSystemClang > m_scratch_ast_ctx_sp
std::unordered_set< std::string > m_class_names
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
ObjCLanguageRuntime(Process *process)
virtual ObjCISA GetISA(ConstString name)
HashToISAMap m_hash_to_isa_map
CompleteClassSet m_negative_complete_class_cache
uint32_t m_isa_to_descriptor_stop_id
virtual EncodingToTypeSP GetEncodingToType()
std::shared_ptr< ClassDescriptor > ClassDescriptorSP
static bool IsSupportedForArchitecture(const ArchSpec &arch)
Returns whether the architecture's object file format supports Objective-C code generation.
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)
CompilerType LookupInRuntime(ConstString class_name)
LazyBool m_has_new_literals_and_indexing
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
CompilerType LookupInModulesVendor(ConstString class_name, Target &process)
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)
static Status FromErrorString(const char *str)
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.
PersistentExpressionState * GetPersistentExpressionStateForLanguage(lldb::LanguageType language)
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)
CompilerType GetCompilerType()
AddrAndType GetPointerValue()
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.
@ eLanguageTypeC
Non-standardized C, such as K&R.
@ eLanguageTypeObjC
Objective-C.
std::shared_ptr< lldb_private::Type > TypeSP
std::shared_ptr< lldb_private::BreakpointPrecondition > BreakpointPreconditionSP
std::shared_ptr< lldb_private::Module > ModuleSP