1 #ifndef _LTT_FACILITY_USER_GENERIC_H_
2 #define _LTT_FACILITY_USER_GENERIC_H_
5 #include <ltt/ltt-facility-id-user_generic.h>
6 #include <ltt/ltt-generic.h>
10 /* Event string structures */
11 static inline void lttng_write_string_user_generic_string_data(
22 /* Flush pending memcpy */
25 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
33 *to
+= ltt_align(*to
, align
); /* align output */
35 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
38 /* Contains variable sized fields : must explode the structure */
40 size
= strlen(obj
) + 1; /* Include final NULL char. */
42 memcpy(buffer
+*to_base
+*to
, obj
, size
);
45 /* Realign the *to_base on arch size, set *to to 0 */
46 *to
+= ltt_align(*to
, sizeof(void *));
47 *to_base
= *to_base
+*to
;
50 /* Put source *from just after the C string */
55 /* Event string logging function */
56 static inline int trace_user_generic_string(
57 const char * lttng_param_data
)
65 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
66 size_t *to_base
= &real_to_base
;
68 size_t *to
= &real_to
;
70 size_t *len
= &real_len
;
73 const void *real_from
;
74 const void **from
= &real_from
;
75 /* For each field, calculate the field size. */
76 /* size = *to_base + *to + *len */
77 /* Assume that the padding for alignment starts at a
78 * sizeof(void *) address. */
80 *from
= lttng_param_data
;
81 lttng_write_string_user_generic_string_data(buffer
, to_base
, to
, from
, len
, lttng_param_data
);
83 reserve_size
= *to_base
+ *to
+ *len
;
85 char stack_buffer
[reserve_size
];
86 buffer
= stack_buffer
;
88 *to_base
= *to
= *len
= 0;
90 *from
= lttng_param_data
;
91 lttng_write_string_user_generic_string_data(buffer
, to_base
, to
, from
, len
, lttng_param_data
);
93 /* Flush pending memcpy */
95 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
100 ret
= ltt_trace_generic(ltt_facility_user_generic_F583779E
, event_user_generic_string
, buffer
, reserve_size
, LTT_BLOCKING
);
108 /* Event string_pointer structures */
109 static inline void lttng_write_string_user_generic_string_pointer_string(
120 /* Flush pending memcpy */
123 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
128 align
= sizeof(char);
131 *to
+= ltt_align(*to
, align
); /* align output */
133 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
136 /* Contains variable sized fields : must explode the structure */
138 size
= strlen(obj
) + 1; /* Include final NULL char. */
140 memcpy(buffer
+*to_base
+*to
, obj
, size
);
143 /* Realign the *to_base on arch size, set *to to 0 */
144 *to
+= ltt_align(*to
, sizeof(void *));
145 *to_base
= *to_base
+*to
;
148 /* Put source *from just after the C string */
153 /* Event string_pointer logging function */
154 static inline int trace_user_generic_string_pointer(
155 const char * lttng_param_string
,
156 const void * lttng_param_pointer
)
164 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
165 size_t *to_base
= &real_to_base
;
167 size_t *to
= &real_to
;
169 size_t *len
= &real_len
;
173 const void *real_from
;
174 const void **from
= &real_from
;
175 /* For each field, calculate the field size. */
176 /* size = *to_base + *to + *len */
177 /* Assume that the padding for alignment starts at a
178 * sizeof(void *) address. */
180 *from
= lttng_param_string
;
181 lttng_write_string_user_generic_string_pointer_string(buffer
, to_base
, to
, from
, len
, lttng_param_string
);
183 *from
= <tng_param_pointer
;
184 align
= sizeof(const void *);
187 *to
+= ltt_align(*to
, align
); /* align output */
189 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
192 *len
+= sizeof(const void *);
194 reserve_size
= *to_base
+ *to
+ *len
;
196 char stack_buffer
[reserve_size
];
197 buffer
= stack_buffer
;
199 *to_base
= *to
= *len
= 0;
201 *from
= lttng_param_string
;
202 lttng_write_string_user_generic_string_pointer_string(buffer
, to_base
, to
, from
, len
, lttng_param_string
);
204 /* Flush pending memcpy */
206 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
211 *from
= <tng_param_pointer
;
212 align
= sizeof(const void *);
215 *to
+= ltt_align(*to
, align
); /* align output */
217 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
220 *len
+= sizeof(const void *);
222 /* Flush pending memcpy */
224 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
229 ret
= ltt_trace_generic(ltt_facility_user_generic_F583779E
, event_user_generic_string_pointer
, buffer
, reserve_size
, LTT_BLOCKING
);
237 /* Event slow_printf structures */
238 static inline void lttng_write_string_user_generic_slow_printf_string(
249 /* Flush pending memcpy */
252 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
257 align
= sizeof(char);
260 *to
+= ltt_align(*to
, align
); /* align output */
262 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
265 /* Contains variable sized fields : must explode the structure */
267 size
= strlen(obj
) + 1; /* Include final NULL char. */
269 memcpy(buffer
+*to_base
+*to
, obj
, size
);
272 /* Realign the *to_base on arch size, set *to to 0 */
273 *to
+= ltt_align(*to
, sizeof(void *));
274 *to_base
= *to_base
+*to
;
277 /* Put source *from just after the C string */
282 /* Event slow_printf logging function */
283 static inline int trace_user_generic_slow_printf_param_buffer(
292 reserve_size
= ltt_align(reserve_size
, sizeof(void *));
294 ret
= ltt_trace_generic(ltt_facility_user_generic_F583779E
, event_user_generic_slow_printf
, buffer
, reserve_size
, LTT_BLOCKING
);
302 /* Event function_entry structures */
304 /* Event function_entry logging function */
305 static inline __attribute__((no_instrument_function
)) int trace_user_generic_function_entry(
306 const void * lttng_param_this_fn
,
307 const void * lttng_param_call_site
)
315 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
316 size_t *to_base
= &real_to_base
;
318 size_t *to
= &real_to
;
320 size_t *len
= &real_len
;
324 const void *real_from
;
325 const void **from
= &real_from
;
326 /* For each field, calculate the field size. */
327 /* size = *to_base + *to + *len */
328 /* Assume that the padding for alignment starts at a
329 * sizeof(void *) address. */
331 *from
= <tng_param_this_fn
;
332 align
= sizeof(const void *);
335 *to
+= ltt_align(*to
, align
); /* align output */
337 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
340 *len
+= sizeof(const void *);
342 *from
= <tng_param_call_site
;
343 align
= sizeof(const void *);
346 *to
+= ltt_align(*to
, align
); /* align output */
348 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
351 *len
+= sizeof(const void *);
353 reserve_size
= *to_base
+ *to
+ *len
;
355 char stack_buffer
[reserve_size
];
356 buffer
= stack_buffer
;
358 *to_base
= *to
= *len
= 0;
360 *from
= <tng_param_this_fn
;
361 align
= sizeof(const void *);
364 *to
+= ltt_align(*to
, align
); /* align output */
366 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
369 *len
+= sizeof(const void *);
371 /* Flush pending memcpy */
373 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
378 *from
= <tng_param_call_site
;
379 align
= sizeof(const void *);
382 *to
+= ltt_align(*to
, align
); /* align output */
384 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
387 *len
+= sizeof(const void *);
389 /* Flush pending memcpy */
391 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
396 ret
= ltt_trace_generic(ltt_facility_user_generic_F583779E
, event_user_generic_function_entry
, buffer
, reserve_size
, LTT_BLOCKING
);
404 /* Event function_exit structures */
406 /* Event function_exit logging function */
407 static inline __attribute__((no_instrument_function
)) int trace_user_generic_function_exit(
408 const void * lttng_param_this_fn
,
409 const void * lttng_param_call_site
)
417 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
418 size_t *to_base
= &real_to_base
;
420 size_t *to
= &real_to
;
422 size_t *len
= &real_len
;
426 const void *real_from
;
427 const void **from
= &real_from
;
428 /* For each field, calculate the field size. */
429 /* size = *to_base + *to + *len */
430 /* Assume that the padding for alignment starts at a
431 * sizeof(void *) address. */
433 *from
= <tng_param_this_fn
;
434 align
= sizeof(const void *);
437 *to
+= ltt_align(*to
, align
); /* align output */
439 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
442 *len
+= sizeof(const void *);
444 *from
= <tng_param_call_site
;
445 align
= sizeof(const void *);
448 *to
+= ltt_align(*to
, align
); /* align output */
450 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
453 *len
+= sizeof(const void *);
455 reserve_size
= *to_base
+ *to
+ *len
;
457 char stack_buffer
[reserve_size
];
458 buffer
= stack_buffer
;
460 *to_base
= *to
= *len
= 0;
462 *from
= <tng_param_this_fn
;
463 align
= sizeof(const void *);
466 *to
+= ltt_align(*to
, align
); /* align output */
468 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
471 *len
+= sizeof(const void *);
473 /* Flush pending memcpy */
475 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
480 *from
= <tng_param_call_site
;
481 align
= sizeof(const void *);
484 *to
+= ltt_align(*to
, align
); /* align output */
486 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
489 *len
+= sizeof(const void *);
491 /* Flush pending memcpy */
493 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
498 ret
= ltt_trace_generic(ltt_facility_user_generic_F583779E
, event_user_generic_function_exit
, buffer
, reserve_size
, LTT_BLOCKING
);
506 #endif //_LTT_FACILITY_USER_GENERIC_H_