1#import <Foundation/Foundation.h>
2
3@interface OverridesALot: NSObject
4
5- (void)boring;
6
7@end
8
9@implementation OverridesALot
10
11+ (id)alloc {
12 NSLog(@"alloc");
13 return [super alloc];
14}
15
16+ (id)allocWithZone: (NSZone *)z {
17 NSLog(@"allocWithZone:");
18 return [super allocWithZone: z];
19}
20
21+ (id)new {
22 NSLog(@"new");
23 return [super new];
24}
25
26- (id)init {
27 NSLog(@"init");
28 return [super init];
29}
30
31- (id)self {
32 NSLog(@"self");
33 return [super self];
34}
35
36+ (id)class {
37 NSLog(@"class");
38 return [super class];
39}
40
41- (BOOL)isKindOfClass: (Class)c {
42 NSLog(@"isKindOfClass:");
43 return [super isKindOfClass: c];
44}
45
46- (BOOL)respondsToSelector: (SEL)s {
47 NSLog(@"respondsToSelector:");
48 return [super respondsToSelector: s];
49}
50
51- (id)retain {
52 NSLog(@"retain");
53 return [super retain];
54}
55
56- (oneway void)release {
57 NSLog(@"release");
58 [super release];
59}
60
61- (id)autorelease {
62 NSLog(@"autorelease");
63 return [super autorelease];
64}
65
66- (void)boring {
67 NSLog(@"boring");
68}
69
70@end
71
72@interface OverridesInit: NSObject
73
74- (void)boring;
75
76@end
77
78@implementation OverridesInit
79
80- (id)init {
81 NSLog(@"init");
82 return [super init];
83}
84
85@end
86
87int main() {
88 id obj;
89
90 // First make an object of the class that overrides everything,
91 // and make sure we step into all the methods:
92
93 obj = [OverridesALot alloc]; // Stop here to start stepping
94 [obj release]; // Stop Location 2
95
96 obj = [OverridesALot allocWithZone: NULL]; // Stop Location 3
97 [obj release]; // Stop Location 4
98
99 obj = [OverridesALot new]; // Stop Location 5
100 [obj release]; // Stop Location 6
101
102 obj = [[OverridesALot alloc] init]; // Stop Location 7
103 [obj self]; // Stop Location 8
104 [obj isKindOfClass: [OverridesALot class]]; // Stop Location 9
105 [obj respondsToSelector: @selector(hello)]; // Stop Location 10
106 [obj retain]; // Stop Location 11
107 [obj autorelease]; // Stop Location 12
108 [obj boring]; // Stop Location 13
109 [obj release]; // Stop Location 14
110
111 // Now try a class that only overrides init but not alloc, to make
112 // sure we get into the second method in a combined call:
113
114 obj = [[OverridesInit alloc] init]; // Stop Location 15
115
116 return 0; // Stop Location 15
117}
118

source code of lldb/test/API/lang/objc/direct-dispatch-step/stepping-tests.m