b09f3215 |
1 | |
04180f7f |
2 | /* LTTng user-space "fast" tracing code |
b09f3215 |
3 | * |
4 | * Copyright 2006 Mathieu Desnoyers |
5 | * |
6 | */ |
7 | |
8 | |
9 | #include <sys/types.h> |
10 | #include <sys/wait.h> |
11 | #include <unistd.h> |
12 | #include <stdlib.h> |
13 | #include <stdio.h> |
14 | #include <signal.h> |
15 | #include <syscall.h> |
16 | #include <features.h> |
17 | #include <pthread.h> |
18 | #include <malloc.h> |
19 | #include <string.h> |
20 | |
1c48e587 |
21 | #include "ltt-usertrace-fast.h" |
b09f3215 |
22 | |
51bf1553 |
23 | /* TLS for the trace buffer |
b09f3215 |
24 | * http://www.dis.com/gnu/gcc/C--98-Thread-Local-Edits.html |
25 | * |
26 | * Add after paragraph 4 |
27 | * |
28 | * The storage for an object of thread storage duration shall be statically |
29 | * initialized before the first statement of the thread startup function. An |
30 | * object of thread storage duration shall not require dynamic |
31 | * initialization. |
b09f3215 |
32 | */ |
33 | |
51bf1553 |
34 | __thread struct lttng_trace_info lttng_trace_info = |
35 | { |
36 | .init = 0, |
37 | .filter = 0, |
38 | .nesting = ATOMIC_INIT(0), |
39 | .channel.facilities = |
40 | { ATOMIC_INIT(0), |
b09f3215 |
41 | ATOMIC_INIT(0), |
42 | ATOMIC_INIT(0), |
51bf1553 |
43 | ATOMIC_INIT(0) |
44 | }, |
45 | .channel.cpu = |
46 | { ATOMIC_INIT(0), |
b09f3215 |
47 | ATOMIC_INIT(0), |
48 | ATOMIC_INIT(0), |
49 | ATOMIC_INIT(0) |
51bf1553 |
50 | }, |
b09f3215 |
51 | }; |
52 | |
53 | |
51bf1553 |
54 | static void ltt_cleanup_thread(void *arg) |
b09f3215 |
55 | { |
51bf1553 |
56 | /* Flush the data in the lttng_trace_info */ |
b09f3215 |
57 | |
b09f3215 |
58 | } |
59 | |
60 | |
51bf1553 |
61 | void ltt_thread_init(void) |
b09f3215 |
62 | { |
51bf1553 |
63 | _pthread_cleanup_push(<tng_trace_info.cleanup, |
64 | ltt_cleanup_thread, NULL); |
b09f3215 |
65 | } |
66 | |
67 | |
04180f7f |
68 | void __attribute__((constructor)) __ltt_usertrace_fast_init(void) |
b09f3215 |
69 | { |
b09f3215 |
70 | int err; |
71 | |
51bf1553 |
72 | printf("LTTng usertrace-fast init\n"); |
b09f3215 |
73 | |
1c48e587 |
74 | ltt_thread_init(); |
b09f3215 |
75 | |
b09f3215 |
76 | } |
77 | |