You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
829 B
Objective-C

#include "Test.h"
#include "../objc/hooks.h"
#include "../objc/objc-exception.h"
#include <stdlib.h>
#ifdef _WIN32
#include <Windows.h>
#endif
id exceptionObj = @"Exception";
void _UncaughtExceptionHandler(id exception)
{
assert(exception == exceptionObj);
#ifdef _WIN32
// on Windows we will exit in _UnhandledExceptionFilter() below
#else
exit(0);
#endif
}
#ifdef _WIN32
LONG WINAPI _UnhandledExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo)
{
assert(exceptionInfo != NULL);
exit(0);
}
#endif
int main(void)
{
#ifdef _WIN32
// also verify that an existing handler still gets called after we set ours
SetUnhandledExceptionFilter(&_UnhandledExceptionFilter);
#endif
objc_setUncaughtExceptionHandler(_UncaughtExceptionHandler);
@throw exceptionObj;
assert(0 && "should not be reached!");
return -1;
}