#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/DebuggerEvents.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Expression/UtilityFunction.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Interpreter/CommandObjectMultiword.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionValueBoolean.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/TypeList.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/LanguageRuntime.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StackFrameRecognizer.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Scalar.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/Timer.h"
#include "lldb/lldb-enumerations.h"
#include "AppleObjCClassDescriptorV2.h"
#include "AppleObjCDeclVendor.h"
#include "AppleObjCRuntimeV2.h"
#include "AppleObjCTrampolineHandler.h"
#include "AppleObjCTypeEncodingParser.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclObjC.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/ScopeExit.h"
#include <cstdint>
#include <memory>
#include <string>
#include <vector>
usingnamespacelldb;
usingnamespacelldb_private;
char AppleObjCRuntimeV2::ID = …;
static const char *g_get_dynamic_class_info_name = …;
static const char *g_get_dynamic_class_info_body = …;
static const char *g_get_dynamic_class_info2_name = …;
static const char *g_get_dynamic_class_info2_body = …;
static const char *g_get_dynamic_class_info3_name = …;
static const char *g_get_dynamic_class_info3_body = …;
static const char *g_shared_cache_class_name_funcptr = …;
static const char *g_get_shared_cache_class_info_name = …;
static const char *g_get_shared_cache_class_info_body = …;
static uint64_t
ExtractRuntimeGlobalSymbol(Process *process, ConstString name,
const ModuleSP &module_sp, Status &error,
bool read_value = true, uint8_t byte_size = 0,
uint64_t default_value = LLDB_INVALID_ADDRESS,
SymbolType sym_type = lldb::eSymbolTypeData) { … }
static void RegisterObjCExceptionRecognizer(Process *process);
AppleObjCRuntimeV2::AppleObjCRuntimeV2(Process *process,
const ModuleSP &objc_module_sp)
: … { … }
LanguageRuntime *
AppleObjCRuntimeV2::GetPreferredLanguageRuntime(ValueObject &in_value) { … }
bool AppleObjCRuntimeV2::GetDynamicTypeAndAddress(
ValueObject &in_value, lldb::DynamicValueType use_dynamic,
TypeAndOrName &class_type_or_name, Address &address,
Value::ValueType &value_type) { … }
LanguageRuntime *AppleObjCRuntimeV2::CreateInstance(Process *process,
LanguageType language) { … }
static constexpr OptionDefinition g_objc_classtable_dump_options[] = …;
class CommandObjectObjC_ClassTable_Dump : public CommandObjectParsed { … };
class CommandObjectMultiwordObjC_TaggedPointer_Info
: public CommandObjectParsed { … };
class CommandObjectMultiwordObjC_ClassTable : public CommandObjectMultiword { … };
class CommandObjectMultiwordObjC_TaggedPointer : public CommandObjectMultiword { … };
class CommandObjectMultiwordObjC : public CommandObjectMultiword { … };
void AppleObjCRuntimeV2::Initialize() { … }
void AppleObjCRuntimeV2::Terminate() { … }
BreakpointResolverSP
AppleObjCRuntimeV2::CreateExceptionResolver(const BreakpointSP &bkpt,
bool catch_bp, bool throw_bp) { … }
llvm::Expected<std::unique_ptr<UtilityFunction>>
AppleObjCRuntimeV2::CreateObjectChecker(std::string name,
ExecutionContext &exe_ctx) { … }
size_t AppleObjCRuntimeV2::GetByteOffsetForIvar(CompilerType &parent_ast_type,
const char *ivar_name) { … }
bool AppleObjCRuntimeV2::IsTaggedPointer(addr_t ptr) { … }
class RemoteNXMapTable { … };
AppleObjCRuntimeV2::HashTableSignature::HashTableSignature() = default;
void AppleObjCRuntimeV2::HashTableSignature::UpdateSignature(
const RemoteNXMapTable &hash_table) { … }
bool AppleObjCRuntimeV2::HashTableSignature::NeedsUpdate(
Process *process, AppleObjCRuntimeV2 *runtime,
RemoteNXMapTable &hash_table) { … }
ObjCLanguageRuntime::ClassDescriptorSP
AppleObjCRuntimeV2::GetClassDescriptorFromISA(ObjCISA isa) { … }
ObjCLanguageRuntime::ClassDescriptorSP
AppleObjCRuntimeV2::GetClassDescriptor(ValueObject &valobj) { … }
lldb::addr_t AppleObjCRuntimeV2::GetTaggedPointerObfuscator() { … }
lldb::addr_t AppleObjCRuntimeV2::GetISAHashTablePointer() { … }
std::unique_ptr<AppleObjCRuntimeV2::SharedCacheImageHeaders>
AppleObjCRuntimeV2::SharedCacheImageHeaders::CreateSharedCacheImageHeaders(
AppleObjCRuntimeV2 &runtime) { … }
llvm::Error AppleObjCRuntimeV2::SharedCacheImageHeaders::UpdateIfNeeded() { … }
bool AppleObjCRuntimeV2::SharedCacheImageHeaders::IsImageLoaded(
uint16_t image_index) { … }
uint64_t AppleObjCRuntimeV2::SharedCacheImageHeaders::GetVersion() { … }
std::unique_ptr<UtilityFunction>
AppleObjCRuntimeV2::DynamicClassInfoExtractor::GetClassInfoUtilityFunctionImpl(
ExecutionContext &exe_ctx, Helper helper, std::string code,
std::string name) { … }
UtilityFunction *
AppleObjCRuntimeV2::DynamicClassInfoExtractor::GetClassInfoUtilityFunction(
ExecutionContext &exe_ctx, Helper helper) { … }
lldb::addr_t &
AppleObjCRuntimeV2::DynamicClassInfoExtractor::GetClassInfoArgs(Helper helper) { … }
AppleObjCRuntimeV2::DynamicClassInfoExtractor::Helper
AppleObjCRuntimeV2::DynamicClassInfoExtractor::ComputeHelper(
ExecutionContext &exe_ctx) const { … }
std::unique_ptr<UtilityFunction>
AppleObjCRuntimeV2::SharedCacheClassInfoExtractor::
GetClassInfoUtilityFunctionImpl(ExecutionContext &exe_ctx) { … }
UtilityFunction *
AppleObjCRuntimeV2::SharedCacheClassInfoExtractor::GetClassInfoUtilityFunction(
ExecutionContext &exe_ctx) { … }
AppleObjCRuntimeV2::DescriptorMapUpdateResult
AppleObjCRuntimeV2::DynamicClassInfoExtractor::UpdateISAToDescriptorMap(
RemoteNXMapTable &hash_table) { … }
uint32_t AppleObjCRuntimeV2::ParseClassInfoArray(const DataExtractor &data,
uint32_t num_class_infos) { … }
bool AppleObjCRuntimeV2::HasSymbol(ConstString Name) { … }
AppleObjCRuntimeV2::DescriptorMapUpdateResult
AppleObjCRuntimeV2::SharedCacheClassInfoExtractor::UpdateISAToDescriptorMap() { … }
lldb::addr_t AppleObjCRuntimeV2::GetSharedCacheReadOnlyAddress() { … }
lldb::addr_t AppleObjCRuntimeV2::GetSharedCacheBaseAddress() { … }
void AppleObjCRuntimeV2::UpdateISAToDescriptorMapIfNeeded() { … }
bool AppleObjCRuntimeV2::RealizedClassGenerationCountChanged() { … }
static bool DoesProcessHaveSharedCache(Process &process) { … }
void AppleObjCRuntimeV2::WarnIfNoClassesCached(
SharedCacheWarningReason reason) { … }
void AppleObjCRuntimeV2::WarnIfNoExpandedSharedCache() { … }
DeclVendor *AppleObjCRuntimeV2::GetDeclVendor() { … }
lldb::addr_t AppleObjCRuntimeV2::LookupRuntimeSymbol(ConstString name) { … }
AppleObjCRuntimeV2::NonPointerISACache *
AppleObjCRuntimeV2::NonPointerISACache::CreateInstance(
AppleObjCRuntimeV2 &runtime, const lldb::ModuleSP &objc_module_sp) { … }
AppleObjCRuntimeV2::TaggedPointerVendorV2 *
AppleObjCRuntimeV2::TaggedPointerVendorV2::CreateInstance(
AppleObjCRuntimeV2 &runtime, const lldb::ModuleSP &objc_module_sp) { … }
bool AppleObjCRuntimeV2::TaggedPointerVendorLegacy::IsPossibleTaggedPointer(
lldb::addr_t ptr) { … }
ObjCLanguageRuntime::ClassDescriptorSP
AppleObjCRuntimeV2::TaggedPointerVendorLegacy::GetClassDescriptor(
lldb::addr_t ptr) { … }
AppleObjCRuntimeV2::TaggedPointerVendorRuntimeAssisted::
TaggedPointerVendorRuntimeAssisted(
AppleObjCRuntimeV2 &runtime, uint64_t objc_debug_taggedpointer_mask,
uint32_t objc_debug_taggedpointer_slot_shift,
uint32_t objc_debug_taggedpointer_slot_mask,
uint32_t objc_debug_taggedpointer_payload_lshift,
uint32_t objc_debug_taggedpointer_payload_rshift,
lldb::addr_t objc_debug_taggedpointer_classes)
: … { … }
bool AppleObjCRuntimeV2::TaggedPointerVendorRuntimeAssisted::
IsPossibleTaggedPointer(lldb::addr_t ptr) { … }
ObjCLanguageRuntime::ClassDescriptorSP
AppleObjCRuntimeV2::TaggedPointerVendorRuntimeAssisted::GetClassDescriptor(
lldb::addr_t ptr) { … }
AppleObjCRuntimeV2::TaggedPointerVendorExtended::TaggedPointerVendorExtended(
AppleObjCRuntimeV2 &runtime, uint64_t objc_debug_taggedpointer_mask,
uint64_t objc_debug_taggedpointer_ext_mask,
uint32_t objc_debug_taggedpointer_slot_shift,
uint32_t objc_debug_taggedpointer_ext_slot_shift,
uint32_t objc_debug_taggedpointer_slot_mask,
uint32_t objc_debug_taggedpointer_ext_slot_mask,
uint32_t objc_debug_taggedpointer_payload_lshift,
uint32_t objc_debug_taggedpointer_payload_rshift,
uint32_t objc_debug_taggedpointer_ext_payload_lshift,
uint32_t objc_debug_taggedpointer_ext_payload_rshift,
lldb::addr_t objc_debug_taggedpointer_classes,
lldb::addr_t objc_debug_taggedpointer_ext_classes)
: … { … }
bool AppleObjCRuntimeV2::TaggedPointerVendorExtended::
IsPossibleExtendedTaggedPointer(lldb::addr_t ptr) { … }
ObjCLanguageRuntime::ClassDescriptorSP
AppleObjCRuntimeV2::TaggedPointerVendorExtended::GetClassDescriptor(
lldb::addr_t ptr) { … }
AppleObjCRuntimeV2::NonPointerISACache::NonPointerISACache(
AppleObjCRuntimeV2 &runtime, const ModuleSP &objc_module_sp,
uint64_t objc_debug_isa_class_mask, uint64_t objc_debug_isa_magic_mask,
uint64_t objc_debug_isa_magic_value,
uint64_t objc_debug_indexed_isa_magic_mask,
uint64_t objc_debug_indexed_isa_magic_value,
uint64_t objc_debug_indexed_isa_index_mask,
uint64_t objc_debug_indexed_isa_index_shift,
lldb::addr_t objc_indexed_classes)
: … { … }
ObjCLanguageRuntime::ClassDescriptorSP
AppleObjCRuntimeV2::NonPointerISACache::GetClassDescriptor(ObjCISA isa) { … }
bool AppleObjCRuntimeV2::NonPointerISACache::EvaluateNonPointerISA(
ObjCISA isa, ObjCISA &ret_isa) { … }
ObjCLanguageRuntime::EncodingToTypeSP AppleObjCRuntimeV2::GetEncodingToType() { … }
lldb_private::AppleObjCRuntime::ObjCISA
AppleObjCRuntimeV2::GetPointerISA(ObjCISA isa) { … }
bool AppleObjCRuntimeV2::GetCFBooleanValuesIfNeeded() { … }
void AppleObjCRuntimeV2::GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true,
lldb::addr_t &cf_false) { … }
void AppleObjCRuntimeV2::ModulesDidLoad(const ModuleList &module_list) { … }
bool AppleObjCRuntimeV2::IsSharedCacheImageLoaded(uint16_t image_index) { … }
std::optional<uint64_t> AppleObjCRuntimeV2::GetSharedCacheImageHeaderVersion() { … }
#pragma mark Frame recognizers
class ObjCExceptionRecognizedStackFrame : public RecognizedStackFrame { … };
class ObjCExceptionThrowFrameRecognizer : public StackFrameRecognizer { … };
static void RegisterObjCExceptionRecognizer(Process *process) { … }