1 #import <Foundation/Foundation.h>
3 // Observable side effect that is changed when one of our trap functions is
4 // called. This should always retain its initial value in a successful test run.
5 const char *called_function = "none";
7 // Below several trap functions are declared in different scopes that should
8 // never be called even though they share the name of some of the utility
9 // functions that LLDB has to call when updating the Objective-C class list
10 // (i.e. 'free' and 'objc_copyRealizedClassList_nolock').
11 // All functions just indicate that they got called by setting 'called_function'
15 void free(void *) { called_function = "N::free"; }
16 void objc_copyRealizedClassList_nolock(unsigned int *) {
17 called_function = "N::objc_copyRealizedClassList_nolock";
22 void free(void *) { called_function = "Context::free"; }
23 void objc_copyRealizedClassList_nolock(unsigned int *) {
24 called_function = "Context::objc_copyRealizedClassList_nolock";
28 @interface ObjCContext : NSObject {
30 - (void)free:(void *)p;
31 - (void)objc_copyRealizedClassList_nolock:(unsigned int *)outCount;
34 @implementation ObjCContext
35 - (void)free:(void *)p {
36 called_function = "ObjCContext::free";
39 - (void)objc_copyRealizedClassList_nolock:(unsigned int *)outCount {
40 called_function = "ObjCContext::objc_copyRealizedClassList_nolock";
44 int main(int argc, char **argv) {
46 // Make sure all our conflicting functions/methods are emitted. The condition
47 // is never executed in the test as the process is launched without args.
51 o.objc_copyRealizedClassList_nolock(nullptr);
53 N::objc_copyRealizedClassList_nolock(nullptr);
54 ObjCContext *obj = [[ObjCContext alloc] init];
56 [obj objc_copyRealizedClassList_nolock:nullptr];
58 return 0; // break here