59#include "clang/AST/ASTContext.h"
60#include "clang/AST/DeclObjC.h"
61#include "clang/Basic/TargetInfo.h"
62#include "llvm/ADT/STLExtras.h"
63#include "llvm/ADT/ScopeExit.h"
64#include "llvm/ADT/Sequence.h"
65#include "llvm/Support/Error.h"
77struct RuntimeGlobalSymbolSpec {
81 bool read_value =
true;
84 uint8_t byte_size = 0;
87struct RuntimeGlobalSymbolResult {
96 "__lldb_apple_objc_v2_get_dynamic_class_info";
102 size_t strlen(const char *);
103 char *strncpy (char * s1, const char * s2, size_t n);
104 int printf(const char * format, ...);
106#define DEBUG_PRINTF(fmt, ...) if (should_log) printf(fmt, ## __VA_ARGS__)
108typedef struct _NXMapTable {
110 unsigned num_classes;
111 unsigned num_buckets_minus_one;
115#define NX_MAPNOTAKEY ((void *)(-1))
117typedef struct BucketInfo
119 const char *name_ptr;
127} __attribute__((__packed__));
130__lldb_apple_objc_v2_get_dynamic_class_info (void *gdb_objc_realized_classes_ptr,
131 void *class_infos_ptr,
132 uint32_t class_infos_byte_size,
135 DEBUG_PRINTF ("gdb_objc_realized_classes_ptr = %p\n", gdb_objc_realized_classes_ptr);
136 DEBUG_PRINTF ("class_infos_ptr = %p\n", class_infos_ptr);
137 DEBUG_PRINTF ("class_infos_byte_size = %u\n", class_infos_byte_size);
138 const NXMapTable *grc = (const NXMapTable *)gdb_objc_realized_classes_ptr;
141 const unsigned num_classes = grc->num_classes;
142 DEBUG_PRINTF ("num_classes = %u\n", grc->num_classes);
145 const unsigned num_buckets_minus_one = grc->num_buckets_minus_one;
146 DEBUG_PRINTF ("num_buckets_minus_one = %u\n", num_buckets_minus_one);
148 const size_t max_class_infos = class_infos_byte_size/sizeof(ClassInfo);
149 DEBUG_PRINTF ("max_class_infos = %u\n", max_class_infos);
151 ClassInfo *class_infos = (ClassInfo *)class_infos_ptr;
152 BucketInfo *buckets = (BucketInfo *)grc->buckets;
155 for (unsigned i=0; i<=num_buckets_minus_one; ++i)
157 if (buckets[i].name_ptr != NX_MAPNOTAKEY)
159 if (idx < max_class_infos)
161 const char *s = buckets[i].name_ptr;
163 for (unsigned char c = *s; c; c = *++s)
164 h = ((h << 5) + h) + c;
165 class_infos[idx].hash = h;
166 class_infos[idx].isa = buckets[i].isa;
167 DEBUG_PRINTF ("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, buckets[i].name_ptr);
172 if (idx < max_class_infos)
174 class_infos[idx].isa = NULL;
175 class_infos[idx].hash = 0;
186 "__lldb_apple_objc_v2_get_dynamic_class_info2";
191 int printf(const char * format, ...);
192 void free(void *ptr);
193 Class* objc_copyRealizedClassList_nolock(unsigned int *outCount);
194 const char* objc_debug_class_getNameRaw(Class cls);
197#define DEBUG_PRINTF(fmt, ...) if (should_log) printf(fmt, ## __VA_ARGS__)
203} __attribute__((__packed__));
206__lldb_apple_objc_v2_get_dynamic_class_info2(void *gdb_objc_realized_classes_ptr,
207 void *class_infos_ptr,
208 uint32_t class_infos_byte_size,
211 DEBUG_PRINTF ("class_infos_ptr = %p\n", class_infos_ptr);
212 DEBUG_PRINTF ("class_infos_byte_size = %u\n", class_infos_byte_size);
214 const size_t max_class_infos = class_infos_byte_size/sizeof(ClassInfo);
215 DEBUG_PRINTF ("max_class_infos = %u\n", max_class_infos);
217 ClassInfo *class_infos = (ClassInfo *)class_infos_ptr;
220 Class* realized_class_list = objc_copyRealizedClassList_nolock(&count);
221 DEBUG_PRINTF ("count = %u\n", count);
224 for (uint32_t i=0; i<count; ++i)
226 if (idx < max_class_infos)
228 Class isa = realized_class_list[i];
229 const char *name_ptr = objc_debug_class_getNameRaw(isa);
232 const char *s = name_ptr;
234 for (unsigned char c = *s; c; c = *++s)
235 h = ((h << 5) + h) + c;
236 class_infos[idx].hash = h;
237 class_infos[idx].isa = isa;
238 DEBUG_PRINTF ("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, name_ptr);
243 if (idx < max_class_infos)
245 class_infos[idx].isa = NULL;
246 class_infos[idx].hash = 0;
249 free(realized_class_list);
255 "__lldb_apple_objc_v2_get_dynamic_class_info3";
260 int printf(const char * format, ...);
261 void free(void *ptr);
262 size_t objc_getRealizedClassList_trylock(Class *buffer, size_t len);
263 const char* objc_debug_class_getNameRaw(Class cls);
264 const char* class_getName(Class cls);
267#define DEBUG_PRINTF(fmt, ...) if (should_log) printf(fmt, ## __VA_ARGS__)
273} __attribute__((__packed__));
276__lldb_apple_objc_v2_get_dynamic_class_info3(void *gdb_objc_realized_classes_ptr,
277 void *class_infos_ptr,
278 uint32_t class_infos_byte_size,
280 uint32_t class_buffer_len,
283 DEBUG_PRINTF ("class_infos_ptr = %p\n", class_infos_ptr);
284 DEBUG_PRINTF ("class_infos_byte_size = %u\n", class_infos_byte_size);
286 const size_t max_class_infos = class_infos_byte_size/sizeof(ClassInfo);
287 DEBUG_PRINTF ("max_class_infos = %u\n", max_class_infos);
289 ClassInfo *class_infos = (ClassInfo *)class_infos_ptr;
291 Class *realized_class_list = (Class*)class_buffer;
293 uint32_t count = objc_getRealizedClassList_trylock(realized_class_list,
295 DEBUG_PRINTF ("count = %u\n", count);
298 for (uint32_t i=0; i<count; ++i)
300 if (idx < max_class_infos)
302 Class isa = realized_class_list[i];
303 const char *name_ptr = objc_debug_class_getNameRaw(isa);
305 class_getName(isa); // Realize name of lazy classes.
306 name_ptr = objc_debug_class_getNameRaw(isa);
310 const char *s = name_ptr;
312 for (unsigned char c = *s; c; c = *++s)
313 h = ((h << 5) + h) + c;
314 class_infos[idx].hash = h;
315 class_infos[idx].isa = isa;
316 DEBUG_PRINTF ("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, name_ptr);
321 if (idx < max_class_infos)
323 class_infos[idx].isa = NULL;
324 class_infos[idx].hash = 0;
336 const char *{0}(void *objc_class);
337 const char *(*class_name_lookup_func)(void *) = {1};
342 "__lldb_apple_objc_v2_get_shared_cache_class_info";
348 size_t strlen(const char *);
349 char *strncpy (char * s1, const char * s2, size_t n);
350 int printf(const char * format, ...);
353#define DEBUG_PRINTF(fmt, ...) if (should_log) printf(fmt, ## __VA_ARGS__)
356struct objc_classheader_t {
361struct objc_classheader_v16_t {
362 uint64_t isDuplicate : 1,
363 objectCacheOffset : 47, // Offset from the shared cache base
367struct objc_clsopt_t {
375 uint32_t scramble[256];
376 uint8_t tab[0]; // tab[mask+1]
377 // uint8_t checkbytes[capacity];
378 // int32_t offset[capacity];
379 // objc_classheader_t clsOffsets[capacity];
380 // uint32_t duplicateCount;
381 // objc_classheader_t duplicateOffsets[duplicateCount];
384struct objc_clsopt_v16_t {
392 uint32_t scramble[256];
393 uint8_t tab[0]; // tab[mask+1]
394 // uint8_t checkbytes[capacity];
395 // int32_t offset[capacity];
396 // objc_classheader_t clsOffsets[capacity];
397 // uint32_t duplicateCount;
398 // objc_classheader_t duplicateOffsets[duplicateCount];
403 int32_t selopt_offset;
404 int32_t headeropt_offset;
405 int32_t clsopt_offset;
408struct objc_opt_v14_t {
411 int32_t selopt_offset;
412 int32_t headeropt_offset;
413 int32_t clsopt_offset;
416struct objc_opt_v16_t {
419 int32_t selopt_offset;
420 int32_t headeropt_ro_offset;
421 int32_t unused_clsopt_offset;
422 int32_t unused_protocolopt_offset;
423 int32_t headeropt_rw_offset;
424 int32_t unused_protocolopt2_offset;
425 int32_t largeSharedCachesClassOffset;
426 int32_t largeSharedCachesProtocolOffset;
427 uint64_t relativeMethodSelectorBaseAddressCacheOffset;
434} __attribute__((__packed__));
440__lldb_apple_objc_v2_get_shared_cache_class_info (void *objc_opt_ro_ptr,
441 void *shared_cache_base_ptr,
442 void *class_infos_ptr,
443 uint64_t *relative_selector_offset,
444 uint32_t class_infos_byte_size,
448 *relative_selector_offset = 0;
450 DEBUG_PRINTF ("objc_opt_ro_ptr = %p\n", objc_opt_ro_ptr);
451 DEBUG_PRINTF ("shared_cache_base_ptr = %p\n", shared_cache_base_ptr);
452 DEBUG_PRINTF ("class_infos_ptr = %p\n", class_infos_ptr);
453 DEBUG_PRINTF ("class_infos_byte_size = %u (%llu class infos)\n", class_infos_byte_size, (uint64_t)(class_infos_byte_size/sizeof(ClassInfo)));
454 DEBUG_PRINTF ("start_idx = %u\n", *start_idx);
457 const objc_opt_t *objc_opt = (objc_opt_t *)objc_opt_ro_ptr;
458 const objc_opt_v14_t* objc_opt_v14 = (objc_opt_v14_t*)objc_opt_ro_ptr;
459 const objc_opt_v16_t* objc_opt_v16 = (objc_opt_v16_t*)objc_opt_ro_ptr;
460 if (objc_opt->version >= 16)
462 *relative_selector_offset = objc_opt_v16->relativeMethodSelectorBaseAddressCacheOffset;
463 DEBUG_PRINTF ("objc_opt->version = %u\n", objc_opt_v16->version);
464 DEBUG_PRINTF ("objc_opt->flags = %u\n", objc_opt_v16->flags);
465 DEBUG_PRINTF ("objc_opt->selopt_offset = %d\n", objc_opt_v16->selopt_offset);
466 DEBUG_PRINTF ("objc_opt->headeropt_ro_offset = %d\n", objc_opt_v16->headeropt_ro_offset);
467 DEBUG_PRINTF ("objc_opt->relativeMethodSelectorBaseAddressCacheOffset = %d\n", *relative_selector_offset);
469 else if (objc_opt->version >= 14)
471 DEBUG_PRINTF ("objc_opt->version = %u\n", objc_opt_v14->version);
472 DEBUG_PRINTF ("objc_opt->flags = %u\n", objc_opt_v14->flags);
473 DEBUG_PRINTF ("objc_opt->selopt_offset = %d\n", objc_opt_v14->selopt_offset);
474 DEBUG_PRINTF ("objc_opt->headeropt_offset = %d\n", objc_opt_v14->headeropt_offset);
475 DEBUG_PRINTF ("objc_opt->clsopt_offset = %d\n", objc_opt_v14->clsopt_offset);
479 DEBUG_PRINTF ("objc_opt->version = %u\n", objc_opt->version);
480 DEBUG_PRINTF ("objc_opt->selopt_offset = %d\n", objc_opt->selopt_offset);
481 DEBUG_PRINTF ("objc_opt->headeropt_offset = %d\n", objc_opt->headeropt_offset);
482 DEBUG_PRINTF ("objc_opt->clsopt_offset = %d\n", objc_opt->clsopt_offset);
485 if (objc_opt->version == 16)
487 int32_t large_offset = objc_opt_v16->largeSharedCachesClassOffset;
488 const objc_clsopt_v16_t* clsopt = (const objc_clsopt_v16_t*)((uint8_t *)objc_opt + large_offset);
489 // Work around a bug in some version shared cache builder where the offset overflows 2GiB (rdar://146432183).
490 uint32_t unsigned_offset = (uint32_t)large_offset;
491 if (unsigned_offset > 0x7fffffff && unsigned_offset < 0x82000000) {
492 clsopt = (const objc_clsopt_v16_t*)((uint8_t *)objc_opt + unsigned_offset);
493 DEBUG_PRINTF("warning: applying largeSharedCachesClassOffset overflow workaround!\n");
495 const size_t max_class_infos = class_infos_byte_size/sizeof(ClassInfo);
497 DEBUG_PRINTF("max_class_infos = %llu\n", (uint64_t)max_class_infos);
499 ClassInfo *class_infos = (ClassInfo *)class_infos_ptr;
501 const uint8_t *checkbytes = &clsopt->tab[clsopt->mask+1];
502 const int32_t *offsets = (const int32_t *)(checkbytes + clsopt->capacity);
503 const objc_classheader_v16_t *classOffsets = (const objc_classheader_v16_t *)(offsets + clsopt->capacity);
505 DEBUG_PRINTF ("clsopt->capacity = %u\n", clsopt->capacity);
506 DEBUG_PRINTF ("clsopt->mask = 0x%8.8x\n", clsopt->mask);
507 DEBUG_PRINTF ("classOffsets = %p\n", classOffsets);
509 const uint32_t original_start_idx = *start_idx;
511 // Always start at the start_idx here. If it's greater than the capacity,
512 // it will skip the loop entirely and go to the duplicate handling below.
513 for (uint32_t i=*start_idx; i<clsopt->capacity; ++i)
515 const uint64_t objectCacheOffset = classOffsets[i].objectCacheOffset;
516 DEBUG_PRINTF("objectCacheOffset[%u] = %u\n", i, objectCacheOffset);
518 if (classOffsets[i].isDuplicate) {
519 DEBUG_PRINTF("isDuplicate = true\n");
520 continue; // duplicate
523 if (objectCacheOffset == 0) {
524 DEBUG_PRINTF("objectCacheOffset == invalidEntryOffset\n");
525 continue; // invalid offset
528 if (class_infos && idx < max_class_infos)
530 class_infos[idx].isa = (Class)((uint8_t *)shared_cache_base_ptr + objectCacheOffset);
532 // Lookup the class name.
533 const char *name = class_name_lookup_func(class_infos[idx].isa);
534 DEBUG_PRINTF("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, name);
536 // Hash the class name so we don't have to read it.
537 const char *s = name;
539 for (unsigned char c = *s; c; c = *++s)
541 // class_getName demangles swift names and the hash must
542 // be calculated on the mangled name. hash==0 means lldb
543 // will fetch the mangled name and compute the hash in
544 // ParseClassInfoArray.
550 h = ((h << 5) + h) + c;
552 class_infos[idx].hash = h;
556 DEBUG_PRINTF("not(class_infos && idx < max_class_infos)\n");
563 if (idx < max_class_infos) {
564 const uint32_t *duplicate_count_ptr = (uint32_t *)&classOffsets[clsopt->capacity];
565 const uint32_t duplicate_count = *duplicate_count_ptr;
566 const objc_classheader_v16_t *duplicateClassOffsets = (const objc_classheader_v16_t *)(&duplicate_count_ptr[1]);
568 DEBUG_PRINTF ("duplicate_count = %u\n", duplicate_count);
569 DEBUG_PRINTF ("duplicateClassOffsets = %p\n", duplicateClassOffsets);
571 const uint32_t duplicate_start_idx =
572 *start_idx < clsopt->capacity ?
574 *start_idx - clsopt->capacity;
576 for (uint32_t i=duplicate_start_idx; i<duplicate_count; ++i)
578 const uint64_t objectCacheOffset = duplicateClassOffsets[i].objectCacheOffset;
579 DEBUG_PRINTF("objectCacheOffset[%u] = %u\n", i, objectCacheOffset);
581 if (duplicateClassOffsets[i].isDuplicate) {
582 DEBUG_PRINTF("isDuplicate = true\n");
583 continue; // duplicate
586 if (objectCacheOffset == 0) {
587 DEBUG_PRINTF("objectCacheOffset == invalidEntryOffset\n");
588 continue; // invalid offset
591 if (class_infos && idx < max_class_infos)
593 class_infos[idx].isa = (Class)((uint8_t *)shared_cache_base_ptr + objectCacheOffset);
595 // Lookup the class name.
596 const char *name = class_name_lookup_func(class_infos[idx].isa);
597 DEBUG_PRINTF("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, name);
599 // Hash the class name so we don't have to read it.
600 const char *s = name;
602 for (unsigned char c = *s; c; c = *++s)
604 // class_getName demangles swift names and the hash must
605 // be calculated on the mangled name. hash==0 means lldb
606 // will fetch the mangled name and compute the hash in
607 // ParseClassInfoArray.
613 h = ((h << 5) + h) + c;
615 class_infos[idx].hash = h;
617 DEBUG_PRINTF("not(class_infos && idx < max_class_infos)\n");
624 // Always make sure start_idx gets updated. Otherwise we have an infinite
625 // loop if there are exactly max_class_infos number of classes.
626 if (*start_idx == original_start_idx) {
630 else if (objc_opt->version >= 12 && objc_opt->version <= 15)
632 const objc_clsopt_t* clsopt = NULL;
633 if (objc_opt->version >= 14)
634 clsopt = (const objc_clsopt_t*)((uint8_t *)objc_opt_v14 + objc_opt_v14->clsopt_offset);
636 clsopt = (const objc_clsopt_t*)((uint8_t *)objc_opt + objc_opt->clsopt_offset);
637 const size_t max_class_infos = class_infos_byte_size/sizeof(ClassInfo);
638 DEBUG_PRINTF("max_class_infos = %llu\n", (uint64_t)max_class_infos);
639 ClassInfo *class_infos = (ClassInfo *)class_infos_ptr;
640 int32_t invalidEntryOffset = 0;
641 // this is safe to do because the version field order is invariant
642 if (objc_opt->version == 12)
643 invalidEntryOffset = 16;
644 const uint8_t *checkbytes = &clsopt->tab[clsopt->mask+1];
645 const int32_t *offsets = (const int32_t *)(checkbytes + clsopt->capacity);
646 const objc_classheader_t *classOffsets = (const objc_classheader_t *)(offsets + clsopt->capacity);
647 DEBUG_PRINTF ("clsopt->capacity = %u\n", clsopt->capacity);
648 DEBUG_PRINTF ("clsopt->mask = 0x%8.8x\n", clsopt->mask);
649 DEBUG_PRINTF ("classOffsets = %p\n", classOffsets);
650 DEBUG_PRINTF("invalidEntryOffset = %d\n", invalidEntryOffset);
651 for (uint32_t i=0; i<clsopt->capacity; ++i)
653 const int32_t clsOffset = classOffsets[i].clsOffset;
654 DEBUG_PRINTF("clsOffset[%u] = %u\n", i, clsOffset);
657 DEBUG_PRINTF("clsOffset & 1\n");
658 continue; // duplicate
660 else if (clsOffset == invalidEntryOffset)
662 DEBUG_PRINTF("clsOffset == invalidEntryOffset\n");
663 continue; // invalid offset
666 if (class_infos && idx < max_class_infos)
668 class_infos[idx].isa = (Class)((uint8_t *)clsopt + clsOffset);
669 const char *name = class_name_lookup_func (class_infos[idx].isa);
670 DEBUG_PRINTF ("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, name);
671 // Hash the class name so we don't have to read it
672 const char *s = name;
674 for (unsigned char c = *s; c; c = *++s)
676 // class_getName demangles swift names and the hash must
677 // be calculated on the mangled name. hash==0 means lldb
678 // will fetch the mangled name and compute the hash in
679 // ParseClassInfoArray.
685 h = ((h << 5) + h) + c;
687 class_infos[idx].hash = h;
691 DEBUG_PRINTF("not(class_infos && idx < max_class_infos)\n");
696 const uint32_t *duplicate_count_ptr = (uint32_t *)&classOffsets[clsopt->capacity];
697 const uint32_t duplicate_count = *duplicate_count_ptr;
698 const objc_classheader_t *duplicateClassOffsets = (const objc_classheader_t *)(&duplicate_count_ptr[1]);
699 DEBUG_PRINTF ("duplicate_count = %u\n", duplicate_count);
700 DEBUG_PRINTF ("duplicateClassOffsets = %p\n", duplicateClassOffsets);
701 for (uint32_t i=0; i<duplicate_count; ++i)
703 const int32_t clsOffset = duplicateClassOffsets[i].clsOffset;
705 continue; // duplicate
706 else if (clsOffset == invalidEntryOffset)
707 continue; // invalid offset
709 if (class_infos && idx < max_class_infos)
711 class_infos[idx].isa = (Class)((uint8_t *)clsopt + clsOffset);
712 const char *name = class_name_lookup_func (class_infos[idx].isa);
713 DEBUG_PRINTF ("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, name);
714 // Hash the class name so we don't have to read it
715 const char *s = name;
717 for (unsigned char c = *s; c; c = *++s)
719 // class_getName demangles swift names and the hash must
720 // be calculated on the mangled name. hash==0 means lldb
721 // will fetch the mangled name and compute the hash in
722 // ParseClassInfoArray.
728 h = ((h << 5) + h) + c;
730 class_infos[idx].hash = h;
735 DEBUG_PRINTF ("%u class_infos\n", idx);
736 DEBUG_PRINTF ("done\n");
747 bool read_value =
true, uint8_t byte_size = 0,
752 return default_value;
757 return default_value;
767 return default_value;
774 return default_value;
779 default_value,
error);
780 return symbol_load_addr;
785static llvm::SmallVector<RuntimeGlobalSymbolResult>
788 llvm::ArrayRef<RuntimeGlobalSymbolSpec> specs) {
791 llvm::SmallVector<RuntimeGlobalSymbolResult> results(specs.size());
793 if (!process || !module_sp)
805 llvm::SmallVector<ReadEntry> work_list;
806 for (
auto [i, spec] : llvm::enumerate(specs)) {
807 const uint8_t size = spec.byte_size ? spec.byte_size : ptr_size;
808 const Symbol *symbol = module_sp->FindFirstSymbolWithNameAndType(
819 if (!spec.read_value)
820 results[i] = {symbol_load_addr,
true};
822 work_list.push_back({i, symbol_load_addr, size});
827 llvm::stable_sort(work_list, [](
const ReadEntry &a,
const ReadEntry &b) {
828 return a.byte_size < b.byte_size;
831 for (
size_t i = 0; i < work_list.size();) {
832 const uint8_t byte_size = work_list[i].byte_size;
833 const size_t group_start = i;
835 llvm::SmallVector<lldb::addr_t> addrs;
836 while (i < work_list.size() && work_list[i].byte_size == byte_size)
837 addrs.push_back(work_list[i++].addr);
842 for (
size_t j = 0; j < addrs.size(); ++j) {
843 size_t idx = work_list[group_start + j].result_idx;
844 if (read_values[j].has_value())
845 results[idx] = {*read_values[j],
true};
869 static const ConstString g_gdb_object_getClass(
"gdb_object_getClass");
871 static const ConstString g_objc_copyRealizedClassList(
872 "_ZL33objc_copyRealizedClassList_nolockPj");
873 static const ConstString g_objc_getRealizedClassList_trylock(
874 "_objc_getRealizedClassList_trylock");
877 HasSymbol(g_objc_getRealizedClassList_trylock);
889 if (runtime !=
this && runtime->IsPreferredLanguageRuntimeFor(in_value))
892 LanguageType impl_lang = descriptor_sp->GetImplementationLanguage();
894 return process_sp->GetLanguageRuntime(impl_lang);
918 class_type_or_name.
Clear();
930 ConstString class_name(objc_class_sp->GetClassName());
931 class_type_or_name.
SetName(class_name);
932 TypeSP type_sp(objc_class_sp->GetType());
938 objc_class_sp->SetType(type_sp);
943 auto types = vendor->FindTypes(class_name, 1);
951 return !class_type_or_name.
IsEmpty();
981 "Print ivar and method information in detail"}};
995 switch (short_option) {
1003 "unrecognized short option '%c'", short_option);
1023 "Dump information on Objective-C classes "
1024 "known to the current process.",
1025 "language objc class-table dump",
1026 eCommandRequiresProcess |
1027 eCommandProcessMustBeLaunched |
1028 eCommandProcessMustBePaused),
1039 std::unique_ptr<RegularExpression> regex_up;
1046 if (!regex_up->IsValid()) {
1048 "invalid argument - please provide a valid regular expression");
1055 result.
AppendError(
"please provide 0 or 1 arguments");
1065 auto iterator = iterators_pair.first;
1067 for (; iterator != iterators_pair.second; iterator++) {
1068 if (iterator->second) {
1069 const char *class_name =
1070 iterator->second->GetClassName().AsCString(
"<unknown>");
1071 if (regex_up && class_name &&
1072 !regex_up->Execute(llvm::StringRef(class_name)))
1074 std_out.Printf(
"isa = 0x%" PRIx64, iterator->first);
1075 std_out.Printf(
" name = %s", class_name);
1076 std_out.Printf(
" instance size = %" PRIu64,
1077 iterator->second->GetInstanceSize());
1078 std_out.Printf(
" num ivars = %" PRIuPTR,
1079 (uintptr_t)iterator->second->GetNumIVars());
1080 if (
auto superclass = iterator->second->GetSuperclass()) {
1081 std_out.Printf(
" superclass = %s",
1082 superclass->GetClassName().AsCString(
"<unknown>"));
1084 std_out.Printf(
"\n");
1086 for (
size_t i = 0; i < iterator->second->GetNumIVars(); i++) {
1087 auto ivar = iterator->second->GetIVarAtIndex(i);
1089 " ivar name = %s type = %s size = %" PRIu64
1090 " offset = %" PRId32
"\n",
1091 ivar.m_name.AsCString(
"<unknown>"),
1092 ivar.m_type.GetDisplayTypeName().AsCString(
"<unknown>"),
1093 ivar.m_size, ivar.m_offset);
1096 iterator->second->Describe(
1098 [&std_out](
const char *name,
const char *type) ->
bool {
1099 std_out.Printf(
" instance method name = %s type = %s\n",
1103 [&std_out](
const char *name,
const char *type) ->
bool {
1104 std_out.Printf(
" class method name = %s type = %s\n", name,
1111 if (regex_up && !regex_up->Execute(llvm::StringRef()))
1113 std_out.Printf(
"isa = 0x%" PRIx64
" has no associated class.\n",
1120 result.
AppendError(
"current process has no Objective-C runtime loaded");
1132 interpreter,
"info",
"Dump information on a tagged pointer.",
1133 "language objc tagged-pointer info",
1134 eCommandRequiresProcess | eCommandProcessMustBeLaunched |
1135 eCommandProcessMustBePaused) {
1144 result.
AppendError(
"this command requires arguments");
1153 if (!objc_runtime) {
1154 result.
AppendError(
"current process has no Objective-C runtime loaded");
1161 if (!tagged_ptr_vendor) {
1162 result.
AppendError(
"current process has no tagged pointer support");
1177 "could not convert '{0}' to a valid address\n", arg_str);
1188 if (!descriptor_sp) {
1190 "could not get class descriptor for {0:x16}\n", arg_addr);
1195 uint64_t info_bits = 0;
1196 uint64_t value_bits = 0;
1197 uint64_t payload = 0;
1198 if (descriptor_sp->GetTaggedPointerInfo(&info_bits, &value_bits,
1202 "\tpayload = {1:x16}\n"
1203 "\tvalue = {2:x16}\n"
1204 "\tinfo bits = {3:x16}\n"
1206 arg_addr, payload, value_bits, info_bits,
1207 descriptor_sp->GetClassName().AsCString(
"<unknown>"));
1221 interpreter,
"class-table",
1222 "Commands for operating on the Objective-C class table.",
1223 "class-table <subcommand> [<subcommand-options>]") {
1236 interpreter,
"tagged-pointer",
1237 "Commands for operating on Objective-C tagged pointers.",
1238 "tagged-pointer <subcommand> [<subcommand-options>]") {
1252 interpreter,
"objc",
1253 "Commands for operating on the Objective-C language runtime.",
1254 "objc <subcommand> [<subcommand-options>]") {
1282 bool catch_bp,
bool throw_bp) {
1286 resolver_sp = std::make_shared<BreakpointResolverName>(
1296llvm::Expected<std::unique_ptr<UtilityFunction>>
1299 char check_function_code[2048];
1303 len = ::snprintf(check_function_code,
sizeof(check_function_code), R
"(
1304 extern "C" void *gdb_object_getClass(void *);
1305 extern "C" int printf(const char *format, ...);
1307 %s(void *$__lldb_arg_obj, void *$__lldb_arg_selector) {
1308 if ($__lldb_arg_obj == (void *)0)
1309 return; // nil is ok
1310 if (!gdb_object_getClass($__lldb_arg_obj)) {
1311 *((volatile int *)0) = 'ocgc';
1312 } else if ($__lldb_arg_selector != (void *)0) {
1313 signed char $responds = (signed char)
1314 [(id)$__lldb_arg_obj respondsToSelector:
1315 (void *) $__lldb_arg_selector];
1316 if ($responds == (signed char) 0)
1317 *((volatile int *)0) = 'ocgc';
1322 len = ::snprintf(check_function_code,
sizeof(check_function_code), R
"(
1323 extern "C" void *gdb_class_getClass(void *);
1324 extern "C" int printf(const char *format, ...);
1326 %s(void *$__lldb_arg_obj, void *$__lldb_arg_selector) {
1327 if ($__lldb_arg_obj == (void *)0)
1328 return; // nil is ok
1329 void **$isa_ptr = (void **)$__lldb_arg_obj;
1330 if (*$isa_ptr == (void *)0 ||
1331 !gdb_class_getClass(*$isa_ptr))
1332 *((volatile int *)0) = 'ocgc';
1333 else if ($__lldb_arg_selector != (void *)0) {
1334 signed char $responds = (signed char)
1335 [(id)$__lldb_arg_obj respondsToSelector:
1336 (void *) $__lldb_arg_selector];
1337 if ($responds == (signed char) 0)
1338 *((volatile int *)0) = 'ocgc';
1344 assert(len < (int)
sizeof(check_function_code));
1352 const char *ivar_name) {
1355 ConstString class_name = parent_ast_type.
GetTypeName();
1356 if (!class_name.
IsEmpty() && ivar_name && ivar_name[0]) {
1359 std::string buffer(
"OBJC_IVAR_$_");
1361 buffer.push_back(
'.');
1362 buffer.append(ivar_name);
1363 ConstString ivar_const_str(buffer);
1378 if (ivar_offset_symbol.
symbol)
1379 ivar_offset_address =
1389 ivar_offset =
m_process->ReadUnsignedIntegerFromMemory(
1405class RemoteNXMapTable {
1407 RemoteNXMapTable() : m_end_iterator(*this, -1) {}
1410 printf(
"RemoteNXMapTable.m_load_addr = 0x%" PRIx64
"\n", m_load_addr);
1411 printf(
"RemoteNXMapTable.m_count = %u\n", m_count);
1412 printf(
"RemoteNXMapTable.m_num_buckets_minus_one = %u\n",
1413 m_num_buckets_minus_one);
1414 printf(
"RemoteNXMapTable.m_buckets_ptr = 0x%" PRIX64
"\n", m_buckets_ptr);
1418 m_process = process;
1419 m_load_addr = load_addr;
1420 m_map_pair_size = m_process->GetAddressByteSize() * 2;
1428 const uint32_t unsigned_byte_size =
sizeof(uint32_t);
1432 bool success =
true;
1440 cursor, unsigned_byte_size, 0, err);
1442 cursor += unsigned_byte_size;
1446 cursor, unsigned_byte_size, 0, err);
1447 cursor += unsigned_byte_size;
1450 std::optional<lldb::addr_t> buckets_ptr =
1451 llvm::expectedToOptional(
m_process->ReadPointerFromMemory(cursor));
1455 success =
m_count > 0 && buckets_ptr.has_value();
1469 typedef std::pair<ConstString, ObjCLanguageRuntime::ObjCISA>
element;
1480 : m_parent(rhs.m_parent), m_index(rhs.m_index) {
1484 const_iterator &operator=(
const const_iterator &rhs) {
1486 assert(&m_parent == &rhs.m_parent);
1487 m_index = rhs.m_index;
1491 bool operator==(
const const_iterator &rhs)
const {
1492 if (&m_parent != &rhs.m_parent)
1494 if (m_index != rhs.m_index)
1500 bool operator!=(
const const_iterator &rhs)
const {
1504 const_iterator &operator++() {
1505 AdvanceToValidIndex();
1510 if (m_index == -1) {
1516 size_t map_pair_size = m_parent.m_map_pair_size;
1517 lldb::addr_t pair_ptr = pairs_ptr + (m_index * map_pair_size);
1519 llvm::Expected<lldb::addr_t> key =
1520 m_parent.m_process->ReadPointerFromMemory(pair_ptr);
1522 llvm::consumeError(key.takeError());
1525 llvm::Expected<lldb::addr_t> value =
1526 m_parent.m_process->ReadPointerFromMemory(
1527 pair_ptr + m_parent.m_process->GetAddressByteSize());
1529 llvm::consumeError(value.takeError());
1533 std::string key_string;
1536 m_parent.m_process->ReadCStringFromMemory(*key, key_string, err);
1545 void AdvanceToValidIndex() {
1550 const size_t map_pair_size = m_parent.m_map_pair_size;
1551 const lldb::addr_t invalid_key = m_parent.m_invalid_key;
1555 llvm::Expected<lldb::addr_t> key =
1556 m_parent.m_process->ReadPointerFromMemory(pair_ptr);
1559 llvm::consumeError(key.takeError());
1564 if (*key != invalid_key)
1572 const_iterator begin() {
1573 return const_iterator(*
this, m_num_buckets_minus_one + 1);
1576 const_iterator end() {
return m_end_iterator; }
1578 uint32_t GetCount()
const {
return m_count; }
1580 uint32_t GetBucketCount()
const {
return m_num_buckets_minus_one; }
1582 lldb::addr_t GetBucketDataPointer()
const {
return m_buckets_ptr; }
1584 lldb::addr_t GetTableLoadAddress()
const {
return m_load_addr; }
1588 uint32_t m_count = 0;
1589 uint32_t m_num_buckets_minus_one = 0;
1592 const_iterator m_end_iterator;
1594 size_t m_map_pair_size = 0;
1616 if (m_count == hash_table.
GetCount() &&
1630 class_descriptor_sp = non_pointer_isa_cache->GetClassDescriptor(isa);
1631 if (!class_descriptor_sp)
1633 return class_descriptor_sp;
1645 seen.insert(&valobj);
1649 ValueObject *parent = valobj.
GetParent();
1651 if (!parent || seen.count(parent))
1655 return parent_descriptor_sp->GetSuperclass();
1662 return objc_class_sp;
1665 return objc_class_sp;
1672 Process *process = exe_ctx.GetProcessPtr();
1674 return objc_class_sp;
1676 llvm::Expected<lldb::addr_t> isa_or_err =
1679 llvm::consumeError(isa_or_err.takeError());
1680 return objc_class_sp;
1685 if (!objc_class_sp) {
1687 isa = abi_sp->FixCodeAddress(isa);
1691 if (isa && !objc_class_sp) {
1694 "0x%" PRIx64
": AppleObjCRuntimeV2::GetClassDescriptor() ISA was "
1695 "not in class descriptor cache 0x%" PRIx64,
1698 return objc_class_sp;
1708 if (!objc_module_sp)
1712 "objc_debug_taggedpointer_obfuscator");
1714 const Symbol *symbol = objc_module_sp->FindFirstSymbolWithNameAndType(
1722 llvm::expectedToOptional(
1740 if (!objc_module_sp)
1743 static ConstString g_gdb_objc_realized_classes(
"gdb_objc_realized_classes");
1745 const Symbol *symbol = objc_module_sp->FindFirstSymbolWithNameAndType(
1753 llvm::expectedToOptional(
1761std::unique_ptr<AppleObjCRuntimeV2::SharedCacheImageHeaders>
1767 if (!objc_module_sp || !process)
1770 const Symbol *symbol = objc_module_sp->FindFirstSymbolWithNameAndType(
1773 LLDB_LOG(log,
"Symbol 'objc_debug_headerInfoRWs' unavailable. Some "
1774 "information concerning the shared cache may be unavailable");
1781 LLDB_LOG(log,
"Symbol 'objc_debug_headerInfoRWs' was found but we were "
1782 "unable to get its load address");
1786 llvm::Expected<lldb::addr_t> objc_debug_headerInfoRWs_ptr_or_err =
1788 if (!objc_debug_headerInfoRWs_ptr_or_err) {
1789 llvm::consumeError(objc_debug_headerInfoRWs_ptr_or_err.takeError());
1791 "Failed to read address of 'objc_debug_headerInfoRWs' at {0:x}",
1792 objc_debug_headerInfoRWs_addr);
1796 *objc_debug_headerInfoRWs_ptr_or_err;
1798 const size_t metadata_size =
1799 sizeof(uint32_t) +
sizeof(uint32_t);
1800 DataBufferHeap metadata_buffer(metadata_size,
'\0');
1802 process->
ReadMemory(objc_debug_headerInfoRWs_ptr, metadata_buffer.GetBytes(),
1806 "Unable to read metadata for 'objc_debug_headerInfoRWs' at {0:x}",
1807 objc_debug_headerInfoRWs_ptr);
1811 DataExtractor metadata_extractor(metadata_buffer.GetBytes(), metadata_size,
1815 uint32_t count = metadata_extractor.GetU32_unchecked(&cursor);
1816 uint32_t entsize = metadata_extractor.GetU32_unchecked(&cursor);
1817 if (count == 0 || entsize == 0) {
1819 "'objc_debug_headerInfoRWs' had count {0} with entsize {1}. These "
1820 "should both be non-zero.",
1825 std::unique_ptr<SharedCacheImageHeaders> shared_cache_image_headers(
1826 new SharedCacheImageHeaders(runtime, objc_debug_headerInfoRWs_ptr, count,
1828 if (
auto Err = shared_cache_image_headers->UpdateIfNeeded()) {
1830 "Failed to update SharedCacheImageHeaders: {0}");
1834 return shared_cache_image_headers;
1838 if (!m_needs_update)
1839 return llvm::Error::success();
1841 Process *process = m_runtime.GetProcess();
1843 sizeof(uint32_t) +
sizeof(uint32_t);
1847 const size_t memory_needed =
static_cast<size_t>(m_count) * m_entsize;
1848 if (memory_needed > 1024 * 1024 * 1024)
1849 return llvm::createStringError(
1850 "SharedCacheImageHeaders require too much memory");
1852 const lldb::addr_t first_header_addr = m_headerInfoRWs_ptr + metadata_size;
1854 llvm::SmallVector<Range<addr_t, size_t>> mem_ranges =
1855 llvm::to_vector(llvm::map_range(llvm::seq(m_count), [&](uint32_t i) {
1856 return Range<addr_t, size_t>(first_header_addr + (i * m_entsize),
1860 llvm::SmallVector<uint8_t, 0> buffer(memory_needed, 0);
1861 llvm::SmallVector<llvm::MutableArrayRef<uint8_t>> read_results =
1864 for (
auto [i, header_data] : llvm::enumerate(read_results)) {
1866 return llvm::createStringError(llvm::inconvertibleErrorCode(),
1867 "Failed to read memory from inferior when "
1868 "populating SharedCacheImageHeaders");
1874 bool is_loaded =
false;
1886 m_loaded_images.set(i);
1888 m_loaded_images.reset(i);
1890 m_needs_update =
false;
1892 return llvm::Error::success();
1896 uint16_t image_index) {
1897 if (image_index >= m_count)
1899 if (
auto Err = UpdateIfNeeded()) {
1902 "Failed to update SharedCacheImageHeaders: {0}");
1904 return m_loaded_images.test(image_index);
1908 if (
auto Err = UpdateIfNeeded()) {
1911 "Failed to update SharedCacheImageHeaders: {0}");
1920 ts_or_err.takeError(),
1921 "Couldn't get the scratch type system: {0}");
1927std::unique_ptr<UtilityFunction>
1929 ExecutionContext &exe_ctx, Helper helper, std::string code,
1933 LLDB_LOG(log,
"Creating utility function {0}", name);
1942 if (!utility_fn_or_error) {
1944 log, utility_fn_or_error.takeError(),
1945 "Failed to get utility function for dynamic info extractor: {0}");
1950 CompilerType clang_uint32_t_type =
1951 scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(
eEncodingUint, 32);
1952 CompilerType clang_void_pointer_type =
1953 scratch_ts_sp->GetBasicTypeFromAST(
eBasicTypeVoid).GetPointerType();
1956 ValueList arguments;
1976 std::unique_ptr<UtilityFunction> utility_fn = std::move(*utility_fn_or_error);
1979 utility_fn->MakeFunctionCaller(clang_uint32_t_type, arguments,
1984 "Failed to make function caller for implementation lookup: {0}.",
2012 case objc_getRealizedClassList_trylock: {
2013 if (!m_objc_getRealizedClassList_trylock_helper.utility_function)
2014 m_objc_getRealizedClassList_trylock_helper.utility_function =
2015 GetClassInfoUtilityFunctionImpl(exe_ctx, helper,
2018 return m_objc_getRealizedClassList_trylock_helper.utility_function.get();
2021 llvm_unreachable(
"Unexpected helper");
2027 case gdb_objc_realized_classes:
2028 return m_gdb_objc_realized_classes_helper.args;
2029 case objc_copyRealizedClassList:
2030 return m_objc_copyRealizedClassList_helper.args;
2031 case objc_getRealizedClassList_trylock:
2032 return m_objc_getRealizedClassList_trylock_helper.args;
2034 llvm_unreachable(
"Unexpected helper");
2040 if (!m_runtime.m_has_objc_copyRealizedClassList &&
2041 !m_runtime.m_has_objc_getRealizedClassList_trylock)
2044 if (
Process *process = m_runtime.GetProcess()) {
2046 if (loader->IsFullyInitialized()) {
2051 if (m_runtime.m_has_objc_getRealizedClassList_trylock)
2055 if (m_runtime.m_has_objc_copyRealizedClassList)
2068std::unique_ptr<UtilityFunction>
2073 LLDB_LOG(log,
"Creating utility function {0}",
2083 static ConstString g_class_getName_symbol_name(
"class_getName");
2084 static ConstString g_class_getNameRaw_symbol_name(
2085 "objc_debug_class_getNameRaw");
2087 ConstString class_name_getter_function_name =
2088 m_runtime.HasSymbol(g_class_getNameRaw_symbol_name)
2089 ? g_class_getNameRaw_symbol_name
2090 : g_class_getName_symbol_name;
2095 std::string shared_class_expression;
2096 llvm::raw_string_ostream(shared_class_expression) << llvm::formatv(
2098 class_name_getter_function_name);
2107 if (!utility_fn_or_error) {
2109 log, utility_fn_or_error.takeError(),
2110 "Failed to get utility function for shared class info extractor: {0}");
2115 CompilerType clang_uint32_t_type =
2116 scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(
eEncodingUint, 32);
2117 CompilerType clang_void_pointer_type =
2118 scratch_ts_sp->GetBasicTypeFromAST(
eBasicTypeVoid).GetPointerType();
2119 CompilerType clang_uint64_t_pointer_type =
2120 scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(
eEncodingUint, 64)
2122 CompilerType clang_uint32_t_pointer_type =
2123 scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(
eEncodingUint, 32)
2127 ValueList arguments;
2151 std::unique_ptr<UtilityFunction> utility_fn = std::move(*utility_fn_or_error);
2154 utility_fn->MakeFunctionCaller(clang_uint32_t_type, arguments,
2159 "Failed to make function caller for implementation lookup: {0}.",
2170 if (!m_utility_function)
2171 m_utility_function = GetClassInfoUtilityFunctionImpl(exe_ctx);
2172 return m_utility_function.get();
2175AppleObjCRuntimeV2::DescriptorMapUpdateResult
2177 RemoteNXMapTable &hash_table) {
2178 Process *process = m_runtime.GetProcess();
2179 if (process ==
nullptr)
2182 uint32_t num_class_infos = 0;
2186 ExecutionContext exe_ctx;
2193 if (!thread_sp->SafeToCallFunctions())
2196 thread_sp->CalculateExecutionContext(exe_ctx);
2203 Address function_address;
2213 const uint32_t num_classes =
2216 : m_runtime.m_realized_class_generation_count;
2217 if (num_classes == 0) {
2218 LLDB_LOGF(log,
"No dynamic classes found.");
2222 UtilityFunction *get_class_info_code =
2223 GetClassInfoUtilityFunction(exe_ctx, helper);
2224 if (!get_class_info_code) {
2229 FunctionCaller *get_class_info_function =
2232 if (!get_class_info_function) {
2233 LLDB_LOGF(log,
"Failed to get implementation lookup function caller.");
2239 DiagnosticManager diagnostics;
2241 const uint32_t class_info_byte_size = addr_size + 4;
2242 const uint32_t class_infos_byte_size = num_classes * class_info_byte_size;
2244 class_infos_byte_size, ePermissionsReadable | ePermissionsWritable, err);
2248 "unable to allocate %" PRIu32
2249 " bytes in process for shared cache read",
2250 class_infos_byte_size);
2254 llvm::scope_exit deallocate_class_infos([&] {
2261 const uint32_t class_byte_size = addr_size;
2262 const uint32_t class_buffer_len = num_classes;
2263 const uint32_t class_buffer_byte_size = class_buffer_len * class_byte_size;
2264 if (helper == Helper::objc_getRealizedClassList_trylock) {
2266 class_buffer_byte_size, ePermissionsReadable | ePermissionsWritable,
2270 "unable to allocate %" PRIu32
2271 " bytes in process for shared cache read",
2272 class_buffer_byte_size);
2277 llvm::scope_exit deallocate_class_buffer([&] {
2283 std::lock_guard<std::mutex> guard(m_mutex);
2300 bool dump_log = type_log && type_log->
GetVerbose();
2304 bool success =
false;
2306 diagnostics.
Clear();
2310 exe_ctx, GetClassInfoArgs(helper), arguments, diagnostics)) {
2311 EvaluateExpressionOptions options;
2319 CompilerType clang_uint32_t_type =
2320 scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(
eEncodingUint, 32);
2327 diagnostics.
Clear();
2331 exe_ctx, &GetClassInfoArgs(helper), options, diagnostics, return_value);
2336 LLDB_LOG(log,
"Discovered {0} Objective-C classes", num_class_infos);
2337 if (num_class_infos > 0) {
2339 DataBufferHeap buffer(num_class_infos * class_info_byte_size, 0);
2346 m_runtime.ParseClassInfoArray(class_infos_data, num_class_infos);
2352 LLDB_LOGF(log,
"Error evaluating our find class name function.");
2353 diagnostics.
Dump(log);
2358 LLDB_LOGF(log,
"Error writing function arguments.");
2359 diagnostics.
Dump(log);
2367 uint32_t num_class_infos) {
2379 uint32_t num_parsed = 0;
2383 for (uint32_t i = 0; i < num_class_infos; ++i) {
2389 log,
"AppleObjCRuntimeV2 found NULL isa, ignoring this class info");
2397 "AppleObjCRuntimeV2 found cached isa=0x%" PRIx64
2398 ", ignoring this class info",
2403 const uint32_t name_hash = data.
GetU32(&offset);
2404 ClassDescriptorSP descriptor_sp(
2413 AddClass(isa, descriptor_sp, name_hash);
2416 descriptor_sp->GetClassName().AsCString(
nullptr));
2420 "AppleObjCRuntimeV2 added isa=0x%" PRIx64
2421 ", hash=0x%8.8x, name=%s",
2423 descriptor_sp->GetClassName().AsCString(
"<unknown>"));
2427 LLDB_LOGF(log,
"AppleObjCRuntimeV2 parsed %" PRIu32
" class infos",
2443AppleObjCRuntimeV2::DescriptorMapUpdateResult
2445 Process *process = m_runtime.GetProcess();
2446 if (process ==
nullptr)
2451 ExecutionContext exe_ctx;
2458 if (!thread_sp->SafeToCallFunctions())
2461 thread_sp->CalculateExecutionContext(exe_ctx);
2468 Address function_address;
2474 uint32_t num_class_infos = 0;
2476 const lldb::addr_t objc_opt_ptr = m_runtime.GetSharedCacheReadOnlyAddress();
2478 m_runtime.GetSharedCacheBaseAddress();
2486 const uint32_t max_num_classes_in_buffer = 212992;
2488 UtilityFunction *get_class_info_code = GetClassInfoUtilityFunction(exe_ctx);
2489 if (!get_class_info_code) {
2494 FunctionCaller *get_shared_cache_class_info_function =
2497 if (!get_shared_cache_class_info_function) {
2498 LLDB_LOGF(log,
"Failed to get implementation lookup function caller.");
2502 ValueList arguments =
2505 DiagnosticManager diagnostics;
2507 const uint32_t class_info_byte_size = addr_size + 4;
2508 const uint32_t class_infos_byte_size =
2509 max_num_classes_in_buffer * class_info_byte_size;
2511 class_infos_byte_size, ePermissionsReadable | ePermissionsWritable, err);
2512 const uint32_t relative_selector_offset_addr_size = 64;
2515 ePermissionsReadable | ePermissionsWritable, err);
2516 constexpr uint32_t class_info_start_idx_byte_size =
sizeof(uint32_t);
2519 ePermissionsReadable | ePermissionsWritable, err);
2525 "unable to allocate %" PRIu32
2526 " bytes in process for shared cache read",
2527 class_infos_byte_size);
2531 const uint32_t start_idx_init_value = 0;
2533 class_info_start_idx_addr, &start_idx_init_value,
sizeof(uint32_t), err);
2534 if (bytes_written !=
sizeof(uint32_t)) {
2536 "unable to write %" PRIu32
2537 " bytes in process for shared cache read",
2538 class_infos_byte_size);
2542 std::lock_guard<std::mutex> guard(m_mutex);
2554 bool dump_log = type_log && type_log->
GetVerbose();
2558 bool success =
false;
2560 diagnostics.
Clear();
2564 exe_ctx, m_args, arguments, diagnostics)) {
2565 EvaluateExpressionOptions options;
2573 CompilerType clang_uint32_t_type =
2574 scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(
eEncodingUint, 32);
2581 diagnostics.
Clear();
2583 uint32_t num_class_infos_read = 0;
2584 bool already_read_relative_selector_offset =
false;
2590 exe_ctx, &m_args, options, diagnostics, return_value);
2595 num_class_infos += num_class_infos_read;
2596 LLDB_LOG(log,
"Discovered {0} Objective-C classes in the shared cache",
2597 num_class_infos_read);
2598 if (num_class_infos_read > 0) {
2603 if (!already_read_relative_selector_offset) {
2604 DataBufferHeap relative_selector_offset_buffer(64, 0);
2606 relative_selector_offset_addr,
2607 relative_selector_offset_buffer.GetBytes(),
2608 relative_selector_offset_buffer.GetByteSize(),
2609 err) == relative_selector_offset_buffer.GetByteSize()) {
2610 DataExtractor relative_selector_offset_data(
2611 relative_selector_offset_buffer.GetBytes(),
2612 relative_selector_offset_buffer.GetByteSize(),
2615 uint64_t relative_selector_offset =
2616 relative_selector_offset_data.GetU64(&offset);
2617 if (relative_selector_offset > 0) {
2619 m_runtime.SetRelativeSelectorBaseAddr(objc_opt_ptr +
2620 relative_selector_offset);
2623 already_read_relative_selector_offset =
true;
2627 DataBufferHeap class_infos_buffer(
2628 num_class_infos_read * class_info_byte_size, 0);
2630 class_infos_buffer.GetBytes(),
2631 class_infos_buffer.GetByteSize(),
2632 err) == class_infos_buffer.GetByteSize()) {
2633 DataExtractor class_infos_data(class_infos_buffer.GetBytes(),
2634 class_infos_buffer.GetByteSize(),
2637 m_runtime.ParseClassInfoArray(class_infos_data,
2638 num_class_infos_read);
2642 LLDB_LOGF(log,
"Error evaluating our find class name function.");
2643 diagnostics.
Dump(log);
2646 }
while (num_class_infos_read == max_num_classes_in_buffer);
2648 LLDB_LOGF(log,
"Error writing function arguments.");
2649 diagnostics.
Dump(log);
2652 LLDB_LOG(log,
"Processed {0} Objective-C classes total from the shared cache",
2668 if (objc_module_sp) {
2669 ObjectFile *objc_object = objc_module_sp->GetObjectFile();
2672 SectionList *section_list = objc_module_sp->GetSectionList();
2677 if (text_segment_sp) {
2679 text_segment_sp->GetChildren().FindSectionByName(
2682 if (objc_opt_section_sp) {
2683 return objc_opt_section_sp->GetLoadBaseAddress(
2699 StructuredData::Dictionary *info_dict = info->GetAsDictionary();
2720 RemoteNXMapTable hash_table;
2731 !class_count_changed)
2751 const uint32_t num_classes_to_warn_at = 500;
2757 "attempted to read objc class data - results: "
2758 "[dynamic_update]: ran: %s, retry: %s, count: %" PRIu32
2759 " [shared_cache_update]: ran: %s, retry: %s, count: %" PRIu32,
2760 dynamic_update_result.m_update_ran ?
"yes" :
"no",
2761 dynamic_update_result.m_retry_update ?
"yes" :
"no",
2762 dynamic_update_result.m_num_found,
2763 shared_cache_update_result.m_update_ran ?
"yes" :
"no",
2764 shared_cache_update_result.m_retry_update ?
"yes" :
"no",
2765 shared_cache_update_result.m_num_found);
2770 if (dynamic_update_result.m_retry_update ||
2771 shared_cache_update_result.m_retry_update)
2773 else if ((!shared_cache_update_result.m_update_ran) ||
2774 (!dynamic_update_result.m_update_ran))
2777 else if (dynamic_update_result.m_num_found +
2778 shared_cache_update_result.m_num_found <
2779 num_classes_to_warn_at)
2795 uint64_t objc_debug_realized_class_generation_count =
2797 process,
ConstString(
"objc_debug_realized_class_generation_count"),
2803 objc_debug_realized_class_generation_count)
2808 "objc_debug_realized_class_generation_count changed from {0} to {1}",
2810 objc_debug_realized_class_generation_count);
2813 objc_debug_realized_class_generation_count;
2823 llvm::StringRef platform_plugin_name_sr = platform_sp->GetPluginName();
2824 if (platform_plugin_name_sr.ends_with(
"-simulator"))
2842 "the process. This may reduce the quality of type "
2843 "information available\n",
2848 "could not execute support code to read "
2849 "Objective-C class data in the process. This may "
2850 "reduce the quality of type information available\n",
2855 "could not execute support code to read Objective-C class data because "
2856 "it's not yet safe to do so, and will be retried later\n",
2857 debugger.GetID(),
nullptr);
2880 llvm::raw_string_ostream os(buffer);
2882 os <<
"libobjc.A.dylib is being read from process memory. This "
2883 "indicates that LLDB could not ";
2885 if (platform_sp->IsHost()) {
2886 os <<
"read from the host's in-memory shared cache";
2888 os <<
"find the on-disk shared cache for this device";
2891 os <<
"read from the shared cache";
2893 os <<
". This will likely reduce debugging performance\n";
2909 if (!name.empty()) {
2910 llvm::StringRef ivar_prefix(
"OBJC_IVAR_$_");
2911 llvm::StringRef class_prefix(
"OBJC_CLASS_$_");
2913 if (name.starts_with(ivar_prefix)) {
2914 llvm::StringRef ivar_skipped_prefix = name.substr(ivar_prefix.size());
2915 std::pair<llvm::StringRef, llvm::StringRef> class_and_ivar =
2916 ivar_skipped_prefix.split(
'.');
2918 if (!class_and_ivar.first.empty() && !class_and_ivar.second.empty()) {
2919 const ConstString class_name_cs(class_and_ivar.first);
2924 const ConstString ivar_name_cs(class_and_ivar.second);
2925 const char *ivar_name_cstr = ivar_name_cs.AsCString(
nullptr);
2927 auto ivar_func = [&ret,
2928 ivar_name_cstr](
const char *name,
const char *type,
2931 if (!strcmp(name, ivar_name_cstr)) {
2938 descriptor->Describe(
2939 std::function<
void(
ObjCISA)>(
nullptr),
2940 std::function<
bool(
const char *,
const char *)>(
nullptr),
2941 std::function<
bool(
const char *,
const char *)>(
nullptr),
2945 }
else if (name.starts_with(class_prefix)) {
2946 llvm::StringRef class_skipped_prefix = name.substr(class_prefix.size());
2947 const ConstString class_name_cs(class_skipped_prefix);
2952 ret = descriptor->GetISA();
2959AppleObjCRuntimeV2::NonPointerISACache *
2978 llvm::SmallVector<RuntimeGlobalSymbolSpec> specs = {
2979 {ConstString(
"objc_debug_isa_magic_mask")},
2980 {ConstString(
"objc_debug_isa_magic_value")},
2981 {ConstString(
"objc_debug_isa_class_mask")},
2982 {ConstString(
"objc_debug_indexed_isa_magic_mask")},
2983 {ConstString(
"objc_debug_indexed_isa_magic_value")},
2984 {ConstString(
"objc_debug_indexed_isa_index_mask")},
2985 {ConstString(
"objc_debug_indexed_isa_index_shift")},
2986 {ConstString(
"objc_indexed_classes"),
false},
2988 assert(specs.size() == kISASymbolCount);
2994 if (!results[kMagicMask].success || !results[kMagicValue].success ||
2995 !results[kClassMask].success)
2998 auto objc_debug_isa_magic_mask = results[kMagicMask].value;
2999 auto objc_debug_isa_magic_value = results[kMagicValue].value;
3000 auto objc_debug_isa_class_mask = results[kClassMask].value;
3003 log->
PutCString(
"AOCRT::NPI: Found all the non-indexed ISA masks");
3006 bool foundError = !results[kIndexedMagicMask].success ||
3007 !results[kIndexedMagicValue].success ||
3008 !results[kIndexedIndexMask].success ||
3009 !results[kIndexedIndexShift].success ||
3010 !results[kIndexedClasses].success;
3012 auto objc_debug_indexed_isa_magic_mask = results[kIndexedMagicMask].value;
3013 auto objc_debug_indexed_isa_magic_value = results[kIndexedMagicValue].value;
3014 auto objc_debug_indexed_isa_index_mask = results[kIndexedIndexMask].value;
3015 auto objc_debug_indexed_isa_index_shift = results[kIndexedIndexShift].value;
3016 auto objc_indexed_classes = results[kIndexedClasses].value;
3018 if (log && !foundError)
3019 log->
PutCString(
"AOCRT::NPI: Found all the indexed ISA masks");
3025 runtime, objc_module_sp, objc_debug_isa_class_mask,
3026 objc_debug_isa_magic_mask, objc_debug_isa_magic_value,
3027 objc_debug_indexed_isa_magic_mask, objc_debug_indexed_isa_magic_value,
3028 objc_debug_indexed_isa_index_mask, objc_debug_indexed_isa_index_shift,
3029 foundError ? 0 : objc_indexed_classes);
3038 enum TaggedPtrSymbol {
3051 kTaggedPtrSymbolCount,
3053 llvm::SmallVector<RuntimeGlobalSymbolSpec> specs = {
3055 {
ConstString(
"objc_debug_taggedpointer_slot_shift"),
true, 4},
3056 {ConstString(
"objc_debug_taggedpointer_slot_mask"),
true, 4},
3057 {ConstString(
"objc_debug_taggedpointer_payload_lshift"),
true, 4},
3058 {ConstString(
"objc_debug_taggedpointer_payload_rshift"),
true, 4},
3059 {ConstString(
"objc_debug_taggedpointer_classes"),
false},
3060 {ConstString(
"objc_debug_taggedpointer_ext_mask")},
3061 {ConstString(
"objc_debug_taggedpointer_ext_slot_shift"),
true, 4},
3062 {ConstString(
"objc_debug_taggedpointer_ext_slot_mask"),
true, 4},
3063 {ConstString(
"objc_debug_taggedpointer_ext_classes"),
false},
3064 {ConstString(
"objc_debug_taggedpointer_ext_payload_lshift"),
true, 4},
3065 {ConstString(
"objc_debug_taggedpointer_ext_payload_rshift"),
true, 4},
3067 assert(specs.size() == kTaggedPtrSymbolCount);
3073 bool required_success =
3074 results[kMask].success && results[kSlotShift].success &&
3075 results[kSlotMask].success && results[kPayloadLshift].success &&
3076 results[kPayloadRshift].success && results[kClasses].success;
3078 if (!required_success)
3081 auto objc_debug_taggedpointer_mask = results[kMask].value;
3082 auto objc_debug_taggedpointer_slot_shift = results[kSlotShift].value;
3083 auto objc_debug_taggedpointer_slot_mask = results[kSlotMask].value;
3084 auto objc_debug_taggedpointer_payload_lshift = results[kPayloadLshift].value;
3085 auto objc_debug_taggedpointer_payload_rshift = results[kPayloadRshift].value;
3086 auto objc_debug_taggedpointer_classes = results[kClasses].value;
3089 bool extended_success =
3090 results[kExtMask].success && results[kExtSlotShift].success &&
3091 results[kExtSlotMask].success && results[kExtClasses].success &&
3092 results[kExtPayloadLshift].success && results[kExtPayloadRshift].success;
3094 if (extended_success) {
3095 auto objc_debug_taggedpointer_ext_mask = results[kExtMask].value;
3096 auto objc_debug_taggedpointer_ext_slot_shift = results[kExtSlotShift].value;
3097 auto objc_debug_taggedpointer_ext_slot_mask = results[kExtSlotMask].value;
3098 auto objc_debug_taggedpointer_ext_classes = results[kExtClasses].value;
3099 auto objc_debug_taggedpointer_ext_payload_lshift =
3100 results[kExtPayloadLshift].value;
3101 auto objc_debug_taggedpointer_ext_payload_rshift =
3102 results[kExtPayloadRshift].value;
3105 runtime, objc_debug_taggedpointer_mask,
3106 objc_debug_taggedpointer_ext_mask, objc_debug_taggedpointer_slot_shift,
3107 objc_debug_taggedpointer_ext_slot_shift,
3108 objc_debug_taggedpointer_slot_mask,
3109 objc_debug_taggedpointer_ext_slot_mask,
3110 objc_debug_taggedpointer_payload_lshift,
3111 objc_debug_taggedpointer_payload_rshift,
3112 objc_debug_taggedpointer_ext_payload_lshift,
3113 objc_debug_taggedpointer_ext_payload_rshift,
3114 objc_debug_taggedpointer_classes, objc_debug_taggedpointer_ext_classes);
3121 runtime, objc_debug_taggedpointer_mask,
3122 objc_debug_taggedpointer_slot_shift, objc_debug_taggedpointer_slot_mask,
3123 objc_debug_taggedpointer_payload_lshift,
3124 objc_debug_taggedpointer_payload_rshift,
3125 objc_debug_taggedpointer_classes);
3133std::unique_ptr<ObjCLanguageRuntime::ClassDescriptor>
3136 if (!IsPossibleTaggedPointer(ptr))
3139 uint32_t foundation_version = m_runtime.GetFoundationVersion();
3144 uint64_t class_bits = (ptr & 0xE) >> 1;
3150 static ConstString g_NSManagedObject(
"NSManagedObject");
3153 if (foundation_version >= 900) {
3154 switch (class_bits) {
3165 name = g_NSManagedObject;
3174 switch (class_bits) {
3179 name = g_NSManagedObject;
3192 lldb::addr_t unobfuscated = ptr ^ m_runtime.GetTaggedPointerObfuscator();
3193 return std::make_unique<ClassDescriptorV2Tagged>(name, unobfuscated);
3199 uint32_t objc_debug_taggedpointer_slot_shift,
3200 uint32_t objc_debug_taggedpointer_slot_mask,
3201 uint32_t objc_debug_taggedpointer_payload_lshift,
3202 uint32_t objc_debug_taggedpointer_payload_rshift,
3204 : TaggedPointerVendorV2(runtime), m_cache(),
3205 m_objc_debug_taggedpointer_mask(objc_debug_taggedpointer_mask),
3206 m_objc_debug_taggedpointer_slot_shift(
3207 objc_debug_taggedpointer_slot_shift),
3208 m_objc_debug_taggedpointer_slot_mask(objc_debug_taggedpointer_slot_mask),
3209 m_objc_debug_taggedpointer_payload_lshift(
3210 objc_debug_taggedpointer_payload_lshift),
3211 m_objc_debug_taggedpointer_payload_rshift(
3212 objc_debug_taggedpointer_payload_rshift),
3213 m_objc_debug_taggedpointer_classes(objc_debug_taggedpointer_classes) {}
3217 return (ptr & m_objc_debug_taggedpointer_mask) != 0;
3220std::unique_ptr<ObjCLanguageRuntime::ClassDescriptor>
3224 uint64_t unobfuscated = (ptr) ^ m_runtime.GetTaggedPointerObfuscator();
3226 if (!IsPossibleTaggedPointer(unobfuscated))
3229 uintptr_t slot = (ptr >> m_objc_debug_taggedpointer_slot_shift) &
3230 m_objc_debug_taggedpointer_slot_mask;
3232 CacheIterator iterator = m_cache.find(slot), end = m_cache.end();
3233 if (iterator != end) {
3234 actual_class_descriptor_sp = iterator->second;
3236 Process *process(m_runtime.GetProcess());
3239 llvm::Expected<lldb::addr_t> slot_data_or_err =
3241 if (!slot_data_or_err) {
3242 llvm::consumeError(slot_data_or_err.takeError());
3245 uintptr_t slot_data = *slot_data_or_err;
3248 actual_class_descriptor_sp =
3249 m_runtime.GetClassDescriptorFromISA((
ObjCISA)slot_data);
3250 if (!actual_class_descriptor_sp) {
3253 actual_class_descriptor_sp =
3254 m_runtime.GetClassDescriptorFromISA(fixed_isa);
3257 if (!actual_class_descriptor_sp)
3259 m_cache[slot] = actual_class_descriptor_sp;
3262 uint64_t data_payload =
3263 ((unobfuscated << m_objc_debug_taggedpointer_payload_lshift) >>
3264 m_objc_debug_taggedpointer_payload_rshift);
3265 int64_t data_payload_signed =
3266 ((int64_t)(unobfuscated << m_objc_debug_taggedpointer_payload_lshift) >>
3267 m_objc_debug_taggedpointer_payload_rshift);
3268 return std::make_unique<ClassDescriptorV2Tagged>(
3269 actual_class_descriptor_sp, data_payload, data_payload_signed);
3274 uint64_t objc_debug_taggedpointer_ext_mask,
3275 uint32_t objc_debug_taggedpointer_slot_shift,
3276 uint32_t objc_debug_taggedpointer_ext_slot_shift,
3277 uint32_t objc_debug_taggedpointer_slot_mask,
3278 uint32_t objc_debug_taggedpointer_ext_slot_mask,
3279 uint32_t objc_debug_taggedpointer_payload_lshift,
3280 uint32_t objc_debug_taggedpointer_payload_rshift,
3281 uint32_t objc_debug_taggedpointer_ext_payload_lshift,
3282 uint32_t objc_debug_taggedpointer_ext_payload_rshift,
3286 runtime, objc_debug_taggedpointer_mask,
3287 objc_debug_taggedpointer_slot_shift,
3288 objc_debug_taggedpointer_slot_mask,
3289 objc_debug_taggedpointer_payload_lshift,
3290 objc_debug_taggedpointer_payload_rshift,
3291 objc_debug_taggedpointer_classes),
3295 objc_debug_taggedpointer_ext_slot_shift),
3297 objc_debug_taggedpointer_ext_slot_mask),
3299 objc_debug_taggedpointer_ext_payload_lshift),
3301 objc_debug_taggedpointer_ext_payload_rshift),
3303 objc_debug_taggedpointer_ext_classes) {}
3307 if (!IsPossibleTaggedPointer(ptr))
3310 if (m_objc_debug_taggedpointer_ext_mask == 0)
3313 return ((ptr & m_objc_debug_taggedpointer_ext_mask) ==
3314 m_objc_debug_taggedpointer_ext_mask);
3317std::unique_ptr<ObjCLanguageRuntime::ClassDescriptor>
3320 ClassDescriptorSP actual_class_descriptor_sp;
3321 uint64_t unobfuscated = (ptr) ^ m_runtime.GetTaggedPointerObfuscator();
3323 if (!IsPossibleTaggedPointer(unobfuscated))
3326 if (!IsPossibleExtendedTaggedPointer(unobfuscated))
3329 uintptr_t slot = (ptr >> m_objc_debug_taggedpointer_ext_slot_shift) &
3330 m_objc_debug_taggedpointer_ext_slot_mask;
3332 CacheIterator iterator = m_ext_cache.find(slot), end = m_ext_cache.end();
3333 if (iterator != end) {
3334 actual_class_descriptor_sp = iterator->second;
3336 Process *process(m_runtime.GetProcess());
3338 m_objc_debug_taggedpointer_ext_classes;
3339 llvm::Expected<lldb::addr_t> slot_data_or_err =
3341 if (!slot_data_or_err) {
3342 llvm::consumeError(slot_data_or_err.takeError());
3345 uintptr_t slot_data = *slot_data_or_err;
3348 actual_class_descriptor_sp =
3349 m_runtime.GetClassDescriptorFromISA((
ObjCISA)slot_data);
3350 if (!actual_class_descriptor_sp)
3352 m_ext_cache[slot] = actual_class_descriptor_sp;
3355 uint64_t data_payload = (((uint64_t)unobfuscated
3356 << m_objc_debug_taggedpointer_ext_payload_lshift) >>
3357 m_objc_debug_taggedpointer_ext_payload_rshift);
3358 int64_t data_payload_signed =
3359 ((int64_t)((uint64_t)unobfuscated
3360 << m_objc_debug_taggedpointer_ext_payload_lshift) >>
3361 m_objc_debug_taggedpointer_ext_payload_rshift);
3363 return std::make_unique<ClassDescriptorV2Tagged>(
3364 actual_class_descriptor_sp, data_payload, data_payload_signed);
3369 uint64_t objc_debug_isa_class_mask, uint64_t objc_debug_isa_magic_mask,
3370 uint64_t objc_debug_isa_magic_value,
3371 uint64_t objc_debug_indexed_isa_magic_mask,
3372 uint64_t objc_debug_indexed_isa_magic_value,
3373 uint64_t objc_debug_indexed_isa_index_mask,
3374 uint64_t objc_debug_indexed_isa_index_shift,
3389 if (!EvaluateNonPointerISA(isa, real_isa))
3391 auto cache_iter = m_cache.find(real_isa);
3392 if (cache_iter != m_cache.end())
3393 return cache_iter->second;
3394 auto descriptor_sp =
3395 m_runtime.ObjCLanguageRuntime::GetClassDescriptorFromISA(real_isa);
3397 m_cache[real_isa] = descriptor_sp;
3398 return descriptor_sp;
3405 LLDB_LOGF(log,
"AOCRT::NPI Evaluate(isa = 0x%" PRIx64
")", (uint64_t)isa);
3407 if ((isa & ~m_objc_debug_isa_class_mask) == 0)
3414 if (m_objc_debug_indexed_isa_magic_mask &&
3415 m_objc_debug_indexed_isa_magic_value &&
3416 m_objc_debug_indexed_isa_index_mask &&
3417 m_objc_debug_indexed_isa_index_shift && m_objc_indexed_classes) {
3418 if ((isa & ~m_objc_debug_indexed_isa_index_mask) == 0)
3421 if ((isa & m_objc_debug_indexed_isa_magic_mask) ==
3422 m_objc_debug_indexed_isa_magic_value) {
3424 uintptr_t index = (isa & m_objc_debug_indexed_isa_index_mask) >>
3425 m_objc_debug_indexed_isa_index_shift;
3430 if (index > m_indexed_isa_cache.size()) {
3432 "AOCRT::NPI (index = %" PRIu64
3433 ") exceeds cache (size = %" PRIu64
")",
3434 (uint64_t)index, (uint64_t)m_indexed_isa_cache.size());
3436 Process *process(m_runtime.GetProcess());
3439 if (!objc_module_sp)
3444 process,
ConstString(
"objc_indexed_classes_count"), objc_module_sp,
3449 LLDB_LOGF(log,
"AOCRT::NPI (new class count = %" PRIu64
")",
3450 (uint64_t)objc_indexed_classes_count);
3452 if (objc_indexed_classes_count > m_indexed_isa_cache.size()) {
3456 auto num_new_classes =
3457 objc_indexed_classes_count - m_indexed_isa_cache.size();
3462 m_objc_indexed_classes + (m_indexed_isa_cache.size() * addr_size);
3464 last_read_class, buffer.GetBytes(), buffer.GetByteSize(),
error);
3465 if (
error.Fail() || bytes_read != buffer.GetByteSize())
3468 LLDB_LOGF(log,
"AOCRT::NPI (read new classes count = %" PRIu64
")",
3469 (uint64_t)num_new_classes);
3477 for (
unsigned i = 0; i != num_new_classes; ++i)
3478 m_indexed_isa_cache.push_back(data.
GetAddress(&offset));
3483 if (index >= m_indexed_isa_cache.size())
3486 LLDB_LOGF(log,
"AOCRT::NPI Evaluate(ret_isa = 0x%" PRIx64
")",
3487 (uint64_t)m_indexed_isa_cache[index]);
3489 ret_isa = m_indexed_isa_cache[index];
3490 return (ret_isa != 0);
3498 if ((isa & m_objc_debug_isa_magic_mask) == m_objc_debug_isa_magic_value) {
3499 ret_isa = isa & m_objc_debug_isa_class_mask;
3500 return (ret_isa != 0);
3508 std::make_shared<AppleObjCTypeEncodingParser>(*
this);
3517 non_pointer_isa_cache->EvaluateNonPointerISA(isa, ret);
3526 static ConstString g_dunder_kCFBooleanFalse(
"__kCFBooleanFalse");
3527 static ConstString g_dunder_kCFBooleanTrue(
"__kCFBooleanTrue");
3528 static ConstString g_kCFBooleanFalse(
"kCFBooleanFalse");
3529 static ConstString g_kCFBooleanTrue(
"kCFBooleanTrue");
3533 ModuleSP corefoundation_module_sp =
3535 corefoundation_module_spec);
3537 if (!corefoundation_module_sp)
3540 auto get_symbol = [
this, &corefoundation_module_sp](
3543 corefoundation_module_sp->FindFirstSymbolWithNameAndType(
3548 symbol = corefoundation_module_sp->FindFirstSymbolWithNameAndType(
3554 return llvm::expectedToOptional(
GetProcess()->ReadPointerFromMemory(addr))
3558 lldb::addr_t false_addr = get_symbol(g_dunder_kCFBooleanFalse, g_kCFBooleanFalse);
3559 lldb::addr_t true_addr = get_symbol(g_dunder_kCFBooleanTrue, g_kCFBooleanTrue);
3598 return std::nullopt;
3603 auto dict_up = std::make_unique<StructuredData::Dictionary>();
3604 dict_up->AddItem(
"Objective-C runtime version",
3605 std::make_unique<StructuredData::UnsignedInteger>(2));
3609#pragma mark Frame recognizers
3611class ObjCExceptionRecognizedStackFrame :
public RecognizedStackFrame {
3613 ObjCExceptionRecognizedStackFrame(
StackFrameSP frame_sp) {
3614 ThreadSP thread_sp = frame_sp->GetThread();
3615 ProcessSP process_sp = thread_sp->GetProcess();
3634 if (!abi->GetArgumentValues(*thread_sp, args))
3639 Value value(exception_addr);
3640 value.SetCompilerType(voidstar);
3647 m_arguments = std::make_shared<ValueObjectList>();
3648 m_arguments->Append(exception);
3650 m_stop_desc =
"hit Objective-C exception";
3658class ObjCExceptionThrowFrameRecognizer :
public StackFrameRecognizer {
3662 new ObjCExceptionRecognizedStackFrame(frame));
3664 std::string
GetName()
override {
3665 return "ObjC Exception Throw StackFrame Recognizer";
3671 ConstString function;
3673 std::vector<ConstString> symbols = {function};
static const char * g_get_dynamic_class_info_name
static void RegisterObjCExceptionRecognizer(Process *process)
static llvm::SmallVector< RuntimeGlobalSymbolResult > ExtractRuntimeGlobalSymbolsBatched(Process *process, const ModuleSP &module_sp, llvm::ArrayRef< RuntimeGlobalSymbolSpec > specs)
Batched version of ExtractRuntimeGlobalSymbol.
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 lldb::TypeSystemSP GetScratchTypeSystemForObjCRuntime(Target &target)
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 const char * g_get_shared_cache_class_info_definitions
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()
static llvm::StringRef GetName(XcodeSDK::Type type)
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)
void AdvanceToValidIndex()
RemoteNXMapTable & m_parent
const_iterator(RemoteNXMapTable &parent, int index)
lldb_private::Process * m_process
bool ParseHeader(Process *process, lldb::addr_t load_addr)
uint32_t m_num_buckets_minus_one
lldb::addr_t m_buckets_ptr
std::pair< ConstString, ObjCLanguageRuntime::ObjCISA > element
lldb::addr_t GetTableLoadAddress() const
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)
bool IsValid() const
Check if the object state is valid.
void UpdateSignature(const RemoteNXMapTable &hash_table)
bool NeedsUpdate(Process *process, AppleObjCRuntimeV2 *runtime, RemoteNXMapTable &hash_table)
lldb::addr_t m_buckets_ptr
lldb::ModuleWP m_objc_module_wp
uint64_t m_objc_debug_isa_magic_value
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)
std::vector< lldb::addr_t > m_indexed_isa_cache
uint64_t m_objc_debug_isa_magic_mask
friend class AppleObjCRuntimeV2
uint64_t m_objc_debug_indexed_isa_magic_mask
bool EvaluateNonPointerISA(ObjCISA isa, ObjCISA &ret_isa)
ObjCLanguageRuntime::ClassDescriptorSP GetClassDescriptor(ObjCISA isa)
lldb::addr_t m_objc_indexed_classes
uint64_t m_objc_debug_indexed_isa_index_mask
uint64_t m_objc_debug_indexed_isa_magic_value
static NonPointerISACache * CreateInstance(AppleObjCRuntimeV2 &runtime, const lldb::ModuleSP &objc_module_sp)
uint64_t m_objc_debug_indexed_isa_index_shift
AppleObjCRuntimeV2 & m_runtime
std::map< ObjCISA, ObjCLanguageRuntime::ClassDescriptorSP > m_cache
uint64_t m_objc_debug_isa_class_mask
uint64_t m_objc_debug_taggedpointer_ext_mask
std::unique_ptr< ObjCLanguageRuntime::ClassDescriptor > GetClassDescriptor(lldb::addr_t ptr) override
uint32_t m_objc_debug_taggedpointer_ext_slot_shift
lldb::addr_t m_objc_debug_taggedpointer_ext_classes
uint32_t m_objc_debug_taggedpointer_ext_payload_lshift
uint32_t m_objc_debug_taggedpointer_ext_slot_mask
uint32_t m_objc_debug_taggedpointer_ext_payload_rshift
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
std::unique_ptr< ObjCLanguageRuntime::ClassDescriptor > GetClassDescriptor(lldb::addr_t ptr) override
lldb::addr_t m_objc_debug_taggedpointer_classes
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)
std::unique_ptr< ObjCLanguageRuntime::ClassDescriptor > GetClassDescriptor(lldb::addr_t ptr) override
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)
llvm::SmallPtrSet< ValueObject *, 8 > ValueObjectSet
bool RealizedClassGenerationCountChanged()
Update the generation count of realized classes.
static llvm::StringRef GetPluginNameStatic()
EncodingToTypeSP GetEncodingToType() override
AppleObjCRuntimeV2(Process *process, const lldb::ModuleSP &objc_module_sp)
bool GetDynamicTypeAndAddress(ValueObject &in_value, lldb::DynamicValueType use_dynamic, TypeAndOrName &class_type_or_name, Address &address, Value::ValueType &value_type, llvm::ArrayRef< uint8_t > &local_buffer) override
This call should return true if it could set the name and/or the type Sets address to the address of ...
lldb::addr_t LookupRuntimeSymbol(llvm::StringRef name) override
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
@ eExpressionExecutionFailure
std::unique_ptr< SharedCacheImageHeaders > m_shared_cache_image_headers_up
friend class ClassDescriptorV2
ClassDescriptorSP GetClassDescriptor(ValueObject &valobj) override
lldb::addr_t m_relative_selector_base
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()
ObjCISA GetPointerISA(ObjCISA isa) override
lldb::addr_t m_tagged_pointer_obfuscator
std::unique_ptr< TaggedPointerVendor > m_tagged_pointer_vendor_up
std::unique_ptr< NonPointerISACache > m_non_pointer_isa_cache_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()
ClassDescriptorSP GetClassDescriptorImpl(ValueObject &valobj, ValueObjectSet &seen)
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()
AppleObjCRuntime(Process *process)
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.
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
CommandObjectMultiword(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
friend class CommandInterpreter
CommandObjectParsed(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
void AddSimpleArgumentList(lldb::CommandArgumentType arg_type, ArgumentRepetitionType repetition_type=eArgRepeatPlain)
ExecutionContext m_exe_ctx
void AppendError(llvm::StringRef in_string)
void SetStatus(lldb::ReturnStatus status)
void AppendErrorWithFormatv(const char *format, Args &&...args)
Stream & GetOutputStream()
Generic representation of a type in a programming language.
ConstString GetTypeName(bool BaseOnly=false) const
A uniqued constant string class.
bool IsEmpty() const
Test for empty string.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
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.
llvm::StringRef GetFilename() const
Filename string const get accessor.
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.
lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const
Finds the first module whose file specification matches module_spec.
void FindSymbolsWithNameAndType(llvm::StringRef name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
virtual std::unique_ptr< ClassDescriptor > GetClassDescriptor(lldb::addr_t ptr)=0
virtual bool IsPossibleTaggedPointer(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.
std::vector< Option > m_getopt_table
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.
size_t ReadMemory(const ProcessAddress &process_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
llvm::SmallVector< std::optional< uint64_t > > ReadUnsignedIntegersFromMemory(llvm::ArrayRef< lldb::addr_t > addresses, unsigned byte_size)
Use Process::ReadMemoryRanges to efficiently read multiple unsigned integers from memory at once.
lldb::ByteOrder GetByteOrder() const
llvm::Expected< lldb::addr_t > ReadPointerFromMemory(lldb::addr_t vm_addr)
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.
Status DeallocateMemory(lldb::addr_t ptr)
The public interface to deallocating memory in the process.
uint32_t GetAddressByteSize() const
uint32_t GetStopID() const
size_t WriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Status &error)
Write memory to a process.
virtual DynamicLoader * GetDynamicLoader()
Get the dynamic loader plug-in for this process.
llvm::SmallVector< llvm::MutableArrayRef< uint8_t > > ReadMemoryRanges(llvm::ArrayRef< Range< lldb::addr_t, size_t > > ranges, llvm::MutableArrayRef< uint8_t > buffer)
Read from multiple memory ranges and write the results into buffer.
const lldb::ABISP & GetABI()
Target & GetTarget()
Get the target object pointer for this module.
unsigned long long ULongLong(unsigned long long fail_value=0) const
unsigned long ULong(unsigned long fail_value=0) const
lldb::SectionSP FindSectionByName(llvm::StringRef section_name) const
void AddRecognizer(lldb::StackFrameRecognizerSP recognizer, std::string module, std::vector< ConstString > symbols, Mangled::NamePreference symbol_mangling, bool first_instruction_only=true)
Add a new recognizer that triggers on a given symbol name.
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)
Forwards the arguments to llvm::formatv and writes to the stream.
ObjectSP GetValueForKey(llvm::StringRef key) const
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
Debugger & GetDebugger() const
llvm::Expected< lldb::TypeSystemSP > GetScratchTypeSystemForLanguage(lldb::LanguageType language, bool create_on_demand=true)
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, ValueObjectManager *manager=nullptr)
These routines create ValueObjectConstResult ValueObjects from various data sources.
static lldb::ValueObjectSP Create(ValueObject &valobj, lldb::ValueType type)
lldb::ProcessSP GetProcessSP() const
virtual bool IsBaseClass()
lldb::TargetSP GetTargetSP() const
CompilerType GetCompilerType()
AddrAndType GetPointerValue()
virtual ValueObject * GetParent()
const ExecutionContextRef & GetExecutionContextRef() const
const Scalar & GetScalar() const
See comment on m_scalar to understand what GetScalar returns.
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
llvm::Error exception(const char *s=nullptr)
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.
const Scalar operator*(Scalar lhs, Scalar rhs)
bool operator!=(const Address &lhs, const Address &rhs)
@ eDynamicClassInfoHelperCopyRealizedClassList
@ eDynamicClassInfoHelperGetRealizedClassList
@ eDynamicClassInfoHelperAuto
@ eDynamicClassInfoHelperRealizedClassesStruct
std::shared_ptr< lldb_private::TypeSystem > TypeSystemSP
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
@ eEncodingUint
unsigned integer
@ eReturnStatusSuccessFinishResult
@ eArgTypeRegularExpression
@ eValueTypeVariableArgument
function argument variables
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
static DescriptorMapUpdateResult Fail()
static DescriptorMapUpdateResult Success(uint32_t found)
static DescriptorMapUpdateResult Retry()
static lldb::addr_t ToRawAddress(const ExecutionContext *exe_ctx, llvm::StringRef s, lldb::addr_t fail_value, Status *error_ptr)
As for ToAddress but do not remove non-address bits from the result.
lldb::user_id_t GetID() const
Get accessor for the user ID.