20 Process *process, std::unique_ptr<objc_class_t> &objc_class)
const {
21 objc_class = std::make_unique<objc_class_t>();
36 return 0x00007ffffffffff8UL;
48 size_t objc_class_size = ptr_size
57 process->
ReadMemory(addr, objc_class_buf.GetBytes(), objc_class_size,
error);
62 DataExtractor extractor(objc_class_buf.GetBytes(), objc_class_size,
78 if (ABISP abi_sp = process->
GetABI()) {
115 if (ABISP abi_sp = process->
GetABI())
116 m_ro_ptr = abi_sp->FixCodeAddress(m_ro_ptr);
132 if (ABISP abi_sp = process->
GetABI())
133 m_ro_ptr = abi_sp->FixCodeAddress(m_ro_ptr);
192 m_name.assign((
char *)name_buf.GetBytes());
199 std::unique_ptr<class_ro_t> &class_ro,
200 std::unique_ptr<class_rw_t> &class_rw)
const {
207 if (!
error.Success())
211 class_rw = std::make_unique<class_rw_t>();
213 if (!class_rw->Read(process, objc_class.
m_data_ptr)) {
218 class_ro = std::make_unique<class_ro_t>();
220 if (!class_ro->Read(process, class_rw->m_ro_ptr)) {
226 class_ro = std::make_unique<class_ro_t>();
228 if (!class_ro->Read(process, objc_class.
m_data_ptr)) {
245 if (ABISP abi_sp = process->
GetABI())
246 addr = abi_sp->FixCodeAddress(addr);
258 m_is_small = (entsize & 0x80000000) != 0;
259 m_has_direct_selector = (entsize & 0x40000000) != 0;
260 m_entsize = entsize & 0xfffc;
262 m_first_ptr = addr + cursor;
269 bool is_small,
bool has_direct_sel) {
271 size_t size = GetSize(process, is_small);
290 m_name_ptr = addr + nameref_offset;
292 if (!has_direct_sel) {
296 if (!
error.Success())
299 m_name_ptr = relative_selector_base_addr + nameref_offset;
301 m_types_ptr = addr + 4 + types_offset;
302 m_imp_ptr = addr + 8 + imp_offset;
315 return !
error.Fail();
337 m_first_ptr = addr + cursor;
343 size_t size = GetSize(process);
370 return !
error.Fail();
375 std::function<
bool(
const char *,
const char *)>
const &instance_method_func,
376 std::function<
bool(
const char *,
const char *)>
const &class_method_func,
377 std::function<
bool(
const char *,
const char *,
lldb::addr_t,
378 uint64_t)>
const &ivar_func)
const {
381 std::unique_ptr<objc_class_t> objc_class;
382 std::unique_ptr<class_ro_t> class_ro;
383 std::unique_ptr<class_rw_t> class_rw;
392 if (
m_name != NSObject_name && superclass_func)
393 superclass_func(objc_class->m_superclass);
395 if (instance_method_func) {
396 std::unique_ptr<method_list_t> base_method_list;
398 base_method_list = std::make_unique<method_list_t>();
399 if (!base_method_list->Read(process, class_ro->m_baseMethods_ptr))
402 bool is_small = base_method_list->m_is_small;
403 bool has_direct_selector = base_method_list->m_has_direct_selector;
408 std::unique_ptr<method_t> method = std::make_unique<method_t>();
411 for (
uint32_t i = 0, e = base_method_list->m_count; i < e; ++i) {
412 method->Read(process,
413 base_method_list->m_first_ptr +
414 (i * base_method_list->m_entsize),
415 relative_selector_base_addr, is_small, has_direct_selector);
417 if (instance_method_func(method->m_name.c_str(), method->m_types.c_str()))
422 if (class_method_func) {
432 std::function<
bool(
const char *,
const char *)>(
nullptr),
433 std::function<
bool(
const char *,
const char *,
lldb::addr_t,
434 uint64_t)>(
nullptr));
439 if (class_ro->m_ivars_ptr != 0) {
441 if (!ivar_list.
Read(process, class_ro->m_ivars_ptr))
467 std::unique_ptr<objc_class_t> objc_class;
468 std::unique_ptr<class_ro_t> class_ro;
469 std::unique_ptr<class_rw_t> class_rw;
488 std::unique_ptr<objc_class_t> objc_class;
493 return m_runtime.ObjCLanguageRuntime::GetClassDescriptorFromISA(
494 objc_class->m_superclass);
503 std::unique_ptr<objc_class_t> objc_class;
518 std::unique_ptr<objc_class_t> objc_class;
519 std::unique_ptr<class_ro_t> class_ro;
520 std::unique_ptr<class_rw_t> class_rw;
527 return class_ro->m_instanceSize;
546 std::lock_guard<std::recursive_mutex> guard(m_mutex);
553 if (!encoding_to_type_sp)
555 descriptor.
Describe(
nullptr,
nullptr,
nullptr, [
this, process,
557 log](
const char *name,
560 uint64_t size) ->
bool {
561 const bool for_expression =
false;
562 const bool stop_loop =
false;
563 LLDB_LOGV(log,
"name = {0}, encoding = {1}, offset_ptr = {2:x}, size = {3}",
564 name, type, offset_ptr, size);
566 encoding_to_type_sp->RealizeType(type, for_expression);
569 "name = {0}, encoding = {1}, offset_ptr = {2:x}, size = "
570 "{3}, type_size = {4}",
571 name, type, offset_ptr, size,
575 const int offset_ptr_size = 4;
576 const bool is_signed =
false;
578 offset_ptr, offset_ptr_size, is_signed, offset_scalar,
error);
579 if (
error.Success() && 4 == read) {
580 LLDB_LOGV(log,
"offset_ptr = {0:x} --> {1}", offset_ptr,
581 offset_scalar.
SInt());
585 LLDB_LOGV(log,
"offset_ptr = {0:x} --> read fail, read = %{1}",
static lldb::addr_t GetClassDataMask(Process *process)
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGV(log,...)
EncodingToTypeSP GetEncodingToType() override
ObjCISA GetPointerISA(ObjCISA isa)
lldb::addr_t GetRelativeSelectorBaseAddr()
Returns the base address for relative method list selector strings.
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
ConstString GetClassName() override
static const uint32_t RW_REALIZED
bool Read_objc_class(Process *process, std::unique_ptr< objc_class_t > &objc_class) const
void GetIVarInformation()
uint64_t GetInstanceSize() override
ObjCLanguageRuntime::ClassDescriptorSP GetMetaclass() const override
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
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
#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.
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 Read(Process *process, lldb::addr_t addr)
bool Read(Process *process, lldb::addr_t addr, lldb::addr_t relative_method_lists_base_addr, bool, bool)
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