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-usertrace.h>
14 /* Event string structures */
15 static inline void lttng_write_string_user_generic_string_data(
26 /* Flush pending memcpy */
29 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
37 *to
+= ltt_align(*to
, align
); /* align output */
39 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
42 /* Contains variable sized fields : must explode the structure */
44 size
= strlen(obj
) + 1; /* Include final NULL char. */
46 memcpy(buffer
+*to_base
+*to
, obj
, size
);
49 /* Realign the *to_base on arch size, set *to to 0 */
50 *to
+= ltt_align(*to
, sizeof(void *));
51 *to_base
= *to_base
+*to
;
54 /* Put source *from just after the C string */
59 /* Event string logging function */
60 static inline int trace_user_generic_string(
61 const char * lttng_param_data
);
63 #ifndef LTT_TRACE_FAST
64 static inline int trace_user_generic_string(
65 const char * lttng_param_data
)
73 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
74 size_t *to_base
= &real_to_base
;
76 size_t *to
= &real_to
;
78 size_t *len
= &real_len
;
81 const char *real_from
;
82 const char **from
= &real_from
;
83 /* For each field, calculate the field size. */
84 /* size = *to_base + *to + *len */
85 /* Assume that the padding for alignment starts at a
86 * sizeof(void *) address. */
88 *from
= (const char*)lttng_param_data
;
89 lttng_write_string_user_generic_string_data(buffer
, to_base
, to
, from
, len
, lttng_param_data
);
91 reserve_size
= *to_base
+ *to
+ *len
;
93 char stack_buffer
[reserve_size
];
94 buffer
= stack_buffer
;
96 *to_base
= *to
= *len
= 0;
98 *from
= (const char*)lttng_param_data
;
99 lttng_write_string_user_generic_string_data(buffer
, to_base
, to
, from
, len
, lttng_param_data
);
101 /* Flush pending memcpy */
103 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
108 ret
= ltt_trace_generic(ltt_facility_user_generic_B1865E44
, event_user_generic_string
, buffer
, reserve_size
, LTT_BLOCKING
, 0);
115 #endif //!LTT_TRACE_FAST
117 #ifdef LTT_TRACE_FAST
118 static inline int trace_user_generic_string(
119 const char * lttng_param_data
)
126 struct ltt_trace_info
*trace
= thread_trace_info
;
127 struct ltt_buf
*ltt_buf
;
129 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
130 size_t *to_base
= &real_to_base
;
132 size_t *to
= &real_to
;
134 size_t *len
= &real_len
;
137 const char *real_from
;
138 const char **from
= &real_from
;
140 size_t before_hdr_pad
, after_hdr_pad
, header_size
;
144 trace
= thread_trace_info
;
148 /* For each field, calculate the field size. */
149 /* size = *to_base + *to + *len */
150 /* Assume that the padding for alignment starts at a
151 * sizeof(void *) address. */
153 *from
= (const char*)lttng_param_data
;
154 lttng_write_string_user_generic_string_data(buffer
, to_base
, to
, from
, len
, lttng_param_data
);
156 reserve_size
= *to_base
+ *to
+ *len
;
158 index
= ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44
,
159 event_user_generic_string
);
162 ltt_buf
= ltt_get_channel_from_index(trace
, index
);
164 buffer
= ltt_reserve_slot(trace
, ltt_buf
,
165 reserve_size
, &slot_size
, &tsc
,
166 &before_hdr_pad
, &after_hdr_pad
, &header_size
);
167 if(!buffer
) goto end
; /* buffer full */
169 *to_base
= *to
= *len
= 0;
171 ltt_write_event_header(trace
, ltt_buf
, buffer
,
172 ltt_facility_user_generic_B1865E44
, event_user_generic_string
,
173 reserve_size
, before_hdr_pad
, tsc
);
174 *to_base
+= before_hdr_pad
+ after_hdr_pad
+ header_size
;
176 *from
= (const char*)lttng_param_data
;
177 lttng_write_string_user_generic_string_data(buffer
, to_base
, to
, from
, len
, lttng_param_data
);
179 /* Flush pending memcpy */
181 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
186 ltt_commit_slot(ltt_buf
, buffer
, slot_size
);
194 #endif //LTT_TRACE_FAST
196 /* Event string_pointer structures */
197 static inline void lttng_write_string_user_generic_string_pointer_string(
208 /* Flush pending memcpy */
211 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
216 align
= sizeof(char);
219 *to
+= ltt_align(*to
, align
); /* align output */
221 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
224 /* Contains variable sized fields : must explode the structure */
226 size
= strlen(obj
) + 1; /* Include final NULL char. */
228 memcpy(buffer
+*to_base
+*to
, obj
, size
);
231 /* Realign the *to_base on arch size, set *to to 0 */
232 *to
+= ltt_align(*to
, sizeof(void *));
233 *to_base
= *to_base
+*to
;
236 /* Put source *from just after the C string */
241 /* Event string_pointer logging function */
242 static inline int trace_user_generic_string_pointer(
243 const char * lttng_param_string
,
244 const void * lttng_param_pointer
);
246 #ifndef LTT_TRACE_FAST
247 static inline int trace_user_generic_string_pointer(
248 const char * lttng_param_string
,
249 const void * lttng_param_pointer
)
257 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
258 size_t *to_base
= &real_to_base
;
260 size_t *to
= &real_to
;
262 size_t *len
= &real_len
;
266 const char *real_from
;
267 const char **from
= &real_from
;
268 /* For each field, calculate the field size. */
269 /* size = *to_base + *to + *len */
270 /* Assume that the padding for alignment starts at a
271 * sizeof(void *) address. */
273 *from
= (const char*)lttng_param_string
;
274 lttng_write_string_user_generic_string_pointer_string(buffer
, to_base
, to
, from
, len
, lttng_param_string
);
276 *from
= (const char*)<tng_param_pointer
;
277 align
= sizeof(const void *);
280 *to
+= ltt_align(*to
, align
); /* align output */
282 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
285 *len
+= sizeof(const void *);
287 reserve_size
= *to_base
+ *to
+ *len
;
289 char stack_buffer
[reserve_size
];
290 buffer
= stack_buffer
;
292 *to_base
= *to
= *len
= 0;
294 *from
= (const char*)lttng_param_string
;
295 lttng_write_string_user_generic_string_pointer_string(buffer
, to_base
, to
, from
, len
, lttng_param_string
);
297 /* Flush pending memcpy */
299 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
304 *from
= (const char*)<tng_param_pointer
;
305 align
= sizeof(const void *);
308 *to
+= ltt_align(*to
, align
); /* align output */
310 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
313 *len
+= sizeof(const void *);
315 /* Flush pending memcpy */
317 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
322 ret
= ltt_trace_generic(ltt_facility_user_generic_B1865E44
, event_user_generic_string_pointer
, buffer
, reserve_size
, LTT_BLOCKING
, 0);
329 #endif //!LTT_TRACE_FAST
331 #ifdef LTT_TRACE_FAST
332 static inline int trace_user_generic_string_pointer(
333 const char * lttng_param_string
,
334 const void * lttng_param_pointer
)
341 struct ltt_trace_info
*trace
= thread_trace_info
;
342 struct ltt_buf
*ltt_buf
;
344 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
345 size_t *to_base
= &real_to_base
;
347 size_t *to
= &real_to
;
349 size_t *len
= &real_len
;
353 const char *real_from
;
354 const char **from
= &real_from
;
356 size_t before_hdr_pad
, after_hdr_pad
, header_size
;
360 trace
= thread_trace_info
;
364 /* For each field, calculate the field size. */
365 /* size = *to_base + *to + *len */
366 /* Assume that the padding for alignment starts at a
367 * sizeof(void *) address. */
369 *from
= (const char*)lttng_param_string
;
370 lttng_write_string_user_generic_string_pointer_string(buffer
, to_base
, to
, from
, len
, lttng_param_string
);
372 *from
= (const char*)<tng_param_pointer
;
373 align
= sizeof(const void *);
376 *to
+= ltt_align(*to
, align
); /* align output */
378 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
381 *len
+= sizeof(const void *);
383 reserve_size
= *to_base
+ *to
+ *len
;
385 index
= ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44
,
386 event_user_generic_string_pointer
);
389 ltt_buf
= ltt_get_channel_from_index(trace
, index
);
391 buffer
= ltt_reserve_slot(trace
, ltt_buf
,
392 reserve_size
, &slot_size
, &tsc
,
393 &before_hdr_pad
, &after_hdr_pad
, &header_size
);
394 if(!buffer
) goto end
; /* buffer full */
396 *to_base
= *to
= *len
= 0;
398 ltt_write_event_header(trace
, ltt_buf
, buffer
,
399 ltt_facility_user_generic_B1865E44
, event_user_generic_string_pointer
,
400 reserve_size
, before_hdr_pad
, tsc
);
401 *to_base
+= before_hdr_pad
+ after_hdr_pad
+ header_size
;
403 *from
= (const char*)lttng_param_string
;
404 lttng_write_string_user_generic_string_pointer_string(buffer
, to_base
, to
, from
, len
, lttng_param_string
);
406 /* Flush pending memcpy */
408 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
413 *from
= (const char*)<tng_param_pointer
;
414 align
= sizeof(const void *);
417 *to
+= ltt_align(*to
, align
); /* align output */
419 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
422 *len
+= sizeof(const void *);
424 /* Flush pending memcpy */
426 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
431 ltt_commit_slot(ltt_buf
, buffer
, slot_size
);
439 #endif //LTT_TRACE_FAST
441 /* Event slow_printf structures */
442 static inline void lttng_write_string_user_generic_slow_printf_string(
453 /* Flush pending memcpy */
456 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
461 align
= sizeof(char);
464 *to
+= ltt_align(*to
, align
); /* align output */
466 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
469 /* Contains variable sized fields : must explode the structure */
471 size
= strlen(obj
) + 1; /* Include final NULL char. */
473 memcpy(buffer
+*to_base
+*to
, obj
, size
);
476 /* Realign the *to_base on arch size, set *to to 0 */
477 *to
+= ltt_align(*to
, sizeof(void *));
478 *to_base
= *to_base
+*to
;
481 /* Put source *from just after the C string */
486 /* Event slow_printf logging function */
487 static inline int trace_user_generic_slow_printf_param_buffer(
489 size_t reserve_size
);
491 #ifndef LTT_TRACE_FAST
492 static inline int trace_user_generic_slow_printf_param_buffer(
502 ret
= ltt_trace_generic(ltt_facility_user_generic_B1865E44
, event_user_generic_slow_printf
, buffer
, reserve_size
, LTT_BLOCKING
, 0);
509 #endif //!LTT_TRACE_FAST
511 #ifdef LTT_TRACE_FAST
512 static inline int trace_user_generic_slow_printf(
513 const char * lttng_param_string
)
520 struct ltt_trace_info
*trace
= thread_trace_info
;
521 struct ltt_buf
*ltt_buf
;
523 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
524 size_t *to_base
= &real_to_base
;
526 size_t *to
= &real_to
;
528 size_t *len
= &real_len
;
531 const char *real_from
;
532 const char **from
= &real_from
;
534 size_t before_hdr_pad
, after_hdr_pad
, header_size
;
538 trace
= thread_trace_info
;
542 /* For each field, calculate the field size. */
543 /* size = *to_base + *to + *len */
544 /* Assume that the padding for alignment starts at a
545 * sizeof(void *) address. */
547 *from
= (const char*)lttng_param_string
;
548 lttng_write_string_user_generic_slow_printf_string(buffer
, to_base
, to
, from
, len
, lttng_param_string
);
550 reserve_size
= *to_base
+ *to
+ *len
;
552 index
= ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44
,
553 event_user_generic_slow_printf
);
556 ltt_buf
= ltt_get_channel_from_index(trace
, index
);
558 buffer
= ltt_reserve_slot(trace
, ltt_buf
,
559 reserve_size
, &slot_size
, &tsc
,
560 &before_hdr_pad
, &after_hdr_pad
, &header_size
);
561 if(!buffer
) goto end
; /* buffer full */
563 *to_base
= *to
= *len
= 0;
565 ltt_write_event_header(trace
, ltt_buf
, buffer
,
566 ltt_facility_user_generic_B1865E44
, event_user_generic_slow_printf
,
567 reserve_size
, before_hdr_pad
, tsc
);
568 *to_base
+= before_hdr_pad
+ after_hdr_pad
+ header_size
;
570 *from
= (const char*)lttng_param_string
;
571 lttng_write_string_user_generic_slow_printf_string(buffer
, to_base
, to
, from
, len
, lttng_param_string
);
573 /* Flush pending memcpy */
575 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
580 ltt_commit_slot(ltt_buf
, buffer
, slot_size
);
588 #endif //LTT_TRACE_FAST
590 /* Event function_entry structures */
592 /* Event function_entry logging function */
593 static inline __attribute__((no_instrument_function
)) int trace_user_generic_function_entry(
594 const void * lttng_param_this_fn
,
595 const void * lttng_param_call_site
);
597 #ifndef LTT_TRACE_FAST
598 static inline int trace_user_generic_function_entry(
599 const void * lttng_param_this_fn
,
600 const void * lttng_param_call_site
)
608 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
609 size_t *to_base
= &real_to_base
;
611 size_t *to
= &real_to
;
613 size_t *len
= &real_len
;
617 const char *real_from
;
618 const char **from
= &real_from
;
619 /* For each field, calculate the field size. */
620 /* size = *to_base + *to + *len */
621 /* Assume that the padding for alignment starts at a
622 * sizeof(void *) address. */
624 *from
= (const char*)<tng_param_this_fn
;
625 align
= sizeof(const void *);
628 *to
+= ltt_align(*to
, align
); /* align output */
630 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
633 *len
+= sizeof(const void *);
635 *from
= (const char*)<tng_param_call_site
;
636 align
= sizeof(const void *);
639 *to
+= ltt_align(*to
, align
); /* align output */
641 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
644 *len
+= sizeof(const void *);
646 reserve_size
= *to_base
+ *to
+ *len
;
648 char stack_buffer
[reserve_size
];
649 buffer
= stack_buffer
;
651 *to_base
= *to
= *len
= 0;
653 *from
= (const char*)<tng_param_this_fn
;
654 align
= sizeof(const void *);
657 *to
+= ltt_align(*to
, align
); /* align output */
659 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
662 *len
+= sizeof(const void *);
664 /* Flush pending memcpy */
666 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
671 *from
= (const char*)<tng_param_call_site
;
672 align
= sizeof(const void *);
675 *to
+= ltt_align(*to
, align
); /* align output */
677 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
680 *len
+= sizeof(const void *);
682 /* Flush pending memcpy */
684 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
689 ret
= ltt_trace_generic(ltt_facility_user_generic_B1865E44
, event_user_generic_function_entry
, buffer
, reserve_size
, LTT_BLOCKING
, 0);
696 #endif //!LTT_TRACE_FAST
698 #ifdef LTT_TRACE_FAST
699 static inline __attribute__((no_instrument_function
)) int trace_user_generic_function_entry(
700 const void * lttng_param_this_fn
,
701 const void * lttng_param_call_site
)
708 struct ltt_trace_info
*trace
= thread_trace_info
;
709 struct ltt_buf
*ltt_buf
;
711 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
712 size_t *to_base
= &real_to_base
;
714 size_t *to
= &real_to
;
716 size_t *len
= &real_len
;
720 const char *real_from
;
721 const char **from
= &real_from
;
723 size_t before_hdr_pad
, after_hdr_pad
, header_size
;
727 trace
= thread_trace_info
;
731 /* For each field, calculate the field size. */
732 /* size = *to_base + *to + *len */
733 /* Assume that the padding for alignment starts at a
734 * sizeof(void *) address. */
736 *from
= (const char*)<tng_param_this_fn
;
737 align
= sizeof(const void *);
740 *to
+= ltt_align(*to
, align
); /* align output */
742 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
745 *len
+= sizeof(const void *);
747 *from
= (const char*)<tng_param_call_site
;
748 align
= sizeof(const void *);
751 *to
+= ltt_align(*to
, align
); /* align output */
753 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
756 *len
+= sizeof(const void *);
758 reserve_size
= *to_base
+ *to
+ *len
;
760 index
= ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44
,
761 event_user_generic_function_entry
);
764 ltt_buf
= ltt_get_channel_from_index(trace
, index
);
766 buffer
= ltt_reserve_slot(trace
, ltt_buf
,
767 reserve_size
, &slot_size
, &tsc
,
768 &before_hdr_pad
, &after_hdr_pad
, &header_size
);
769 if(!buffer
) goto end
; /* buffer full */
771 *to_base
= *to
= *len
= 0;
773 ltt_write_event_header(trace
, ltt_buf
, buffer
,
774 ltt_facility_user_generic_B1865E44
, event_user_generic_function_entry
,
775 reserve_size
, before_hdr_pad
, tsc
);
776 *to_base
+= before_hdr_pad
+ after_hdr_pad
+ header_size
;
778 *from
= (const char*)<tng_param_this_fn
;
779 align
= sizeof(const void *);
782 *to
+= ltt_align(*to
, align
); /* align output */
784 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
787 *len
+= sizeof(const void *);
789 /* Flush pending memcpy */
791 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
796 *from
= (const char*)<tng_param_call_site
;
797 align
= sizeof(const void *);
800 *to
+= ltt_align(*to
, align
); /* align output */
802 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
805 *len
+= sizeof(const void *);
807 /* Flush pending memcpy */
809 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
814 ltt_commit_slot(ltt_buf
, buffer
, slot_size
);
822 #endif //LTT_TRACE_FAST
824 /* Event function_exit structures */
826 /* Event function_exit logging function */
827 static inline __attribute__((no_instrument_function
)) int trace_user_generic_function_exit(
828 const void * lttng_param_this_fn
,
829 const void * lttng_param_call_site
);
831 #ifndef LTT_TRACE_FAST
832 static inline int trace_user_generic_function_exit(
833 const void * lttng_param_this_fn
,
834 const void * lttng_param_call_site
)
842 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
843 size_t *to_base
= &real_to_base
;
845 size_t *to
= &real_to
;
847 size_t *len
= &real_len
;
851 const char *real_from
;
852 const char **from
= &real_from
;
853 /* For each field, calculate the field size. */
854 /* size = *to_base + *to + *len */
855 /* Assume that the padding for alignment starts at a
856 * sizeof(void *) address. */
858 *from
= (const char*)<tng_param_this_fn
;
859 align
= sizeof(const void *);
862 *to
+= ltt_align(*to
, align
); /* align output */
864 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
867 *len
+= sizeof(const void *);
869 *from
= (const char*)<tng_param_call_site
;
870 align
= sizeof(const void *);
873 *to
+= ltt_align(*to
, align
); /* align output */
875 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
878 *len
+= sizeof(const void *);
880 reserve_size
= *to_base
+ *to
+ *len
;
882 char stack_buffer
[reserve_size
];
883 buffer
= stack_buffer
;
885 *to_base
= *to
= *len
= 0;
887 *from
= (const char*)<tng_param_this_fn
;
888 align
= sizeof(const void *);
891 *to
+= ltt_align(*to
, align
); /* align output */
893 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
896 *len
+= sizeof(const void *);
898 /* Flush pending memcpy */
900 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
905 *from
= (const char*)<tng_param_call_site
;
906 align
= sizeof(const void *);
909 *to
+= ltt_align(*to
, align
); /* align output */
911 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
914 *len
+= sizeof(const void *);
916 /* Flush pending memcpy */
918 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
923 ret
= ltt_trace_generic(ltt_facility_user_generic_B1865E44
, event_user_generic_function_exit
, buffer
, reserve_size
, LTT_BLOCKING
, 0);
930 #endif //!LTT_TRACE_FAST
932 #ifdef LTT_TRACE_FAST
933 static inline __attribute__((no_instrument_function
)) int trace_user_generic_function_exit(
934 const void * lttng_param_this_fn
,
935 const void * lttng_param_call_site
)
942 struct ltt_trace_info
*trace
= thread_trace_info
;
943 struct ltt_buf
*ltt_buf
;
945 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
946 size_t *to_base
= &real_to_base
;
948 size_t *to
= &real_to
;
950 size_t *len
= &real_len
;
954 const char *real_from
;
955 const char **from
= &real_from
;
957 size_t before_hdr_pad
, after_hdr_pad
, header_size
;
961 trace
= thread_trace_info
;
965 /* For each field, calculate the field size. */
966 /* size = *to_base + *to + *len */
967 /* Assume that the padding for alignment starts at a
968 * sizeof(void *) address. */
970 *from
= (const char*)<tng_param_this_fn
;
971 align
= sizeof(const void *);
974 *to
+= ltt_align(*to
, align
); /* align output */
976 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
979 *len
+= sizeof(const void *);
981 *from
= (const char*)<tng_param_call_site
;
982 align
= sizeof(const void *);
985 *to
+= ltt_align(*to
, align
); /* align output */
987 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
990 *len
+= sizeof(const void *);
992 reserve_size
= *to_base
+ *to
+ *len
;
994 index
= ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44
,
995 event_user_generic_function_exit
);
998 ltt_buf
= ltt_get_channel_from_index(trace
, index
);
1000 buffer
= ltt_reserve_slot(trace
, ltt_buf
,
1001 reserve_size
, &slot_size
, &tsc
,
1002 &before_hdr_pad
, &after_hdr_pad
, &header_size
);
1003 if(!buffer
) goto end
; /* buffer full */
1005 *to_base
= *to
= *len
= 0;
1007 ltt_write_event_header(trace
, ltt_buf
, buffer
,
1008 ltt_facility_user_generic_B1865E44
, event_user_generic_function_exit
,
1009 reserve_size
, before_hdr_pad
, tsc
);
1010 *to_base
+= before_hdr_pad
+ after_hdr_pad
+ header_size
;
1012 *from
= (const char*)<tng_param_this_fn
;
1013 align
= sizeof(const void *);
1016 *to
+= ltt_align(*to
, align
); /* align output */
1018 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
1021 *len
+= sizeof(const void *);
1023 /* Flush pending memcpy */
1025 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
1030 *from
= (const char*)<tng_param_call_site
;
1031 align
= sizeof(const void *);
1034 *to
+= ltt_align(*to
, align
); /* align output */
1036 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
1039 *len
+= sizeof(const void *);
1041 /* Flush pending memcpy */
1043 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
1048 ltt_commit_slot(ltt_buf
, buffer
, slot_size
);
1056 #endif //LTT_TRACE_FAST
1058 /* Event thread_brand structures */
1059 static inline void lttng_write_string_user_generic_thread_brand_name(
1070 /* Flush pending memcpy */
1073 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
1078 align
= sizeof(char);
1081 *to
+= ltt_align(*to
, align
); /* align output */
1083 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
1086 /* Contains variable sized fields : must explode the structure */
1088 size
= strlen(obj
) + 1; /* Include final NULL char. */
1090 memcpy(buffer
+*to_base
+*to
, obj
, size
);
1093 /* Realign the *to_base on arch size, set *to to 0 */
1094 *to
+= ltt_align(*to
, sizeof(void *));
1095 *to_base
= *to_base
+*to
;
1098 /* Put source *from just after the C string */
1103 /* Event thread_brand logging function */
1104 static inline int trace_user_generic_thread_brand(
1105 const char * lttng_param_name
);
1107 #ifndef LTT_TRACE_FAST
1108 static inline int trace_user_generic_thread_brand(
1109 const char * lttng_param_name
)
1116 char *buffer
= NULL
;
1117 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
1118 size_t *to_base
= &real_to_base
;
1120 size_t *to
= &real_to
;
1121 size_t real_len
= 0;
1122 size_t *len
= &real_len
;
1123 size_t reserve_size
;
1125 const char *real_from
;
1126 const char **from
= &real_from
;
1127 /* For each field, calculate the field size. */
1128 /* size = *to_base + *to + *len */
1129 /* Assume that the padding for alignment starts at a
1130 * sizeof(void *) address. */
1132 *from
= (const char*)lttng_param_name
;
1133 lttng_write_string_user_generic_thread_brand_name(buffer
, to_base
, to
, from
, len
, lttng_param_name
);
1135 reserve_size
= *to_base
+ *to
+ *len
;
1137 char stack_buffer
[reserve_size
];
1138 buffer
= stack_buffer
;
1140 *to_base
= *to
= *len
= 0;
1142 *from
= (const char*)lttng_param_name
;
1143 lttng_write_string_user_generic_thread_brand_name(buffer
, to_base
, to
, from
, len
, lttng_param_name
);
1145 /* Flush pending memcpy */
1147 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
1152 ret
= ltt_trace_generic(ltt_facility_user_generic_B1865E44
, event_user_generic_thread_brand
, buffer
, reserve_size
, LTT_BLOCKING
, 1);
1159 #endif //!LTT_TRACE_FAST
1161 #ifdef LTT_TRACE_FAST
1162 static inline int trace_user_generic_thread_brand(
1163 const char * lttng_param_name
)
1170 struct ltt_trace_info
*trace
= thread_trace_info
;
1171 struct ltt_buf
*ltt_buf
;
1172 char *buffer
= NULL
;
1173 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
1174 size_t *to_base
= &real_to_base
;
1176 size_t *to
= &real_to
;
1177 size_t real_len
= 0;
1178 size_t *len
= &real_len
;
1179 size_t reserve_size
;
1181 const char *real_from
;
1182 const char **from
= &real_from
;
1184 size_t before_hdr_pad
, after_hdr_pad
, header_size
;
1188 trace
= thread_trace_info
;
1192 /* For each field, calculate the field size. */
1193 /* size = *to_base + *to + *len */
1194 /* Assume that the padding for alignment starts at a
1195 * sizeof(void *) address. */
1197 *from
= (const char*)lttng_param_name
;
1198 lttng_write_string_user_generic_thread_brand_name(buffer
, to_base
, to
, from
, len
, lttng_param_name
);
1200 reserve_size
= *to_base
+ *to
+ *len
;
1202 index
= ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44
,
1203 event_user_generic_thread_brand
);
1206 ltt_buf
= ltt_get_channel_from_index(trace
, index
);
1208 buffer
= ltt_reserve_slot(trace
, ltt_buf
,
1209 reserve_size
, &slot_size
, &tsc
,
1210 &before_hdr_pad
, &after_hdr_pad
, &header_size
);
1211 if(!buffer
) goto end
; /* buffer full */
1213 *to_base
= *to
= *len
= 0;
1215 ltt_write_event_header(trace
, ltt_buf
, buffer
,
1216 ltt_facility_user_generic_B1865E44
, event_user_generic_thread_brand
,
1217 reserve_size
, before_hdr_pad
, tsc
);
1218 *to_base
+= before_hdr_pad
+ after_hdr_pad
+ header_size
;
1220 *from
= (const char*)lttng_param_name
;
1221 lttng_write_string_user_generic_thread_brand_name(buffer
, to_base
, to
, from
, len
, lttng_param_name
);
1223 /* Flush pending memcpy */
1225 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
1230 ltt_commit_slot(ltt_buf
, buffer
, slot_size
);
1238 #endif //LTT_TRACE_FAST
1241 } /* end of extern "C" */
1244 #endif //_LTT_FACILITY_USER_GENERIC_H_