aboutsummaryrefslogtreecommitdiffstats
path: root/debuggerd/crasher.c
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-03 18:29:04 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-03 18:29:04 -0800
commite54eebbf1a908d65ee8cf80bab62821c05666d70 (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /debuggerd/crasher.c
parenta1e1c1b106423de09bc918502e7a51d4ffe5a4ae (diff)
downloadsystem_core-e54eebbf1a908d65ee8cf80bab62821c05666d70.tar.gz
system_core-e54eebbf1a908d65ee8cf80bab62821c05666d70.tar.bz2
system_core-e54eebbf1a908d65ee8cf80bab62821c05666d70.zip
auto import from //depot/cupcake/@135843
Diffstat (limited to 'debuggerd/crasher.c')
-rw-r--r--debuggerd/crasher.c105
1 files changed, 0 insertions, 105 deletions
diff --git a/debuggerd/crasher.c b/debuggerd/crasher.c
deleted file mode 100644
index f4a5a62b..00000000
--- a/debuggerd/crasher.c
+++ /dev/null
@@ -1,105 +0,0 @@
-
-//#include <cutils/misc.h>
-
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sched.h>
-#include <errno.h>
-
-#include <signal.h>
-#include <sys/ptrace.h>
-#include <sys/wait.h>
-#include <sys/socket.h>
-
-#include <pthread.h>
-
-#include <cutils/sockets.h>
-
-void crash1(void);
-void crashnostack(void);
-
-static void debuggerd_connect()
-{
- char tmp[1];
- int s;
- sprintf(tmp, "%d", gettid());
- s = socket_local_client("android:debuggerd",
- ANDROID_SOCKET_NAMESPACE_ABSTRACT, SOCK_STREAM);
- if(s >= 0) {
- read(s, tmp, 1);
- close(s);
- }
-}
-
-void test_call1()
-{
- *((int*) 32) = 1;
-}
-
-void *test_thread(void *x)
-{
- printf("crasher: thread pid=%d tid=%d\n", getpid(), gettid());
-
- sleep(1);
- test_call1();
- printf("goodbye\n");
-
- return 0;
-}
-
-void *noisy(void *x)
-{
- char c = (unsigned) x;
- for(;;) {
- usleep(250*1000);
- write(2, &c, 1);
- if(c == 'C') *((unsigned*) 0) = 42;
- }
- return 0;
-}
-
-int ctest()
-{
- pthread_t thr;
- pthread_attr_t attr;
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- pthread_create(&thr, &attr, noisy, (void*) 'A');
- pthread_create(&thr, &attr, noisy, (void*) 'B');
- pthread_create(&thr, &attr, noisy, (void*) 'C');
- for(;;) ;
- return 0;
-}
-
-int main(int argc, char **argv)
-{
- pthread_t thr;
- pthread_attr_t attr;
-
- fprintf(stderr,"crasher: " __TIME__ "!@\n");
- fprintf(stderr,"crasher: init pid=%d tid=%d\n", getpid(), gettid());
-
- if(argc > 1) {
- if(!strcmp(argv[1],"nostack")) crashnostack();
- if(!strcmp(argv[1],"ctest")) return ctest();
- if(!strcmp(argv[1],"exit")) exit(1);
- if(!strcmp(argv[1],"abort")) maybeabort();
-
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- pthread_create(&thr, &attr, test_thread, 0);
- while(1) sleep(1);
- } else {
- crash1();
-// *((int*) 0) = 42;
- }
-
- return 0;
-}
-
-void maybeabort()
-{
- if(time(0) != 42) abort();
-}