2 /* LTTng user-space tracing code
4 * Copyright 2006 Mathieu Desnoyers
21 #include <asm/atomic.h>
22 #include "lttng_usertrace.h"
29 atomic_t reserve_count
;
30 atomic_t commit_count
;
35 struct lttng_trace_info
{
38 struct ltt_buf facilities
;
44 /* TLS for the trace info */
45 /* http://www.dis.com/gnu/gcc/C--98-Thread-Local-Edits.html
47 * Add after paragraph 4
49 * The storage for an object of thread storage duration shall be statically
50 * initialized before the first statement of the thread startup function. An
51 * object of thread storage duration shall not require dynamic
53 * GCC extention permits init of a range.
56 static __thread
struct lttng_trace_info lttng_trace_info
[MAX_TRACES
] =
57 { [ 0 ... MAX_TRACES
-1 ].active
= 0,
58 [ 0 ... MAX_TRACES
-1 ].channel
=
69 void __lttng_sig_trace_handler(int signo
)
74 printf("LTTng signal handler : thread id : %lu, pid %lu\n", pthread_self(), getpid());
77 ret
= sigfillset(&set
);
79 printf("Error in sigfillset\n");
83 ret
= sigprocmask(SIG_BLOCK
, &set
, &oldset
);
85 printf("Error in sigprocmask\n");
89 /* Get all the new traces */
92 /* FIXME : allocate the trace structure somewhere : thread private */
93 ret
= ltt_update(addr
, &active
, &filter
);
96 printf("Error in ltt_update system call\n");
105 ret
= sigprocmask(SIG_SETMASK
, &oldset
, NULL
);
107 printf("Error in sigprocmask\n");
114 static void thread_init(void)
119 err
= ltt_switch((unsigned long)NULL
);
121 printf("Error in ltt_switch system call\n");
125 /* Make the first ltt_update system call */
126 err
= ltt_update(1, NULL
, NULL
);
128 printf("Error in ltt_update system call\n");
132 /* Make some ltt_switch syscalls */
133 err
= ltt_switch((unsigned long)NULL
);
135 printf("Error in ltt_switch system call\n");
140 void __attribute__((constructor
)) __lttng_user_init(void)
142 static struct sigaction act
;
145 printf("LTTng user init\n");
147 /* Activate the signal */
148 act
.sa_handler
= __lttng_sig_trace_handler
;
149 err
= sigemptyset(&(act
.sa_mask
));
150 if(err
) perror("Error with sigemptyset");
151 err
= sigaddset(&(act
.sa_mask
), SIGRTMIN
+3);
152 if(err
) perror("Error with sigaddset");
153 err
= sigaction(SIGRTMIN
+3, &act
, NULL
);
154 if(err
) perror("Error with sigaction");
160 void lttng_thread_init(void)