]> git.saurik.com Git - apple/objc4.git/blob - test/gdb.m
objc4-493.9.tar.gz
[apple/objc4.git] / test / gdb.m
1 // TEST_CFLAGS -Wno-deprecated-declarations
2
3 #include "test.h"
4
5 #if TARGET_OS_IPHONE
6
7 int main()
8 {
9 succeed(__FILE__);
10 }
11
12 #else
13
14 #include <objc/objc-gdb.h>
15 #include <objc/runtime.h>
16
17 @interface Super { @public id isa; } @end
18 @implementation Super
19 +(void)initialize { }
20 +class { return self; }
21 @end
22
23
24 int main()
25 {
26 // Class hashes
27 #if __OBJC2__
28
29 Class result;
30
31 // Class should not be realized yet
32 // fixme not true during class hash rearrangement
33 // result = NXMapGet(gdb_objc_realized_classes, "Super");
34 // testassert(!result);
35
36 [Super class];
37 // Now class should be realized
38
39 result = (Class)NXMapGet(gdb_objc_realized_classes, "Super");
40 testassert(result);
41 testassert(result == [Super class]);
42
43 result = (Class)NXMapGet(gdb_objc_realized_classes, "DoesNotExist");
44 testassert(!result);
45
46 #else
47
48 struct objc_class query;
49 Class result;
50
51 query.name = "Super";
52 result = (Class)NXHashGet(_objc_debug_class_hash, &query);
53 testassert(result);
54 testassert((id)result == [Super class]);
55
56 query.name = "DoesNotExist";
57 result = (Class)NXHashGet(_objc_debug_class_hash, &query);
58 testassert(!result);
59
60 #endif
61
62 succeed(__FILE__);
63 }
64
65 #endif