forked from mdavidsaver/ci-core-dumper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrasher.c
46 lines (39 loc) · 1017 Bytes
/
crasher.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifdef _WIN32
# include <windows.h>
# include <crtdbg.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
volatile int* volatile oops;
void doAbort()
{
abort();
}
int doCrash()
{
return *oops;
}
int main(int argc, char *argv[])
{
#ifdef _WIN32
/* disable abort() dialog */
_CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE |_CRTDBG_MODE_DEBUG );
_CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );
_CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE |_CRTDBG_MODE_DEBUG );
_CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDERR );
_CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE |_CRTDBG_MODE_DEBUG );
_CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR );
#endif
if(argc<2) {
printf("%s [abort|crash]\n", argv[0]);
return 2;
} else if(strcmp(argv[1], "abort")==0) {
doAbort();
return 0; // not going to happen
} else if(strcmp(argv[1], "crash")==0) {
return doCrash();
} else {
return 3;
}
}