59#include "clang/AST/ASTContext.h"
60#include "clang/AST/DeclObjC.h"
61#include "clang/Basic/TargetInfo.h"
62#include "llvm/ADT/ScopeExit.h"
75 "__lldb_apple_objc_v2_get_dynamic_class_info";
81 size_t strlen(const char *);
82 char *strncpy (char * s1, const char * s2, size_t n);
83 int printf(const char * format, ...);
85#define DEBUG_PRINTF(fmt, ...) if (should_log) printf(fmt, ## __VA_ARGS__)
87typedef struct _NXMapTable {
90 unsigned num_buckets_minus_one;
94#define NX_MAPNOTAKEY ((void *)(-1))
96typedef struct BucketInfo
106} __attribute__((__packed__));
109__lldb_apple_objc_v2_get_dynamic_class_info (void *gdb_objc_realized_classes_ptr,
110 void *class_infos_ptr,
111 uint32_t class_infos_byte_size,
114 DEBUG_PRINTF ("gdb_objc_realized_classes_ptr = %p\n", gdb_objc_realized_classes_ptr);
115 DEBUG_PRINTF ("class_infos_ptr = %p\n", class_infos_ptr);
116 DEBUG_PRINTF ("class_infos_byte_size = %u\n", class_infos_byte_size);
117 const NXMapTable *grc = (const NXMapTable *)gdb_objc_realized_classes_ptr;
120 const unsigned num_classes = grc->num_classes;
121 DEBUG_PRINTF ("num_classes = %u\n", grc->num_classes);
124 const unsigned num_buckets_minus_one = grc->num_buckets_minus_one;
125 DEBUG_PRINTF ("num_buckets_minus_one = %u\n", num_buckets_minus_one);
127 const size_t max_class_infos = class_infos_byte_size/sizeof(ClassInfo);
128 DEBUG_PRINTF ("max_class_infos = %u\n", max_class_infos);
130 ClassInfo *class_infos = (ClassInfo *)class_infos_ptr;
131 BucketInfo *buckets = (BucketInfo *)grc->buckets;
134 for (unsigned i=0; i<=num_buckets_minus_one; ++i)
136 if (buckets[i].name_ptr != NX_MAPNOTAKEY)
138 if (idx < max_class_infos)
140 const char *s = buckets[i].name_ptr;
142 for (unsigned char c = *s; c; c = *++s)
143 h = ((h << 5) + h) + c;
144 class_infos[idx].hash = h;
145 class_infos[idx].isa = buckets[i].isa;
146 DEBUG_PRINTF ("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, buckets[i].name_ptr);
151 if (idx < max_class_infos)
153 class_infos[idx].isa = NULL;
154 class_infos[idx].hash = 0;
165 "__lldb_apple_objc_v2_get_dynamic_class_info2";
170 int printf(const char * format, ...);
171 void free(void *ptr);
172 Class* objc_copyRealizedClassList_nolock(unsigned int *outCount);
173 const char* objc_debug_class_getNameRaw(Class cls);
176#define DEBUG_PRINTF(fmt, ...) if (should_log) printf(fmt, ## __VA_ARGS__)
182} __attribute__((__packed__));
185__lldb_apple_objc_v2_get_dynamic_class_info2(void *gdb_objc_realized_classes_ptr,
186 void *class_infos_ptr,
187 uint32_t class_infos_byte_size,
190 DEBUG_PRINTF ("class_infos_ptr = %p\n", class_infos_ptr);
191 DEBUG_PRINTF ("class_infos_byte_size = %u\n", class_infos_byte_size);
193 const size_t max_class_infos = class_infos_byte_size/sizeof(ClassInfo);
194 DEBUG_PRINTF ("max_class_infos = %u\n", max_class_infos);
196 ClassInfo *class_infos = (ClassInfo *)class_infos_ptr;
199 Class* realized_class_list = objc_copyRealizedClassList_nolock(&count);
200 DEBUG_PRINTF ("count = %u\n", count);
203 for (uint32_t i=0; i<count; ++i)
205 if (idx < max_class_infos)
207 Class isa = realized_class_list[i];
208 const char *name_ptr = objc_debug_class_getNameRaw(isa);
211 const char *s = name_ptr;
213 for (unsigned char c = *s; c; c = *++s)
214 h = ((h << 5) + h) + c;
215 class_infos[idx].hash = h;
216 class_infos[idx].isa = isa;
217 DEBUG_PRINTF ("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, name_ptr);
222 if (idx < max_class_infos)
224 class_infos[idx].isa = NULL;
225 class_infos[idx].hash = 0;
228 free(realized_class_list);
234 "__lldb_apple_objc_v2_get_dynamic_class_info3";
239 int printf(const char * format, ...);
240 void free(void *ptr);
241 size_t objc_getRealizedClassList_trylock(Class *buffer, size_t len);
242 const char* objc_debug_class_getNameRaw(Class cls);
243 const char* class_getName(Class cls);
246#define DEBUG_PRINTF(fmt, ...) if (should_log) printf(fmt, ## __VA_ARGS__)
252} __attribute__((__packed__));
255__lldb_apple_objc_v2_get_dynamic_class_info3(void *gdb_objc_realized_classes_ptr,
256 void *class_infos_ptr,
257 uint32_t class_infos_byte_size,
259 uint32_t class_buffer_len,
262 DEBUG_PRINTF ("class_infos_ptr = %p\n", class_infos_ptr);
263 DEBUG_PRINTF ("class_infos_byte_size = %u\n", class_infos_byte_size);
265 const size_t max_class_infos = class_infos_byte_size/sizeof(ClassInfo);
266 DEBUG_PRINTF ("max_class_infos = %u\n", max_class_infos);
268 ClassInfo *class_infos = (ClassInfo *)class_infos_ptr;
270 Class *realized_class_list = (Class*)class_buffer;
272 uint32_t count = objc_getRealizedClassList_trylock(realized_class_list,
274 DEBUG_PRINTF ("count = %u\n", count);
277 for (uint32_t i=0; i<count; ++i)
279 if (idx < max_class_infos)
281 Class isa = realized_class_list[i];
282 const char *name_ptr = objc_debug_class_getNameRaw(isa);
284 class_getName(isa); // Realize name of lazy classes.
285 name_ptr = objc_debug_class_getNameRaw(isa);
289 const char *s = name_ptr;
291 for (unsigned char c = *s; c; c = *++s)
292 h = ((h << 5) + h) + c;
293 class_infos[idx].hash = h;
294 class_infos[idx].isa = isa;
295 DEBUG_PRINTF ("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, name_ptr);
300 if (idx < max_class_infos)
302 class_infos[idx].isa = NULL;
303 class_infos[idx].hash = 0;
315 const char *%s(void *objc_class);
316 const char *(*class_name_lookup_func)(void *) = %s;
321 "__lldb_apple_objc_v2_get_shared_cache_class_info";
327 size_t strlen(const char *);
328 char *strncpy (char * s1, const char * s2, size_t n);
329 int printf(const char * format, ...);
332#define DEBUG_PRINTF(fmt, ...) if (should_log) printf(fmt, ## __VA_ARGS__)
335struct objc_classheader_t {
340struct objc_classheader_v16_t {
341 uint64_t isDuplicate : 1,
342 objectCacheOffset : 47, // Offset from the shared cache base
346struct objc_clsopt_t {
354 uint32_t scramble[256];
355 uint8_t tab[0]; // tab[mask+1]
356 // uint8_t checkbytes[capacity];
357 // int32_t offset[capacity];
358 // objc_classheader_t clsOffsets[capacity];
359 // uint32_t duplicateCount;
360 // objc_classheader_t duplicateOffsets[duplicateCount];
363struct objc_clsopt_v16_t {
371 uint32_t scramble[256];
372 uint8_t tab[0]; // tab[mask+1]
373 // uint8_t checkbytes[capacity];
374 // int32_t offset[capacity];
375 // objc_classheader_t clsOffsets[capacity];
376 // uint32_t duplicateCount;
377 // objc_classheader_t duplicateOffsets[duplicateCount];
382 int32_t selopt_offset;
383 int32_t headeropt_offset;
384 int32_t clsopt_offset;
387struct objc_opt_v14_t {
390 int32_t selopt_offset;
391 int32_t headeropt_offset;
392 int32_t clsopt_offset;
395struct objc_opt_v16_t {
398 int32_t selopt_offset;
399 int32_t headeropt_ro_offset;
400 int32_t unused_clsopt_offset;
401 int32_t unused_protocolopt_offset;
402 int32_t headeropt_rw_offset;
403 int32_t unused_protocolopt2_offset;
404 int32_t largeSharedCachesClassOffset;
405 int32_t largeSharedCachesProtocolOffset;
406 uint64_t relativeMethodSelectorBaseAddressCacheOffset;
413} __attribute__((__packed__));
416__lldb_apple_objc_v2_get_shared_cache_class_info (void *objc_opt_ro_ptr,
417 void *shared_cache_base_ptr,
418 void *class_infos_ptr,
419 uint64_t *relative_selector_offset,
420 uint32_t class_infos_byte_size,
423 *relative_selector_offset = 0;
425 DEBUG_PRINTF ("objc_opt_ro_ptr = %p\n", objc_opt_ro_ptr);
426 DEBUG_PRINTF ("shared_cache_base_ptr = %p\n", shared_cache_base_ptr);
427 DEBUG_PRINTF ("class_infos_ptr = %p\n", class_infos_ptr);
428 DEBUG_PRINTF ("class_infos_byte_size = %u (%llu class infos)\n", class_infos_byte_size, (uint64_t)(class_infos_byte_size/sizeof(ClassInfo)));
431 const objc_opt_t *objc_opt = (objc_opt_t *)objc_opt_ro_ptr;
432 const objc_opt_v14_t* objc_opt_v14 = (objc_opt_v14_t*)objc_opt_ro_ptr;
433 const objc_opt_v16_t* objc_opt_v16 = (objc_opt_v16_t*)objc_opt_ro_ptr;
434 if (objc_opt->version >= 16)
436 *relative_selector_offset = objc_opt_v16->relativeMethodSelectorBaseAddressCacheOffset;
437 DEBUG_PRINTF ("objc_opt->version = %u\n", objc_opt_v16->version);
438 DEBUG_PRINTF ("objc_opt->flags = %u\n", objc_opt_v16->flags);
439 DEBUG_PRINTF ("objc_opt->selopt_offset = %d\n", objc_opt_v16->selopt_offset);
440 DEBUG_PRINTF ("objc_opt->headeropt_ro_offset = %d\n", objc_opt_v16->headeropt_ro_offset);
441 DEBUG_PRINTF ("objc_opt->relativeMethodSelectorBaseAddressCacheOffset = %d\n", *relative_selector_offset);
443 else if (objc_opt->version >= 14)
445 DEBUG_PRINTF ("objc_opt->version = %u\n", objc_opt_v14->version);
446 DEBUG_PRINTF ("objc_opt->flags = %u\n", objc_opt_v14->flags);
447 DEBUG_PRINTF ("objc_opt->selopt_offset = %d\n", objc_opt_v14->selopt_offset);
448 DEBUG_PRINTF ("objc_opt->headeropt_offset = %d\n", objc_opt_v14->headeropt_offset);
449 DEBUG_PRINTF ("objc_opt->clsopt_offset = %d\n", objc_opt_v14->clsopt_offset);
453 DEBUG_PRINTF ("objc_opt->version = %u\n", objc_opt->version);
454 DEBUG_PRINTF ("objc_opt->selopt_offset = %d\n", objc_opt->selopt_offset);
455 DEBUG_PRINTF ("objc_opt->headeropt_offset = %d\n", objc_opt->headeropt_offset);
456 DEBUG_PRINTF ("objc_opt->clsopt_offset = %d\n", objc_opt->clsopt_offset);
459 if (objc_opt->version == 16)
461 const objc_clsopt_v16_t* clsopt = (const objc_clsopt_v16_t*)((uint8_t *)objc_opt + objc_opt_v16->largeSharedCachesClassOffset);
462 const size_t max_class_infos = class_infos_byte_size/sizeof(ClassInfo);
464 DEBUG_PRINTF("max_class_infos = %llu\n", (uint64_t)max_class_infos);
466 ClassInfo *class_infos = (ClassInfo *)class_infos_ptr;
468 const uint8_t *checkbytes = &clsopt->tab[clsopt->mask+1];
469 const int32_t *offsets = (const int32_t *)(checkbytes + clsopt->capacity);
470 const objc_classheader_v16_t *classOffsets = (const objc_classheader_v16_t *)(offsets + clsopt->capacity);
472 DEBUG_PRINTF ("clsopt->capacity = %u\n", clsopt->capacity);
473 DEBUG_PRINTF ("clsopt->mask = 0x%8.8x\n", clsopt->mask);
474 DEBUG_PRINTF ("classOffsets = %p\n", classOffsets);
476 for (uint32_t i=0; i<clsopt->capacity; ++i)
478 const uint64_t objectCacheOffset = classOffsets[i].objectCacheOffset;
479 DEBUG_PRINTF("objectCacheOffset[%u] = %u\n", i, objectCacheOffset);
481 if (classOffsets[i].isDuplicate) {
482 DEBUG_PRINTF("isDuplicate = true\n");
483 continue; // duplicate
486 if (objectCacheOffset == 0) {
487 DEBUG_PRINTF("objectCacheOffset == invalidEntryOffset\n");
488 continue; // invalid offset
491 if (class_infos && idx < max_class_infos)
493 class_infos[idx].isa = (Class)((uint8_t *)shared_cache_base_ptr + objectCacheOffset);
495 // Lookup the class name.
496 const char *name = class_name_lookup_func(class_infos[idx].isa);
497 DEBUG_PRINTF("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, name);
499 // Hash the class name so we don't have to read it.
500 const char *s = name;
502 for (unsigned char c = *s; c; c = *++s)
504 // class_getName demangles swift names and the hash must
505 // be calculated on the mangled name. hash==0 means lldb
506 // will fetch the mangled name and compute the hash in
507 // ParseClassInfoArray.
513 h = ((h << 5) + h) + c;
515 class_infos[idx].hash = h;
519 DEBUG_PRINTF("not(class_infos && idx < max_class_infos)\n");
524 const uint32_t *duplicate_count_ptr = (uint32_t *)&classOffsets[clsopt->capacity];
525 const uint32_t duplicate_count = *duplicate_count_ptr;
526 const objc_classheader_v16_t *duplicateClassOffsets = (const objc_classheader_v16_t *)(&duplicate_count_ptr[1]);
528 DEBUG_PRINTF ("duplicate_count = %u\n", duplicate_count);
529 DEBUG_PRINTF ("duplicateClassOffsets = %p\n", duplicateClassOffsets);
531 for (uint32_t i=0; i<duplicate_count; ++i)
533 const uint64_t objectCacheOffset = classOffsets[i].objectCacheOffset;
534 DEBUG_PRINTF("objectCacheOffset[%u] = %u\n", i, objectCacheOffset);
536 if (classOffsets[i].isDuplicate) {
537 DEBUG_PRINTF("isDuplicate = true\n");
538 continue; // duplicate
541 if (objectCacheOffset == 0) {
542 DEBUG_PRINTF("objectCacheOffset == invalidEntryOffset\n");
543 continue; // invalid offset
546 if (class_infos && idx < max_class_infos)
548 class_infos[idx].isa = (Class)((uint8_t *)shared_cache_base_ptr + objectCacheOffset);
550 // Lookup the class name.
551 const char *name = class_name_lookup_func(class_infos[idx].isa);
552 DEBUG_PRINTF("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, name);
554 // Hash the class name so we don't have to read it.
555 const char *s = name;
557 for (unsigned char c = *s; c; c = *++s)
559 // class_getName demangles swift names and the hash must
560 // be calculated on the mangled name. hash==0 means lldb
561 // will fetch the mangled name and compute the hash in
562 // ParseClassInfoArray.
568 h = ((h << 5) + h) + c;
570 class_infos[idx].hash = h;
574 else if (objc_opt->version >= 12 && objc_opt->version <= 15)
576 const objc_clsopt_t* clsopt = NULL;
577 if (objc_opt->version >= 14)
578 clsopt = (const objc_clsopt_t*)((uint8_t *)objc_opt_v14 + objc_opt_v14->clsopt_offset);
580 clsopt = (const objc_clsopt_t*)((uint8_t *)objc_opt + objc_opt->clsopt_offset);
581 const size_t max_class_infos = class_infos_byte_size/sizeof(ClassInfo);
582 DEBUG_PRINTF("max_class_infos = %llu\n", (uint64_t)max_class_infos);
583 ClassInfo *class_infos = (ClassInfo *)class_infos_ptr;
584 int32_t invalidEntryOffset = 0;
585 // this is safe to do because the version field order is invariant
586 if (objc_opt->version == 12)
587 invalidEntryOffset = 16;
588 const uint8_t *checkbytes = &clsopt->tab[clsopt->mask+1];
589 const int32_t *offsets = (const int32_t *)(checkbytes + clsopt->capacity);
590 const objc_classheader_t *classOffsets = (const objc_classheader_t *)(offsets + clsopt->capacity);
591 DEBUG_PRINTF ("clsopt->capacity = %u\n", clsopt->capacity);
592 DEBUG_PRINTF ("clsopt->mask = 0x%8.8x\n", clsopt->mask);
593 DEBUG_PRINTF ("classOffsets = %p\n", classOffsets);
594 DEBUG_PRINTF("invalidEntryOffset = %d\n", invalidEntryOffset);
595 for (uint32_t i=0; i<clsopt->capacity; ++i)
597 const int32_t clsOffset = classOffsets[i].clsOffset;
598 DEBUG_PRINTF("clsOffset[%u] = %u\n", i, clsOffset);
601 DEBUG_PRINTF("clsOffset & 1\n");
602 continue; // duplicate
604 else if (clsOffset == invalidEntryOffset)
606 DEBUG_PRINTF("clsOffset == invalidEntryOffset\n");
607 continue; // invalid offset
610 if (class_infos && idx < max_class_infos)
612 class_infos[idx].isa = (Class)((uint8_t *)clsopt + clsOffset);
613 const char *name = class_name_lookup_func (class_infos[idx].isa);
614 DEBUG_PRINTF ("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, name);
615 // Hash the class name so we don't have to read it
616 const char *s = name;
618 for (unsigned char c = *s; c; c = *++s)
620 // class_getName demangles swift names and the hash must
621 // be calculated on the mangled name. hash==0 means lldb
622 // will fetch the mangled name and compute the hash in
623 // ParseClassInfoArray.
629 h = ((h << 5) + h) + c;
631 class_infos[idx].hash = h;
635 DEBUG_PRINTF("not(class_infos && idx < max_class_infos)\n");
640 const uint32_t *duplicate_count_ptr = (uint32_t *)&classOffsets[clsopt->capacity];
641 const uint32_t duplicate_count = *duplicate_count_ptr;
642 const objc_classheader_t *duplicateClassOffsets = (const objc_classheader_t *)(&duplicate_count_ptr[1]);
643 DEBUG_PRINTF ("duplicate_count = %u\n", duplicate_count);
644 DEBUG_PRINTF ("duplicateClassOffsets = %p\n", duplicateClassOffsets);
645 for (uint32_t i=0; i<duplicate_count; ++i)
647 const int32_t clsOffset = duplicateClassOffsets[i].clsOffset;
649 continue; // duplicate
650 else if (clsOffset == invalidEntryOffset)
651 continue; // invalid offset
653 if (class_infos && idx < max_class_infos)
655 class_infos[idx].isa = (Class)((uint8_t *)clsopt + clsOffset);
656 const char *name = class_name_lookup_func (class_infos[idx].isa);
657 DEBUG_PRINTF ("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, name);
658 // Hash the class name so we don't have to read it
659 const char *s = name;
661 for (unsigned char c = *s; c; c = *++s)
663 // class_getName demangles swift names and the hash must
664 // be calculated on the mangled name. hash==0 means lldb
665 // will fetch the mangled name and compute the hash in
666 // ParseClassInfoArray.
672 h = ((h << 5) + h) + c;
674 class_infos[idx].hash = h;
679 DEBUG_PRINTF ("%u class_infos\n", idx);
680 DEBUG_PRINTF ("done\n");
691 bool read_value =
true, uint8_t byte_size = 0,
696 return default_value;
701 return default_value;
711 return default_value;
718 return default_value;
723 default_value,
error);
724 return symbol_load_addr;
732 m_dynamic_class_info_extractor(*this),
733 m_shared_cache_class_info_extractor(*this), m_decl_vendor_up(),
737 m_has_object_getClass(false), m_has_objc_copyRealizedClassList(false),
738 m_has_objc_getRealizedClassList_trylock(false), m_loaded_objc_opt(false),
739 m_non_pointer_isa_cache_up(),
740 m_tagged_pointer_vendor_up(
742 m_encoding_to_type_sp(), m_CFBoolean_values(),
743 m_realized_class_generation_count(0) {
744 static const ConstString g_gdb_object_getClass(
"gdb_object_getClass");
746 static const ConstString g_objc_copyRealizedClassList(
747 "_ZL33objc_copyRealizedClassList_nolockPj");
748 static const ConstString g_objc_getRealizedClassList_trylock(
749 "_objc_getRealizedClassList_trylock");
752 HasSymbol(g_objc_getRealizedClassList_trylock);
762 LanguageType impl_lang = descriptor_sp->GetImplementationLanguage();
764 return process_sp->GetLanguageRuntime(impl_lang);
788 class_type_or_name.
Clear();
800 ConstString class_name(objc_class_sp->GetClassName());
801 class_type_or_name.
SetName(class_name);
802 TypeSP type_sp(objc_class_sp->GetType());
808 objc_class_sp->SetType(type_sp);
813 auto types = vendor->FindTypes(class_name, 1);
821 return !class_type_or_name.
IsEmpty();
851 "Print ivar and method information in detail"}};
864 const int short_option = m_getopt_table[option_idx].val;
865 switch (short_option) {
867 m_verbose.SetCurrentValue(
true);
868 m_verbose.SetOptionWasSet();
873 "unrecognized short option '%c'", short_option);
893 "Dump information on Objective-C classes "
894 "known to the current process.",
895 "language objc class-table dump",
896 eCommandRequiresProcess |
897 eCommandProcessMustBeLaunched |
898 eCommandProcessMustBePaused),
909 std::unique_ptr<RegularExpression> regex_up;
916 if (!regex_up->IsValid()) {
918 "invalid argument - please provide a valid regular expression");
925 result.
AppendError(
"please provide 0 or 1 arguments");
931 Process *process = m_exe_ctx.GetProcessPtr();
935 auto iterator = iterators_pair.first;
937 for (; iterator != iterators_pair.second; iterator++) {
938 if (iterator->second) {
939 const char *class_name =
940 iterator->second->GetClassName().AsCString(
"<unknown>");
941 if (regex_up && class_name &&
942 !regex_up->Execute(llvm::StringRef(class_name)))
944 std_out.
Printf(
"isa = 0x%" PRIx64, iterator->first);
945 std_out.Printf(
" name = %s", class_name);
946 std_out.Printf(
" instance size = %" PRIu64,
947 iterator->second->GetInstanceSize());
948 std_out.Printf(
" num ivars = %" PRIuPTR,
949 (uintptr_t)iterator->second->GetNumIVars());
950 if (
auto superclass = iterator->second->GetSuperclass()) {
951 std_out.Printf(
" superclass = %s",
952 superclass->GetClassName().AsCString(
"<unknown>"));
954 std_out.Printf(
"\n");
955 if (m_options.m_verbose) {
956 for (
size_t i = 0; i < iterator->second->GetNumIVars(); i++) {
957 auto ivar = iterator->second->GetIVarAtIndex(i);
959 " ivar name = %s type = %s size = %" PRIu64
960 " offset = %" PRId32
"\n",
961 ivar.m_name.AsCString(
"<unknown>"),
962 ivar.m_type.GetDisplayTypeName().AsCString(
"<unknown>"),
963 ivar.m_size, ivar.m_offset);
966 iterator->second->Describe(
968 [&std_out](
const char *name,
const char *type) ->
bool {
969 std_out.Printf(
" instance method name = %s type = %s\n",
973 [&std_out](
const char *name,
const char *type) ->
bool {
974 std_out.Printf(
" class method name = %s type = %s\n", name,
981 if (regex_up && !regex_up->Execute(llvm::StringRef()))
983 std_out.Printf(
"isa = 0x%" PRIx64
" has no associated class.\n",
990 result.
AppendError(
"current process has no Objective-C runtime loaded");
1002 interpreter,
"info",
"Dump information on a tagged pointer.",
1003 "language objc tagged-pointer info",
1004 eCommandRequiresProcess | eCommandProcessMustBeLaunched |
1005 eCommandProcessMustBePaused) {
1014 result.
AppendError(
"this command requires arguments");
1019 Process *process = m_exe_ctx.GetProcessPtr();
1023 if (!objc_runtime) {
1024 result.
AppendError(
"current process has no Objective-C runtime loaded");
1031 if (!tagged_ptr_vendor) {
1032 result.
AppendError(
"current process has no tagged pointer support");
1047 "could not convert '{0}' to a valid address\n", arg_str);
1058 if (!descriptor_sp) {
1060 "could not get class descriptor for {0:x16}\n", arg_addr);
1065 uint64_t info_bits = 0;
1066 uint64_t value_bits = 0;
1067 uint64_t payload = 0;
1068 if (descriptor_sp->GetTaggedPointerInfo(&info_bits, &value_bits,
1072 "\tpayload = {1:x16}\n"
1073 "\tvalue = {2:x16}\n"
1074 "\tinfo bits = {3:x16}\n"
1076 arg_addr, payload, value_bits, info_bits,
1077 descriptor_sp->GetClassName().AsCString(
"<unknown>"));
1091 interpreter,
"class-table",
1092 "Commands for operating on the Objective-C class table.",
1093 "class-table <subcommand> [<subcommand-options>]") {
1106 interpreter,
"tagged-pointer",
1107 "Commands for operating on Objective-C tagged pointers.",
1108 "class-table <subcommand> [<subcommand-options>]") {
1122 interpreter,
"objc",
1123 "Commands for operating on the Objective-C language runtime.",
1124 "objc <subcommand> [<subcommand-options>]") {
1125 LoadSubCommand(
"class-table",
1128 LoadSubCommand(
"tagged-pointer",
1152 bool catch_bp,
bool throw_bp) {
1156 resolver_sp = std::make_shared<BreakpointResolverName>(
1166llvm::Expected<std::unique_ptr<UtilityFunction>>
1169 char check_function_code[2048];
1173 len = ::snprintf(check_function_code,
sizeof(check_function_code), R
"(
1174 extern "C" void *gdb_object_getClass(void *);
1175 extern "C" int printf(const char *format, ...);
1177 %s(void *$__lldb_arg_obj, void *$__lldb_arg_selector) {
1178 if ($__lldb_arg_obj == (void *)0)
1179 return; // nil is ok
1180 if (!gdb_object_getClass($__lldb_arg_obj)) {
1181 *((volatile int *)0) = 'ocgc';
1182 } else if ($__lldb_arg_selector != (void *)0) {
1183 signed char $responds = (signed char)
1184 [(id)$__lldb_arg_obj respondsToSelector:
1185 (void *) $__lldb_arg_selector];
1186 if ($responds == (signed char) 0)
1187 *((volatile int *)0) = 'ocgc';
1192 len = ::snprintf(check_function_code,
sizeof(check_function_code), R
"(
1193 extern "C" void *gdb_class_getClass(void *);
1194 extern "C" int printf(const char *format, ...);
1196 %s(void *$__lldb_arg_obj, void *$__lldb_arg_selector) {
1197 if ($__lldb_arg_obj == (void *)0)
1198 return; // nil is ok
1199 void **$isa_ptr = (void **)$__lldb_arg_obj;
1200 if (*$isa_ptr == (void *)0 ||
1201 !gdb_class_getClass(*$isa_ptr))
1202 *((volatile int *)0) = 'ocgc';
1203 else if ($__lldb_arg_selector != (void *)0) {
1204 signed char $responds = (signed char)
1205 [(id)$__lldb_arg_obj respondsToSelector:
1206 (void *) $__lldb_arg_selector];
1207 if ($responds == (signed char) 0)
1208 *((volatile int *)0) = 'ocgc';
1214 assert(len < (int)
sizeof(check_function_code));
1222 const char *ivar_name) {
1226 if (!class_name.
IsEmpty() && ivar_name && ivar_name[0]) {
1229 std::string buffer(
"OBJC_IVAR_$_");
1231 buffer.push_back(
'.');
1232 buffer.append(ivar_name);
1248 if (ivar_offset_symbol.
symbol)
1249 ivar_offset_address =
1280 printf(
"RemoteNXMapTable.m_load_addr = 0x%" PRIx64
"\n", m_load_addr);
1281 printf(
"RemoteNXMapTable.m_count = %u\n", m_count);
1282 printf(
"RemoteNXMapTable.m_num_buckets_minus_one = %u\n",
1283 m_num_buckets_minus_one);
1284 printf(
"RemoteNXMapTable.m_buckets_ptr = 0x%" PRIX64
"\n", m_buckets_ptr);
1288 m_process = process;
1289 m_load_addr = load_addr;
1298 const uint32_t unsigned_byte_size =
sizeof(uint32_t);
1302 bool success =
true;
1306 lldb::addr_t cursor = load_addr + m_process->GetAddressByteSize();
1309 m_count = m_process->ReadUnsignedIntegerFromMemory(
1310 cursor, unsigned_byte_size, 0, err);
1312 cursor += unsigned_byte_size;
1315 m_num_buckets_minus_one = m_process->ReadUnsignedIntegerFromMemory(
1316 cursor, unsigned_byte_size, 0, err);
1317 cursor += unsigned_byte_size;
1320 m_buckets_ptr = m_process->ReadPointerFromMemory(cursor, err);
1328 m_num_buckets_minus_one = 0;
1336 typedef std::pair<ConstString, ObjCLanguageRuntime::ObjCISA>
element;
1342 : m_parent(parent), m_index(index) {
1343 AdvanceToValidIndex();
1347 : m_parent(rhs.m_parent), m_index(rhs.m_index) {
1353 assert(&m_parent == &rhs.
m_parent);
1372 AdvanceToValidIndex();
1377 if (m_index == -1) {
1383 size_t map_pair_size = m_parent.m_map_pair_size;
1384 lldb::addr_t pair_ptr = pairs_ptr + (m_index * map_pair_size);
1389 m_parent.m_process->ReadPointerFromMemory(pair_ptr, err);
1392 lldb::addr_t value = m_parent.m_process->ReadPointerFromMemory(
1393 pair_ptr + m_parent.m_process->GetAddressByteSize(), err);
1397 std::string key_string;
1399 m_parent.m_process->ReadCStringFromMemory(key, key_string, err);
1413 const size_t map_pair_size = m_parent.m_map_pair_size;
1414 const lldb::addr_t invalid_key = m_parent.m_invalid_key;
1418 lldb::addr_t pair_ptr = pairs_ptr + (m_index * map_pair_size);
1420 m_parent.m_process->ReadPointerFromMemory(pair_ptr, err);
1427 if (key != invalid_key)
1451 uint32_t m_count = 0;
1452 uint32_t m_num_buckets_minus_one = 0;
1457 size_t m_map_pair_size = 0;
1479 if (m_count == hash_table.
GetCount() &&
1493 class_descriptor_sp = non_pointer_isa_cache->GetClassDescriptor(isa);
1494 if (!class_descriptor_sp)
1496 return class_descriptor_sp;
1505 if (parent && parent != &valobj) {
1507 if (parent_descriptor_sp)
1508 return parent_descriptor_sp->GetSuperclass();
1516 return objc_class_sp;
1526 return objc_class_sp;
1531 return objc_class_sp;
1534 if (!objc_class_sp) {
1536 isa = abi_sp->FixCodeAddress(isa);
1540 if (isa && !objc_class_sp) {
1543 "0x%" PRIx64
": AppleObjCRuntimeV2::GetClassDescriptor() ISA was "
1544 "not in class descriptor cache 0x%" PRIx64,
1547 return objc_class_sp;
1557 if (!objc_module_sp)
1561 "objc_debug_taggedpointer_obfuscator");
1563 const Symbol *symbol = objc_module_sp->FindFirstSymbolWithNameAndType(
1589 if (!objc_module_sp)
1592 static ConstString g_gdb_objc_realized_classes(
"gdb_objc_realized_classes");
1594 const Symbol *symbol = objc_module_sp->FindFirstSymbolWithNameAndType(
1603 gdb_objc_realized_classes_ptr,
error);
1610std::unique_ptr<AppleObjCRuntimeV2::SharedCacheImageHeaders>
1616 if (!objc_module_sp || !process)
1619 const Symbol *symbol = objc_module_sp->FindFirstSymbolWithNameAndType(
1622 LLDB_LOG(log,
"Symbol 'objc_debug_headerInfoRWs' unavailable. Some "
1623 "information concerning the shared cache may be unavailable");
1630 LLDB_LOG(log,
"Symbol 'objc_debug_headerInfoRWs' was found but we were "
1631 "unable to get its load address");
1640 "Failed to read address of 'objc_debug_headerInfoRWs' at {0:x}",
1641 objc_debug_headerInfoRWs_addr);
1645 const size_t metadata_size =
1646 sizeof(uint32_t) +
sizeof(uint32_t);
1649 metadata_size,
error);
1652 "Unable to read metadata for 'objc_debug_headerInfoRWs' at {0:x}",
1653 objc_debug_headerInfoRWs_ptr);
1663 if (count == 0 || entsize == 0) {
1665 "'objc_debug_headerInfoRWs' had count {0} with entsize {1}. These "
1666 "should both be non-zero.",
1671 std::unique_ptr<SharedCacheImageHeaders> shared_cache_image_headers(
1674 if (
auto Err = shared_cache_image_headers->UpdateIfNeeded()) {
1676 "Failed to update SharedCacheImageHeaders: {0}");
1680 return shared_cache_image_headers;
1684 if (!m_needs_update)
1685 return llvm::Error::success();
1687 Process *process = m_runtime.GetProcess();
1689 sizeof(uint32_t) +
sizeof(uint32_t);
1692 const lldb::addr_t first_header_addr = m_headerInfoRWs_ptr + metadata_size;
1695 for (uint32_t i = 0; i < m_count; i++) {
1696 const lldb::addr_t header_addr = first_header_addr + (i * m_entsize);
1700 return llvm::createStringError(llvm::inconvertibleErrorCode(),
1701 "Failed to read memory from inferior when "
1702 "populating SharedCacheImageHeaders");
1708 bool is_loaded =
false;
1709 if (m_entsize == 4) {
1720 m_loaded_images.set(i);
1722 m_loaded_images.reset(i);
1724 m_needs_update =
false;
1726 return llvm::Error::success();
1730 uint16_t image_index) {
1731 if (image_index >= m_count)
1733 if (
auto Err = UpdateIfNeeded()) {
1736 "Failed to update SharedCacheImageHeaders: {0}");
1738 return m_loaded_images.test(image_index);
1742 if (
auto Err = UpdateIfNeeded()) {
1745 "Failed to update SharedCacheImageHeaders: {0}");
1750std::unique_ptr<UtilityFunction>
1756 LLDB_LOG(log,
"Creating utility function {0}", name);
1765 if (!utility_fn_or_error) {
1767 log, utility_fn_or_error.takeError(),
1768 "Failed to get utility function for dynamic info extractor: {0}");
1774 scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(
eEncodingUint, 32);
1790 if (helper == Helper::objc_getRealizedClassList_trylock) {
1799 std::unique_ptr<UtilityFunction> utility_fn = std::move(*utility_fn_or_error);
1802 utility_fn->MakeFunctionCaller(clang_uint32_t_type, arguments,
1807 "Failed to make function caller for implementation lookup: {0}.",
1819 case gdb_objc_realized_classes: {
1820 if (!m_gdb_objc_realized_classes_helper.utility_function)
1821 m_gdb_objc_realized_classes_helper.utility_function =
1822 GetClassInfoUtilityFunctionImpl(exe_ctx, helper,
1825 return m_gdb_objc_realized_classes_helper.utility_function.get();
1827 case objc_copyRealizedClassList: {
1828 if (!m_objc_copyRealizedClassList_helper.utility_function)
1829 m_objc_copyRealizedClassList_helper.utility_function =
1830 GetClassInfoUtilityFunctionImpl(exe_ctx, helper,
1833 return m_objc_copyRealizedClassList_helper.utility_function.get();
1835 case objc_getRealizedClassList_trylock: {
1836 if (!m_objc_getRealizedClassList_trylock_helper.utility_function)
1837 m_objc_getRealizedClassList_trylock_helper.utility_function =
1838 GetClassInfoUtilityFunctionImpl(exe_ctx, helper,
1841 return m_objc_getRealizedClassList_trylock_helper.utility_function.get();
1844 llvm_unreachable(
"Unexpected helper");
1850 case gdb_objc_realized_classes:
1851 return m_gdb_objc_realized_classes_helper.args;
1852 case objc_copyRealizedClassList:
1853 return m_objc_copyRealizedClassList_helper.args;
1854 case objc_getRealizedClassList_trylock:
1855 return m_objc_getRealizedClassList_trylock_helper.args;
1857 llvm_unreachable(
"Unexpected helper");
1863 if (!m_runtime.m_has_objc_copyRealizedClassList &&
1864 !m_runtime.m_has_objc_getRealizedClassList_trylock)
1867 if (
Process *process = m_runtime.GetProcess()) {
1869 if (loader->IsFullyInitialized()) {
1874 if (m_runtime.m_has_objc_getRealizedClassList_trylock)
1878 if (m_runtime.m_has_objc_copyRealizedClassList)
1891std::unique_ptr<UtilityFunction>
1896 LLDB_LOG(log,
"Creating utility function {0}",
1906 static ConstString g_class_getName_symbol_name(
"class_getName");
1907 static ConstString g_class_getNameRaw_symbol_name(
1908 "objc_debug_class_getNameRaw");
1911 m_runtime.HasSymbol(g_class_getNameRaw_symbol_name)
1912 ? g_class_getNameRaw_symbol_name
1913 : g_class_getName_symbol_name;
1918 std::string shared_class_expression;
1919 llvm::raw_string_ostream(shared_class_expression)
1921 class_name_getter_function_name.
AsCString(),
1922 class_name_getter_function_name.
AsCString());
1930 if (!utility_fn_or_error) {
1932 log, utility_fn_or_error.takeError(),
1933 "Failed to get utility function for shared class info extractor: {0}");
1939 scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(
eEncodingUint, 32);
1943 scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(
eEncodingUint, 64)
1964 std::unique_ptr<UtilityFunction> utility_fn = std::move(*utility_fn_or_error);
1967 utility_fn->MakeFunctionCaller(clang_uint32_t_type, arguments,
1972 "Failed to make function caller for implementation lookup: {0}.",
1983 if (!m_utility_function)
1984 m_utility_function = GetClassInfoUtilityFunctionImpl(exe_ctx);
1985 return m_utility_function.get();
1991 Process *process = m_runtime.GetProcess();
1992 if (process ==
nullptr)
1995 uint32_t num_class_infos = 0;
2006 if (!thread_sp->SafeToCallFunctions())
2009 thread_sp->CalculateExecutionContext(exe_ctx);
2026 const uint32_t num_classes =
2029 : m_runtime.m_realized_class_generation_count;
2030 if (num_classes == 0) {
2031 LLDB_LOGF(log,
"No dynamic classes found.");
2036 GetClassInfoUtilityFunction(exe_ctx, helper);
2037 if (!get_class_info_code) {
2045 if (!get_class_info_function) {
2046 LLDB_LOGF(log,
"Failed to get implementation lookup function caller.");
2054 const uint32_t class_info_byte_size = addr_size + 4;
2055 const uint32_t class_infos_byte_size = num_classes * class_info_byte_size;
2057 class_infos_byte_size, ePermissionsReadable | ePermissionsWritable, err);
2061 "unable to allocate %" PRIu32
2062 " bytes in process for shared cache read",
2063 class_infos_byte_size);
2067 auto deallocate_class_infos = llvm::make_scope_exit([&] {
2074 const uint32_t class_byte_size = addr_size;
2075 const uint32_t class_buffer_len = num_classes;
2076 const uint32_t class_buffer_byte_size = class_buffer_len * class_byte_size;
2077 if (helper == Helper::objc_getRealizedClassList_trylock) {
2079 class_buffer_byte_size, ePermissionsReadable | ePermissionsWritable,
2083 "unable to allocate %" PRIu32
2084 " bytes in process for shared cache read",
2085 class_buffer_byte_size);
2090 auto deallocate_class_buffer = llvm::make_scope_exit([&] {
2096 std::lock_guard<std::mutex> guard(m_mutex);
2113 bool dump_log = type_log && type_log->
GetVerbose();
2117 bool success =
false;
2119 diagnostics.
Clear();
2123 exe_ctx, GetClassInfoArgs(helper), arguments, diagnostics)) {
2133 scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(
eEncodingUint, 32);
2140 diagnostics.
Clear();
2144 exe_ctx, &GetClassInfoArgs(helper), options, diagnostics, return_value);
2149 LLDB_LOG(log,
"Discovered {0} Objective-C classes", num_class_infos);
2150 if (num_class_infos > 0) {
2152 DataBufferHeap buffer(num_class_infos * class_info_byte_size, 0);
2159 m_runtime.ParseClassInfoArray(class_infos_data, num_class_infos);
2165 LLDB_LOGF(log,
"Error evaluating our find class name function.");
2166 diagnostics.
Dump(log);
2171 LLDB_LOGF(log,
"Error writing function arguments.");
2172 diagnostics.
Dump(log);
2180 uint32_t num_class_infos) {
2192 uint32_t num_parsed = 0;
2196 for (uint32_t i = 0; i < num_class_infos; ++i) {
2202 log,
"AppleObjCRuntimeV2 found NULL isa, ignoring this class info");
2210 "AppleObjCRuntimeV2 found cached isa=0x%" PRIx64
2211 ", ignoring this class info",
2216 const uint32_t name_hash = data.
GetU32(&offset);
2226 AddClass(isa, descriptor_sp, name_hash);
2229 descriptor_sp->GetClassName().AsCString(
nullptr));
2233 "AppleObjCRuntimeV2 added isa=0x%" PRIx64
2234 ", hash=0x%8.8x, name=%s",
2236 descriptor_sp->GetClassName().AsCString(
"<unknown>"));
2240 LLDB_LOGF(log,
"AppleObjCRuntimeV2 parsed %" PRIu32
" class infos",
2250 if (symbol->ValueIsAddress() || symbol->GetAddressRef().IsValid())
2258 Process *process = m_runtime.GetProcess();
2259 if (process ==
nullptr)
2271 if (!thread_sp->SafeToCallFunctions())
2274 thread_sp->CalculateExecutionContext(exe_ctx);
2287 uint32_t num_class_infos = 0;
2289 const lldb::addr_t objc_opt_ptr = m_runtime.GetSharedCacheReadOnlyAddress();
2291 m_runtime.GetSharedCacheBaseAddress();
2302 const uint32_t max_num_classes = 212992;
2304 UtilityFunction *get_class_info_code = GetClassInfoUtilityFunction(exe_ctx);
2305 if (!get_class_info_code) {
2313 if (!get_shared_cache_class_info_function) {
2314 LLDB_LOGF(log,
"Failed to get implementation lookup function caller.");
2323 const uint32_t class_info_byte_size = addr_size + 4;
2324 const uint32_t class_infos_byte_size = max_num_classes * class_info_byte_size;
2326 class_infos_byte_size, ePermissionsReadable | ePermissionsWritable, err);
2327 const uint32_t relative_selector_offset_addr_size = 64;
2330 ePermissionsReadable | ePermissionsWritable, err);
2334 "unable to allocate %" PRIu32
2335 " bytes in process for shared cache read",
2336 class_infos_byte_size);
2340 std::lock_guard<std::mutex> guard(m_mutex);
2351 bool dump_log = type_log && type_log->
GetVerbose();
2355 bool success =
false;
2357 diagnostics.
Clear();
2361 exe_ctx, m_args, arguments, diagnostics)) {
2371 scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(
eEncodingUint, 32);
2378 diagnostics.
Clear();
2383 exe_ctx, &m_args, options, diagnostics, return_value);
2388 LLDB_LOG(log,
"Discovered {0} Objective-C classes in the shared cache",
2392 assert(num_class_infos <= max_num_classes);
2393 if (num_class_infos > 0) {
2394 if (num_class_infos > max_num_classes) {
2395 num_class_infos = max_num_classes;
2404 if (process->
ReadMemory(relative_selector_offset_addr,
2405 relative_selector_offset_buffer.
GetBytes(),
2410 relative_selector_offset_buffer.
GetBytes(),
2414 uint64_t relative_selector_offset =
2415 relative_selector_offset_data.
GetU64(&offset);
2416 if (relative_selector_offset > 0) {
2418 m_runtime.SetRelativeSelectorBaseAddr(objc_opt_ptr +
2419 relative_selector_offset);
2425 num_class_infos * class_info_byte_size, 0);
2433 m_runtime.ParseClassInfoArray(class_infos_data, num_class_infos);
2440 LLDB_LOGF(log,
"Error evaluating our find class name function.");
2441 diagnostics.
Dump(log);
2446 LLDB_LOGF(log,
"Error writing function arguments.");
2447 diagnostics.
Dump(log);
2463 if (objc_module_sp) {
2464 ObjectFile *objc_object = objc_module_sp->GetObjectFile();
2467 SectionList *section_list = objc_module_sp->GetSectionList();
2473 if (text_segment_sp) {
2475 text_segment_sp->GetChildren().FindSectionByName(
2478 if (objc_opt_section_sp) {
2479 return objc_opt_section_sp->GetLoadBaseAddress(
2527 !class_count_changed)
2547 const uint32_t num_classes_to_warn_at = 500;
2553 "attempted to read objc class data - results: "
2554 "[dynamic_update]: ran: %s, retry: %s, count: %" PRIu32
2555 " [shared_cache_update]: ran: %s, retry: %s, count: %" PRIu32,
2559 shared_cache_update_result.
m_update_ran ?
"yes" :
"no",
2575 num_classes_to_warn_at)
2591 uint64_t objc_debug_realized_class_generation_count =
2593 process,
ConstString(
"objc_debug_realized_class_generation_count"),
2599 objc_debug_realized_class_generation_count)
2604 "objc_debug_realized_class_generation_count changed from {0} to {1}",
2606 objc_debug_realized_class_generation_count);
2609 objc_debug_realized_class_generation_count;
2619 llvm::StringRef platform_plugin_name_sr = platform_sp->GetPluginName();
2620 if (platform_plugin_name_sr.ends_with(
"-simulator"))
2638 "the process. This may reduce the quality of type "
2639 "information available.\n",
2644 "could not execute support code to read "
2645 "Objective-C class data in the process. This may "
2646 "reduce the quality of type information available.\n",
2651 "could not execute support code to read Objective-C class data because "
2652 "it's not yet safe to do so, and will be retried later.\n",
2653 debugger.
GetID(),
nullptr);
2673 llvm::raw_string_ostream os(buffer);
2675 os <<
"libobjc.A.dylib is being read from process memory. This "
2676 "indicates that LLDB could not ";
2678 if (platform_sp->IsHost()) {
2679 os <<
"read from the host's in-memory shared cache";
2681 os <<
"find the on-disk shared cache for this device";
2684 os <<
"read from the shared cache";
2686 os <<
". This will likely reduce debugging performance.\n";
2702 const char *name_cstr = name.
AsCString();
2705 llvm::StringRef name_strref(name_cstr);
2707 llvm::StringRef ivar_prefix(
"OBJC_IVAR_$_");
2708 llvm::StringRef class_prefix(
"OBJC_CLASS_$_");
2710 if (name_strref.starts_with(ivar_prefix)) {
2711 llvm::StringRef ivar_skipped_prefix =
2712 name_strref.substr(ivar_prefix.size());
2713 std::pair<llvm::StringRef, llvm::StringRef> class_and_ivar =
2714 ivar_skipped_prefix.split(
'.');
2716 if (!class_and_ivar.first.empty() && !class_and_ivar.second.empty()) {
2717 const ConstString class_name_cs(class_and_ivar.first);
2722 const ConstString ivar_name_cs(class_and_ivar.second);
2723 const char *ivar_name_cstr = ivar_name_cs.
AsCString();
2725 auto ivar_func = [&ret,
2726 ivar_name_cstr](
const char *name,
const char *type,
2729 if (!strcmp(name, ivar_name_cstr)) {
2736 descriptor->Describe(
2737 std::function<
void(
ObjCISA)>(
nullptr),
2738 std::function<
bool(
const char *,
const char *)>(
nullptr),
2739 std::function<
bool(
const char *,
const char *)>(
nullptr),
2743 }
else if (name_strref.starts_with(class_prefix)) {
2744 llvm::StringRef class_skipped_prefix =
2745 name_strref.substr(class_prefix.size());
2746 const ConstString class_name_cs(class_skipped_prefix);
2751 ret = descriptor->GetISA();
2773 process,
ConstString(
"objc_debug_isa_magic_value"), objc_module_sp,
2784 log->
PutCString(
"AOCRT::NPI: Found all the non-indexed ISA masks");
2786 bool foundError =
false;
2788 process,
ConstString(
"objc_debug_indexed_isa_magic_mask"), objc_module_sp,
2790 foundError |=
error.Fail();
2793 process,
ConstString(
"objc_debug_indexed_isa_magic_value"),
2794 objc_module_sp,
error);
2795 foundError |=
error.Fail();
2798 process,
ConstString(
"objc_debug_indexed_isa_index_mask"), objc_module_sp,
2800 foundError |=
error.Fail();
2803 process,
ConstString(
"objc_debug_indexed_isa_index_shift"),
2804 objc_module_sp,
error);
2805 foundError |=
error.Fail();
2807 auto objc_indexed_classes =
2809 objc_module_sp,
error,
false);
2810 foundError |=
error.Fail();
2813 log->
PutCString(
"AOCRT::NPI: Found all the indexed ISA masks");
2819 runtime, objc_module_sp, objc_debug_isa_class_mask,
2820 objc_debug_isa_magic_mask, objc_debug_isa_magic_value,
2821 objc_debug_indexed_isa_magic_mask, objc_debug_indexed_isa_magic_value,
2822 objc_debug_indexed_isa_index_mask, objc_debug_indexed_isa_index_shift,
2823 foundError ? 0 : objc_indexed_classes);
2834 process,
ConstString(
"objc_debug_taggedpointer_mask"), objc_module_sp,
2840 process,
ConstString(
"objc_debug_taggedpointer_slot_shift"),
2841 objc_module_sp,
error,
true, 4);
2846 process,
ConstString(
"objc_debug_taggedpointer_slot_mask"),
2847 objc_module_sp,
error,
true, 4);
2852 process,
ConstString(
"objc_debug_taggedpointer_payload_lshift"),
2853 objc_module_sp,
error,
true, 4);
2858 process,
ConstString(
"objc_debug_taggedpointer_payload_rshift"),
2859 objc_module_sp,
error,
true, 4);
2864 process,
ConstString(
"objc_debug_taggedpointer_classes"), objc_module_sp,
2873 process,
ConstString(
"objc_debug_taggedpointer_ext_mask"),
2874 objc_module_sp,
error);
2879 process,
ConstString(
"objc_debug_taggedpointer_ext_slot_shift"),
2880 objc_module_sp,
error,
true, 4);
2885 process,
ConstString(
"objc_debug_taggedpointer_ext_slot_mask"),
2886 objc_module_sp,
error,
true, 4);
2891 process,
ConstString(
"objc_debug_taggedpointer_ext_classes"),
2892 objc_module_sp,
error,
false);
2896 auto objc_debug_taggedpointer_ext_payload_lshift =
2898 process,
ConstString(
"objc_debug_taggedpointer_ext_payload_lshift"),
2899 objc_module_sp,
error,
true, 4);
2903 auto objc_debug_taggedpointer_ext_payload_rshift =
2905 process,
ConstString(
"objc_debug_taggedpointer_ext_payload_rshift"),
2906 objc_module_sp,
error,
true, 4);
2911 runtime, objc_debug_taggedpointer_mask,
2912 objc_debug_taggedpointer_ext_mask, objc_debug_taggedpointer_slot_shift,
2913 objc_debug_taggedpointer_ext_slot_shift,
2914 objc_debug_taggedpointer_slot_mask,
2915 objc_debug_taggedpointer_ext_slot_mask,
2916 objc_debug_taggedpointer_payload_lshift,
2917 objc_debug_taggedpointer_payload_rshift,
2918 objc_debug_taggedpointer_ext_payload_lshift,
2919 objc_debug_taggedpointer_ext_payload_rshift,
2920 objc_debug_taggedpointer_classes, objc_debug_taggedpointer_ext_classes);
2927 runtime, objc_debug_taggedpointer_mask,
2928 objc_debug_taggedpointer_slot_shift, objc_debug_taggedpointer_slot_mask,
2929 objc_debug_taggedpointer_payload_lshift,
2930 objc_debug_taggedpointer_payload_rshift,
2931 objc_debug_taggedpointer_classes);
2942 if (!IsPossibleTaggedPointer(ptr))
2945 uint32_t foundation_version = m_runtime.GetFoundationVersion();
2950 uint64_t class_bits = (ptr & 0xE) >> 1;
2956 static ConstString g_NSManagedObject(
"NSManagedObject");
2959 if (foundation_version >= 900) {
2960 switch (class_bits) {
2971 name = g_NSManagedObject;
2980 switch (class_bits) {
2985 name = g_NSManagedObject;
2998 lldb::addr_t unobfuscated = ptr ^ m_runtime.GetTaggedPointerObfuscator();
3005 uint32_t objc_debug_taggedpointer_slot_shift,
3006 uint32_t objc_debug_taggedpointer_slot_mask,
3007 uint32_t objc_debug_taggedpointer_payload_lshift,
3008 uint32_t objc_debug_taggedpointer_payload_rshift,
3011 m_objc_debug_taggedpointer_mask(objc_debug_taggedpointer_mask),
3012 m_objc_debug_taggedpointer_slot_shift(
3013 objc_debug_taggedpointer_slot_shift),
3014 m_objc_debug_taggedpointer_slot_mask(objc_debug_taggedpointer_slot_mask),
3015 m_objc_debug_taggedpointer_payload_lshift(
3016 objc_debug_taggedpointer_payload_lshift),
3017 m_objc_debug_taggedpointer_payload_rshift(
3018 objc_debug_taggedpointer_payload_rshift),
3019 m_objc_debug_taggedpointer_classes(objc_debug_taggedpointer_classes) {}
3023 return (ptr & m_objc_debug_taggedpointer_mask) != 0;
3030 uint64_t unobfuscated = (ptr) ^ m_runtime.GetTaggedPointerObfuscator();
3032 if (!IsPossibleTaggedPointer(unobfuscated))
3035 uintptr_t slot = (ptr >> m_objc_debug_taggedpointer_slot_shift) &
3036 m_objc_debug_taggedpointer_slot_mask;
3038 CacheIterator iterator = m_cache.find(slot), end = m_cache.end();
3039 if (iterator != end) {
3040 actual_class_descriptor_sp = iterator->second;
3042 Process *process(m_runtime.GetProcess());
3044 m_objc_debug_taggedpointer_classes;
3047 if (
error.Fail() || slot_data == 0 ||
3050 actual_class_descriptor_sp =
3051 m_runtime.GetClassDescriptorFromISA((
ObjCISA)slot_data);
3052 if (!actual_class_descriptor_sp) {
3055 actual_class_descriptor_sp =
3056 m_runtime.GetClassDescriptorFromISA(fixed_isa);
3059 if (!actual_class_descriptor_sp)
3061 m_cache[slot] = actual_class_descriptor_sp;
3064 uint64_t data_payload =
3065 ((unobfuscated << m_objc_debug_taggedpointer_payload_lshift) >>
3066 m_objc_debug_taggedpointer_payload_rshift);
3067 int64_t data_payload_signed =
3068 ((int64_t)(unobfuscated << m_objc_debug_taggedpointer_payload_lshift) >>
3069 m_objc_debug_taggedpointer_payload_rshift);
3071 actual_class_descriptor_sp, data_payload, data_payload_signed));
3076 uint64_t objc_debug_taggedpointer_ext_mask,
3077 uint32_t objc_debug_taggedpointer_slot_shift,
3078 uint32_t objc_debug_taggedpointer_ext_slot_shift,
3079 uint32_t objc_debug_taggedpointer_slot_mask,
3080 uint32_t objc_debug_taggedpointer_ext_slot_mask,
3081 uint32_t objc_debug_taggedpointer_payload_lshift,
3082 uint32_t objc_debug_taggedpointer_payload_rshift,
3083 uint32_t objc_debug_taggedpointer_ext_payload_lshift,
3084 uint32_t objc_debug_taggedpointer_ext_payload_rshift,
3088 runtime, objc_debug_taggedpointer_mask,
3089 objc_debug_taggedpointer_slot_shift,
3090 objc_debug_taggedpointer_slot_mask,
3091 objc_debug_taggedpointer_payload_lshift,
3092 objc_debug_taggedpointer_payload_rshift,
3093 objc_debug_taggedpointer_classes),
3095 m_objc_debug_taggedpointer_ext_mask(objc_debug_taggedpointer_ext_mask),
3096 m_objc_debug_taggedpointer_ext_slot_shift(
3097 objc_debug_taggedpointer_ext_slot_shift),
3098 m_objc_debug_taggedpointer_ext_slot_mask(
3099 objc_debug_taggedpointer_ext_slot_mask),
3100 m_objc_debug_taggedpointer_ext_payload_lshift(
3101 objc_debug_taggedpointer_ext_payload_lshift),
3102 m_objc_debug_taggedpointer_ext_payload_rshift(
3103 objc_debug_taggedpointer_ext_payload_rshift),
3104 m_objc_debug_taggedpointer_ext_classes(
3105 objc_debug_taggedpointer_ext_classes) {}
3109 if (!IsPossibleTaggedPointer(ptr))
3112 if (m_objc_debug_taggedpointer_ext_mask == 0)
3115 return ((ptr & m_objc_debug_taggedpointer_ext_mask) ==
3116 m_objc_debug_taggedpointer_ext_mask);
3123 uint64_t unobfuscated = (ptr) ^ m_runtime.GetTaggedPointerObfuscator();
3125 if (!IsPossibleTaggedPointer(unobfuscated))
3128 if (!IsPossibleExtendedTaggedPointer(unobfuscated))
3131 uintptr_t slot = (ptr >> m_objc_debug_taggedpointer_ext_slot_shift) &
3132 m_objc_debug_taggedpointer_ext_slot_mask;
3134 CacheIterator iterator = m_ext_cache.find(slot), end = m_ext_cache.end();
3135 if (iterator != end) {
3136 actual_class_descriptor_sp = iterator->second;
3138 Process *process(m_runtime.GetProcess());
3140 m_objc_debug_taggedpointer_ext_classes;
3143 if (
error.Fail() || slot_data == 0 ||
3146 actual_class_descriptor_sp =
3147 m_runtime.GetClassDescriptorFromISA((
ObjCISA)slot_data);
3148 if (!actual_class_descriptor_sp)
3150 m_ext_cache[slot] = actual_class_descriptor_sp;
3153 uint64_t data_payload = (((uint64_t)unobfuscated
3154 << m_objc_debug_taggedpointer_ext_payload_lshift) >>
3155 m_objc_debug_taggedpointer_ext_payload_rshift);
3156 int64_t data_payload_signed =
3157 ((int64_t)((uint64_t)unobfuscated
3158 << m_objc_debug_taggedpointer_ext_payload_lshift) >>
3159 m_objc_debug_taggedpointer_ext_payload_rshift);
3162 actual_class_descriptor_sp, data_payload, data_payload_signed));
3167 uint64_t objc_debug_isa_class_mask, uint64_t objc_debug_isa_magic_mask,
3168 uint64_t objc_debug_isa_magic_value,
3169 uint64_t objc_debug_indexed_isa_magic_mask,
3170 uint64_t objc_debug_indexed_isa_magic_value,
3171 uint64_t objc_debug_indexed_isa_index_mask,
3172 uint64_t objc_debug_indexed_isa_index_shift,
3175 m_objc_debug_isa_class_mask(objc_debug_isa_class_mask),
3176 m_objc_debug_isa_magic_mask(objc_debug_isa_magic_mask),
3177 m_objc_debug_isa_magic_value(objc_debug_isa_magic_value),
3178 m_objc_debug_indexed_isa_magic_mask(objc_debug_indexed_isa_magic_mask),
3179 m_objc_debug_indexed_isa_magic_value(objc_debug_indexed_isa_magic_value),
3180 m_objc_debug_indexed_isa_index_mask(objc_debug_indexed_isa_index_mask),
3181 m_objc_debug_indexed_isa_index_shift(objc_debug_indexed_isa_index_shift),
3182 m_objc_indexed_classes(objc_indexed_classes), m_indexed_isa_cache() {}
3187 if (!EvaluateNonPointerISA(isa, real_isa))
3189 auto cache_iter = m_cache.find(real_isa);
3190 if (cache_iter != m_cache.end())
3191 return cache_iter->second;
3192 auto descriptor_sp =
3193 m_runtime.ObjCLanguageRuntime::GetClassDescriptorFromISA(real_isa);
3195 m_cache[real_isa] = descriptor_sp;
3196 return descriptor_sp;
3203 LLDB_LOGF(log,
"AOCRT::NPI Evaluate(isa = 0x%" PRIx64
")", (uint64_t)isa);
3205 if ((isa & ~m_objc_debug_isa_class_mask) == 0)
3212 if (m_objc_debug_indexed_isa_magic_mask &&
3213 m_objc_debug_indexed_isa_magic_value &&
3214 m_objc_debug_indexed_isa_index_mask &&
3215 m_objc_debug_indexed_isa_index_shift && m_objc_indexed_classes) {
3216 if ((isa & ~m_objc_debug_indexed_isa_index_mask) == 0)
3219 if ((isa & m_objc_debug_indexed_isa_magic_mask) ==
3220 m_objc_debug_indexed_isa_magic_value) {
3222 uintptr_t index = (isa & m_objc_debug_indexed_isa_index_mask) >>
3223 m_objc_debug_indexed_isa_index_shift;
3228 if (index > m_indexed_isa_cache.size()) {
3230 "AOCRT::NPI (index = %" PRIu64
3231 ") exceeds cache (size = %" PRIu64
")",
3232 (uint64_t)index, (uint64_t)m_indexed_isa_cache.size());
3234 Process *process(m_runtime.GetProcess());
3237 if (!objc_module_sp)
3242 process,
ConstString(
"objc_indexed_classes_count"), objc_module_sp,
3247 LLDB_LOGF(log,
"AOCRT::NPI (new class count = %" PRIu64
")",
3248 (uint64_t)objc_indexed_classes_count);
3250 if (objc_indexed_classes_count > m_indexed_isa_cache.size()) {
3254 auto num_new_classes =
3255 objc_indexed_classes_count - m_indexed_isa_cache.size();
3260 m_objc_indexed_classes + (m_indexed_isa_cache.size() * addr_size);
3266 LLDB_LOGF(log,
"AOCRT::NPI (read new classes count = %" PRIu64
")",
3267 (uint64_t)num_new_classes);
3275 for (
unsigned i = 0; i != num_new_classes; ++i)
3276 m_indexed_isa_cache.push_back(data.
GetAddress(&offset));
3281 if (index >= m_indexed_isa_cache.size())
3284 LLDB_LOGF(log,
"AOCRT::NPI Evaluate(ret_isa = 0x%" PRIx64
")",
3285 (uint64_t)m_indexed_isa_cache[index]);
3287 ret_isa = m_indexed_isa_cache[index];
3288 return (ret_isa != 0);
3296 if ((isa & m_objc_debug_isa_magic_mask) == m_objc_debug_isa_magic_value) {
3297 ret_isa = isa & m_objc_debug_isa_class_mask;
3298 return (ret_isa != 0);
3306 std::make_shared<AppleObjCTypeEncodingParser>(*
this);
3315 non_pointer_isa_cache->EvaluateNonPointerISA(isa, ret);
3324 static ConstString g_dunder_kCFBooleanFalse(
"__kCFBooleanFalse");
3325 static ConstString g_dunder_kCFBooleanTrue(
"__kCFBooleanTrue");
3326 static ConstString g_kCFBooleanFalse(
"kCFBooleanFalse");
3327 static ConstString g_kCFBooleanTrue(
"kCFBooleanTrue");
3358 lldb::addr_t false_addr = get_symbol(g_dunder_kCFBooleanFalse, g_kCFBooleanFalse);
3359 lldb::addr_t true_addr = get_symbol(g_dunder_kCFBooleanTrue, g_kCFBooleanTrue);
3398 return std::nullopt;
3403 auto dict_up = std::make_unique<StructuredData::Dictionary>();
3404 dict_up->AddItem(
"Objective-C runtime version",
3405 std::make_unique<StructuredData::UnsignedInteger>(2));
3409#pragma mark Frame recognizers
3414 ThreadSP thread_sp = frame_sp->GetThread();
3415 ProcessSP process_sp = thread_sp->GetProcess();
3433 if (!abi->GetArgumentValues(*thread_sp, args))
3438 Value value(exception_addr);
3447 m_arguments->Append(exception);
3449 m_stop_desc =
"hit Objective-C exception";
3464 return "ObjC Exception Throw StackFrame Recognizer";
3472 std::vector<ConstString> symbols = {function};
static const char * g_get_dynamic_class_info_name
static void RegisterObjCExceptionRecognizer(Process *process)
static const char * g_get_dynamic_class_info3_body
static const char * g_get_dynamic_class_info2_body
static const char * g_get_shared_cache_class_info_name
static const char * g_get_dynamic_class_info3_name
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 constexpr OptionDefinition g_objc_classtable_dump_options[]
static const char * g_get_shared_cache_class_info_body
static const char * g_shared_cache_class_name_funcptr
static const char * g_get_dynamic_class_info_body
static const char * g_get_dynamic_class_info2_name
static bool DoesProcessHaveSharedCache(Process &process)
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,...)
#define LLDB_LOG_ERROR(log, error,...)
#define LLDB_SCOPED_TIMER()
CommandObjectMultiwordObjC_ClassTable(CommandInterpreter &interpreter)
~CommandObjectMultiwordObjC_ClassTable() override=default
~CommandObjectMultiwordObjC_TaggedPointer_Info() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectMultiwordObjC_TaggedPointer_Info(CommandInterpreter &interpreter)
CommandObjectMultiwordObjC_TaggedPointer(CommandInterpreter &interpreter)
~CommandObjectMultiwordObjC_TaggedPointer() override=default
~CommandObjectMultiwordObjC() override=default
CommandObjectMultiwordObjC(CommandInterpreter &interpreter)
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
void OptionParsingStarting(ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
~CommandOptions() override=default
OptionValueBoolean m_verbose
Options * GetOptions() override
~CommandObjectObjC_ClassTable_Dump() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectObjC_ClassTable_Dump(CommandInterpreter &interpreter)
lldb::ValueObjectSP GetExceptionObject() override
ObjCExceptionRecognizedStackFrame(StackFrameSP frame_sp)
lldb::RecognizedStackFrameSP RecognizeFrame(lldb::StackFrameSP frame) override
std::string GetName() override
element operator*() const
bool operator==(const const_iterator &rhs) const
const_iterator & operator++()
void AdvanceToValidIndex()
const_iterator & operator=(const const_iterator &rhs)
RemoteNXMapTable & m_parent
const_iterator(RemoteNXMapTable &parent, int index)
bool operator!=(const const_iterator &rhs) const
const_iterator(const const_iterator &rhs)
bool ParseHeader(Process *process, lldb::addr_t load_addr)
std::pair< ConstString, ObjCLanguageRuntime::ObjCISA > element
lldb::addr_t GetTableLoadAddress() const
const_iterator m_end_iterator
uint32_t GetCount() const
lldb::addr_t GetBucketDataPointer() const
uint32_t GetBucketCount() const
A section + offset based address class.
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
void SetRawAddress(lldb::addr_t addr)
void UpdateSignature(const RemoteNXMapTable &hash_table)
bool NeedsUpdate(Process *process, AppleObjCRuntimeV2 *runtime, RemoteNXMapTable &hash_table)
lldb::addr_t m_buckets_ptr
NonPointerISACache(AppleObjCRuntimeV2 &runtime, const lldb::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)
bool EvaluateNonPointerISA(ObjCISA isa, ObjCISA &ret_isa)
ObjCLanguageRuntime::ClassDescriptorSP GetClassDescriptor(ObjCISA isa)
static NonPointerISACache * CreateInstance(AppleObjCRuntimeV2 &runtime, const lldb::ModuleSP &objc_module_sp)
ObjCLanguageRuntime::ClassDescriptorSP GetClassDescriptor(lldb::addr_t ptr) override
Cache::iterator CacheIterator
bool IsPossibleExtendedTaggedPointer(lldb::addr_t ptr)
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 IsPossibleTaggedPointer(lldb::addr_t ptr) override
ObjCLanguageRuntime::ClassDescriptorSP GetClassDescriptor(lldb::addr_t ptr) override
Cache::iterator CacheIterator
ObjCLanguageRuntime::ClassDescriptorSP GetClassDescriptor(lldb::addr_t ptr) override
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 IsPossibleTaggedPointer(lldb::addr_t ptr) override
static TaggedPointerVendorV2 * CreateInstance(AppleObjCRuntimeV2 &runtime, const lldb::ModuleSP &objc_module_sp)
llvm::Expected< std::unique_ptr< UtilityFunction > > CreateObjectChecker(std::string name, ExecutionContext &exe_ctx) override
bool m_has_objc_getRealizedClassList_trylock
bool IsTaggedPointer(lldb::addr_t ptr) override
uint32_t ParseClassInfoArray(const lldb_private::DataExtractor &data, uint32_t num_class_infos)
bool RealizedClassGenerationCountChanged()
Update the generation count of realized classes.
static llvm::StringRef GetPluginNameStatic()
EncodingToTypeSP GetEncodingToType() override
ObjCISA GetPointerISA(ObjCISA isa)
AppleObjCRuntimeV2(Process *process, const lldb::ModuleSP &objc_module_sp)
NonPointerISACache * GetNonPointerIsaCache()
std::once_flag m_no_expanded_cache_warning
size_t GetByteOffsetForIvar(CompilerType &parent_ast_type, const char *ivar_name) override
StructuredData::ObjectSP GetLanguageSpecificData(SymbolContext sc) override
Language runtime plugins can use this API to report language-specific runtime information about this ...
lldb::addr_t m_isa_hash_table_ptr
HashTableSignature m_hash_signature
bool m_has_object_getClass
SharedCacheClassInfoExtractor m_shared_cache_class_info_extractor
DynamicClassInfoExtractor m_dynamic_class_info_extractor
lldb::addr_t GetISAHashTablePointer()
ClassDescriptorSP GetClassDescriptorFromISA(ObjCISA isa) override
bool GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic, TypeAndOrName &class_type_or_name, Address &address, Value::ValueType &value_type) override
@ eExpressionExecutionFailure
std::unique_ptr< SharedCacheImageHeaders > m_shared_cache_image_headers_up
friend class ClassDescriptorV2
lldb::addr_t LookupRuntimeSymbol(ConstString name) override
ClassDescriptorSP GetClassDescriptor(ValueObject &valobj) override
void ModulesDidLoad(const ModuleList &module_list) override
Called when modules have been loaded in the process.
bool IsSharedCacheImageLoaded(uint16_t image_index)
bool HasSymbol(ConstString Name)
EncodingToTypeSP m_encoding_to_type_sp
lldb::addr_t GetSharedCacheBaseAddress()
std::once_flag m_no_classes_cached_warning
std::optional< std::pair< lldb::addr_t, lldb::addr_t > > m_CFBoolean_values
std::unique_ptr< DeclVendor > m_decl_vendor_up
uint64_t m_realized_class_generation_count
lldb::addr_t GetTaggedPointerObfuscator()
void WarnIfNoExpandedSharedCache()
lldb::addr_t m_tagged_pointer_obfuscator
std::unique_ptr< TaggedPointerVendor > m_tagged_pointer_vendor_up
bool GetCFBooleanValuesIfNeeded()
lldb::addr_t GetSharedCacheReadOnlyAddress()
void GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true, lldb::addr_t &cf_false) override
void UpdateISAToDescriptorMapIfNeeded() override
lldb::BreakpointResolverSP CreateExceptionResolver(const lldb::BreakpointSP &bkpt, bool catch_bp, bool throw_bp) override
LanguageRuntime * GetPreferredLanguageRuntime(ValueObject &in_value) override
Return the preferred language runtime instance, which in most cases will be the current instance.
lldb::ModuleSP m_objc_module_sp
std::optional< uint64_t > GetSharedCacheImageHeaderVersion()
void WarnIfNoClassesCached(SharedCacheWarningReason reason)
static lldb_private::LanguageRuntime * CreateInstance(Process *process, lldb::LanguageType language)
DeclVendor * GetDeclVendor() override
bool m_has_objc_copyRealizedClassList
virtual void GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true, lldb::addr_t &cf_false)
lldb::ModuleWP m_objc_module_wp
static std::tuple< FileSpec, ConstString > GetExceptionThrowLocation()
static ObjCRuntimeVersions GetObjCVersion(Process *process, lldb::ModuleSP &objc_module_sp)
bool HasReadObjCLibrary() override
lldb::ModuleSP GetObjCModule()
void ModulesDidLoad(const ModuleList &module_list) override
Called when modules have been loaded in the process.
bool CouldHaveDynamicValue(ValueObject &in_value) override
A command line argument class.
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
const char * GetArgumentAtIndex(size_t idx) const
Gets the NULL terminated C string argument pointer for the argument at index idx.
void AppendErrorWithFormatv(const char *format, Args &&... args)
void void AppendError(llvm::StringRef in_string)
void SetStatus(lldb::ReturnStatus status)
Stream & GetOutputStream()
Generic representation of a type in a programming language.
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
ConstString GetTypeName(bool BaseOnly=false) const
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
bool IsEmpty() const
Test for empty string.
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.
A class to manage flag bits.
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
A plug-in interface definition class for dynamic loaders.
void SetUnwindOnError(bool unwind=false)
void SetTryAllThreads(bool try_others=true)
void SetTimeout(const Timeout< std::micro > &timeout)
void SetStopOthers(bool stop_others=true)
void SetIsForUtilityExpr(bool b)
void SetIgnoreBreakpoints(bool ignore=false)
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
const lldb::ThreadSP & GetThreadSP() const
Get accessor to get the thread shared pointer.
Target & GetTargetRef() const
Returns a reference to the target object.
Process * GetProcessPtr() const
Returns a pointer to the process object.
const ConstString & GetFilename() const
Filename string const get accessor.
Encapsulates a function that can be called.
ValueList GetArgumentValues() const
lldb::ExpressionResults ExecuteFunction(ExecutionContext &exe_ctx, lldb::addr_t *args_addr_ptr, const EvaluateExpressionOptions &options, DiagnosticManager &diagnostic_manager, Value &results)
Run the function this FunctionCaller was created with.
bool WriteFunctionArguments(ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, DiagnosticManager &diagnostic_manager)
Insert the default function argument struct.
void PutCString(const char *cstr)
A collection class for Module objects.
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
virtual bool IsPossibleTaggedPointer(lldb::addr_t ptr)=0
virtual ObjCLanguageRuntime::ClassDescriptorSP GetClassDescriptor(lldb::addr_t ptr)=0
uint32_t m_isa_to_descriptor_stop_id
std::shared_ptr< ClassDescriptor > ClassDescriptorSP
bool AddClass(ObjCISA isa, const ClassDescriptorSP &descriptor_sp)
std::pair< ISAToDescriptorIterator, ISAToDescriptorIterator > GetDescriptorIteratorPair(bool update_if_needed=true)
virtual TaggedPointerVendor * GetTaggedPointerVendor()
lldb::TypeSP LookupInCompleteClassCache(ConstString &name)
ClassDescriptorSP GetNonKVOClassDescriptor(ValueObject &in_value)
virtual ClassDescriptorSP GetClassDescriptorFromISA(ObjCISA isa)
bool ISAIsCached(ObjCISA isa) const
static ObjCLanguageRuntime * Get(Process &process)
virtual ClassDescriptorSP GetClassDescriptorFromClassName(ConstString class_name)
static lldb::BreakpointPreconditionSP GetBreakpointExceptionPrecondition(lldb::LanguageType language, bool throw_bp)
std::shared_ptr< EncodingToType > EncodingToTypeSP
A plug-in interface definition class for object file parsers.
bool IsInMemory() const
Returns true if the object file exists only in memory.
A command line option parsing protocol class.
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
std::chrono::seconds GetUtilityExpressionTimeout() const
A plug-in interface definition class for debugging a process.
ThreadList & GetThreadList()
lldb::addr_t AllocateMemory(size_t size, uint32_t permissions, Status &error)
The public interface to allocating memory in the process.
virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
lldb::TargetSP CalculateTarget() override
virtual lldb_private::StructuredData::ObjectSP GetSharedCacheInfo()
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.
lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status &error)
Status DeallocateMemory(lldb::addr_t ptr)
The public interface to deallocating memory in the process.
uint32_t GetAddressByteSize() const
uint32_t GetStopID() const
const lldb::ABISP & GetABI()
Target & GetTarget()
Get the target object pointer for this module.
This class provides extra information about a stack frame that was provided by a specific stack frame...
unsigned long long ULongLong(unsigned long long fail_value=0) const
unsigned long ULong(unsigned long fail_value=0) const
static lldb::TypeSystemClangSP GetForTarget(Target &target, std::optional< IsolatedASTKind > ast_kind=DefaultAST, bool create_on_demand=true)
Returns the scratch TypeSystemClang for the given target.
lldb::SectionSP FindSectionByName(ConstString section_dstr) const
void AddRecognizer(lldb::StackFrameRecognizerSP recognizer, ConstString module, llvm::ArrayRef< ConstString > symbols, Mangled::NamePreference symbol_mangling, bool first_instruction_only=true)
Add a new recognizer that triggers on a given symbol name.
A base class for frame recognizers.
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
static Status FromErrorString(const char *str)
bool Success() const
Test for success condition.
void Format(const char *format, Args &&... args)
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
ObjectSP GetValueForKey(llvm::StringRef key) const
Dictionary * GetAsDictionary()
std::shared_ptr< Object > ObjectSP
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.
Symbol * symbol
The Symbol for a given query.
lldb::addr_t GetLoadAddress(Target *target) const
bool ValueIsAddress() const
Address & GetAddressRef()
DynamicClassInfoHelper GetDynamicClassInfoHelper() const
StackFrameRecognizerManager & GetFrameRecognizerManager()
llvm::Expected< std::unique_ptr< UtilityFunction > > CreateUtilityFunction(std::string expression, std::string name, lldb::LanguageType language, ExecutionContext &exe_ctx)
Creates and installs a UtilityFunction for the given language.
lldb::PlatformSP GetPlatform()
const ModuleList & GetImages() const
Get accessor for the images for this process.
lldb::ThreadSP GetExpressionExecutionThread()
Sometimes you can find the name of the type corresponding to an object, but we don't have debug infor...
void SetName(ConstString type_name)
void SetCompilerType(CompilerType compiler_type)
void SetTypeSP(lldb::TypeSP type_sp)
"lldb/Expression/UtilityFunction.h" Encapsulates a bit of source code that provides a function that i...
FunctionCaller * GetFunctionCaller()
void PushValue(const Value &value)
Value * GetValueAtIndex(size_t idx)
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size, lldb::addr_t address=LLDB_INVALID_ADDRESS)
A collection of ValueObject values that.
static lldb::ValueObjectSP Create(ValueObject &parent, lldb::ValueType type)
lldb::addr_t GetPointerValue(AddressType *address_type=nullptr)
CompilerType GetCompilerType()
lldb::ProcessSP GetProcessSP() const
virtual bool IsBaseClass()
lldb::TargetSP GetTargetSP() const
virtual ValueObject * GetParent()
const ExecutionContextRef & GetExecutionContextRef() const
const Scalar & GetScalar() const
ValueType
Type that describes Value::m_value.
@ Scalar
A raw scalar value.
void SetCompilerType(const CompilerType &compiler_type)
void SetValueType(ValueType value_type)
uint8_t * GetBytes()
Get a pointer to the data.
#define LLDB_INVALID_MODULE_VERSION
#define UNUSED_IF_ASSERT_DISABLED(x)
#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.
@ eDynamicClassInfoHelperCopyRealizedClassList
@ eDynamicClassInfoHelperGetRealizedClassList
@ eDynamicClassInfoHelperAuto
@ eDynamicClassInfoHelperRealizedClassesStruct
std::shared_ptr< lldb_private::ABI > ABISP
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::RecognizedStackFrame > RecognizedStackFrameSP
std::shared_ptr< lldb_private::BreakpointResolver > BreakpointResolverSP
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::Platform > PlatformSP
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
@ eLanguageTypeC
Non-standardized C, such as K&R.
@ eLanguageTypeObjC
Objective-C.
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
ExpressionResults
The results of expression evaluation.
std::shared_ptr< lldb_private::Type > TypeSP
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::ValueObjectList > ValueObjectListSP
@ eEncodingUint
unsigned integer
@ eReturnStatusSuccessFinishResult
@ eArgTypeRegularExpression
std::shared_ptr< lldb_private::TypeSystemClang > TypeSystemClangSP
std::shared_ptr< lldb_private::StackFrameRecognizer > StackFrameRecognizerSP
std::shared_ptr< lldb_private::Section > SectionSP
bool LLDB_API operator==(const SBAddress &lhs, const SBAddress &rhs)
std::shared_ptr< lldb_private::Module > ModuleSP
@ eValueTypeVariableArgument
function argument variables
static DescriptorMapUpdateResult Fail()
static DescriptorMapUpdateResult Success(uint32_t found)
static DescriptorMapUpdateResult Retry()
static lldb::addr_t ToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s, lldb::addr_t fail_value, Status *error_ptr)
Try to parse an address.
lldb::user_id_t GetID() const
Get accessor for the user ID.