]> git.saurik.com Git - apple/objc4.git/blob - test/gdb.m
objc4-779.1.tar.gz
[apple/objc4.git] / test / gdb.m
1 // TEST_CFLAGS -Wno-deprecated-declarations
2
3 #include "test.h"
4 #include "testroot.i"
5 #include <objc/objc-gdb.h>
6 #include <objc/runtime.h>
7
8 #define SwiftV1MangledName4 "_TtC6Swiftt13SwiftV1Class4"
9 __attribute__((objc_runtime_name(SwiftV1MangledName4)))
10 @interface SwiftV1Class4 : TestRoot @end
11 @implementation SwiftV1Class4 @end
12
13 int main()
14 {
15 // Class hashes
16 Class result;
17
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);
22
23 [TestRoot class];
24 // Now class should be realized
25
26 result = (__bridge Class)(NXMapGet(gdb_objc_realized_classes, "TestRoot"));
27 testassert(result);
28 testassert(result == [TestRoot class]);
29
30 result = (__bridge Class)(NXMapGet(gdb_objc_realized_classes, "DoesNotExist"));
31 testassert(!result);
32
33 // Class structure decoding
34
35 uintptr_t *maskp = (uintptr_t *)dlsym(RTLD_DEFAULT, "objc_debug_class_rw_data_mask");
36 testassert(maskp);
37
38 // Raw class names
39 testassert(strcmp(objc_debug_class_getNameRaw([SwiftV1Class4 class]), SwiftV1MangledName4) == 0);
40 testassert(strcmp(objc_debug_class_getNameRaw([TestRoot class]), "TestRoot") == 0);
41
42
43 succeed(__FILE__);
44 }