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 Sig handler : pid : %lu\n", 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");
103 ret
= sigprocmask(SIG_SETMASK
, &oldset
, NULL
);
105 printf("Error in sigprocmask\n");
112 void __lttng_init_trace_info(void)
114 memset(<tng_trace_info
, 0, MAX_TRACES
*sizeof(struct lttng_trace_info
));
117 void __attribute__((constructor
)) __lttng_user_init(void)
119 static struct sigaction act
;
122 printf("LTTng user init\n");
124 /* Init trace info */
125 __lttng_init_trace_info();
127 /* Activate the signal */
128 act
.sa_handler
= __lttng_sig_trace_handler
;
129 err
= sigemptyset(&(act
.sa_mask
));
130 if(err
) perror("Error with sigemptyset");
131 err
= sigaddset(&(act
.sa_mask
), SIGRTMIN
+3);
132 if(err
) perror("Error with sigaddset");
133 err
= sigaction(SIGRTMIN
+3, &act
, NULL
);
134 if(err
) perror("Error with sigaction");
137 err
= ltt_switch((unsigned long)NULL
);
139 printf("Error in ltt_switch system call\n");
143 /* Make the first ltt_update system call */
144 err
= ltt_update(1, NULL
, NULL
);
146 printf("Error in ltt_update system call\n");
150 /* Make some ltt_switch syscalls */
151 err
= ltt_switch((unsigned long)NULL
);
153 printf("Error in ltt_switch system call\n");