signals ok
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 26 Jan 2006 22:32:41 +0000 (22:32 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 26 Jan 2006 22:32:41 +0000 (22:32 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1497 04897980-b3bd-0310-b5e0-8ef037075253

usertrace/lttng_usertrace.c
usertrace/lttng_usertrace.h
usertrace/test.c

index 7f1039f44eb01e7c8909e7ec8cccd26fba495bc4..51204181d33a4eff2669347f464ff15e73663216 100644 (file)
@@ -71,8 +71,8 @@ void __lttng_sig_trace_handler(int signo)
        int ret;
        sigset_t set, oldset;
        
-  printf("LTTng Sig handler : pid : %lu\n", getpid());
-
+  printf("LTTng signal handler : thread id : %lu, pid %lu\n", pthread_self(), getpid());
+#if 0
        /* Disable signals */
        ret = sigfillset(&set);
        if(ret) {
@@ -85,7 +85,7 @@ void __lttng_sig_trace_handler(int signo)
                printf("Error in sigprocmask\n");
                exit(1);
        }
-       
+#endif //0
        /* Get all the new traces */
 #if 0
        do {
@@ -99,40 +99,22 @@ void __lttng_sig_trace_handler(int signo)
        } while(addr);
                
 #endif //0
+
+#if 0
        /* Enable signals */
        ret = sigprocmask(SIG_SETMASK, &oldset, NULL);
        if(ret) {
                printf("Error in sigprocmask\n");
                exit(1);
        }
-       
+#endif //0
 }
 
 
-void __lttng_init_trace_info(void)
-{
-       memset(&lttng_trace_info, 0, MAX_TRACES*sizeof(struct lttng_trace_info));
-}
-
-void __attribute__((constructor)) __lttng_user_init(void)
+static void thread_init(void)
 {
-       static struct sigaction act;
        int err;
 
-  printf("LTTng user init\n");
-
-       /* Init trace info */
-       __lttng_init_trace_info();
-       
-       /* Activate the signal */
-       act.sa_handler = __lttng_sig_trace_handler;
-       err = sigemptyset(&(act.sa_mask));
-       if(err) perror("Error with sigemptyset");
-       err = sigaddset(&(act.sa_mask), SIGRTMIN+3);
-       if(err) perror("Error with sigaddset");
-       err = sigaction(SIGRTMIN+3, &act, NULL);
-       if(err) perror("Error with sigaction");
-
        /* TEST */
        err = ltt_switch((unsigned long)NULL);
        if(err) {
@@ -153,7 +135,34 @@ void __attribute__((constructor)) __lttng_user_init(void)
                printf("Error in ltt_switch system call\n");
                exit(1);
        }
+}
+
+void __attribute__((constructor)) __lttng_user_init(void)
+{
+       static struct sigaction act;
+       int err;
+
+  printf("LTTng user init\n");
+
+       /* Activate the signal */
+       act.sa_handler = __lttng_sig_trace_handler;
+       err = sigemptyset(&(act.sa_mask));
+       if(err) perror("Error with sigemptyset");
+       err = sigaddset(&(act.sa_mask), SIGRTMIN+3);
+       if(err) perror("Error with sigaddset");
+       err = sigaction(SIGRTMIN+3, &act, NULL);
+       if(err) perror("Error with sigaction");
 
+       thread_init();
+}
 
 
+void lttng_thread_init(void)
+{
+       thread_init();
 }
+
+
+
+
+
index b4aa8f3b6ed74a38a5c9110a6f2e1703ef24ac48..944e8a0f51e1e548544145c74eb53599395aba19 100644 (file)
@@ -26,6 +26,9 @@
 
 void __lttng_sig_trace_handler(int signo);
 
+/* Call this at the beginning of a new thread, except for the main() */
+void lttng_thread_init(void);
+
 static inline _syscall1(int, ltt_switch, unsigned long, addr)
 static inline _syscall3(int, ltt_update, unsigned long, addr, int *, active, int *, filter)
 
index 9c772973f64842b260baf6e8be3b22de998a44d2..a0509a277bfc63561e004d34d8973519ba8dc842 100644 (file)
@@ -10,6 +10,7 @@
 
 void *thr1(void *arg)
 {
+       lttng_thread_init();
   printf("thread 1, thread id : %lu, pid %lu\n", pthread_self(), getpid());
 
   while(1) {}
@@ -20,6 +21,8 @@ void *thr1(void *arg)
 
 void *thr2(void *arg)
 {
+       lttng_thread_init();
+
   while(1) {
     printf("thread 2, thread id : %lu, pid %lu\n", pthread_self(), getpid());
     sleep(2);
@@ -34,6 +37,7 @@ int main()
        pthread_t tid1, tid2;
        void *tret;
 
+  printf("thread main, thread id : %lu, pid %lu\n", pthread_self(), getpid());
   err = pthread_create(&tid1, NULL, thr1, NULL);
   if(err!=0) exit(1);
 
This page took 0.041703 seconds and 4 git commands to generate.