1da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes#include <assert.h> 2da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes#include <errno.h> 3da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes#include <pthread.h> 4da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes#include <sched.h> 5da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes#include <signal.h> 6dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#include <stdio.h> 7dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#include <stdlib.h> 8dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#include <string.h> 9f1a8dfa0ebfc233e569ffa83e21e37d0a829b94cMark Salyzyn#include <sys/cdefs.h> 108606eaa7700609a2f9f2383b954b4e64dbc4c827Brigid Smith#include <sys/mman.h> 11dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#include <sys/ptrace.h> 12dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#include <sys/socket.h> 13da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes#include <sys/wait.h> 14da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes#include <unistd.h> 15dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project 16dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project#include <cutils/sockets.h> 17f1a8dfa0ebfc233e569ffa83e21e37d0a829b94cMark Salyzyn#include <log/log.h> 18f1a8dfa0ebfc233e569ffa83e21e37d0a829b94cMark Salyzyn 19f1a8dfa0ebfc233e569ffa83e21e37d0a829b94cMark Salyzyn#ifndef __unused 20f1a8dfa0ebfc233e569ffa83e21e37d0a829b94cMark Salyzyn#define __unused __attribute__((__unused__)) 21f1a8dfa0ebfc233e569ffa83e21e37d0a829b94cMark Salyzyn#endif 22dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project 233808c4ecb4c2d4f05261e6631a765464b055d8b1Elliott Hughesextern const char* __progname; 243808c4ecb4c2d4f05261e6631a765464b055d8b1Elliott Hughes 25dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid crash1(void); 26dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Projectvoid crashnostack(void); 276f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughesstatic int do_action(const char* arg); 28dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project 29da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughesstatic void maybe_abort() { 30da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes if (time(0) != 42) { 316f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughes abort(); 326f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughes } 336f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughes} 346f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughes 352331b95609e3eb94494aebc9a59cab44d73df234Yabin Cuistatic char* smash_stack_dummy_buf; 362331b95609e3eb94494aebc9a59cab44d73df234Yabin Cui__attribute__ ((noinline)) static void smash_stack_dummy_function(volatile int* plen) { 372331b95609e3eb94494aebc9a59cab44d73df234Yabin Cui smash_stack_dummy_buf[*plen] = 0; 382331b95609e3eb94494aebc9a59cab44d73df234Yabin Cui} 392331b95609e3eb94494aebc9a59cab44d73df234Yabin Cui 402331b95609e3eb94494aebc9a59cab44d73df234Yabin Cui// This must be marked with "__attribute__ ((noinline))", to ensure the 412331b95609e3eb94494aebc9a59cab44d73df234Yabin Cui// compiler generates the proper stack guards around this function. 422331b95609e3eb94494aebc9a59cab44d73df234Yabin Cui// Assign local array address to global variable to force stack guards. 432331b95609e3eb94494aebc9a59cab44d73df234Yabin Cui// Use another noinline function to corrupt the stack. 442331b95609e3eb94494aebc9a59cab44d73df234Yabin Cui__attribute__ ((noinline)) static int smash_stack(volatile int* plen) { 45df4200e8c255fca1d03855b971b57036b9ccaa94Elliott Hughes printf("crasher: deliberately corrupting stack...\n"); 462331b95609e3eb94494aebc9a59cab44d73df234Yabin Cui 472331b95609e3eb94494aebc9a59cab44d73df234Yabin Cui char buf[128]; 482331b95609e3eb94494aebc9a59cab44d73df234Yabin Cui smash_stack_dummy_buf = buf; 492331b95609e3eb94494aebc9a59cab44d73df234Yabin Cui // This should corrupt stack guards and make process abort. 502331b95609e3eb94494aebc9a59cab44d73df234Yabin Cui smash_stack_dummy_function(plen); 512331b95609e3eb94494aebc9a59cab44d73df234Yabin Cui return 0; 52df4200e8c255fca1d03855b971b57036b9ccaa94Elliott Hughes} 53df4200e8c255fca1d03855b971b57036b9ccaa94Elliott Hughes 549466bb2ab64f6647a2c573d01ac7b08349345882Stephen Hines#if defined(__clang__) 5518395cb5074c0e039cd715299e82fd1d024559b7Stephen Hines#pragma clang diagnostic push 5618395cb5074c0e039cd715299e82fd1d024559b7Stephen Hines#pragma clang diagnostic ignored "-Winfinite-recursion" 579466bb2ab64f6647a2c573d01ac7b08349345882Stephen Hines#endif 5818395cb5074c0e039cd715299e82fd1d024559b7Stephen Hines 59b1be27e29b01009d66ac66c20e275506673e962cElliott Hughesstatic void* global = 0; // So GCC doesn't optimize the tail recursion out of overflow_stack. 60b1be27e29b01009d66ac66c20e275506673e962cElliott Hughes 616f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughes__attribute__((noinline)) static void overflow_stack(void* p) { 623808c4ecb4c2d4f05261e6631a765464b055d8b1Elliott Hughes void* buf[1]; 633808c4ecb4c2d4f05261e6631a765464b055d8b1Elliott Hughes buf[0] = p; 64b1be27e29b01009d66ac66c20e275506673e962cElliott Hughes global = buf; 653808c4ecb4c2d4f05261e6631a765464b055d8b1Elliott Hughes overflow_stack(&buf); 66dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project} 67dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project 689466bb2ab64f6647a2c573d01ac7b08349345882Stephen Hines#if defined(__clang__) 6918395cb5074c0e039cd715299e82fd1d024559b7Stephen Hines#pragma clang diagnostic pop 709466bb2ab64f6647a2c573d01ac7b08349345882Stephen Hines#endif 7118395cb5074c0e039cd715299e82fd1d024559b7Stephen Hines 726f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughesstatic void *noisy(void *x) 73dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project{ 745d9fe779c8ec2705865a23061834ad8cdbee5b82Elliott Hughes char c = (uintptr_t) x; 75dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project for(;;) { 76dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project usleep(250*1000); 77dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project write(2, &c, 1); 78a1ff475b07dd7c8a2dfa0e83bc2a25ef159b6152Chih-Hung Hsieh if(c == 'C') *((volatile unsigned*) 0) = 42; 79dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project } 805d9fe779c8ec2705865a23061834ad8cdbee5b82Elliott Hughes return NULL; 81dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project} 82dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project 836f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughesstatic int ctest() 84dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project{ 85dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project pthread_t thr; 86dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project pthread_attr_t attr; 87dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project pthread_attr_init(&attr); 88dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 89dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project pthread_create(&thr, &attr, noisy, (void*) 'A'); 90dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project pthread_create(&thr, &attr, noisy, (void*) 'B'); 91dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project pthread_create(&thr, &attr, noisy, (void*) 'C'); 92dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project for(;;) ; 93dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project return 0; 94dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project} 95dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project 96aa4213057ba1723e4f164e54f80bb7621c3cb6b3Elliott Hughesstatic void* thread_callback(void* raw_arg) 97aa4213057ba1723e4f164e54f80bb7621c3cb6b3Elliott Hughes{ 985d9fe779c8ec2705865a23061834ad8cdbee5b82Elliott Hughes return (void*) (uintptr_t) do_action((const char*) raw_arg); 99aa4213057ba1723e4f164e54f80bb7621c3cb6b3Elliott Hughes} 100aa4213057ba1723e4f164e54f80bb7621c3cb6b3Elliott Hughes 1016f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughesstatic int do_action_on_thread(const char* arg) 102dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project{ 103aa4213057ba1723e4f164e54f80bb7621c3cb6b3Elliott Hughes pthread_t t; 104aa4213057ba1723e4f164e54f80bb7621c3cb6b3Elliott Hughes pthread_create(&t, NULL, thread_callback, (void*) arg); 105aa4213057ba1723e4f164e54f80bb7621c3cb6b3Elliott Hughes void* result = NULL; 106aa4213057ba1723e4f164e54f80bb7621c3cb6b3Elliott Hughes pthread_join(t, &result); 1075d9fe779c8ec2705865a23061834ad8cdbee5b82Elliott Hughes return (int) (uintptr_t) result; 108aa4213057ba1723e4f164e54f80bb7621c3cb6b3Elliott Hughes} 109aa4213057ba1723e4f164e54f80bb7621c3cb6b3Elliott Hughes 1106f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughes__attribute__((noinline)) static int crash3(int a) { 1116f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughes *((int*) 0xdead) = a; 1126f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughes return a*4; 1136f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughes} 1146f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughes 1156f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughes__attribute__((noinline)) static int crash2(int a) { 1166f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughes a = crash3(a) + 2; 1176f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughes return a*3; 118af2cb3667ba24d1ef3037aa5a7b3bc0a238cf040Pavel Chupin} 119af2cb3667ba24d1ef3037aa5a7b3bc0a238cf040Pavel Chupin 1206f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughes__attribute__((noinline)) static int crash(int a) { 1216f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughes a = crash2(a) + 1; 1226f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughes return a*2; 123af2cb3667ba24d1ef3037aa5a7b3bc0a238cf040Pavel Chupin} 124af2cb3667ba24d1ef3037aa5a7b3bc0a238cf040Pavel Chupin 1256f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughesstatic void abuse_heap() { 1266f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughes char buf[16]; 1276f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughes free((void*) buf); // GCC is smart enough to warn about this, but we're doing it deliberately. 128af2cb3667ba24d1ef3037aa5a7b3bc0a238cf040Pavel Chupin} 129af2cb3667ba24d1ef3037aa5a7b3bc0a238cf040Pavel Chupin 1307b2078eeb4f68f3a81695de64ec8df003d3f8e3cBrigid Smithstatic void sigsegv_non_null() { 1317b2078eeb4f68f3a81695de64ec8df003d3f8e3cBrigid Smith int* a = (int *)(&do_action); 1327b2078eeb4f68f3a81695de64ec8df003d3f8e3cBrigid Smith *a = 42; 1337b2078eeb4f68f3a81695de64ec8df003d3f8e3cBrigid Smith} 1347b2078eeb4f68f3a81695de64ec8df003d3f8e3cBrigid Smith 1356f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughesstatic int do_action(const char* arg) 136aa4213057ba1723e4f164e54f80bb7621c3cb6b3Elliott Hughes{ 1373808c4ecb4c2d4f05261e6631a765464b055d8b1Elliott Hughes fprintf(stderr,"crasher: init pid=%d tid=%d\n", getpid(), gettid()); 1383808c4ecb4c2d4f05261e6631a765464b055d8b1Elliott Hughes 1393808c4ecb4c2d4f05261e6631a765464b055d8b1Elliott Hughes if (!strncmp(arg, "thread-", strlen("thread-"))) { 140aa4213057ba1723e4f164e54f80bb7621c3cb6b3Elliott Hughes return do_action_on_thread(arg + strlen("thread-")); 1417b2078eeb4f68f3a81695de64ec8df003d3f8e3cBrigid Smith } else if (!strcmp(arg, "SIGSEGV-non-null")) { 1427b2078eeb4f68f3a81695de64ec8df003d3f8e3cBrigid Smith sigsegv_non_null(); 143da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes } else if (!strcmp(arg, "smash-stack")) { 1442331b95609e3eb94494aebc9a59cab44d73df234Yabin Cui volatile int len = 128; 1452331b95609e3eb94494aebc9a59cab44d73df234Yabin Cui return smash_stack(&len); 146da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes } else if (!strcmp(arg, "stack-overflow")) { 1473808c4ecb4c2d4f05261e6631a765464b055d8b1Elliott Hughes overflow_stack(NULL); 148da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes } else if (!strcmp(arg, "nostack")) { 1493808c4ecb4c2d4f05261e6631a765464b055d8b1Elliott Hughes crashnostack(); 150da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes } else if (!strcmp(arg, "ctest")) { 1513808c4ecb4c2d4f05261e6631a765464b055d8b1Elliott Hughes return ctest(); 152da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes } else if (!strcmp(arg, "exit")) { 1533808c4ecb4c2d4f05261e6631a765464b055d8b1Elliott Hughes exit(1); 154855fcc3114c20ff9fd286fe1723d1413fec9685aElliott Hughes } else if (!strcmp(arg, "crash") || !strcmp(arg, "SIGSEGV")) { 1553808c4ecb4c2d4f05261e6631a765464b055d8b1Elliott Hughes return crash(42); 156da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes } else if (!strcmp(arg, "abort")) { 157da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes maybe_abort(); 158da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes } else if (!strcmp(arg, "assert")) { 159da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes __assert("some_file.c", 123, "false"); 160da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes } else if (!strcmp(arg, "assert2")) { 1613ecc42106ea4cf825a57859cfd58442442685d24Elliott Hughes __assert2("some_file.c", 123, "some_function", "false"); 162da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes } else if (!strcmp(arg, "LOG_ALWAYS_FATAL")) { 163da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes LOG_ALWAYS_FATAL("hello %s", "world"); 164da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes } else if (!strcmp(arg, "LOG_ALWAYS_FATAL_IF")) { 165da6b2e2fd79c9aac12127b2c2f512e9555fdd06dElliott Hughes LOG_ALWAYS_FATAL_IF(true, "hello %s", "world"); 1663ecc42106ea4cf825a57859cfd58442442685d24Elliott Hughes } else if (!strcmp(arg, "SIGFPE")) { 1673ecc42106ea4cf825a57859cfd58442442685d24Elliott Hughes raise(SIGFPE); 1683ecc42106ea4cf825a57859cfd58442442685d24Elliott Hughes return EXIT_SUCCESS; 1697e35ae8fc840cc1855d26084fdd72cbc3241f04dElliott Hughes } else if (!strcmp(arg, "SIGTRAP")) { 1707e35ae8fc840cc1855d26084fdd72cbc3241f04dElliott Hughes raise(SIGTRAP); 1717e35ae8fc840cc1855d26084fdd72cbc3241f04dElliott Hughes return EXIT_SUCCESS; 1726f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughes } else if (!strcmp(arg, "heap-usage")) { 1736f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughes abuse_heap(); 1748606eaa7700609a2f9f2383b954b4e64dbc4c827Brigid Smith } else if (!strcmp(arg, "SIGSEGV-unmapped")) { 1758606eaa7700609a2f9f2383b954b4e64dbc4c827Brigid Smith char* map = mmap(NULL, sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); 1768606eaa7700609a2f9f2383b954b4e64dbc4c827Brigid Smith munmap(map, sizeof(int)); 1778606eaa7700609a2f9f2383b954b4e64dbc4c827Brigid Smith map[0] = '8'; 178aa4213057ba1723e4f164e54f80bb7621c3cb6b3Elliott Hughes } 179aa4213057ba1723e4f164e54f80bb7621c3cb6b3Elliott Hughes 1803808c4ecb4c2d4f05261e6631a765464b055d8b1Elliott Hughes fprintf(stderr, "%s OP\n", __progname); 1813808c4ecb4c2d4f05261e6631a765464b055d8b1Elliott Hughes fprintf(stderr, "where OP is:\n"); 182855fcc3114c20ff9fd286fe1723d1413fec9685aElliott Hughes fprintf(stderr, " smash-stack overwrite a stack-guard canary\n"); 183855fcc3114c20ff9fd286fe1723d1413fec9685aElliott Hughes fprintf(stderr, " stack-overflow recurse until the stack overflows\n"); 184855fcc3114c20ff9fd286fe1723d1413fec9685aElliott Hughes fprintf(stderr, " heap-corruption cause a libc abort by corrupting the heap\n"); 185855fcc3114c20ff9fd286fe1723d1413fec9685aElliott Hughes fprintf(stderr, " heap-usage cause a libc abort by abusing a heap function\n"); 186855fcc3114c20ff9fd286fe1723d1413fec9685aElliott Hughes fprintf(stderr, " nostack crash with a NULL stack pointer\n"); 187855fcc3114c20ff9fd286fe1723d1413fec9685aElliott Hughes fprintf(stderr, " ctest (obsoleted by thread-crash?)\n"); 188855fcc3114c20ff9fd286fe1723d1413fec9685aElliott Hughes fprintf(stderr, " exit call exit(1)\n"); 189855fcc3114c20ff9fd286fe1723d1413fec9685aElliott Hughes fprintf(stderr, " abort call abort()\n"); 190855fcc3114c20ff9fd286fe1723d1413fec9685aElliott Hughes fprintf(stderr, " assert call assert() without a function\n"); 191855fcc3114c20ff9fd286fe1723d1413fec9685aElliott Hughes fprintf(stderr, " assert2 call assert() with a function\n"); 192855fcc3114c20ff9fd286fe1723d1413fec9685aElliott Hughes fprintf(stderr, " LOG_ALWAYS_FATAL call LOG_ALWAYS_FATAL\n"); 193855fcc3114c20ff9fd286fe1723d1413fec9685aElliott Hughes fprintf(stderr, " LOG_ALWAYS_FATAL_IF call LOG_ALWAYS_FATAL\n"); 1943ecc42106ea4cf825a57859cfd58442442685d24Elliott Hughes fprintf(stderr, " SIGFPE cause a SIGFPE\n"); 1957b2078eeb4f68f3a81695de64ec8df003d3f8e3cBrigid Smith fprintf(stderr, " SIGSEGV cause a SIGSEGV at address 0x0 (synonym: crash)\n"); 1967b2078eeb4f68f3a81695de64ec8df003d3f8e3cBrigid Smith fprintf(stderr, " SIGSEGV-non-null cause a SIGSEGV at a non-zero address\n"); 1978606eaa7700609a2f9f2383b954b4e64dbc4c827Brigid Smith fprintf(stderr, " SIGSEGV-unmapped mmap/munmap a region of memory and then attempt to access it\n"); 1987e35ae8fc840cc1855d26084fdd72cbc3241f04dElliott Hughes fprintf(stderr, " SIGTRAP cause a SIGTRAP\n"); 1993808c4ecb4c2d4f05261e6631a765464b055d8b1Elliott Hughes fprintf(stderr, "prefix any of the above with 'thread-' to not run\n"); 2003808c4ecb4c2d4f05261e6631a765464b055d8b1Elliott Hughes fprintf(stderr, "on the process' main thread.\n"); 2013808c4ecb4c2d4f05261e6631a765464b055d8b1Elliott Hughes return EXIT_SUCCESS; 202aa4213057ba1723e4f164e54f80bb7621c3cb6b3Elliott Hughes} 203dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project 204aa4213057ba1723e4f164e54f80bb7621c3cb6b3Elliott Hughesint main(int argc, char **argv) 205aa4213057ba1723e4f164e54f80bb7621c3cb6b3Elliott Hughes{ 206aa4213057ba1723e4f164e54f80bb7621c3cb6b3Elliott Hughes fprintf(stderr,"crasher: built at " __TIME__ "!@\n"); 207dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project 208dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project if(argc > 1) { 209aa4213057ba1723e4f164e54f80bb7621c3cb6b3Elliott Hughes return do_action(argv[1]); 210dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project } else { 211dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project crash1(); 212dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project } 213dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project 2146f40cafd9fe90fb83536c31d84273bf3572e5a32Elliott Hughes return 0; 215dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0The Android Open Source Project} 216