Files
clang-p2996/lldb/test/API/lang/objc/conflicting-class-list-function-from-user/main.m
Raphael Isemann 57bf5c8659 [lldb] Add a test for user-defined objc_copyRealizedClassList_nolock
LLDB evaluates some utility expression to update the Objective-C class list that
ends up calling function such as `free` or `objc_copyRealizedClassList_nolock`.
This adds a test that just tries to define our own bogus version of
`objc_copyRealizedClassList_nolock`. It just tests that LLDB doesn't crash as we
currently don't have a way to tell LLDB to look for the function in a specific
library.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D107778
2021-08-10 14:54:42 +02:00

28 lines
824 B
Objective-C

#import <Foundation/Foundation.h>
#include <stdlib.h>
// A function with this signature will be called by LLDB to retrieve the
// Objective-C class list. We shouldn't call this function that is defined
// by the user if possible.
Class *objc_copyRealizedClassList_nolock(unsigned int *outCount) {
// Don't try to implement this properly but just abort.
abort();
}
// Define some custom class that makes LLDB read the Objective-C class list.
@interface CustomClass : NSObject {
};
@end
@implementation CustomClass
@end
int main(int argc, char **argv) {
id custom_class = [[CustomClass alloc] init];
// Make sure our trap function is emitted but never called (the test doesn't
// launch the executable with any args).
if (argc == 123) {
objc_copyRealizedClassList_nolock(0);
}
return 0; // break here
}