22 Process *process, std::unique_ptr<objc_class_t> &objc_class)
const {
23 objc_class = std::make_unique<objc_class_t>();
38 return 0x00007ffffffffff8UL;
50 size_t objc_class_size = ptr_size
91 size_t size =
sizeof(uint32_t)
118 m_ro_ptr = abi_sp->FixCodeAddress(m_ro_ptr);
135 m_ro_ptr = abi_sp->FixCodeAddress(m_ro_ptr);
144 size_t size =
sizeof(uint32_t)
147 + (ptr_size == 8 ?
sizeof(uint32_t)
201 std::unique_ptr<class_ro_t> &class_ro,
202 std::unique_ptr<class_rw_t> &class_rw)
const {
209 if (!
error.Success())
213 class_rw = std::make_unique<class_rw_t>();
215 if (!class_rw->Read(process, objc_class.
m_data_ptr)) {
220 class_ro = std::make_unique<class_ro_t>();
222 if (!class_ro->Read(process, class_rw->m_ro_ptr)) {
228 class_ro = std::make_unique<class_ro_t>();
230 if (!class_ro->Read(process, objc_class.
m_data_ptr)) {
241 size_t size =
sizeof(uint32_t)
248 addr = abi_sp->FixCodeAddress(addr);
260 m_is_small = (entsize & 0x80000000) != 0;
261 m_has_direct_selector = (entsize & 0x40000000) != 0;
262 m_entsize = entsize & 0xfffc;
264 m_first_ptr = addr + cursor;
271 bool is_small,
bool has_direct_sel) {
273 size_t size = GetSize(process, is_small);
292 m_name_ptr = addr + nameref_offset;
294 if (!has_direct_sel) {
298 if (!
error.Success())
301 m_name_ptr = relative_selector_base_addr + nameref_offset;
303 m_types_ptr = addr + 4 + types_offset;
304 m_imp_ptr = addr + 8 + imp_offset;
317 return !
error.Fail();
321 size_t size =
sizeof(uint32_t)
339 m_first_ptr = addr + cursor;
345 size_t size = GetSize(process);
372 return !
error.Fail();
378 size_t size =
sizeof(uint64_t);
387 LLDB_LOG(log,
"Failed to read relative_list_entry_t at address {0:x}",
396 m_image_index = raw_entry & 0xFFFF;
397 m_list_offset = (int64_t)(raw_entry >> 16);
404 size_t size =
sizeof(uint32_t)
413 LLDB_LOG(log,
"Failed to read relative_list_list_t at address 0x" PRIx64,
423 m_first_ptr = addr + cursor;
427std::optional<ClassDescriptorV2::method_list_t>
432 if (!method_list.
Read(process, method_list_ptr))
436 if (method_list.
m_entsize != method_size) {
438 "method_list_t at address 0x" PRIx64
" has an entsize of " PRIu16
439 " but method size should be " PRIu64,
440 method_list_ptr, method_list.
m_entsize, method_size);
448 std::function<
bool(
const char *,
const char *)>
const &instance_method_func,
451 auto method = std::make_unique<method_t>();
454 for (uint32_t i = 0, e = method_list.
m_count; i < e; ++i) {
456 relative_selector_base_addr, method_list.
m_is_small,
458 if (instance_method_func(method->m_name.c_str(), method->m_types.c_str()))
478 std::function<
bool(
const char *,
const char *)>
const &instance_method_func,
481 auto relative_method_lists = std::make_unique<relative_list_list_t>();
484 if (!relative_method_lists->Read(process, relative_method_list_ptr))
487 auto entry = std::make_unique<relative_list_entry_t>();
488 for (uint32_t i = 0; i < relative_method_lists->m_count; i++) {
491 const lldb::addr_t entry_addr = relative_method_lists->m_first_ptr +
492 (i * relative_method_lists->m_entsize);
493 if (!entry->Read(process, entry_addr))
498 const lldb::addr_t method_list_addr = entry_addr + entry->m_list_offset;
501 std::optional<method_list_t> method_list =
526 std::function<
bool(
const char *,
const char *)>
const &instance_method_func,
527 std::function<
bool(
const char *,
const char *)>
const &class_method_func,
528 std::function<
bool(
const char *,
const char *,
lldb::addr_t,
529 uint64_t)>
const &ivar_func)
const {
532 std::unique_ptr<objc_class_t> objc_class;
533 std::unique_ptr<class_ro_t> class_ro;
534 std::unique_ptr<class_rw_t> class_rw;
543 if (
m_name != NSObject_name && superclass_func)
544 superclass_func(objc_class->m_superclass);
546 if (instance_method_func) {
548 if (class_ro->m_baseMethods_ptr & 1) {
550 class_ro->m_baseMethods_ptr ^ 1))
553 std::optional<method_list_t> base_method_list =
555 if (!base_method_list)
562 if (class_method_func) {
572 std::function<
bool(
const char *,
const char *)>(
nullptr),
573 std::function<
bool(
const char *,
const char *,
lldb::addr_t,
574 uint64_t)>(
nullptr));
579 if (class_ro->m_ivars_ptr != 0) {
581 if (!ivar_list.
Read(process, class_ro->m_ivars_ptr))
589 for (uint32_t i = 0, e = ivar_list.
m_count; i < e; ++i) {
607 std::unique_ptr<objc_class_t> objc_class;
608 std::unique_ptr<class_ro_t> class_ro;
609 std::unique_ptr<class_rw_t> class_rw;
628 std::unique_ptr<objc_class_t> objc_class;
633 return m_runtime.ObjCLanguageRuntime::GetClassDescriptorFromISA(
634 objc_class->m_superclass);
643 std::unique_ptr<objc_class_t> objc_class;
658 std::unique_ptr<objc_class_t> objc_class;
659 std::unique_ptr<class_ro_t> class_ro;
660 std::unique_ptr<class_rw_t> class_rw;
667 return class_ro->m_instanceSize;
677 std::unique_ptr<objc_class_t> objc_class;
699 std::lock_guard<std::recursive_mutex> guard(m_mutex);
706 if (!encoding_to_type_sp)
708 descriptor.
Describe(
nullptr,
nullptr,
nullptr, [
this, process,
710 log](
const char *name,
713 uint64_t size) ->
bool {
714 const bool for_expression =
false;
715 const bool stop_loop =
false;
716 LLDB_LOGV(log,
"name = {0}, encoding = {1}, offset_ptr = {2:x}, size = {3}",
717 name, type, offset_ptr, size);
719 encoding_to_type_sp->RealizeType(type, for_expression);
722 "name = {0}, encoding = {1}, offset_ptr = {2:x}, size = "
723 "{3}, type_size = {4}",
724 name, type, offset_ptr, size,
728 const int offset_ptr_size = 4;
729 const bool is_signed =
false;
731 offset_ptr, offset_ptr_size, is_signed, offset_scalar,
error);
732 if (
error.Success() && 4 == read) {
733 LLDB_LOGV(log,
"offset_ptr = {0:x} --> {1}", offset_ptr,
734 offset_scalar.
SInt());
738 LLDB_LOGV(log,
"offset_ptr = {0:x} --> read fail, read = %{1}",
static lldb::addr_t GetClassDataMask(Process *process)
static uint8_t IS_SWIFT_STABLE
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_LOGV(log,...)
EncodingToTypeSP GetEncodingToType() override
ObjCISA GetPointerISA(ObjCISA isa)
bool IsSharedCacheImageLoaded(uint16_t image_index)
lldb::addr_t GetRelativeSelectorBaseAddr()
Returns the base address for relative method list selector strings.
std::optional< uint64_t > GetSharedCacheImageHeaderVersion()
ObjCLanguageRuntime::ClassDescriptorSP GetSuperclass() override
iVarsStorage m_ivars_storage
lldb::addr_t m_objc_class_ptr
AppleObjCRuntimeV2 & m_runtime
bool Describe(std::function< void(ObjCLanguageRuntime::ObjCISA)> const &superclass_func, std::function< bool(const char *, const char *)> const &instance_method_func, std::function< bool(const char *, const char *)> const &class_method_func, std::function< bool(const char *, const char *, lldb::addr_t, uint64_t)> const &ivar_func) const override
bool Read_class_row(Process *process, const objc_class_t &objc_class, std::unique_ptr< class_ro_t > &class_ro, std::unique_ptr< class_rw_t > &class_rw) const
bool ProcessRelativeMethodLists(std::function< bool(const char *, const char *)> const &instance_method_func, lldb::addr_t relative_method_list_ptr) const
ConstString GetClassName() override
static const uint32_t RW_REALIZED
bool ProcessMethodList(std::function< bool(const char *, const char *)> const &instance_method_func, method_list_t &method_list) const
bool Read_objc_class(Process *process, std::unique_ptr< objc_class_t > &objc_class) const
void GetIVarInformation()
uint64_t GetInstanceSize() override
std::optional< uint64_t > m_last_version_updated
std::map< uint16_t, std::vector< method_list_t > > m_image_to_method_lists
ObjCLanguageRuntime::ClassDescriptorSP GetMetaclass() const override
lldb::LanguageType GetImplementationLanguage() const override
Determine whether this class is implemented in Swift.
std::optional< method_list_t > GetMethodList(Process *process, lldb::addr_t method_list_ptr) const
Generic representation of a type in a programming language.
std::optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
A uniqued constant string class.
A subclass of DataBuffer that stores a data buffer on the heap.
lldb::offset_t GetByteSize() const override
Get the number of bytes in the data buffer.
std::shared_ptr< ClassDescriptor > ClassDescriptorSP
std::shared_ptr< EncodingToType > EncodingToTypeSP
A plug-in interface definition class for debugging a process.
size_t ReadScalarIntegerFromMemory(lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Status &error)
size_t ReadCStringFromMemory(lldb::addr_t vm_addr, char *cstr, size_t cstr_max_len, Status &error)
Read a NULL terminated C string from memory.
virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
lldb::ByteOrder GetByteOrder() const
uint64_t ReadUnsignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, uint64_t fail_value, Status &error)
Reads an unsigned integer of the specified byte size from process memory.
uint32_t GetAddressByteSize() const
const lldb::ABISP & GetABI()
int SInt(int fail_value=0) const
uint8_t * GetBytes()
Get a pointer to the data.
#define LLDB_INVALID_ADDRESS
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
LanguageType
Programming language type.
@ eLanguageTypeSwift
Swift.
@ eLanguageTypeObjC
Objective-C.
bool Read(Process *process, lldb::addr_t addr)
bool Read(Process *process, lldb::addr_t addr)
bool Read(Process *process, lldb::addr_t addr)
static size_t GetSize(Process *process)
bool Read(Process *process, lldb::addr_t addr)
lldb::addr_t m_offset_ptr
bool m_has_direct_selector
bool Read(Process *process, lldb::addr_t addr)
bool Read(Process *process, lldb::addr_t addr, lldb::addr_t relative_selector_base_addr, bool is_small, bool has_direct_sel)
static size_t GetSize(Process *process, bool is_small)
bool Read(Process *process, lldb::addr_t addr)
lldb::addr_t m_vtable_ptr
ObjCLanguageRuntime::ObjCISA m_isa
ObjCLanguageRuntime::ObjCISA m_superclass
bool Read(Process *process, lldb::addr_t addr)
bool Read(Process *process, lldb::addr_t addr)