1 // TEST_CFLAGS -Wno-deprecated-declarations
5 #include <objc/objc-gdb.h>
6 #include <objc/runtime.h>
8 #define SwiftV1MangledName4 "_TtC6Swiftt13SwiftV1Class4"
9 __attribute__((objc_runtime_name(SwiftV1MangledName4)))
10 @interface SwiftV1Class4 : TestRoot @end
11 @implementation SwiftV1Class4 @end
18 // Class should not be realized yet
19 // fixme not true during class hash rearrangement
20 // result = NXMapGet(gdb_objc_realized_classes, "TestRoot");
21 // testassert(!result);
24 // Now class should be realized
27 // In dyld3 mode, the class will be in the launch closure and not in our table.
28 result = (__bridge Class)(NXMapGet(gdb_objc_realized_classes, "TestRoot"));
30 testassert(result == [TestRoot class]);
33 Class dynamic = objc_allocateClassPair([TestRoot class], "Dynamic", 0);
34 objc_registerClassPair(dynamic);
35 result = (__bridge Class)(NXMapGet(gdb_objc_realized_classes, "Dynamic"));
37 testassert(result == dynamic);
39 Class *realizedClasses = objc_copyRealizedClassList(NULL);
40 bool foundTestRoot = false;
41 bool foundDynamic = false;
42 for (Class *cursor = realizedClasses; *cursor; cursor++) {
43 if (*cursor == [TestRoot class])
45 if (*cursor == dynamic)
48 free(realizedClasses);
49 testassert(foundTestRoot);
50 testassert(foundDynamic);
52 result = (__bridge Class)(NXMapGet(gdb_objc_realized_classes, "DoesNotExist"));
55 // Class structure decoding
57 uintptr_t *maskp = (uintptr_t *)dlsym(RTLD_DEFAULT, "objc_debug_class_rw_data_mask");
61 testassert(strcmp(objc_debug_class_getNameRaw([SwiftV1Class4 class]), SwiftV1MangledName4) == 0);
62 testassert(strcmp(objc_debug_class_getNameRaw([TestRoot class]), "TestRoot") == 0);