8#include "clang/AST/Type.h"
27#include "llvm/ADT/StringRef.h"
28#include "llvm/Support/DJB.h"
49 return name == g_self || name == g_cmd;
54 const char *class_name) {
55 return AddClass(isa, descriptor_sp, llvm::djbHash(class_name));
63 "Caching: class 0x%" PRIx64
" selector 0x%" PRIx64
64 " implementation 0x%" PRIx64
".",
65 class_addr, selector, impl_addr);
66 m_impl_cache.insert(std::pair<ClassAndSel, lldb::addr_t>(
71 llvm::StringRef sel_str,
75 LLDB_LOG(log,
"Caching: class {0} selector {1} implementation {2}.",
76 class_addr, sel_str, impl_addr);
92 llvm::StringRef sel_str) {
102 CompleteClassMap::iterator complete_class_iter =
107 TypeSP complete_type_sp(complete_class_iter->second.lock());
109 if (complete_type_sp)
110 return complete_type_sp;
122 const size_t matching_symbols = sc_list.
GetSize();
124 if (matching_symbols) {
136 module_sp->FindTypes(query, results);
139 type_sp->GetForwardCompilerType())) {
152 const char *ivar_name) {
157 lldb::addr_t value, uint32_t ptr_size,
bool allow_NULLs,
bool allow_tagged,
158 bool check_version_specific)
const {
161 if ((value % 2) == 1 && allow_tagged)
163 if ((value % ptr_size) == 0)
164 return (check_version_specific ?
CheckPointer(value, ptr_size) :
true);
189 if (it->second->GetClassName() == name)
196 const uint32_t name_hash = llvm::djbHash(name.
GetStringRef());
201 for (
auto isa : matches_it->second)
212 if (update_if_needed)
223 std::lock_guard<std::recursive_mutex> guard(module_list.
GetMutex());
225 size_t num_modules = module_list.
GetSize();
226 for (
size_t i = 0; i < num_modules; i++) {
241 if (objc_super_class_sp)
242 return objc_super_class_sp->GetISA();
276 return objc_class_sp;
284 if (!objc_class_sp->IsKVO())
285 return objc_class_sp;
288 if (non_kvo_objc_class_sp && non_kvo_objc_class_sp->IsValid())
289 return non_kvo_objc_class_sp;
317 if (objc_class_sp && objc_class_sp->IsValid()) {
318 if (!objc_class_sp->IsKVO())
319 return objc_class_sp;
322 if (non_kvo_objc_class_sp && non_kvo_objc_class_sp->IsValid())
323 return non_kvo_objc_class_sp;
331 bool for_expression) {
343std::optional<uint64_t>
352 if (!class_descriptor_sp)
355 int32_t max_offset = INT32_MIN;
356 uint64_t sizeof_max = 0;
359 for (
size_t idx = 0; idx < class_descriptor_sp->GetNumIVars(); idx++) {
360 const auto &ivar = class_descriptor_sp->GetIVarAtIndex(idx);
361 int32_t cur_offset = ivar.m_offset;
362 if (cur_offset > max_offset) {
363 max_offset = cur_offset;
364 sizeof_max = ivar.m_size;
369 uint64_t size = 8 * (max_offset + sizeof_max);
370 if (found && size > 0) {
387 return precondition_sp;
392 const char *class_name) {
412 "The ObjC Exception breakpoint doesn't support extra options.");
420 auto *persistent_state = llvm::cast<ClangPersistentVariables>(
422 if (!persistent_state)
425 auto clang_modules_decl_vendor_sp =
426 persistent_state->GetClangModulesDeclVendor();
427 if (!clang_modules_decl_vendor_sp)
430 auto types = clang_modules_decl_vendor_sp->FindTypes(
435 return types.front();
443 std::vector<CompilerDecl> compiler_decls;
444 runtime_vendor->FindDecls(class_name,
false,
UINT32_MAX, compiler_decls);
445 if (compiler_decls.empty())
449 llvm::dyn_cast<TypeSystemClang>(compiler_decls[0].GetTypeSystem());
453 return ctx->GetTypeForDecl(compiler_decls[0].GetOpaqueDecl());
456std::optional<CompilerType>
459 bool is_pointer_type =
false;
462 is_pointer_type =
true;
464 class_type = base_type;
475 if (
TypeSP complete_objc_class_type_sp =
478 complete_objc_class_type_sp->GetFullCompilerType();
480 return is_pointer_type ? complete_class.GetPointerType() : complete_class;
486 return is_pointer_type ? found.GetPointerType() : found;
489 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,...)
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
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