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) {
printf("Error in sigprocmask\n");
exit(1);
}
-
+#endif //0
/* Get all the new traces */
#if 0
do {
} 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(<tng_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) {
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();
}
+
+
+
+
+
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)
void *thr1(void *arg)
{
+ lttng_thread_init();
printf("thread 1, thread id : %lu, pid %lu\n", pthread_self(), getpid());
while(1) {}
void *thr2(void *arg)
{
+ lttng_thread_init();
+
while(1) {
printf("thread 2, thread id : %lu, pid %lu\n", pthread_self(), getpid());
sleep(2);
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);