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