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
);
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
);
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(
501 reserve_size
= ltt_align(reserve_size
, sizeof(void *));
503 ret
= ltt_trace_generic(ltt_facility_user_generic_B1865E44
, event_user_generic_slow_printf
, buffer
, reserve_size
, LTT_BLOCKING
);
510 #endif //!LTT_TRACE_FAST
512 #ifdef LTT_TRACE_FAST
513 static inline int trace_user_generic_slow_printf(
514 const char * lttng_param_string
)
521 struct ltt_trace_info
*trace
= thread_trace_info
;
522 struct ltt_buf
*ltt_buf
;
524 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
525 size_t *to_base
= &real_to_base
;
527 size_t *to
= &real_to
;
529 size_t *len
= &real_len
;
532 const char *real_from
;
533 const char **from
= &real_from
;
535 size_t before_hdr_pad
, after_hdr_pad
, header_size
;
539 trace
= thread_trace_info
;
543 /* For each field, calculate the field size. */
544 /* size = *to_base + *to + *len */
545 /* Assume that the padding for alignment starts at a
546 * sizeof(void *) address. */
548 *from
= (const char*)lttng_param_string
;
549 lttng_write_string_user_generic_slow_printf_string(buffer
, to_base
, to
, from
, len
, lttng_param_string
);
551 reserve_size
= *to_base
+ *to
+ *len
;
553 index
= ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44
,
554 event_user_generic_slow_printf
);
557 ltt_buf
= ltt_get_channel_from_index(trace
, index
);
559 buffer
= ltt_reserve_slot(trace
, ltt_buf
,
560 reserve_size
, &slot_size
, &tsc
,
561 &before_hdr_pad
, &after_hdr_pad
, &header_size
);
562 if(!buffer
) goto end
; /* buffer full */
564 *to_base
= *to
= *len
= 0;
566 ltt_write_event_header(trace
, ltt_buf
, buffer
,
567 ltt_facility_user_generic_B1865E44
, event_user_generic_slow_printf
,
568 reserve_size
, before_hdr_pad
, tsc
);
569 *to_base
+= before_hdr_pad
+ after_hdr_pad
+ header_size
;
571 *from
= (const char*)lttng_param_string
;
572 lttng_write_string_user_generic_slow_printf_string(buffer
, to_base
, to
, from
, len
, lttng_param_string
);
574 /* Flush pending memcpy */
576 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
581 ltt_commit_slot(ltt_buf
, buffer
, slot_size
);
589 #endif //LTT_TRACE_FAST
591 /* Event function_entry structures */
593 /* Event function_entry logging function */
594 static inline __attribute__((no_instrument_function
)) int trace_user_generic_function_entry(
595 const void * lttng_param_this_fn
,
596 const void * lttng_param_call_site
);
598 #ifndef LTT_TRACE_FAST
599 static inline int trace_user_generic_function_entry(
600 const void * lttng_param_this_fn
,
601 const void * lttng_param_call_site
)
609 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
610 size_t *to_base
= &real_to_base
;
612 size_t *to
= &real_to
;
614 size_t *len
= &real_len
;
618 const char *real_from
;
619 const char **from
= &real_from
;
620 /* For each field, calculate the field size. */
621 /* size = *to_base + *to + *len */
622 /* Assume that the padding for alignment starts at a
623 * sizeof(void *) address. */
625 *from
= (const char*)<tng_param_this_fn
;
626 align
= sizeof(const void *);
629 *to
+= ltt_align(*to
, align
); /* align output */
631 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
634 *len
+= sizeof(const void *);
636 *from
= (const char*)<tng_param_call_site
;
637 align
= sizeof(const void *);
640 *to
+= ltt_align(*to
, align
); /* align output */
642 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
645 *len
+= sizeof(const void *);
647 reserve_size
= *to_base
+ *to
+ *len
;
649 char stack_buffer
[reserve_size
];
650 buffer
= stack_buffer
;
652 *to_base
= *to
= *len
= 0;
654 *from
= (const char*)<tng_param_this_fn
;
655 align
= sizeof(const void *);
658 *to
+= ltt_align(*to
, align
); /* align output */
660 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
663 *len
+= sizeof(const void *);
665 /* Flush pending memcpy */
667 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
672 *from
= (const char*)<tng_param_call_site
;
673 align
= sizeof(const void *);
676 *to
+= ltt_align(*to
, align
); /* align output */
678 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
681 *len
+= sizeof(const void *);
683 /* Flush pending memcpy */
685 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
690 ret
= ltt_trace_generic(ltt_facility_user_generic_B1865E44
, event_user_generic_function_entry
, buffer
, reserve_size
, LTT_BLOCKING
);
697 #endif //!LTT_TRACE_FAST
699 #ifdef LTT_TRACE_FAST
700 static inline __attribute__((no_instrument_function
)) int trace_user_generic_function_entry(
701 const void * lttng_param_this_fn
,
702 const void * lttng_param_call_site
)
709 struct ltt_trace_info
*trace
= thread_trace_info
;
710 struct ltt_buf
*ltt_buf
;
712 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
713 size_t *to_base
= &real_to_base
;
715 size_t *to
= &real_to
;
717 size_t *len
= &real_len
;
721 const char *real_from
;
722 const char **from
= &real_from
;
724 size_t before_hdr_pad
, after_hdr_pad
, header_size
;
728 trace
= thread_trace_info
;
732 /* For each field, calculate the field size. */
733 /* size = *to_base + *to + *len */
734 /* Assume that the padding for alignment starts at a
735 * sizeof(void *) address. */
737 *from
= (const char*)<tng_param_this_fn
;
738 align
= sizeof(const void *);
741 *to
+= ltt_align(*to
, align
); /* align output */
743 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
746 *len
+= sizeof(const void *);
748 *from
= (const char*)<tng_param_call_site
;
749 align
= sizeof(const void *);
752 *to
+= ltt_align(*to
, align
); /* align output */
754 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
757 *len
+= sizeof(const void *);
759 reserve_size
= *to_base
+ *to
+ *len
;
761 index
= ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44
,
762 event_user_generic_function_entry
);
765 ltt_buf
= ltt_get_channel_from_index(trace
, index
);
767 buffer
= ltt_reserve_slot(trace
, ltt_buf
,
768 reserve_size
, &slot_size
, &tsc
,
769 &before_hdr_pad
, &after_hdr_pad
, &header_size
);
770 if(!buffer
) goto end
; /* buffer full */
772 *to_base
= *to
= *len
= 0;
774 ltt_write_event_header(trace
, ltt_buf
, buffer
,
775 ltt_facility_user_generic_B1865E44
, event_user_generic_function_entry
,
776 reserve_size
, before_hdr_pad
, tsc
);
777 *to_base
+= before_hdr_pad
+ after_hdr_pad
+ header_size
;
779 *from
= (const char*)<tng_param_this_fn
;
780 align
= sizeof(const void *);
783 *to
+= ltt_align(*to
, align
); /* align output */
785 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
788 *len
+= sizeof(const void *);
790 /* Flush pending memcpy */
792 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
797 *from
= (const char*)<tng_param_call_site
;
798 align
= sizeof(const void *);
801 *to
+= ltt_align(*to
, align
); /* align output */
803 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
806 *len
+= sizeof(const void *);
808 /* Flush pending memcpy */
810 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
815 ltt_commit_slot(ltt_buf
, buffer
, slot_size
);
823 #endif //LTT_TRACE_FAST
825 /* Event function_exit structures */
827 /* Event function_exit logging function */
828 static inline __attribute__((no_instrument_function
)) int trace_user_generic_function_exit(
829 const void * lttng_param_this_fn
,
830 const void * lttng_param_call_site
);
832 #ifndef LTT_TRACE_FAST
833 static inline int trace_user_generic_function_exit(
834 const void * lttng_param_this_fn
,
835 const void * lttng_param_call_site
)
843 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
844 size_t *to_base
= &real_to_base
;
846 size_t *to
= &real_to
;
848 size_t *len
= &real_len
;
852 const char *real_from
;
853 const char **from
= &real_from
;
854 /* For each field, calculate the field size. */
855 /* size = *to_base + *to + *len */
856 /* Assume that the padding for alignment starts at a
857 * sizeof(void *) address. */
859 *from
= (const char*)<tng_param_this_fn
;
860 align
= sizeof(const void *);
863 *to
+= ltt_align(*to
, align
); /* align output */
865 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
868 *len
+= sizeof(const void *);
870 *from
= (const char*)<tng_param_call_site
;
871 align
= sizeof(const void *);
874 *to
+= ltt_align(*to
, align
); /* align output */
876 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
879 *len
+= sizeof(const void *);
881 reserve_size
= *to_base
+ *to
+ *len
;
883 char stack_buffer
[reserve_size
];
884 buffer
= stack_buffer
;
886 *to_base
= *to
= *len
= 0;
888 *from
= (const char*)<tng_param_this_fn
;
889 align
= sizeof(const void *);
892 *to
+= ltt_align(*to
, align
); /* align output */
894 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
897 *len
+= sizeof(const void *);
899 /* Flush pending memcpy */
901 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
906 *from
= (const char*)<tng_param_call_site
;
907 align
= sizeof(const void *);
910 *to
+= ltt_align(*to
, align
); /* align output */
912 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
915 *len
+= sizeof(const void *);
917 /* Flush pending memcpy */
919 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
924 ret
= ltt_trace_generic(ltt_facility_user_generic_B1865E44
, event_user_generic_function_exit
, buffer
, reserve_size
, LTT_BLOCKING
);
931 #endif //!LTT_TRACE_FAST
933 #ifdef LTT_TRACE_FAST
934 static inline __attribute__((no_instrument_function
)) int trace_user_generic_function_exit(
935 const void * lttng_param_this_fn
,
936 const void * lttng_param_call_site
)
943 struct ltt_trace_info
*trace
= thread_trace_info
;
944 struct ltt_buf
*ltt_buf
;
946 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
947 size_t *to_base
= &real_to_base
;
949 size_t *to
= &real_to
;
951 size_t *len
= &real_len
;
955 const char *real_from
;
956 const char **from
= &real_from
;
958 size_t before_hdr_pad
, after_hdr_pad
, header_size
;
962 trace
= thread_trace_info
;
966 /* For each field, calculate the field size. */
967 /* size = *to_base + *to + *len */
968 /* Assume that the padding for alignment starts at a
969 * sizeof(void *) address. */
971 *from
= (const char*)<tng_param_this_fn
;
972 align
= sizeof(const void *);
975 *to
+= ltt_align(*to
, align
); /* align output */
977 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
980 *len
+= sizeof(const void *);
982 *from
= (const char*)<tng_param_call_site
;
983 align
= sizeof(const void *);
986 *to
+= ltt_align(*to
, align
); /* align output */
988 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
991 *len
+= sizeof(const void *);
993 reserve_size
= *to_base
+ *to
+ *len
;
995 index
= ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44
,
996 event_user_generic_function_exit
);
999 ltt_buf
= ltt_get_channel_from_index(trace
, index
);
1001 buffer
= ltt_reserve_slot(trace
, ltt_buf
,
1002 reserve_size
, &slot_size
, &tsc
,
1003 &before_hdr_pad
, &after_hdr_pad
, &header_size
);
1004 if(!buffer
) goto end
; /* buffer full */
1006 *to_base
= *to
= *len
= 0;
1008 ltt_write_event_header(trace
, ltt_buf
, buffer
,
1009 ltt_facility_user_generic_B1865E44
, event_user_generic_function_exit
,
1010 reserve_size
, before_hdr_pad
, tsc
);
1011 *to_base
+= before_hdr_pad
+ after_hdr_pad
+ header_size
;
1013 *from
= (const char*)<tng_param_this_fn
;
1014 align
= sizeof(const void *);
1017 *to
+= ltt_align(*to
, align
); /* align output */
1019 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
1022 *len
+= sizeof(const void *);
1024 /* Flush pending memcpy */
1026 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
1031 *from
= (const char*)<tng_param_call_site
;
1032 align
= sizeof(const void *);
1035 *to
+= ltt_align(*to
, align
); /* align output */
1037 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
1040 *len
+= sizeof(const void *);
1042 /* Flush pending memcpy */
1044 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
1049 ltt_commit_slot(ltt_buf
, buffer
, slot_size
);
1057 #endif //LTT_TRACE_FAST
1059 /* Event thread_brand structures */
1060 static inline void lttng_write_string_user_generic_thread_brand_name(
1071 /* Flush pending memcpy */
1074 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
1079 align
= sizeof(char);
1082 *to
+= ltt_align(*to
, align
); /* align output */
1084 *len
+= ltt_align(*to
+*len
, align
); /* alignment, ok to do a memcpy of it */
1087 /* Contains variable sized fields : must explode the structure */
1089 size
= strlen(obj
) + 1; /* Include final NULL char. */
1091 memcpy(buffer
+*to_base
+*to
, obj
, size
);
1094 /* Realign the *to_base on arch size, set *to to 0 */
1095 *to
+= ltt_align(*to
, sizeof(void *));
1096 *to_base
= *to_base
+*to
;
1099 /* Put source *from just after the C string */
1104 /* Event thread_brand logging function */
1105 static inline int trace_user_generic_thread_brand(
1106 const char * lttng_param_name
);
1108 #ifndef LTT_TRACE_FAST
1109 static inline int trace_user_generic_thread_brand(
1110 const char * lttng_param_name
)
1117 char *buffer
= NULL
;
1118 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
1119 size_t *to_base
= &real_to_base
;
1121 size_t *to
= &real_to
;
1122 size_t real_len
= 0;
1123 size_t *len
= &real_len
;
1124 size_t reserve_size
;
1126 const char *real_from
;
1127 const char **from
= &real_from
;
1128 /* For each field, calculate the field size. */
1129 /* size = *to_base + *to + *len */
1130 /* Assume that the padding for alignment starts at a
1131 * sizeof(void *) address. */
1133 *from
= (const char*)lttng_param_name
;
1134 lttng_write_string_user_generic_thread_brand_name(buffer
, to_base
, to
, from
, len
, lttng_param_name
);
1136 reserve_size
= *to_base
+ *to
+ *len
;
1138 char stack_buffer
[reserve_size
];
1139 buffer
= stack_buffer
;
1141 *to_base
= *to
= *len
= 0;
1143 *from
= (const char*)lttng_param_name
;
1144 lttng_write_string_user_generic_thread_brand_name(buffer
, to_base
, to
, from
, len
, lttng_param_name
);
1146 /* Flush pending memcpy */
1148 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
1153 ret
= ltt_trace_generic(ltt_facility_user_generic_B1865E44
, event_user_generic_thread_brand
, buffer
, reserve_size
, LTT_BLOCKING
);
1160 #endif //!LTT_TRACE_FAST
1162 #ifdef LTT_TRACE_FAST
1163 static inline int trace_user_generic_thread_brand(
1164 const char * lttng_param_name
)
1171 struct ltt_trace_info
*trace
= thread_trace_info
;
1172 struct ltt_buf
*ltt_buf
;
1173 char *buffer
= NULL
;
1174 size_t real_to_base
= 0; /* The buffer is allocated on arch_size alignment */
1175 size_t *to_base
= &real_to_base
;
1177 size_t *to
= &real_to
;
1178 size_t real_len
= 0;
1179 size_t *len
= &real_len
;
1180 size_t reserve_size
;
1182 const char *real_from
;
1183 const char **from
= &real_from
;
1185 size_t before_hdr_pad
, after_hdr_pad
, header_size
;
1189 trace
= thread_trace_info
;
1193 /* For each field, calculate the field size. */
1194 /* size = *to_base + *to + *len */
1195 /* Assume that the padding for alignment starts at a
1196 * sizeof(void *) address. */
1198 *from
= (const char*)lttng_param_name
;
1199 lttng_write_string_user_generic_thread_brand_name(buffer
, to_base
, to
, from
, len
, lttng_param_name
);
1201 reserve_size
= *to_base
+ *to
+ *len
;
1203 index
= ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44
,
1204 event_user_generic_thread_brand
);
1207 ltt_buf
= ltt_get_channel_from_index(trace
, index
);
1209 buffer
= ltt_reserve_slot(trace
, ltt_buf
,
1210 reserve_size
, &slot_size
, &tsc
,
1211 &before_hdr_pad
, &after_hdr_pad
, &header_size
);
1212 if(!buffer
) goto end
; /* buffer full */
1214 *to_base
= *to
= *len
= 0;
1216 ltt_write_event_header(trace
, ltt_buf
, buffer
,
1217 ltt_facility_user_generic_B1865E44
, event_user_generic_thread_brand
,
1218 reserve_size
, before_hdr_pad
, tsc
);
1219 *to_base
+= before_hdr_pad
+ after_hdr_pad
+ header_size
;
1221 *from
= (const char*)lttng_param_name
;
1222 lttng_write_string_user_generic_thread_brand_name(buffer
, to_base
, to
, from
, len
, lttng_param_name
);
1224 /* Flush pending memcpy */
1226 memcpy(buffer
+*to_base
+*to
, *from
, *len
);
1231 ltt_commit_slot(ltt_buf
, buffer
, slot_size
);
1239 #endif //LTT_TRACE_FAST
1242 } /* end of extern "C" */
1245 #endif //_LTT_FACILITY_USER_GENERIC_H_