60#include "clang/AST/ASTContext.h"
61#include "clang/AST/DeclObjC.h"
62#include "clang/Basic/TargetInfo.h"
63#include "llvm/ADT/STLExtras.h"
64#include "llvm/ADT/ScopeExit.h"
65#include "llvm/ADT/Sequence.h"
66#include "llvm/Support/Error.h"
78struct RuntimeGlobalSymbolSpec {
82 bool read_value =
true;
85 uint8_t byte_size = 0;
88struct RuntimeGlobalSymbolResult {
97 "__lldb_apple_objc_v2_get_dynamic_class_info";
103 size_t strlen(const char *);
104 char *strncpy (char * s1, const char * s2, size_t n);
105 int printf(const char * format, ...);
107#define DEBUG_PRINTF(fmt, ...) if (should_log) printf(fmt, ## __VA_ARGS__)
109typedef struct _NXMapTable {
111 unsigned num_classes;
112 unsigned num_buckets_minus_one;
116#define NX_MAPNOTAKEY ((void *)(-1))
118typedef struct BucketInfo
120 const char *name_ptr;
128} __attribute__((__packed__));
131__lldb_apple_objc_v2_get_dynamic_class_info (void *gdb_objc_realized_classes_ptr,
132 void *class_infos_ptr,
133 uint32_t class_infos_byte_size,
136 DEBUG_PRINTF ("gdb_objc_realized_classes_ptr = %p\n", gdb_objc_realized_classes_ptr);
137 DEBUG_PRINTF ("class_infos_ptr = %p\n", class_infos_ptr);
138 DEBUG_PRINTF ("class_infos_byte_size = %u\n", class_infos_byte_size);
139 const NXMapTable *grc = (const NXMapTable *)gdb_objc_realized_classes_ptr;
142 const unsigned num_classes = grc->num_classes;
143 DEBUG_PRINTF ("num_classes = %u\n", grc->num_classes);
146 const unsigned num_buckets_minus_one = grc->num_buckets_minus_one;
147 DEBUG_PRINTF ("num_buckets_minus_one = %u\n", num_buckets_minus_one);
149 const size_t max_class_infos = class_infos_byte_size/sizeof(ClassInfo);
150 DEBUG_PRINTF ("max_class_infos = %u\n", max_class_infos);
152 ClassInfo *class_infos = (ClassInfo *)class_infos_ptr;
153 BucketInfo *buckets = (BucketInfo *)grc->buckets;
156 for (unsigned i=0; i<=num_buckets_minus_one; ++i)
158 if (buckets[i].name_ptr != NX_MAPNOTAKEY)
160 if (idx < max_class_infos)
162 const char *s = buckets[i].name_ptr;
164 for (unsigned char c = *s; c; c = *++s)
165 h = ((h << 5) + h) + c;
166 class_infos[idx].hash = h;
167 class_infos[idx].isa = buckets[i].isa;
168 DEBUG_PRINTF ("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, buckets[i].name_ptr);
173 if (idx < max_class_infos)
175 class_infos[idx].isa = NULL;
176 class_infos[idx].hash = 0;
187 "__lldb_apple_objc_v2_get_dynamic_class_info2";
192 int printf(const char * format, ...);
193 void free(void *ptr);
194 Class* objc_copyRealizedClassList_nolock(unsigned int *outCount);
195 const char* objc_debug_class_getNameRaw(Class cls);
198#define DEBUG_PRINTF(fmt, ...) if (should_log) printf(fmt, ## __VA_ARGS__)
204} __attribute__((__packed__));
207__lldb_apple_objc_v2_get_dynamic_class_info2(void *gdb_objc_realized_classes_ptr,
208 void *class_infos_ptr,
209 uint32_t class_infos_byte_size,
212 DEBUG_PRINTF ("class_infos_ptr = %p\n", class_infos_ptr);
213 DEBUG_PRINTF ("class_infos_byte_size = %u\n", class_infos_byte_size);
215 const size_t max_class_infos = class_infos_byte_size/sizeof(ClassInfo);
216 DEBUG_PRINTF ("max_class_infos = %u\n", max_class_infos);
218 ClassInfo *class_infos = (ClassInfo *)class_infos_ptr;
221 Class* realized_class_list = objc_copyRealizedClassList_nolock(&count);
222 DEBUG_PRINTF ("count = %u\n", count);
225 for (uint32_t i=0; i<count; ++i)
227 if (idx < max_class_infos)
229 Class isa = realized_class_list[i];
230 const char *name_ptr = objc_debug_class_getNameRaw(isa);
233 const char *s = name_ptr;
235 for (unsigned char c = *s; c; c = *++s)
236 h = ((h << 5) + h) + c;
237 class_infos[idx].hash = h;
238 class_infos[idx].isa = isa;
239 DEBUG_PRINTF ("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, name_ptr);
244 if (idx < max_class_infos)
246 class_infos[idx].isa = NULL;
247 class_infos[idx].hash = 0;
250 free(realized_class_list);
256 "__lldb_apple_objc_v2_get_dynamic_class_info3";
261 int printf(const char * format, ...);
262 void free(void *ptr);
263 size_t objc_getRealizedClassList_trylock(Class *buffer, size_t len);
264 const char* objc_debug_class_getNameRaw(Class cls);
265 const char* class_getName(Class cls);
268#define DEBUG_PRINTF(fmt, ...) if (should_log) printf(fmt, ## __VA_ARGS__)
274} __attribute__((__packed__));
277__lldb_apple_objc_v2_get_dynamic_class_info3(void *gdb_objc_realized_classes_ptr,
278 void *class_infos_ptr,
279 uint32_t class_infos_byte_size,
281 uint32_t class_buffer_len,
284 DEBUG_PRINTF ("class_infos_ptr = %p\n", class_infos_ptr);
285 DEBUG_PRINTF ("class_infos_byte_size = %u\n", class_infos_byte_size);
287 const size_t max_class_infos = class_infos_byte_size/sizeof(ClassInfo);
288 DEBUG_PRINTF ("max_class_infos = %u\n", max_class_infos);
290 ClassInfo *class_infos = (ClassInfo *)class_infos_ptr;
292 Class *realized_class_list = (Class*)class_buffer;
294 uint32_t count = objc_getRealizedClassList_trylock(realized_class_list,
296 DEBUG_PRINTF ("count = %u\n", count);
299 for (uint32_t i=0; i<count; ++i)
301 if (idx < max_class_infos)
303 Class isa = realized_class_list[i];
304 const char *name_ptr = objc_debug_class_getNameRaw(isa);
306 class_getName(isa); // Realize name of lazy classes.
307 name_ptr = objc_debug_class_getNameRaw(isa);
311 const char *s = name_ptr;
313 for (unsigned char c = *s; c; c = *++s)
314 h = ((h << 5) + h) + c;
315 class_infos[idx].hash = h;
316 class_infos[idx].isa = isa;
317 DEBUG_PRINTF ("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, name_ptr);
322 if (idx < max_class_infos)
324 class_infos[idx].isa = NULL;
325 class_infos[idx].hash = 0;
337 const char *{0}(void *objc_class);
338 const char *(*class_name_lookup_func)(void *) = {1};
343 "__lldb_apple_objc_v2_get_shared_cache_class_info";
349 size_t strlen(const char *);
350 char *strncpy (char * s1, const char * s2, size_t n);
351 int printf(const char * format, ...);
354#define DEBUG_PRINTF(fmt, ...) if (should_log) printf(fmt, ## __VA_ARGS__)
357struct objc_classheader_t {
362struct objc_classheader_v16_t {
363 uint64_t isDuplicate : 1,
364 objectCacheOffset : 47, // Offset from the shared cache base
368struct objc_clsopt_t {
376 uint32_t scramble[256];
377 uint8_t tab[0]; // tab[mask+1]
378 // uint8_t checkbytes[capacity];
379 // int32_t offset[capacity];
380 // objc_classheader_t clsOffsets[capacity];
381 // uint32_t duplicateCount;
382 // objc_classheader_t duplicateOffsets[duplicateCount];
385struct objc_clsopt_v16_t {
393 uint32_t scramble[256];
394 uint8_t tab[0]; // tab[mask+1]
395 // uint8_t checkbytes[capacity];
396 // int32_t offset[capacity];
397 // objc_classheader_t clsOffsets[capacity];
398 // uint32_t duplicateCount;
399 // objc_classheader_t duplicateOffsets[duplicateCount];
404 int32_t selopt_offset;
405 int32_t headeropt_offset;
406 int32_t clsopt_offset;
409struct objc_opt_v14_t {
412 int32_t selopt_offset;
413 int32_t headeropt_offset;
414 int32_t clsopt_offset;
417struct objc_opt_v16_t {
420 int32_t selopt_offset;
421 int32_t headeropt_ro_offset;
422 int32_t unused_clsopt_offset;
423 int32_t unused_protocolopt_offset;
424 int32_t headeropt_rw_offset;
425 int32_t unused_protocolopt2_offset;
426 int32_t largeSharedCachesClassOffset;
427 int32_t largeSharedCachesProtocolOffset;
428 uint64_t relativeMethodSelectorBaseAddressCacheOffset;
435} __attribute__((__packed__));
441__lldb_apple_objc_v2_get_shared_cache_class_info (void *objc_opt_ro_ptr,
442 void *shared_cache_base_ptr,
443 void *class_infos_ptr,
444 uint64_t *relative_selector_offset,
445 uint32_t class_infos_byte_size,
449 *relative_selector_offset = 0;
451 DEBUG_PRINTF ("objc_opt_ro_ptr = %p\n", objc_opt_ro_ptr);
452 DEBUG_PRINTF ("shared_cache_base_ptr = %p\n", shared_cache_base_ptr);
453 DEBUG_PRINTF ("class_infos_ptr = %p\n", class_infos_ptr);
454 DEBUG_PRINTF ("class_infos_byte_size = %u (%llu class infos)\n", class_infos_byte_size, (uint64_t)(class_infos_byte_size/sizeof(ClassInfo)));
455 DEBUG_PRINTF ("start_idx = %u\n", *start_idx);
458 const objc_opt_t *objc_opt = (objc_opt_t *)objc_opt_ro_ptr;
459 const objc_opt_v14_t* objc_opt_v14 = (objc_opt_v14_t*)objc_opt_ro_ptr;
460 const objc_opt_v16_t* objc_opt_v16 = (objc_opt_v16_t*)objc_opt_ro_ptr;
461 if (objc_opt->version >= 16)
463 *relative_selector_offset = objc_opt_v16->relativeMethodSelectorBaseAddressCacheOffset;
464 DEBUG_PRINTF ("objc_opt->version = %u\n", objc_opt_v16->version);
465 DEBUG_PRINTF ("objc_opt->flags = %u\n", objc_opt_v16->flags);
466 DEBUG_PRINTF ("objc_opt->selopt_offset = %d\n", objc_opt_v16->selopt_offset);
467 DEBUG_PRINTF ("objc_opt->headeropt_ro_offset = %d\n", objc_opt_v16->headeropt_ro_offset);
468 DEBUG_PRINTF ("objc_opt->relativeMethodSelectorBaseAddressCacheOffset = %d\n", *relative_selector_offset);
470 else if (objc_opt->version >= 14)
472 DEBUG_PRINTF ("objc_opt->version = %u\n", objc_opt_v14->version);
473 DEBUG_PRINTF ("objc_opt->flags = %u\n", objc_opt_v14->flags);
474 DEBUG_PRINTF ("objc_opt->selopt_offset = %d\n", objc_opt_v14->selopt_offset);
475 DEBUG_PRINTF ("objc_opt->headeropt_offset = %d\n", objc_opt_v14->headeropt_offset);
476 DEBUG_PRINTF ("objc_opt->clsopt_offset = %d\n", objc_opt_v14->clsopt_offset);
480 DEBUG_PRINTF ("objc_opt->version = %u\n", objc_opt->version);
481 DEBUG_PRINTF ("objc_opt->selopt_offset = %d\n", objc_opt->selopt_offset);
482 DEBUG_PRINTF ("objc_opt->headeropt_offset = %d\n", objc_opt->headeropt_offset);
483 DEBUG_PRINTF ("objc_opt->clsopt_offset = %d\n", objc_opt->clsopt_offset);
486 if (objc_opt->version == 16)
488 int32_t large_offset = objc_opt_v16->largeSharedCachesClassOffset;
489 const objc_clsopt_v16_t* clsopt = (const objc_clsopt_v16_t*)((uint8_t *)objc_opt + large_offset);
490 // Work around a bug in some version shared cache builder where the offset overflows 2GiB (rdar://146432183).
491 uint32_t unsigned_offset = (uint32_t)large_offset;
492 if (unsigned_offset > 0x7fffffff && unsigned_offset < 0x82000000) {
493 clsopt = (const objc_clsopt_v16_t*)((uint8_t *)objc_opt + unsigned_offset);
494 DEBUG_PRINTF("warning: applying largeSharedCachesClassOffset overflow workaround!\n");
496 const size_t max_class_infos = class_infos_byte_size/sizeof(ClassInfo);
498 DEBUG_PRINTF("max_class_infos = %llu\n", (uint64_t)max_class_infos);
500 ClassInfo *class_infos = (ClassInfo *)class_infos_ptr;
502 const uint8_t *checkbytes = &clsopt->tab[clsopt->mask+1];
503 const int32_t *offsets = (const int32_t *)(checkbytes + clsopt->capacity);
504 const objc_classheader_v16_t *classOffsets = (const objc_classheader_v16_t *)(offsets + clsopt->capacity);
506 DEBUG_PRINTF ("clsopt->capacity = %u\n", clsopt->capacity);
507 DEBUG_PRINTF ("clsopt->mask = 0x%8.8x\n", clsopt->mask);
508 DEBUG_PRINTF ("classOffsets = %p\n", classOffsets);
510 const uint32_t original_start_idx = *start_idx;
512 // Always start at the start_idx here. If it's greater than the capacity,
513 // it will skip the loop entirely and go to the duplicate handling below.
514 for (uint32_t i=*start_idx; i<clsopt->capacity; ++i)
516 const uint64_t objectCacheOffset = classOffsets[i].objectCacheOffset;
517 DEBUG_PRINTF("objectCacheOffset[%u] = %u\n", i, objectCacheOffset);
519 if (classOffsets[i].isDuplicate) {
520 DEBUG_PRINTF("isDuplicate = true\n");
521 continue; // duplicate
524 if (objectCacheOffset == 0) {
525 DEBUG_PRINTF("objectCacheOffset == invalidEntryOffset\n");
526 continue; // invalid offset
529 if (class_infos && idx < max_class_infos)
531 class_infos[idx].isa = (Class)((uint8_t *)shared_cache_base_ptr + objectCacheOffset);
533 // Lookup the class name.
534 const char *name = class_name_lookup_func(class_infos[idx].isa);
535 DEBUG_PRINTF("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, name);
537 // Hash the class name so we don't have to read it.
538 const char *s = name;
540 for (unsigned char c = *s; c; c = *++s)
542 // class_getName demangles swift names and the hash must
543 // be calculated on the mangled name. hash==0 means lldb
544 // will fetch the mangled name and compute the hash in
545 // ParseClassInfoArray.
551 h = ((h << 5) + h) + c;
553 class_infos[idx].hash = h;
557 DEBUG_PRINTF("not(class_infos && idx < max_class_infos)\n");
564 if (idx < max_class_infos) {
565 const uint32_t *duplicate_count_ptr = (uint32_t *)&classOffsets[clsopt->capacity];
566 const uint32_t duplicate_count = *duplicate_count_ptr;
567 const objc_classheader_v16_t *duplicateClassOffsets = (const objc_classheader_v16_t *)(&duplicate_count_ptr[1]);
569 DEBUG_PRINTF ("duplicate_count = %u\n", duplicate_count);
570 DEBUG_PRINTF ("duplicateClassOffsets = %p\n", duplicateClassOffsets);
572 const uint32_t duplicate_start_idx =
573 *start_idx < clsopt->capacity ?
575 *start_idx - clsopt->capacity;
577 for (uint32_t i=duplicate_start_idx; i<duplicate_count; ++i)
579 const uint64_t objectCacheOffset = duplicateClassOffsets[i].objectCacheOffset;
580 DEBUG_PRINTF("objectCacheOffset[%u] = %u\n", i, objectCacheOffset);
582 if (duplicateClassOffsets[i].isDuplicate) {
583 DEBUG_PRINTF("isDuplicate = true\n");
584 continue; // duplicate
587 if (objectCacheOffset == 0) {
588 DEBUG_PRINTF("objectCacheOffset == invalidEntryOffset\n");
589 continue; // invalid offset
592 if (class_infos && idx < max_class_infos)
594 class_infos[idx].isa = (Class)((uint8_t *)shared_cache_base_ptr + objectCacheOffset);
596 // Lookup the class name.
597 const char *name = class_name_lookup_func(class_infos[idx].isa);
598 DEBUG_PRINTF("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, name);
600 // Hash the class name so we don't have to read it.
601 const char *s = name;
603 for (unsigned char c = *s; c; c = *++s)
605 // class_getName demangles swift names and the hash must
606 // be calculated on the mangled name. hash==0 means lldb
607 // will fetch the mangled name and compute the hash in
608 // ParseClassInfoArray.
614 h = ((h << 5) + h) + c;
616 class_infos[idx].hash = h;
618 DEBUG_PRINTF("not(class_infos && idx < max_class_infos)\n");
625 // Always make sure start_idx gets updated. Otherwise we have an infinite
626 // loop if there are exactly max_class_infos number of classes.
627 if (*start_idx == original_start_idx) {
631 else if (objc_opt->version >= 12 && objc_opt->version <= 15)
633 const objc_clsopt_t* clsopt = NULL;
634 if (objc_opt->version >= 14)
635 clsopt = (const objc_clsopt_t*)((uint8_t *)objc_opt_v14 + objc_opt_v14->clsopt_offset);
637 clsopt = (const objc_clsopt_t*)((uint8_t *)objc_opt + objc_opt->clsopt_offset);
638 const size_t max_class_infos = class_infos_byte_size/sizeof(ClassInfo);
639 DEBUG_PRINTF("max_class_infos = %llu\n", (uint64_t)max_class_infos);
640 ClassInfo *class_infos = (ClassInfo *)class_infos_ptr;
641 int32_t invalidEntryOffset = 0;
642 // this is safe to do because the version field order is invariant
643 if (objc_opt->version == 12)
644 invalidEntryOffset = 16;
645 const uint8_t *checkbytes = &clsopt->tab[clsopt->mask+1];
646 const int32_t *offsets = (const int32_t *)(checkbytes + clsopt->capacity);
647 const objc_classheader_t *classOffsets = (const objc_classheader_t *)(offsets + clsopt->capacity);
648 DEBUG_PRINTF ("clsopt->capacity = %u\n", clsopt->capacity);
649 DEBUG_PRINTF ("clsopt->mask = 0x%8.8x\n", clsopt->mask);
650 DEBUG_PRINTF ("classOffsets = %p\n", classOffsets);
651 DEBUG_PRINTF("invalidEntryOffset = %d\n", invalidEntryOffset);
652 for (uint32_t i=0; i<clsopt->capacity; ++i)
654 const int32_t clsOffset = classOffsets[i].clsOffset;
655 DEBUG_PRINTF("clsOffset[%u] = %u\n", i, clsOffset);
658 DEBUG_PRINTF("clsOffset & 1\n");
659 continue; // duplicate
661 else if (clsOffset == invalidEntryOffset)
663 DEBUG_PRINTF("clsOffset == invalidEntryOffset\n");
664 continue; // invalid offset
667 if (class_infos && idx < max_class_infos)
669 class_infos[idx].isa = (Class)((uint8_t *)clsopt + clsOffset);
670 const char *name = class_name_lookup_func (class_infos[idx].isa);
671 DEBUG_PRINTF ("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, name);
672 // Hash the class name so we don't have to read it
673 const char *s = name;
675 for (unsigned char c = *s; c; c = *++s)
677 // class_getName demangles swift names and the hash must
678 // be calculated on the mangled name. hash==0 means lldb
679 // will fetch the mangled name and compute the hash in
680 // ParseClassInfoArray.
686 h = ((h << 5) + h) + c;
688 class_infos[idx].hash = h;
692 DEBUG_PRINTF("not(class_infos && idx < max_class_infos)\n");
697 const uint32_t *duplicate_count_ptr = (uint32_t *)&classOffsets[clsopt->capacity];
698 const uint32_t duplicate_count = *duplicate_count_ptr;
699 const objc_classheader_t *duplicateClassOffsets = (const objc_classheader_t *)(&duplicate_count_ptr[1]);
700 DEBUG_PRINTF ("duplicate_count = %u\n", duplicate_count);
701 DEBUG_PRINTF ("duplicateClassOffsets = %p\n", duplicateClassOffsets);
702 for (uint32_t i=0; i<duplicate_count; ++i)
704 const int32_t clsOffset = duplicateClassOffsets[i].clsOffset;
706 continue; // duplicate
707 else if (clsOffset == invalidEntryOffset)
708 continue; // invalid offset
710 if (class_infos && idx < max_class_infos)
712 class_infos[idx].isa = (Class)((uint8_t *)clsopt + clsOffset);
713 const char *name = class_name_lookup_func (class_infos[idx].isa);
714 DEBUG_PRINTF ("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, name);
715 // Hash the class name so we don't have to read it
716 const char *s = name;
718 for (unsigned char c = *s; c; c = *++s)
720 // class_getName demangles swift names and the hash must
721 // be calculated on the mangled name. hash==0 means lldb
722 // will fetch the mangled name and compute the hash in
723 // ParseClassInfoArray.
729 h = ((h << 5) + h) + c;
731 class_infos[idx].hash = h;
736 DEBUG_PRINTF ("%u class_infos\n", idx);
737 DEBUG_PRINTF ("done\n");
748 bool read_value =
true, uint8_t byte_size = 0,
753 return default_value;
758 return default_value;
768 return default_value;
775 return default_value;
780 default_value,
error);
781 return symbol_load_addr;
786static llvm::SmallVector<RuntimeGlobalSymbolResult>
789 llvm::ArrayRef<RuntimeGlobalSymbolSpec> specs) {
792 llvm::SmallVector<RuntimeGlobalSymbolResult> results(specs.size());
794 if (!process || !module_sp)
806 llvm::SmallVector<ReadEntry> work_list;
807 for (
auto [i, spec] : llvm::enumerate(specs)) {
808 const uint8_t size = spec.byte_size ? spec.byte_size : ptr_size;
809 const Symbol *symbol = module_sp->FindFirstSymbolWithNameAndType(
820 if (!spec.read_value)
821 results[i] = {symbol_load_addr,
true};
823 work_list.push_back({i, symbol_load_addr, size});
828 llvm::stable_sort(work_list, [](
const ReadEntry &a,
const ReadEntry &b) {
829 return a.byte_size < b.byte_size;
832 for (
size_t i = 0; i < work_list.size();) {
833 const uint8_t byte_size = work_list[i].byte_size;
834 const size_t group_start = i;
836 llvm::SmallVector<lldb::addr_t> addrs;
837 while (i < work_list.size() && work_list[i].byte_size == byte_size)
838 addrs.push_back(work_list[i++].addr);
843 for (
size_t j = 0; j < addrs.size(); ++j) {
844 size_t idx = work_list[group_start + j].result_idx;
845 if (read_values[j].has_value())
846 results[idx] = {*read_values[j],
true};
870 static const ConstString g_gdb_object_getClass(
"gdb_object_getClass");
872 static const ConstString g_objc_copyRealizedClassList(
873 "_ZL33objc_copyRealizedClassList_nolockPj");
874 static const ConstString g_objc_getRealizedClassList_trylock(
875 "_objc_getRealizedClassList_trylock");
878 HasSymbol(g_objc_getRealizedClassList_trylock);
888 LanguageType impl_lang = descriptor_sp->GetImplementationLanguage();
890 return process_sp->GetLanguageRuntime(impl_lang);
914 class_type_or_name.
Clear();
926 ConstString class_name(objc_class_sp->GetClassName());
927 class_type_or_name.
SetName(class_name);
928 TypeSP type_sp(objc_class_sp->GetType());
934 objc_class_sp->SetType(type_sp);
939 auto types = vendor->FindTypes(class_name, 1);
947 return !class_type_or_name.
IsEmpty();
977 "Print ivar and method information in detail"}};
991 switch (short_option) {
999 "unrecognized short option '%c'", short_option);
1019 "Dump information on Objective-C classes "
1020 "known to the current process.",
1021 "language objc class-table dump",
1022 eCommandRequiresProcess |
1023 eCommandProcessMustBeLaunched |
1024 eCommandProcessMustBePaused),
1035 std::unique_ptr<RegularExpression> regex_up;
1042 if (!regex_up->IsValid()) {
1044 "invalid argument - please provide a valid regular expression");
1051 result.
AppendError(
"please provide 0 or 1 arguments");
1061 auto iterator = iterators_pair.first;
1063 for (; iterator != iterators_pair.second; iterator++) {
1064 if (iterator->second) {
1065 const char *class_name =
1066 iterator->second->GetClassName().AsCString(
"<unknown>");
1067 if (regex_up && class_name &&
1068 !regex_up->Execute(llvm::StringRef(class_name)))
1070 std_out.Printf(
"isa = 0x%" PRIx64, iterator->first);
1071 std_out.Printf(
" name = %s", class_name);
1072 std_out.Printf(
" instance size = %" PRIu64,
1073 iterator->second->GetInstanceSize());
1074 std_out.Printf(
" num ivars = %" PRIuPTR,
1075 (uintptr_t)iterator->second->GetNumIVars());
1076 if (
auto superclass = iterator->second->GetSuperclass()) {
1077 std_out.Printf(
" superclass = %s",
1078 superclass->GetClassName().AsCString(
"<unknown>"));
1080 std_out.Printf(
"\n");
1082 for (
size_t i = 0; i < iterator->second->GetNumIVars(); i++) {
1083 auto ivar = iterator->second->GetIVarAtIndex(i);
1085 " ivar name = %s type = %s size = %" PRIu64
1086 " offset = %" PRId32
"\n",
1087 ivar.m_name.AsCString(
"<unknown>"),
1088 ivar.m_type.GetDisplayTypeName().AsCString(
"<unknown>"),
1089 ivar.m_size, ivar.m_offset);
1092 iterator->second->Describe(
1094 [&std_out](
const char *name,
const char *type) ->
bool {
1095 std_out.Printf(
" instance method name = %s type = %s\n",
1099 [&std_out](
const char *name,
const char *type) ->
bool {
1100 std_out.Printf(
" class method name = %s type = %s\n", name,
1107 if (regex_up && !regex_up->Execute(llvm::StringRef()))
1109 std_out.Printf(
"isa = 0x%" PRIx64
" has no associated class.\n",
1116 result.
AppendError(
"current process has no Objective-C runtime loaded");
1128 interpreter,
"info",
"Dump information on a tagged pointer.",
1129 "language objc tagged-pointer info",
1130 eCommandRequiresProcess | eCommandProcessMustBeLaunched |
1131 eCommandProcessMustBePaused) {
1140 result.
AppendError(
"this command requires arguments");
1149 if (!objc_runtime) {
1150 result.
AppendError(
"current process has no Objective-C runtime loaded");
1157 if (!tagged_ptr_vendor) {
1158 result.
AppendError(
"current process has no tagged pointer support");
1173 "could not convert '{0}' to a valid address\n", arg_str);
1184 if (!descriptor_sp) {
1186 "could not get class descriptor for {0:x16}\n", arg_addr);
1191 uint64_t info_bits = 0;
1192 uint64_t value_bits = 0;
1193 uint64_t payload = 0;
1194 if (descriptor_sp->GetTaggedPointerInfo(&info_bits, &value_bits,
1198 "\tpayload = {1:x16}\n"
1199 "\tvalue = {2:x16}\n"
1200 "\tinfo bits = {3:x16}\n"
1202 arg_addr, payload, value_bits, info_bits,
1203 descriptor_sp->GetClassName().AsCString(
"<unknown>"));
1217 interpreter,
"class-table",
1218 "Commands for operating on the Objective-C class table.",
1219 "class-table <subcommand> [<subcommand-options>]") {
1232 interpreter,
"tagged-pointer",
1233 "Commands for operating on Objective-C tagged pointers.",
1234 "tagged-pointer <subcommand> [<subcommand-options>]") {
1248 interpreter,
"objc",
1249 "Commands for operating on the Objective-C language runtime.",
1250 "objc <subcommand> [<subcommand-options>]") {
1278 bool catch_bp,
bool throw_bp) {
1282 resolver_sp = std::make_shared<BreakpointResolverName>(
1292llvm::Expected<std::unique_ptr<UtilityFunction>>
1295 char check_function_code[2048];
1299 len = ::snprintf(check_function_code,
sizeof(check_function_code), R
"(
1300 extern "C" void *gdb_object_getClass(void *);
1301 extern "C" int printf(const char *format, ...);
1303 %s(void *$__lldb_arg_obj, void *$__lldb_arg_selector) {
1304 if ($__lldb_arg_obj == (void *)0)
1305 return; // nil is ok
1306 if (!gdb_object_getClass($__lldb_arg_obj)) {
1307 *((volatile int *)0) = 'ocgc';
1308 } else if ($__lldb_arg_selector != (void *)0) {
1309 signed char $responds = (signed char)
1310 [(id)$__lldb_arg_obj respondsToSelector:
1311 (void *) $__lldb_arg_selector];
1312 if ($responds == (signed char) 0)
1313 *((volatile int *)0) = 'ocgc';
1318 len = ::snprintf(check_function_code,
sizeof(check_function_code), R
"(
1319 extern "C" void *gdb_class_getClass(void *);
1320 extern "C" int printf(const char *format, ...);
1322 %s(void *$__lldb_arg_obj, void *$__lldb_arg_selector) {
1323 if ($__lldb_arg_obj == (void *)0)
1324 return; // nil is ok
1325 void **$isa_ptr = (void **)$__lldb_arg_obj;
1326 if (*$isa_ptr == (void *)0 ||
1327 !gdb_class_getClass(*$isa_ptr))
1328 *((volatile int *)0) = 'ocgc';
1329 else if ($__lldb_arg_selector != (void *)0) {
1330 signed char $responds = (signed char)
1331 [(id)$__lldb_arg_obj respondsToSelector:
1332 (void *) $__lldb_arg_selector];
1333 if ($responds == (signed char) 0)
1334 *((volatile int *)0) = 'ocgc';
1340 assert(len < (int)
sizeof(check_function_code));
1348 const char *ivar_name) {
1351 ConstString class_name = parent_ast_type.
GetTypeName();
1352 if (!class_name.
IsEmpty() && ivar_name && ivar_name[0]) {
1355 std::string buffer(
"OBJC_IVAR_$_");
1357 buffer.push_back(
'.');
1358 buffer.append(ivar_name);
1359 ConstString ivar_const_str(buffer);
1374 if (ivar_offset_symbol.
symbol)
1375 ivar_offset_address =
1385 ivar_offset =
m_process->ReadUnsignedIntegerFromMemory(
1401class RemoteNXMapTable {
1403 RemoteNXMapTable() : m_end_iterator(*this, -1) {}
1406 printf(
"RemoteNXMapTable.m_load_addr = 0x%" PRIx64
"\n", m_load_addr);
1407 printf(
"RemoteNXMapTable.m_count = %u\n", m_count);
1408 printf(
"RemoteNXMapTable.m_num_buckets_minus_one = %u\n",
1409 m_num_buckets_minus_one);
1410 printf(
"RemoteNXMapTable.m_buckets_ptr = 0x%" PRIX64
"\n", m_buckets_ptr);
1414 m_process = process;
1415 m_load_addr = load_addr;
1416 m_map_pair_size = m_process->GetAddressByteSize() * 2;
1424 const uint32_t unsigned_byte_size =
sizeof(uint32_t);
1428 bool success =
true;
1436 cursor, unsigned_byte_size, 0, err);
1438 cursor += unsigned_byte_size;
1442 cursor, unsigned_byte_size, 0, err);
1443 cursor += unsigned_byte_size;
1446 std::optional<lldb::addr_t> buckets_ptr =
1447 llvm::expectedToOptional(
m_process->ReadPointerFromMemory(cursor));
1451 success =
m_count > 0 && buckets_ptr.has_value();
1465 typedef std::pair<ConstString, ObjCLanguageRuntime::ObjCISA>
element;
1476 : m_parent(rhs.m_parent), m_index(rhs.m_index) {
1480 const_iterator &operator=(
const const_iterator &rhs) {
1482 assert(&m_parent == &rhs.m_parent);
1483 m_index = rhs.m_index;
1487 bool operator==(
const const_iterator &rhs)
const {
1488 if (&m_parent != &rhs.m_parent)
1490 if (m_index != rhs.m_index)
1496 bool operator!=(
const const_iterator &rhs)
const {
1500 const_iterator &operator++() {
1501 AdvanceToValidIndex();
1506 if (m_index == -1) {
1512 size_t map_pair_size = m_parent.m_map_pair_size;
1513 lldb::addr_t pair_ptr = pairs_ptr + (m_index * map_pair_size);
1515 llvm::Expected<lldb::addr_t> key =
1516 m_parent.m_process->ReadPointerFromMemory(pair_ptr);
1518 llvm::consumeError(key.takeError());
1521 llvm::Expected<lldb::addr_t> value =
1522 m_parent.m_process->ReadPointerFromMemory(
1523 pair_ptr + m_parent.m_process->GetAddressByteSize());
1525 llvm::consumeError(value.takeError());
1529 std::string key_string;
1532 m_parent.m_process->ReadCStringFromMemory(*key, key_string, err);
1541 void AdvanceToValidIndex() {
1546 const size_t map_pair_size = m_parent.m_map_pair_size;
1547 const lldb::addr_t invalid_key = m_parent.m_invalid_key;
1551 llvm::Expected<lldb::addr_t> key =
1552 m_parent.m_process->ReadPointerFromMemory(pair_ptr);
1555 llvm::consumeError(key.takeError());
1560 if (*key != invalid_key)
1568 const_iterator begin() {
1569 return const_iterator(*
this, m_num_buckets_minus_one + 1);
1572 const_iterator end() {
return m_end_iterator; }
1574 uint32_t GetCount()
const {
return m_count; }
1576 uint32_t GetBucketCount()
const {
return m_num_buckets_minus_one; }
1578 lldb::addr_t GetBucketDataPointer()
const {
return m_buckets_ptr; }
1580 lldb::addr_t GetTableLoadAddress()
const {
return m_load_addr; }
1584 uint32_t m_count = 0;
1585 uint32_t m_num_buckets_minus_one = 0;
1588 const_iterator m_end_iterator;
1590 size_t m_map_pair_size = 0;
1612 if (m_count == hash_table.
GetCount() &&
1626 class_descriptor_sp = non_pointer_isa_cache->GetClassDescriptor(isa);
1627 if (!class_descriptor_sp)
1629 return class_descriptor_sp;
1641 seen.insert(&valobj);
1645 ValueObject *parent = valobj.
GetParent();
1647 if (!parent || seen.count(parent))
1651 return parent_descriptor_sp->GetSuperclass();
1658 return objc_class_sp;
1661 return objc_class_sp;
1668 Process *process = exe_ctx.GetProcessPtr();
1670 return objc_class_sp;
1672 llvm::Expected<lldb::addr_t> isa_or_err =
1675 llvm::consumeError(isa_or_err.takeError());
1676 return objc_class_sp;
1681 if (!objc_class_sp) {
1683 isa = abi_sp->FixCodeAddress(isa);
1687 if (isa && !objc_class_sp) {
1690 "0x%" PRIx64
": AppleObjCRuntimeV2::GetClassDescriptor() ISA was "
1691 "not in class descriptor cache 0x%" PRIx64,
1694 return objc_class_sp;
1704 if (!objc_module_sp)
1708 "objc_debug_taggedpointer_obfuscator");
1710 const Symbol *symbol = objc_module_sp->FindFirstSymbolWithNameAndType(
1718 llvm::expectedToOptional(
1736 if (!objc_module_sp)
1739 static ConstString g_gdb_objc_realized_classes(
"gdb_objc_realized_classes");
1741 const Symbol *symbol = objc_module_sp->FindFirstSymbolWithNameAndType(
1749 llvm::expectedToOptional(
1757std::unique_ptr<AppleObjCRuntimeV2::SharedCacheImageHeaders>
1763 if (!objc_module_sp || !process)
1766 const Symbol *symbol = objc_module_sp->FindFirstSymbolWithNameAndType(
1769 LLDB_LOG(log,
"Symbol 'objc_debug_headerInfoRWs' unavailable. Some "
1770 "information concerning the shared cache may be unavailable");
1777 LLDB_LOG(log,
"Symbol 'objc_debug_headerInfoRWs' was found but we were "
1778 "unable to get its load address");
1782 llvm::Expected<lldb::addr_t> objc_debug_headerInfoRWs_ptr_or_err =
1784 if (!objc_debug_headerInfoRWs_ptr_or_err) {
1785 llvm::consumeError(objc_debug_headerInfoRWs_ptr_or_err.takeError());
1787 "Failed to read address of 'objc_debug_headerInfoRWs' at {0:x}",
1788 objc_debug_headerInfoRWs_addr);
1792 *objc_debug_headerInfoRWs_ptr_or_err;
1794 const size_t metadata_size =
1795 sizeof(uint32_t) +
sizeof(uint32_t);
1796 DataBufferHeap metadata_buffer(metadata_size,
'\0');
1798 process->
ReadMemory(objc_debug_headerInfoRWs_ptr, metadata_buffer.GetBytes(),
1802 "Unable to read metadata for 'objc_debug_headerInfoRWs' at {0:x}",
1803 objc_debug_headerInfoRWs_ptr);
1807 DataExtractor metadata_extractor(metadata_buffer.GetBytes(), metadata_size,
1811 uint32_t count = metadata_extractor.GetU32_unchecked(&cursor);
1812 uint32_t entsize = metadata_extractor.GetU32_unchecked(&cursor);
1813 if (count == 0 || entsize == 0) {
1815 "'objc_debug_headerInfoRWs' had count {0} with entsize {1}. These "
1816 "should both be non-zero.",
1821 std::unique_ptr<SharedCacheImageHeaders> shared_cache_image_headers(
1822 new SharedCacheImageHeaders(runtime, objc_debug_headerInfoRWs_ptr, count,
1824 if (
auto Err = shared_cache_image_headers->UpdateIfNeeded()) {
1826 "Failed to update SharedCacheImageHeaders: {0}");
1830 return shared_cache_image_headers;
1834 if (!m_needs_update)
1835 return llvm::Error::success();
1837 Process *process = m_runtime.GetProcess();
1839 sizeof(uint32_t) +
sizeof(uint32_t);
1843 const size_t memory_needed =
static_cast<size_t>(m_count) * m_entsize;
1844 if (memory_needed > 1024 * 1024 * 1024)
1845 return llvm::createStringError(
1846 "SharedCacheImageHeaders require too much memory");
1848 const lldb::addr_t first_header_addr = m_headerInfoRWs_ptr + metadata_size;
1850 llvm::SmallVector<Range<addr_t, size_t>> mem_ranges =
1851 llvm::to_vector(llvm::map_range(llvm::seq(m_count), [&](uint32_t i) {
1852 return Range<addr_t, size_t>(first_header_addr + (i * m_entsize),
1856 llvm::SmallVector<uint8_t, 0> buffer(memory_needed, 0);
1857 llvm::SmallVector<llvm::MutableArrayRef<uint8_t>> read_results =
1860 for (
auto [i, header_data] : llvm::enumerate(read_results)) {
1862 return llvm::createStringError(llvm::inconvertibleErrorCode(),
1863 "Failed to read memory from inferior when "
1864 "populating SharedCacheImageHeaders");
1870 bool is_loaded =
false;
1882 m_loaded_images.set(i);
1884 m_loaded_images.reset(i);
1886 m_needs_update =
false;
1888 return llvm::Error::success();
1892 uint16_t image_index) {
1893 if (image_index >= m_count)
1895 if (
auto Err = UpdateIfNeeded()) {
1898 "Failed to update SharedCacheImageHeaders: {0}");
1900 return m_loaded_images.test(image_index);
1904 if (
auto Err = UpdateIfNeeded()) {
1907 "Failed to update SharedCacheImageHeaders: {0}");
1912std::unique_ptr<UtilityFunction>
1914 ExecutionContext &exe_ctx, Helper helper, std::string code,
1918 LLDB_LOG(log,
"Creating utility function {0}", name);
1927 if (!utility_fn_or_error) {
1929 log, utility_fn_or_error.takeError(),
1930 "Failed to get utility function for dynamic info extractor: {0}");
1935 CompilerType clang_uint32_t_type =
1936 scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(
eEncodingUint, 32);
1937 CompilerType clang_void_pointer_type =
1941 ValueList arguments;
1961 std::unique_ptr<UtilityFunction> utility_fn = std::move(*utility_fn_or_error);
1964 utility_fn->MakeFunctionCaller(clang_uint32_t_type, arguments,
1969 "Failed to make function caller for implementation lookup: {0}.",
1997 case objc_getRealizedClassList_trylock: {
1998 if (!m_objc_getRealizedClassList_trylock_helper.utility_function)
1999 m_objc_getRealizedClassList_trylock_helper.utility_function =
2000 GetClassInfoUtilityFunctionImpl(exe_ctx, helper,
2003 return m_objc_getRealizedClassList_trylock_helper.utility_function.get();
2006 llvm_unreachable(
"Unexpected helper");
2012 case gdb_objc_realized_classes:
2013 return m_gdb_objc_realized_classes_helper.args;
2014 case objc_copyRealizedClassList:
2015 return m_objc_copyRealizedClassList_helper.args;
2016 case objc_getRealizedClassList_trylock:
2017 return m_objc_getRealizedClassList_trylock_helper.args;
2019 llvm_unreachable(
"Unexpected helper");
2025 if (!m_runtime.m_has_objc_copyRealizedClassList &&
2026 !m_runtime.m_has_objc_getRealizedClassList_trylock)
2029 if (
Process *process = m_runtime.GetProcess()) {
2031 if (loader->IsFullyInitialized()) {
2036 if (m_runtime.m_has_objc_getRealizedClassList_trylock)
2040 if (m_runtime.m_has_objc_copyRealizedClassList)
2053std::unique_ptr<UtilityFunction>
2058 LLDB_LOG(log,
"Creating utility function {0}",
2068 static ConstString g_class_getName_symbol_name(
"class_getName");
2069 static ConstString g_class_getNameRaw_symbol_name(
2070 "objc_debug_class_getNameRaw");
2072 ConstString class_name_getter_function_name =
2073 m_runtime.HasSymbol(g_class_getNameRaw_symbol_name)
2074 ? g_class_getNameRaw_symbol_name
2075 : g_class_getName_symbol_name;
2080 std::string shared_class_expression;
2081 llvm::raw_string_ostream(shared_class_expression) << llvm::formatv(
2083 class_name_getter_function_name);
2092 if (!utility_fn_or_error) {
2094 log, utility_fn_or_error.takeError(),
2095 "Failed to get utility function for shared class info extractor: {0}");
2100 CompilerType clang_uint32_t_type =
2101 scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(
eEncodingUint, 32);
2102 CompilerType clang_void_pointer_type =
2104 CompilerType clang_uint64_t_pointer_type =
2105 scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(
eEncodingUint, 64)
2107 CompilerType clang_uint32_t_pointer_type =
2108 scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(
eEncodingUint, 32)
2112 ValueList arguments;
2136 std::unique_ptr<UtilityFunction> utility_fn = std::move(*utility_fn_or_error);
2139 utility_fn->MakeFunctionCaller(clang_uint32_t_type, arguments,
2144 "Failed to make function caller for implementation lookup: {0}.",
2155 if (!m_utility_function)
2156 m_utility_function = GetClassInfoUtilityFunctionImpl(exe_ctx);
2157 return m_utility_function.get();
2160AppleObjCRuntimeV2::DescriptorMapUpdateResult
2162 RemoteNXMapTable &hash_table) {
2163 Process *process = m_runtime.GetProcess();
2164 if (process ==
nullptr)
2167 uint32_t num_class_infos = 0;
2171 ExecutionContext exe_ctx;
2178 if (!thread_sp->SafeToCallFunctions())
2181 thread_sp->CalculateExecutionContext(exe_ctx);
2188 Address function_address;
2198 const uint32_t num_classes =
2201 : m_runtime.m_realized_class_generation_count;
2202 if (num_classes == 0) {
2203 LLDB_LOGF(log,
"No dynamic classes found.");
2207 UtilityFunction *get_class_info_code =
2208 GetClassInfoUtilityFunction(exe_ctx, helper);
2209 if (!get_class_info_code) {
2214 FunctionCaller *get_class_info_function =
2217 if (!get_class_info_function) {
2218 LLDB_LOGF(log,
"Failed to get implementation lookup function caller.");
2224 DiagnosticManager diagnostics;
2226 const uint32_t class_info_byte_size = addr_size + 4;
2227 const uint32_t class_infos_byte_size = num_classes * class_info_byte_size;
2229 class_infos_byte_size, ePermissionsReadable | ePermissionsWritable, err);
2233 "unable to allocate %" PRIu32
2234 " bytes in process for shared cache read",
2235 class_infos_byte_size);
2239 llvm::scope_exit deallocate_class_infos([&] {
2246 const uint32_t class_byte_size = addr_size;
2247 const uint32_t class_buffer_len = num_classes;
2248 const uint32_t class_buffer_byte_size = class_buffer_len * class_byte_size;
2249 if (helper == Helper::objc_getRealizedClassList_trylock) {
2251 class_buffer_byte_size, ePermissionsReadable | ePermissionsWritable,
2255 "unable to allocate %" PRIu32
2256 " bytes in process for shared cache read",
2257 class_buffer_byte_size);
2262 llvm::scope_exit deallocate_class_buffer([&] {
2268 std::lock_guard<std::mutex> guard(m_mutex);
2285 bool dump_log = type_log && type_log->
GetVerbose();
2289 bool success =
false;
2291 diagnostics.
Clear();
2295 exe_ctx, GetClassInfoArgs(helper), arguments, diagnostics)) {
2296 EvaluateExpressionOptions options;
2304 CompilerType clang_uint32_t_type =
2305 scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(
eEncodingUint, 32);
2312 diagnostics.
Clear();
2316 exe_ctx, &GetClassInfoArgs(helper), options, diagnostics, return_value);
2321 LLDB_LOG(log,
"Discovered {0} Objective-C classes", num_class_infos);
2322 if (num_class_infos > 0) {
2324 DataBufferHeap buffer(num_class_infos * class_info_byte_size, 0);
2331 m_runtime.ParseClassInfoArray(class_infos_data, num_class_infos);
2337 LLDB_LOGF(log,
"Error evaluating our find class name function.");
2338 diagnostics.
Dump(log);
2343 LLDB_LOGF(log,
"Error writing function arguments.");
2344 diagnostics.
Dump(log);
2352 uint32_t num_class_infos) {
2364 uint32_t num_parsed = 0;
2368 for (uint32_t i = 0; i < num_class_infos; ++i) {
2374 log,
"AppleObjCRuntimeV2 found NULL isa, ignoring this class info");
2382 "AppleObjCRuntimeV2 found cached isa=0x%" PRIx64
2383 ", ignoring this class info",
2388 const uint32_t name_hash = data.
GetU32(&offset);
2389 ClassDescriptorSP descriptor_sp(
2398 AddClass(isa, descriptor_sp, name_hash);
2401 descriptor_sp->GetClassName().AsCString(
nullptr));
2405 "AppleObjCRuntimeV2 added isa=0x%" PRIx64
2406 ", hash=0x%8.8x, name=%s",
2408 descriptor_sp->GetClassName().AsCString(
"<unknown>"));
2412 LLDB_LOGF(log,
"AppleObjCRuntimeV2 parsed %" PRIu32
" class infos",
2428AppleObjCRuntimeV2::DescriptorMapUpdateResult
2430 Process *process = m_runtime.GetProcess();
2431 if (process ==
nullptr)
2436 ExecutionContext exe_ctx;
2443 if (!thread_sp->SafeToCallFunctions())
2446 thread_sp->CalculateExecutionContext(exe_ctx);
2453 Address function_address;
2459 uint32_t num_class_infos = 0;
2461 const lldb::addr_t objc_opt_ptr = m_runtime.GetSharedCacheReadOnlyAddress();
2463 m_runtime.GetSharedCacheBaseAddress();
2471 const uint32_t max_num_classes_in_buffer = 212992;
2473 UtilityFunction *get_class_info_code = GetClassInfoUtilityFunction(exe_ctx);
2474 if (!get_class_info_code) {
2479 FunctionCaller *get_shared_cache_class_info_function =
2482 if (!get_shared_cache_class_info_function) {
2483 LLDB_LOGF(log,
"Failed to get implementation lookup function caller.");
2487 ValueList arguments =
2490 DiagnosticManager diagnostics;
2492 const uint32_t class_info_byte_size = addr_size + 4;
2493 const uint32_t class_infos_byte_size =
2494 max_num_classes_in_buffer * class_info_byte_size;
2496 class_infos_byte_size, ePermissionsReadable | ePermissionsWritable, err);
2497 const uint32_t relative_selector_offset_addr_size = 64;
2500 ePermissionsReadable | ePermissionsWritable, err);
2501 constexpr uint32_t class_info_start_idx_byte_size =
sizeof(uint32_t);
2504 ePermissionsReadable | ePermissionsWritable, err);
2510 "unable to allocate %" PRIu32
2511 " bytes in process for shared cache read",
2512 class_infos_byte_size);
2516 const uint32_t start_idx_init_value = 0;
2518 class_info_start_idx_addr, &start_idx_init_value,
sizeof(uint32_t), err);
2519 if (bytes_written !=
sizeof(uint32_t)) {
2521 "unable to write %" PRIu32
2522 " bytes in process for shared cache read",
2523 class_infos_byte_size);
2527 std::lock_guard<std::mutex> guard(m_mutex);
2539 bool dump_log = type_log && type_log->
GetVerbose();
2543 bool success =
false;
2545 diagnostics.
Clear();
2549 exe_ctx, m_args, arguments, diagnostics)) {
2550 EvaluateExpressionOptions options;
2558 CompilerType clang_uint32_t_type =
2559 scratch_ts_sp->GetBuiltinTypeForEncodingAndBitSize(
eEncodingUint, 32);
2566 diagnostics.
Clear();
2568 uint32_t num_class_infos_read = 0;
2569 bool already_read_relative_selector_offset =
false;
2575 exe_ctx, &m_args, options, diagnostics, return_value);
2580 num_class_infos += num_class_infos_read;
2581 LLDB_LOG(log,
"Discovered {0} Objective-C classes in the shared cache",
2582 num_class_infos_read);
2583 if (num_class_infos_read > 0) {
2588 if (!already_read_relative_selector_offset) {
2589 DataBufferHeap relative_selector_offset_buffer(64, 0);
2591 relative_selector_offset_addr,
2592 relative_selector_offset_buffer.GetBytes(),
2593 relative_selector_offset_buffer.GetByteSize(),
2594 err) == relative_selector_offset_buffer.GetByteSize()) {
2595 DataExtractor relative_selector_offset_data(
2596 relative_selector_offset_buffer.GetBytes(),
2597 relative_selector_offset_buffer.GetByteSize(),
2600 uint64_t relative_selector_offset =
2601 relative_selector_offset_data.GetU64(&offset);
2602 if (relative_selector_offset > 0) {
2604 m_runtime.SetRelativeSelectorBaseAddr(objc_opt_ptr +
2605 relative_selector_offset);
2608 already_read_relative_selector_offset =
true;
2612 DataBufferHeap class_infos_buffer(
2613 num_class_infos_read * class_info_byte_size, 0);
2615 class_infos_buffer.GetBytes(),
2616 class_infos_buffer.GetByteSize(),
2617 err) == class_infos_buffer.GetByteSize()) {
2618 DataExtractor class_infos_data(class_infos_buffer.GetBytes(),
2619 class_infos_buffer.GetByteSize(),
2622 m_runtime.ParseClassInfoArray(class_infos_data,
2623 num_class_infos_read);
2627 LLDB_LOGF(log,
"Error evaluating our find class name function.");
2628 diagnostics.
Dump(log);
2631 }
while (num_class_infos_read == max_num_classes_in_buffer);
2633 LLDB_LOGF(log,
"Error writing function arguments.");
2634 diagnostics.
Dump(log);
2637 LLDB_LOG(log,
"Processed {0} Objective-C classes total from the shared cache",
2653 if (objc_module_sp) {
2654 ObjectFile *objc_object = objc_module_sp->GetObjectFile();
2657 SectionList *section_list = objc_module_sp->GetSectionList();
2662 if (text_segment_sp) {
2664 text_segment_sp->GetChildren().FindSectionByName(
2667 if (objc_opt_section_sp) {
2668 return objc_opt_section_sp->GetLoadBaseAddress(
2684 StructuredData::Dictionary *info_dict = info->GetAsDictionary();
2705 RemoteNXMapTable hash_table;
2716 !class_count_changed)
2736 const uint32_t num_classes_to_warn_at = 500;
2742 "attempted to read objc class data - results: "
2743 "[dynamic_update]: ran: %s, retry: %s, count: %" PRIu32
2744 " [shared_cache_update]: ran: %s, retry: %s, count: %" PRIu32,
2745 dynamic_update_result.m_update_ran ?
"yes" :
"no",
2746 dynamic_update_result.m_retry_update ?
"yes" :
"no",
2747 dynamic_update_result.m_num_found,
2748 shared_cache_update_result.m_update_ran ?
"yes" :
"no",
2749 shared_cache_update_result.m_retry_update ?
"yes" :
"no",
2750 shared_cache_update_result.m_num_found);
2755 if (dynamic_update_result.m_retry_update ||
2756 shared_cache_update_result.m_retry_update)
2758 else if ((!shared_cache_update_result.m_update_ran) ||
2759 (!dynamic_update_result.m_update_ran))
2762 else if (dynamic_update_result.m_num_found +
2763 shared_cache_update_result.m_num_found <
2764 num_classes_to_warn_at)
2780 uint64_t objc_debug_realized_class_generation_count =
2782 process,
ConstString(
"objc_debug_realized_class_generation_count"),
2788 objc_debug_realized_class_generation_count)
2793 "objc_debug_realized_class_generation_count changed from {0} to {1}",
2795 objc_debug_realized_class_generation_count);
2798 objc_debug_realized_class_generation_count;
2808 llvm::StringRef platform_plugin_name_sr = platform_sp->GetPluginName();
2809 if (platform_plugin_name_sr.ends_with(
"-simulator"))
2827 "the process. This may reduce the quality of type "
2828 "information available\n",
2833 "could not execute support code to read "
2834 "Objective-C class data in the process. This may "
2835 "reduce the quality of type information available\n",
2840 "could not execute support code to read Objective-C class data because "
2841 "it's not yet safe to do so, and will be retried later\n",
2842 debugger.GetID(),
nullptr);
2865 llvm::raw_string_ostream os(buffer);
2867 os <<
"libobjc.A.dylib is being read from process memory. This "
2868 "indicates that LLDB could not ";
2870 if (platform_sp->IsHost()) {
2871 os <<
"read from the host's in-memory shared cache";
2873 os <<
"find the on-disk shared cache for this device";
2876 os <<
"read from the shared cache";
2878 os <<
". This will likely reduce debugging performance\n";
2894 const char *name_cstr = name.
AsCString(
nullptr);
2897 llvm::StringRef name_strref(name_cstr);
2899 llvm::StringRef ivar_prefix(
"OBJC_IVAR_$_");
2900 llvm::StringRef class_prefix(
"OBJC_CLASS_$_");
2902 if (name_strref.starts_with(ivar_prefix)) {
2903 llvm::StringRef ivar_skipped_prefix =
2904 name_strref.substr(ivar_prefix.size());
2905 std::pair<llvm::StringRef, llvm::StringRef> class_and_ivar =
2906 ivar_skipped_prefix.split(
'.');
2908 if (!class_and_ivar.first.empty() && !class_and_ivar.second.empty()) {
2909 const ConstString class_name_cs(class_and_ivar.first);
2914 const ConstString ivar_name_cs(class_and_ivar.second);
2915 const char *ivar_name_cstr = ivar_name_cs.AsCString(
nullptr);
2917 auto ivar_func = [&ret,
2918 ivar_name_cstr](
const char *name,
const char *type,
2921 if (!strcmp(name, ivar_name_cstr)) {
2928 descriptor->Describe(
2929 std::function<
void(
ObjCISA)>(
nullptr),
2930 std::function<
bool(
const char *,
const char *)>(
nullptr),
2931 std::function<
bool(
const char *,
const char *)>(
nullptr),
2935 }
else if (name_strref.starts_with(class_prefix)) {
2936 llvm::StringRef class_skipped_prefix =
2937 name_strref.substr(class_prefix.size());
2938 const ConstString class_name_cs(class_skipped_prefix);
2943 ret = descriptor->GetISA();
2950AppleObjCRuntimeV2::NonPointerISACache *
2969 llvm::SmallVector<RuntimeGlobalSymbolSpec> specs = {
2970 {ConstString(
"objc_debug_isa_magic_mask")},
2971 {ConstString(
"objc_debug_isa_magic_value")},
2972 {ConstString(
"objc_debug_isa_class_mask")},
2973 {ConstString(
"objc_debug_indexed_isa_magic_mask")},
2974 {ConstString(
"objc_debug_indexed_isa_magic_value")},
2975 {ConstString(
"objc_debug_indexed_isa_index_mask")},
2976 {ConstString(
"objc_debug_indexed_isa_index_shift")},
2977 {ConstString(
"objc_indexed_classes"),
false},
2979 assert(specs.size() == kISASymbolCount);
2985 if (!results[kMagicMask].success || !results[kMagicValue].success ||
2986 !results[kClassMask].success)
2989 auto objc_debug_isa_magic_mask = results[kMagicMask].value;
2990 auto objc_debug_isa_magic_value = results[kMagicValue].value;
2991 auto objc_debug_isa_class_mask = results[kClassMask].value;
2994 log->
PutCString(
"AOCRT::NPI: Found all the non-indexed ISA masks");
2997 bool foundError = !results[kIndexedMagicMask].success ||
2998 !results[kIndexedMagicValue].success ||
2999 !results[kIndexedIndexMask].success ||
3000 !results[kIndexedIndexShift].success ||
3001 !results[kIndexedClasses].success;
3003 auto objc_debug_indexed_isa_magic_mask = results[kIndexedMagicMask].value;
3004 auto objc_debug_indexed_isa_magic_value = results[kIndexedMagicValue].value;
3005 auto objc_debug_indexed_isa_index_mask = results[kIndexedIndexMask].value;
3006 auto objc_debug_indexed_isa_index_shift = results[kIndexedIndexShift].value;
3007 auto objc_indexed_classes = results[kIndexedClasses].value;
3009 if (log && !foundError)
3010 log->
PutCString(
"AOCRT::NPI: Found all the indexed ISA masks");
3016 runtime, objc_module_sp, objc_debug_isa_class_mask,
3017 objc_debug_isa_magic_mask, objc_debug_isa_magic_value,
3018 objc_debug_indexed_isa_magic_mask, objc_debug_indexed_isa_magic_value,
3019 objc_debug_indexed_isa_index_mask, objc_debug_indexed_isa_index_shift,
3020 foundError ? 0 : objc_indexed_classes);
3029 enum TaggedPtrSymbol {
3042 kTaggedPtrSymbolCount,
3044 llvm::SmallVector<RuntimeGlobalSymbolSpec> specs = {
3046 {
ConstString(
"objc_debug_taggedpointer_slot_shift"),
true, 4},
3047 {ConstString(
"objc_debug_taggedpointer_slot_mask"),
true, 4},
3048 {ConstString(
"objc_debug_taggedpointer_payload_lshift"),
true, 4},
3049 {ConstString(
"objc_debug_taggedpointer_payload_rshift"),
true, 4},
3050 {ConstString(
"objc_debug_taggedpointer_classes"),
false},
3051 {ConstString(
"objc_debug_taggedpointer_ext_mask")},
3052 {ConstString(
"objc_debug_taggedpointer_ext_slot_shift"),
true, 4},
3053 {ConstString(
"objc_debug_taggedpointer_ext_slot_mask"),
true, 4},
3054 {ConstString(
"objc_debug_taggedpointer_ext_classes"),
false},
3055 {ConstString(
"objc_debug_taggedpointer_ext_payload_lshift"),
true, 4},
3056 {ConstString(
"objc_debug_taggedpointer_ext_payload_rshift"),
true, 4},
3058 assert(specs.size() == kTaggedPtrSymbolCount);
3064 bool required_success =
3065 results[kMask].success && results[kSlotShift].success &&
3066 results[kSlotMask].success && results[kPayloadLshift].success &&
3067 results[kPayloadRshift].success && results[kClasses].success;
3069 if (!required_success)
3072 auto objc_debug_taggedpointer_mask = results[kMask].value;
3073 auto objc_debug_taggedpointer_slot_shift = results[kSlotShift].value;
3074 auto objc_debug_taggedpointer_slot_mask = results[kSlotMask].value;
3075 auto objc_debug_taggedpointer_payload_lshift = results[kPayloadLshift].value;
3076 auto objc_debug_taggedpointer_payload_rshift = results[kPayloadRshift].value;
3077 auto objc_debug_taggedpointer_classes = results[kClasses].value;
3080 bool extended_success =
3081 results[kExtMask].success && results[kExtSlotShift].success &&
3082 results[kExtSlotMask].success && results[kExtClasses].success &&
3083 results[kExtPayloadLshift].success && results[kExtPayloadRshift].success;
3085 if (extended_success) {
3086 auto objc_debug_taggedpointer_ext_mask = results[kExtMask].value;
3087 auto objc_debug_taggedpointer_ext_slot_shift = results[kExtSlotShift].value;
3088 auto objc_debug_taggedpointer_ext_slot_mask = results[kExtSlotMask].value;
3089 auto objc_debug_taggedpointer_ext_classes = results[kExtClasses].value;
3090 auto objc_debug_taggedpointer_ext_payload_lshift =
3091 results[kExtPayloadLshift].value;
3092 auto objc_debug_taggedpointer_ext_payload_rshift =
3093 results[kExtPayloadRshift].value;
3096 runtime, objc_debug_taggedpointer_mask,
3097 objc_debug_taggedpointer_ext_mask, objc_debug_taggedpointer_slot_shift,
3098 objc_debug_taggedpointer_ext_slot_shift,
3099 objc_debug_taggedpointer_slot_mask,
3100 objc_debug_taggedpointer_ext_slot_mask,
3101 objc_debug_taggedpointer_payload_lshift,
3102 objc_debug_taggedpointer_payload_rshift,
3103 objc_debug_taggedpointer_ext_payload_lshift,
3104 objc_debug_taggedpointer_ext_payload_rshift,
3105 objc_debug_taggedpointer_classes, objc_debug_taggedpointer_ext_classes);
3112 runtime, objc_debug_taggedpointer_mask,
3113 objc_debug_taggedpointer_slot_shift, objc_debug_taggedpointer_slot_mask,
3114 objc_debug_taggedpointer_payload_lshift,
3115 objc_debug_taggedpointer_payload_rshift,
3116 objc_debug_taggedpointer_classes);
3124std::unique_ptr<ObjCLanguageRuntime::ClassDescriptor>
3127 if (!IsPossibleTaggedPointer(ptr))
3130 uint32_t foundation_version = m_runtime.GetFoundationVersion();
3135 uint64_t class_bits = (ptr & 0xE) >> 1;
3141 static ConstString g_NSManagedObject(
"NSManagedObject");
3144 if (foundation_version >= 900) {
3145 switch (class_bits) {
3156 name = g_NSManagedObject;
3165 switch (class_bits) {
3170 name = g_NSManagedObject;
3183 lldb::addr_t unobfuscated = ptr ^ m_runtime.GetTaggedPointerObfuscator();
3184 return std::make_unique<ClassDescriptorV2Tagged>(name, unobfuscated);
3190 uint32_t objc_debug_taggedpointer_slot_shift,
3191 uint32_t objc_debug_taggedpointer_slot_mask,
3192 uint32_t objc_debug_taggedpointer_payload_lshift,
3193 uint32_t objc_debug_taggedpointer_payload_rshift,
3195 : TaggedPointerVendorV2(runtime), m_cache(),
3196 m_objc_debug_taggedpointer_mask(objc_debug_taggedpointer_mask),
3197 m_objc_debug_taggedpointer_slot_shift(
3198 objc_debug_taggedpointer_slot_shift),
3199 m_objc_debug_taggedpointer_slot_mask(objc_debug_taggedpointer_slot_mask),
3200 m_objc_debug_taggedpointer_payload_lshift(
3201 objc_debug_taggedpointer_payload_lshift),
3202 m_objc_debug_taggedpointer_payload_rshift(
3203 objc_debug_taggedpointer_payload_rshift),
3204 m_objc_debug_taggedpointer_classes(objc_debug_taggedpointer_classes) {}
3208 return (ptr & m_objc_debug_taggedpointer_mask) != 0;
3211std::unique_ptr<ObjCLanguageRuntime::ClassDescriptor>
3215 uint64_t unobfuscated = (ptr) ^ m_runtime.GetTaggedPointerObfuscator();
3217 if (!IsPossibleTaggedPointer(unobfuscated))
3220 uintptr_t slot = (ptr >> m_objc_debug_taggedpointer_slot_shift) &
3221 m_objc_debug_taggedpointer_slot_mask;
3223 CacheIterator iterator = m_cache.find(slot), end = m_cache.end();
3224 if (iterator != end) {
3225 actual_class_descriptor_sp = iterator->second;
3227 Process *process(m_runtime.GetProcess());
3230 llvm::Expected<lldb::addr_t> slot_data_or_err =
3232 if (!slot_data_or_err) {
3233 llvm::consumeError(slot_data_or_err.takeError());
3236 uintptr_t slot_data = *slot_data_or_err;
3239 actual_class_descriptor_sp =
3240 m_runtime.GetClassDescriptorFromISA((
ObjCISA)slot_data);
3241 if (!actual_class_descriptor_sp) {
3244 actual_class_descriptor_sp =
3245 m_runtime.GetClassDescriptorFromISA(fixed_isa);
3248 if (!actual_class_descriptor_sp)
3250 m_cache[slot] = actual_class_descriptor_sp;
3253 uint64_t data_payload =
3254 ((unobfuscated << m_objc_debug_taggedpointer_payload_lshift) >>
3255 m_objc_debug_taggedpointer_payload_rshift);
3256 int64_t data_payload_signed =
3257 ((int64_t)(unobfuscated << m_objc_debug_taggedpointer_payload_lshift) >>
3258 m_objc_debug_taggedpointer_payload_rshift);
3259 return std::make_unique<ClassDescriptorV2Tagged>(
3260 actual_class_descriptor_sp, data_payload, data_payload_signed);
3265 uint64_t objc_debug_taggedpointer_ext_mask,
3266 uint32_t objc_debug_taggedpointer_slot_shift,
3267 uint32_t objc_debug_taggedpointer_ext_slot_shift,
3268 uint32_t objc_debug_taggedpointer_slot_mask,
3269 uint32_t objc_debug_taggedpointer_ext_slot_mask,
3270 uint32_t objc_debug_taggedpointer_payload_lshift,
3271 uint32_t objc_debug_taggedpointer_payload_rshift,
3272 uint32_t objc_debug_taggedpointer_ext_payload_lshift,
3273 uint32_t objc_debug_taggedpointer_ext_payload_rshift,
3277 runtime, objc_debug_taggedpointer_mask,
3278 objc_debug_taggedpointer_slot_shift,
3279 objc_debug_taggedpointer_slot_mask,
3280 objc_debug_taggedpointer_payload_lshift,
3281 objc_debug_taggedpointer_payload_rshift,
3282 objc_debug_taggedpointer_classes),
3286 objc_debug_taggedpointer_ext_slot_shift),
3288 objc_debug_taggedpointer_ext_slot_mask),
3290 objc_debug_taggedpointer_ext_payload_lshift),
3292 objc_debug_taggedpointer_ext_payload_rshift),
3294 objc_debug_taggedpointer_ext_classes) {}
3298 if (!IsPossibleTaggedPointer(ptr))
3301 if (m_objc_debug_taggedpointer_ext_mask == 0)
3304 return ((ptr & m_objc_debug_taggedpointer_ext_mask) ==
3305 m_objc_debug_taggedpointer_ext_mask);
3308std::unique_ptr<ObjCLanguageRuntime::ClassDescriptor>
3311 ClassDescriptorSP actual_class_descriptor_sp;
3312 uint64_t unobfuscated = (ptr) ^ m_runtime.GetTaggedPointerObfuscator();
3314 if (!IsPossibleTaggedPointer(unobfuscated))
3317 if (!IsPossibleExtendedTaggedPointer(unobfuscated))
3320 uintptr_t slot = (ptr >> m_objc_debug_taggedpointer_ext_slot_shift) &
3321 m_objc_debug_taggedpointer_ext_slot_mask;
3323 CacheIterator iterator = m_ext_cache.find(slot), end = m_ext_cache.end();
3324 if (iterator != end) {
3325 actual_class_descriptor_sp = iterator->second;
3327 Process *process(m_runtime.GetProcess());
3329 m_objc_debug_taggedpointer_ext_classes;
3330 llvm::Expected<lldb::addr_t> slot_data_or_err =
3332 if (!slot_data_or_err) {
3333 llvm::consumeError(slot_data_or_err.takeError());
3336 uintptr_t slot_data = *slot_data_or_err;
3339 actual_class_descriptor_sp =
3340 m_runtime.GetClassDescriptorFromISA((
ObjCISA)slot_data);
3341 if (!actual_class_descriptor_sp)
3343 m_ext_cache[slot] = actual_class_descriptor_sp;
3346 uint64_t data_payload = (((uint64_t)unobfuscated
3347 << m_objc_debug_taggedpointer_ext_payload_lshift) >>
3348 m_objc_debug_taggedpointer_ext_payload_rshift);
3349 int64_t data_payload_signed =
3350 ((int64_t)((uint64_t)unobfuscated
3351 << m_objc_debug_taggedpointer_ext_payload_lshift) >>
3352 m_objc_debug_taggedpointer_ext_payload_rshift);
3354 return std::make_unique<ClassDescriptorV2Tagged>(
3355 actual_class_descriptor_sp, data_payload, data_payload_signed);
3360 uint64_t objc_debug_isa_class_mask, uint64_t objc_debug_isa_magic_mask,
3361 uint64_t objc_debug_isa_magic_value,
3362 uint64_t objc_debug_indexed_isa_magic_mask,
3363 uint64_t objc_debug_indexed_isa_magic_value,
3364 uint64_t objc_debug_indexed_isa_index_mask,
3365 uint64_t objc_debug_indexed_isa_index_shift,
3380 if (!EvaluateNonPointerISA(isa, real_isa))
3382 auto cache_iter = m_cache.find(real_isa);
3383 if (cache_iter != m_cache.end())
3384 return cache_iter->second;
3385 auto descriptor_sp =
3386 m_runtime.ObjCLanguageRuntime::GetClassDescriptorFromISA(real_isa);
3388 m_cache[real_isa] = descriptor_sp;
3389 return descriptor_sp;
3396 LLDB_LOGF(log,
"AOCRT::NPI Evaluate(isa = 0x%" PRIx64
")", (uint64_t)isa);
3398 if ((isa & ~m_objc_debug_isa_class_mask) == 0)
3405 if (m_objc_debug_indexed_isa_magic_mask &&
3406 m_objc_debug_indexed_isa_magic_value &&
3407 m_objc_debug_indexed_isa_index_mask &&
3408 m_objc_debug_indexed_isa_index_shift && m_objc_indexed_classes) {
3409 if ((isa & ~m_objc_debug_indexed_isa_index_mask) == 0)
3412 if ((isa & m_objc_debug_indexed_isa_magic_mask) ==
3413 m_objc_debug_indexed_isa_magic_value) {
3415 uintptr_t index = (isa & m_objc_debug_indexed_isa_index_mask) >>
3416 m_objc_debug_indexed_isa_index_shift;
3421 if (index > m_indexed_isa_cache.size()) {
3423 "AOCRT::NPI (index = %" PRIu64
3424 ") exceeds cache (size = %" PRIu64
")",
3425 (uint64_t)index, (uint64_t)m_indexed_isa_cache.size());
3427 Process *process(m_runtime.GetProcess());
3430 if (!objc_module_sp)
3435 process,
ConstString(
"objc_indexed_classes_count"), objc_module_sp,
3440 LLDB_LOGF(log,
"AOCRT::NPI (new class count = %" PRIu64
")",
3441 (uint64_t)objc_indexed_classes_count);
3443 if (objc_indexed_classes_count > m_indexed_isa_cache.size()) {
3447 auto num_new_classes =
3448 objc_indexed_classes_count - m_indexed_isa_cache.size();
3453 m_objc_indexed_classes + (m_indexed_isa_cache.size() * addr_size);
3455 last_read_class, buffer.GetBytes(), buffer.GetByteSize(),
error);
3456 if (
error.Fail() || bytes_read != buffer.GetByteSize())
3459 LLDB_LOGF(log,
"AOCRT::NPI (read new classes count = %" PRIu64
")",
3460 (uint64_t)num_new_classes);
3468 for (
unsigned i = 0; i != num_new_classes; ++i)
3469 m_indexed_isa_cache.push_back(data.
GetAddress(&offset));
3474 if (index >= m_indexed_isa_cache.size())
3477 LLDB_LOGF(log,
"AOCRT::NPI Evaluate(ret_isa = 0x%" PRIx64
")",
3478 (uint64_t)m_indexed_isa_cache[index]);
3480 ret_isa = m_indexed_isa_cache[index];
3481 return (ret_isa != 0);
3489 if ((isa & m_objc_debug_isa_magic_mask) == m_objc_debug_isa_magic_value) {
3490 ret_isa = isa & m_objc_debug_isa_class_mask;
3491 return (ret_isa != 0);
3499 std::make_shared<AppleObjCTypeEncodingParser>(*
this);
3508 non_pointer_isa_cache->EvaluateNonPointerISA(isa, ret);
3517 static ConstString g_dunder_kCFBooleanFalse(
"__kCFBooleanFalse");
3518 static ConstString g_dunder_kCFBooleanTrue(
"__kCFBooleanTrue");
3519 static ConstString g_kCFBooleanFalse(
"kCFBooleanFalse");
3520 static ConstString g_kCFBooleanTrue(
"kCFBooleanTrue");
3524 ModuleSP corefoundation_module_sp =
3526 corefoundation_module_spec);
3528 if (!corefoundation_module_sp)
3531 auto get_symbol = [
this, &corefoundation_module_sp](
3534 corefoundation_module_sp->FindFirstSymbolWithNameAndType(
3539 symbol = corefoundation_module_sp->FindFirstSymbolWithNameAndType(
3545 return llvm::expectedToOptional(
GetProcess()->ReadPointerFromMemory(addr))
3549 lldb::addr_t false_addr = get_symbol(g_dunder_kCFBooleanFalse, g_kCFBooleanFalse);
3550 lldb::addr_t true_addr = get_symbol(g_dunder_kCFBooleanTrue, g_kCFBooleanTrue);
3589 return std::nullopt;
3594 auto dict_up = std::make_unique<StructuredData::Dictionary>();
3595 dict_up->AddItem(
"Objective-C runtime version",
3596 std::make_unique<StructuredData::UnsignedInteger>(2));
3600#pragma mark Frame recognizers
3602class ObjCExceptionRecognizedStackFrame :
public RecognizedStackFrame {
3604 ObjCExceptionRecognizedStackFrame(
StackFrameSP frame_sp) {
3605 ThreadSP thread_sp = frame_sp->GetThread();
3606 ProcessSP process_sp = thread_sp->GetProcess();
3624 if (!abi->GetArgumentValues(*thread_sp, args))
3629 Value value(exception_addr);
3630 value.SetCompilerType(voidstar);
3637 m_arguments = std::make_shared<ValueObjectList>();
3638 m_arguments->Append(exception);
3640 m_stop_desc =
"hit Objective-C exception";
3648class ObjCExceptionThrowFrameRecognizer :
public StackFrameRecognizer {
3652 new ObjCExceptionRecognizedStackFrame(frame));
3654 std::string
GetName()
override {
3655 return "ObjC Exception Throw StackFrame Recognizer";
3661 ConstString function;
3663 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 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 ...
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
lldb::addr_t LookupRuntimeSymbol(ConstString name) override
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.
const char * AsCString(const char *value_if_empty) const
Get the string value as a C 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.
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(ConstString 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.
virtual 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
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(llvm::StringRef section_name) 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.
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
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 &parent, 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::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::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
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.