convert from svn repository: remove tags directory
[lttv.git] / trunk / obsolete / ltt-usertrace / ltt / ltt-facility-user_generic.h
CommitLineData
3d57eb5b 1#ifndef _LTT_FACILITY_USER_GENERIC_H_
2#define _LTT_FACILITY_USER_GENERIC_H_
3
4#include <sys/types.h>
5#include <ltt/ltt-facility-id-user_generic.h>
38f24d5c 6#include <ltt/ltt-usertrace.h>
3d57eb5b 7
895ad115 8#ifdef __cplusplus
9extern "C" {
10#endif
11
3d57eb5b 12/* Named types */
13
14/* Event string structures */
15static inline void lttng_write_string_user_generic_string_data(
895ad115 16 char *buffer,
3d57eb5b 17 size_t *to_base,
18 size_t *to,
895ad115 19 const char **from,
3d57eb5b 20 size_t *len,
21 const char * obj)
22{
23 size_t size;
24 size_t align;
25
26 /* Flush pending memcpy */
4ea155a2 27 if (*len != 0) {
28 if (buffer != NULL)
3d57eb5b 29 memcpy(buffer+*to_base+*to, *from, *len);
30 }
31 *to += *len;
32 *len = 0;
33
34 align = sizeof(char);
35
4ea155a2 36 if (*len == 0) {
3d57eb5b 37 *to += ltt_align(*to, align); /* align output */
38 } else {
39 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
40 }
41
42 /* Contains variable sized fields : must explode the structure */
43
44 size = strlen(obj) + 1; /* Include final NULL char. */
4ea155a2 45 if (buffer != NULL)
3d57eb5b 46 memcpy(buffer+*to_base+*to, obj, size);
47 *to += size;
48
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;
52 *to = 0;
53
54 /* Put source *from just after the C string */
55 *from += size;
56}
57
58
59/* Event string logging function */
895ad115 60static inline int trace_user_generic_string(
61 const char * lttng_param_data);
62
8a9103df 63#ifndef LTT_TRACE_FAST
3d57eb5b 64static inline int trace_user_generic_string(
65 const char * lttng_param_data)
66#ifndef LTT_TRACE
67{
68}
69#else
70{
e36efdc5 71 int ret = 0;
895ad115 72 char *buffer = NULL;
3d57eb5b 73 size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
74 size_t *to_base = &real_to_base;
75 size_t real_to = 0;
76 size_t *to = &real_to;
77 size_t real_len = 0;
78 size_t *len = &real_len;
79 size_t reserve_size;
80 size_t slot_size;
895ad115 81 const char *real_from;
82 const char **from = &real_from;
3d57eb5b 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. */
87
895ad115 88 *from = (const char*)lttng_param_data;
3d57eb5b 89 lttng_write_string_user_generic_string_data(buffer, to_base, to, from, len, lttng_param_data);
90
91 reserve_size = *to_base + *to + *len;
92 {
93 char stack_buffer[reserve_size];
94 buffer = stack_buffer;
95
96 *to_base = *to = *len = 0;
97
895ad115 98 *from = (const char*)lttng_param_data;
3d57eb5b 99 lttng_write_string_user_generic_string_data(buffer, to_base, to, from, len, lttng_param_data);
100
101 /* Flush pending memcpy */
4ea155a2 102 if (*len != 0) {
3d57eb5b 103 memcpy(buffer+*to_base+*to, *from, *len);
104 *to += *len;
105 *len = 0;
106 }
107
e38295df 108 ret = ltt_trace_generic(ltt_facility_user_generic_B1865E44, event_user_generic_string, buffer, reserve_size, LTT_BLOCKING, 0);
3d57eb5b 109 }
110
111 return ret;
112
113}
114#endif //LTT_TRACE
8a9103df 115#endif //!LTT_TRACE_FAST
116
117#ifdef LTT_TRACE_FAST
118static inline int trace_user_generic_string(
119 const char * lttng_param_data)
120#ifndef LTT_TRACE
121{
122}
123#else
124{
125 unsigned int index;
126 struct ltt_trace_info *trace = thread_trace_info;
127 struct ltt_buf *ltt_buf;
895ad115 128 char *buffer = NULL;
8a9103df 129 size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
130 size_t *to_base = &real_to_base;
131 size_t real_to = 0;
132 size_t *to = &real_to;
133 size_t real_len = 0;
134 size_t *len = &real_len;
135 size_t reserve_size;
136 size_t slot_size;
895ad115 137 const char *real_from;
138 const char **from = &real_from;
8a9103df 139 uint64_t tsc;
4ea155a2 140 if (!trace) {
ba017bc3 141 ltt_thread_init();
142 trace = thread_trace_info;
143 }
144
8a9103df 145
146 /* For each field, calculate the field size. */
147 /* size = *to_base + *to + *len */
148 /* Assume that the padding for alignment starts at a
149 * sizeof(void *) address. */
150
895ad115 151 *from = (const char*)lttng_param_data;
8a9103df 152 lttng_write_string_user_generic_string_data(buffer, to_base, to, from, len, lttng_param_data);
153
154 reserve_size = *to_base + *to + *len;
155 trace->nesting++;
e619eb4e 156 index = ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44,
8a9103df 157 event_user_generic_string);
158
159 {
160 ltt_buf = ltt_get_channel_from_index(trace, index);
161 slot_size = 0;
162 buffer = ltt_reserve_slot(trace, ltt_buf,
4ea155a2 163 reserve_size, &slot_size, &tsc);
164 if (!buffer)
165 goto end; /* buffer full */
8a9103df 166
167 *to_base = *to = *len = 0;
168
4ea155a2 169 buffer = ltt_write_event_header(trace, ltt_buf, buffer,
e619eb4e 170 ltt_facility_user_generic_B1865E44, event_user_generic_string,
4ea155a2 171 reserve_size, tsc);
895ad115 172 *from = (const char*)lttng_param_data;
8a9103df 173 lttng_write_string_user_generic_string_data(buffer, to_base, to, from, len, lttng_param_data);
174
175 /* Flush pending memcpy */
4ea155a2 176 if (*len != 0) {
8a9103df 177 memcpy(buffer+*to_base+*to, *from, *len);
178 *to += *len;
179 *len = 0;
180 }
181
182 ltt_commit_slot(ltt_buf, buffer, slot_size);
183
184}
185
186end:
187 trace->nesting--;
188}
189#endif //LTT_TRACE
190#endif //LTT_TRACE_FAST
3d57eb5b 191
192/* Event string_pointer structures */
193static inline void lttng_write_string_user_generic_string_pointer_string(
895ad115 194 char *buffer,
3d57eb5b 195 size_t *to_base,
196 size_t *to,
895ad115 197 const char **from,
3d57eb5b 198 size_t *len,
199 const char * obj)
200{
201 size_t size;
202 size_t align;
203
204 /* Flush pending memcpy */
4ea155a2 205 if (*len != 0) {
206 if (buffer != NULL)
3d57eb5b 207 memcpy(buffer+*to_base+*to, *from, *len);
208 }
209 *to += *len;
210 *len = 0;
211
212 align = sizeof(char);
213
4ea155a2 214 if (*len == 0) {
3d57eb5b 215 *to += ltt_align(*to, align); /* align output */
216 } else {
217 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
218 }
219
220 /* Contains variable sized fields : must explode the structure */
221
222 size = strlen(obj) + 1; /* Include final NULL char. */
4ea155a2 223 if (buffer != NULL)
3d57eb5b 224 memcpy(buffer+*to_base+*to, obj, size);
225 *to += size;
226
227 /* Realign the *to_base on arch size, set *to to 0 */
228 *to += ltt_align(*to, sizeof(void *));
229 *to_base = *to_base+*to;
230 *to = 0;
231
232 /* Put source *from just after the C string */
233 *from += size;
234}
235
236
237/* Event string_pointer logging function */
895ad115 238static inline int trace_user_generic_string_pointer(
239 const char * lttng_param_string,
240 const void * lttng_param_pointer);
241
8a9103df 242#ifndef LTT_TRACE_FAST
3d57eb5b 243static inline int trace_user_generic_string_pointer(
244 const char * lttng_param_string,
245 const void * lttng_param_pointer)
246#ifndef LTT_TRACE
247{
248}
249#else
250{
e36efdc5 251 int ret = 0;
895ad115 252 char *buffer = NULL;
3d57eb5b 253 size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
254 size_t *to_base = &real_to_base;
255 size_t real_to = 0;
256 size_t *to = &real_to;
257 size_t real_len = 0;
258 size_t *len = &real_len;
259 size_t reserve_size;
260 size_t slot_size;
3d57eb5b 261 size_t align;
895ad115 262 const char *real_from;
263 const char **from = &real_from;
3d57eb5b 264 /* For each field, calculate the field size. */
265 /* size = *to_base + *to + *len */
266 /* Assume that the padding for alignment starts at a
267 * sizeof(void *) address. */
268
895ad115 269 *from = (const char*)lttng_param_string;
3d57eb5b 270 lttng_write_string_user_generic_string_pointer_string(buffer, to_base, to, from, len, lttng_param_string);
271
895ad115 272 *from = (const char*)&lttng_param_pointer;
3d57eb5b 273 align = sizeof(const void *);
274
4ea155a2 275 if (*len == 0) {
3d57eb5b 276 *to += ltt_align(*to, align); /* align output */
277 } else {
278 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
279 }
280
281 *len += sizeof(const void *);
282
283 reserve_size = *to_base + *to + *len;
284 {
285 char stack_buffer[reserve_size];
286 buffer = stack_buffer;
287
288 *to_base = *to = *len = 0;
289
895ad115 290 *from = (const char*)lttng_param_string;
3d57eb5b 291 lttng_write_string_user_generic_string_pointer_string(buffer, to_base, to, from, len, lttng_param_string);
292
293 /* Flush pending memcpy */
4ea155a2 294 if (*len != 0) {
3d57eb5b 295 memcpy(buffer+*to_base+*to, *from, *len);
296 *to += *len;
297 *len = 0;
298 }
299
895ad115 300 *from = (const char*)&lttng_param_pointer;
3d57eb5b 301 align = sizeof(const void *);
302
4ea155a2 303 if (*len == 0) {
3d57eb5b 304 *to += ltt_align(*to, align); /* align output */
305 } else {
306 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
307 }
308
309 *len += sizeof(const void *);
310
311 /* Flush pending memcpy */
4ea155a2 312 if (*len != 0) {
3d57eb5b 313 memcpy(buffer+*to_base+*to, *from, *len);
314 *to += *len;
315 *len = 0;
316 }
317
e38295df 318 ret = ltt_trace_generic(ltt_facility_user_generic_B1865E44, event_user_generic_string_pointer, buffer, reserve_size, LTT_BLOCKING, 0);
e36efdc5 319 }
320
321 return ret;
322
323}
324#endif //LTT_TRACE
8a9103df 325#endif //!LTT_TRACE_FAST
326
327#ifdef LTT_TRACE_FAST
328static inline int trace_user_generic_string_pointer(
329 const char * lttng_param_string,
330 const void * lttng_param_pointer)
331#ifndef LTT_TRACE
332{
333}
334#else
335{
336 unsigned int index;
337 struct ltt_trace_info *trace = thread_trace_info;
338 struct ltt_buf *ltt_buf;
895ad115 339 char *buffer = NULL;
8a9103df 340 size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
341 size_t *to_base = &real_to_base;
342 size_t real_to = 0;
343 size_t *to = &real_to;
344 size_t real_len = 0;
345 size_t *len = &real_len;
346 size_t reserve_size;
347 size_t slot_size;
348 size_t align;
895ad115 349 const char *real_from;
350 const char **from = &real_from;
8a9103df 351 uint64_t tsc;
4ea155a2 352 if (!trace) {
ba017bc3 353 ltt_thread_init();
354 trace = thread_trace_info;
355 }
356
8a9103df 357
358 /* For each field, calculate the field size. */
359 /* size = *to_base + *to + *len */
360 /* Assume that the padding for alignment starts at a
361 * sizeof(void *) address. */
362
895ad115 363 *from = (const char*)lttng_param_string;
8a9103df 364 lttng_write_string_user_generic_string_pointer_string(buffer, to_base, to, from, len, lttng_param_string);
365
895ad115 366 *from = (const char*)&lttng_param_pointer;
8a9103df 367 align = sizeof(const void *);
368
4ea155a2 369 if (*len == 0) {
8a9103df 370 *to += ltt_align(*to, align); /* align output */
371 } else {
372 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
373 }
374
375 *len += sizeof(const void *);
376
377 reserve_size = *to_base + *to + *len;
378 trace->nesting++;
e619eb4e 379 index = ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44,
8a9103df 380 event_user_generic_string_pointer);
381
382 {
383 ltt_buf = ltt_get_channel_from_index(trace, index);
384 slot_size = 0;
385 buffer = ltt_reserve_slot(trace, ltt_buf,
4ea155a2 386 reserve_size, &slot_size, &tsc);
387 if (!buffer)
388 goto end; /* buffer full */
8a9103df 389
390 *to_base = *to = *len = 0;
391
4ea155a2 392 buffer = ltt_write_event_header(trace, ltt_buf, buffer,
e619eb4e 393 ltt_facility_user_generic_B1865E44, event_user_generic_string_pointer,
4ea155a2 394 reserve_size, tsc);
895ad115 395 *from = (const char*)lttng_param_string;
8a9103df 396 lttng_write_string_user_generic_string_pointer_string(buffer, to_base, to, from, len, lttng_param_string);
397
398 /* Flush pending memcpy */
4ea155a2 399 if (*len != 0) {
8a9103df 400 memcpy(buffer+*to_base+*to, *from, *len);
401 *to += *len;
402 *len = 0;
403 }
404
895ad115 405 *from = (const char*)&lttng_param_pointer;
8a9103df 406 align = sizeof(const void *);
407
4ea155a2 408 if (*len == 0) {
8a9103df 409 *to += ltt_align(*to, align); /* align output */
410 } else {
411 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
412 }
413
414 *len += sizeof(const void *);
415
416 /* Flush pending memcpy */
4ea155a2 417 if (*len != 0) {
8a9103df 418 memcpy(buffer+*to_base+*to, *from, *len);
419 *to += *len;
420 *len = 0;
421 }
422
423 ltt_commit_slot(ltt_buf, buffer, slot_size);
424
425}
426
427end:
428 trace->nesting--;
429}
430#endif //LTT_TRACE
431#endif //LTT_TRACE_FAST
e36efdc5 432
433/* Event slow_printf structures */
434static inline void lttng_write_string_user_generic_slow_printf_string(
895ad115 435 char *buffer,
e36efdc5 436 size_t *to_base,
437 size_t *to,
895ad115 438 const char **from,
e36efdc5 439 size_t *len,
440 const char * obj)
441{
442 size_t size;
443 size_t align;
444
445 /* Flush pending memcpy */
4ea155a2 446 if (*len != 0) {
447 if (buffer != NULL)
e36efdc5 448 memcpy(buffer+*to_base+*to, *from, *len);
449 }
450 *to += *len;
451 *len = 0;
452
453 align = sizeof(char);
454
4ea155a2 455 if (*len == 0) {
e36efdc5 456 *to += ltt_align(*to, align); /* align output */
457 } else {
458 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
459 }
460
461 /* Contains variable sized fields : must explode the structure */
462
463 size = strlen(obj) + 1; /* Include final NULL char. */
4ea155a2 464 if (buffer != NULL)
e36efdc5 465 memcpy(buffer+*to_base+*to, obj, size);
466 *to += size;
467
468 /* Realign the *to_base on arch size, set *to to 0 */
469 *to += ltt_align(*to, sizeof(void *));
470 *to_base = *to_base+*to;
471 *to = 0;
472
473 /* Put source *from just after the C string */
474 *from += size;
475}
476
477
478/* Event slow_printf logging function */
895ad115 479static inline int trace_user_generic_slow_printf_param_buffer(
480 char *buffer,
481 size_t reserve_size);
482
8a9103df 483#ifndef LTT_TRACE_FAST
e36efdc5 484static inline int trace_user_generic_slow_printf_param_buffer(
895ad115 485 char *buffer,
e36efdc5 486 size_t reserve_size)
487#ifndef LTT_TRACE
488{
489}
490#else
491{
492 int ret = 0;
e36efdc5 493 {
e38295df 494 ret = ltt_trace_generic(ltt_facility_user_generic_B1865E44, event_user_generic_slow_printf, buffer, reserve_size, LTT_BLOCKING, 0);
e90c7b86 495 }
496
497 return ret;
498
499}
500#endif //LTT_TRACE
8a9103df 501#endif //!LTT_TRACE_FAST
502
503#ifdef LTT_TRACE_FAST
504static inline int trace_user_generic_slow_printf(
505 const char * lttng_param_string)
506#ifndef LTT_TRACE
507{
508}
509#else
510{
511 unsigned int index;
512 struct ltt_trace_info *trace = thread_trace_info;
513 struct ltt_buf *ltt_buf;
895ad115 514 char *buffer = NULL;
8a9103df 515 size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
516 size_t *to_base = &real_to_base;
517 size_t real_to = 0;
518 size_t *to = &real_to;
519 size_t real_len = 0;
520 size_t *len = &real_len;
521 size_t reserve_size;
522 size_t slot_size;
895ad115 523 const char *real_from;
524 const char **from = &real_from;
8a9103df 525 uint64_t tsc;
4ea155a2 526 if (!trace) {
ba017bc3 527 ltt_thread_init();
528 trace = thread_trace_info;
529 }
530
8a9103df 531
532 /* For each field, calculate the field size. */
533 /* size = *to_base + *to + *len */
534 /* Assume that the padding for alignment starts at a
535 * sizeof(void *) address. */
536
895ad115 537 *from = (const char*)lttng_param_string;
8a9103df 538 lttng_write_string_user_generic_slow_printf_string(buffer, to_base, to, from, len, lttng_param_string);
539
540 reserve_size = *to_base + *to + *len;
541 trace->nesting++;
e619eb4e 542 index = ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44,
8a9103df 543 event_user_generic_slow_printf);
544
545 {
546 ltt_buf = ltt_get_channel_from_index(trace, index);
547 slot_size = 0;
548 buffer = ltt_reserve_slot(trace, ltt_buf,
4ea155a2 549 reserve_size, &slot_size, &tsc);
550 if (!buffer)
551 goto end; /* buffer full */
8a9103df 552
553 *to_base = *to = *len = 0;
554
4ea155a2 555 buffer = ltt_write_event_header(trace, ltt_buf, buffer,
e619eb4e 556 ltt_facility_user_generic_B1865E44, event_user_generic_slow_printf,
4ea155a2 557 reserve_size, tsc);
895ad115 558 *from = (const char*)lttng_param_string;
8a9103df 559 lttng_write_string_user_generic_slow_printf_string(buffer, to_base, to, from, len, lttng_param_string);
560
561 /* Flush pending memcpy */
4ea155a2 562 if (*len != 0) {
8a9103df 563 memcpy(buffer+*to_base+*to, *from, *len);
564 *to += *len;
565 *len = 0;
566 }
567
568 ltt_commit_slot(ltt_buf, buffer, slot_size);
569
570}
571
572end:
573 trace->nesting--;
574}
575#endif //LTT_TRACE
576#endif //LTT_TRACE_FAST
e90c7b86 577
578/* Event function_entry structures */
579
580/* Event function_entry logging function */
581static inline __attribute__((no_instrument_function)) int trace_user_generic_function_entry(
895ad115 582 const void * lttng_param_this_fn,
583 const void * lttng_param_call_site);
584
585#ifndef LTT_TRACE_FAST
586static inline int trace_user_generic_function_entry(
e90c7b86 587 const void * lttng_param_this_fn,
588 const void * lttng_param_call_site)
589#ifndef LTT_TRACE
590{
591}
592#else
593{
594 int ret = 0;
895ad115 595 char *buffer = NULL;
e90c7b86 596 size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
597 size_t *to_base = &real_to_base;
598 size_t real_to = 0;
599 size_t *to = &real_to;
600 size_t real_len = 0;
601 size_t *len = &real_len;
602 size_t reserve_size;
603 size_t slot_size;
604 size_t align;
895ad115 605 const char *real_from;
606 const char **from = &real_from;
e90c7b86 607 /* For each field, calculate the field size. */
608 /* size = *to_base + *to + *len */
609 /* Assume that the padding for alignment starts at a
610 * sizeof(void *) address. */
611
895ad115 612 *from = (const char*)&lttng_param_this_fn;
e90c7b86 613 align = sizeof(const void *);
614
4ea155a2 615 if (*len == 0) {
e90c7b86 616 *to += ltt_align(*to, align); /* align output */
617 } else {
618 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
619 }
620
621 *len += sizeof(const void *);
622
895ad115 623 *from = (const char*)&lttng_param_call_site;
e90c7b86 624 align = sizeof(const void *);
625
4ea155a2 626 if (*len == 0) {
e90c7b86 627 *to += ltt_align(*to, align); /* align output */
628 } else {
629 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
630 }
631
632 *len += sizeof(const void *);
633
634 reserve_size = *to_base + *to + *len;
635 {
636 char stack_buffer[reserve_size];
637 buffer = stack_buffer;
638
639 *to_base = *to = *len = 0;
640
895ad115 641 *from = (const char*)&lttng_param_this_fn;
e90c7b86 642 align = sizeof(const void *);
643
4ea155a2 644 if (*len == 0) {
e90c7b86 645 *to += ltt_align(*to, align); /* align output */
646 } else {
647 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
648 }
649
650 *len += sizeof(const void *);
651
652 /* Flush pending memcpy */
4ea155a2 653 if (*len != 0) {
e90c7b86 654 memcpy(buffer+*to_base+*to, *from, *len);
655 *to += *len;
656 *len = 0;
657 }
658
895ad115 659 *from = (const char*)&lttng_param_call_site;
e90c7b86 660 align = sizeof(const void *);
661
4ea155a2 662 if (*len == 0) {
e90c7b86 663 *to += ltt_align(*to, align); /* align output */
664 } else {
665 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
666 }
667
668 *len += sizeof(const void *);
669
670 /* Flush pending memcpy */
4ea155a2 671 if (*len != 0) {
e90c7b86 672 memcpy(buffer+*to_base+*to, *from, *len);
673 *to += *len;
674 *len = 0;
675 }
676
e38295df 677 ret = ltt_trace_generic(ltt_facility_user_generic_B1865E44, event_user_generic_function_entry, buffer, reserve_size, LTT_BLOCKING, 0);
e90c7b86 678 }
679
680 return ret;
681
682}
683#endif //LTT_TRACE
8a9103df 684#endif //!LTT_TRACE_FAST
685
686#ifdef LTT_TRACE_FAST
687static inline __attribute__((no_instrument_function)) int trace_user_generic_function_entry(
688 const void * lttng_param_this_fn,
689 const void * lttng_param_call_site)
690#ifndef LTT_TRACE
691{
692}
693#else
694{
695 unsigned int index;
696 struct ltt_trace_info *trace = thread_trace_info;
697 struct ltt_buf *ltt_buf;
895ad115 698 char *buffer = NULL;
8a9103df 699 size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
700 size_t *to_base = &real_to_base;
701 size_t real_to = 0;
702 size_t *to = &real_to;
703 size_t real_len = 0;
704 size_t *len = &real_len;
705 size_t reserve_size;
706 size_t slot_size;
707 size_t align;
895ad115 708 const char *real_from;
709 const char **from = &real_from;
8a9103df 710 uint64_t tsc;
4ea155a2 711 if (!trace) {
ba017bc3 712 ltt_thread_init();
713 trace = thread_trace_info;
714 }
715
8a9103df 716
717 /* For each field, calculate the field size. */
718 /* size = *to_base + *to + *len */
719 /* Assume that the padding for alignment starts at a
720 * sizeof(void *) address. */
721
895ad115 722 *from = (const char*)&lttng_param_this_fn;
8a9103df 723 align = sizeof(const void *);
724
4ea155a2 725 if (*len == 0) {
8a9103df 726 *to += ltt_align(*to, align); /* align output */
727 } else {
728 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
729 }
730
731 *len += sizeof(const void *);
732
895ad115 733 *from = (const char*)&lttng_param_call_site;
8a9103df 734 align = sizeof(const void *);
735
4ea155a2 736 if (*len == 0) {
8a9103df 737 *to += ltt_align(*to, align); /* align output */
738 } else {
739 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
740 }
741
742 *len += sizeof(const void *);
743
744 reserve_size = *to_base + *to + *len;
745 trace->nesting++;
e619eb4e 746 index = ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44,
8a9103df 747 event_user_generic_function_entry);
748
749 {
750 ltt_buf = ltt_get_channel_from_index(trace, index);
751 slot_size = 0;
752 buffer = ltt_reserve_slot(trace, ltt_buf,
4ea155a2 753 reserve_size, &slot_size, &tsc);
754 if (!buffer)
755 goto end; /* buffer full */
8a9103df 756
757 *to_base = *to = *len = 0;
758
4ea155a2 759 buffer = ltt_write_event_header(trace, ltt_buf, buffer,
e619eb4e 760 ltt_facility_user_generic_B1865E44, event_user_generic_function_entry,
4ea155a2 761 reserve_size, tsc);
895ad115 762 *from = (const char*)&lttng_param_this_fn;
8a9103df 763 align = sizeof(const void *);
764
4ea155a2 765 if (*len == 0) {
8a9103df 766 *to += ltt_align(*to, align); /* align output */
767 } else {
768 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
769 }
770
771 *len += sizeof(const void *);
772
773 /* Flush pending memcpy */
4ea155a2 774 if (*len != 0) {
8a9103df 775 memcpy(buffer+*to_base+*to, *from, *len);
776 *to += *len;
777 *len = 0;
778 }
779
895ad115 780 *from = (const char*)&lttng_param_call_site;
8a9103df 781 align = sizeof(const void *);
782
4ea155a2 783 if (*len == 0) {
8a9103df 784 *to += ltt_align(*to, align); /* align output */
785 } else {
786 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
787 }
788
789 *len += sizeof(const void *);
790
791 /* Flush pending memcpy */
4ea155a2 792 if (*len != 0) {
8a9103df 793 memcpy(buffer+*to_base+*to, *from, *len);
794 *to += *len;
795 *len = 0;
796 }
797
798 ltt_commit_slot(ltt_buf, buffer, slot_size);
799
800}
801
802end:
803 trace->nesting--;
804}
805#endif //LTT_TRACE
806#endif //LTT_TRACE_FAST
e90c7b86 807
808/* Event function_exit structures */
809
810/* Event function_exit logging function */
811static inline __attribute__((no_instrument_function)) int trace_user_generic_function_exit(
895ad115 812 const void * lttng_param_this_fn,
813 const void * lttng_param_call_site);
814
815#ifndef LTT_TRACE_FAST
816static inline int trace_user_generic_function_exit(
e90c7b86 817 const void * lttng_param_this_fn,
818 const void * lttng_param_call_site)
819#ifndef LTT_TRACE
820{
821}
822#else
823{
824 int ret = 0;
895ad115 825 char *buffer = NULL;
e90c7b86 826 size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
827 size_t *to_base = &real_to_base;
828 size_t real_to = 0;
829 size_t *to = &real_to;
830 size_t real_len = 0;
831 size_t *len = &real_len;
832 size_t reserve_size;
833 size_t slot_size;
834 size_t align;
895ad115 835 const char *real_from;
836 const char **from = &real_from;
e90c7b86 837 /* For each field, calculate the field size. */
838 /* size = *to_base + *to + *len */
839 /* Assume that the padding for alignment starts at a
840 * sizeof(void *) address. */
841
895ad115 842 *from = (const char*)&lttng_param_this_fn;
e90c7b86 843 align = sizeof(const void *);
844
4ea155a2 845 if (*len == 0) {
e90c7b86 846 *to += ltt_align(*to, align); /* align output */
847 } else {
848 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
849 }
850
851 *len += sizeof(const void *);
852
895ad115 853 *from = (const char*)&lttng_param_call_site;
e90c7b86 854 align = sizeof(const void *);
855
4ea155a2 856 if (*len == 0) {
e90c7b86 857 *to += ltt_align(*to, align); /* align output */
858 } else {
859 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
860 }
861
862 *len += sizeof(const void *);
863
864 reserve_size = *to_base + *to + *len;
865 {
866 char stack_buffer[reserve_size];
867 buffer = stack_buffer;
868
869 *to_base = *to = *len = 0;
870
895ad115 871 *from = (const char*)&lttng_param_this_fn;
e90c7b86 872 align = sizeof(const void *);
873
4ea155a2 874 if (*len == 0) {
e90c7b86 875 *to += ltt_align(*to, align); /* align output */
876 } else {
877 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
878 }
879
880 *len += sizeof(const void *);
881
882 /* Flush pending memcpy */
4ea155a2 883 if (*len != 0) {
e90c7b86 884 memcpy(buffer+*to_base+*to, *from, *len);
885 *to += *len;
886 *len = 0;
887 }
888
895ad115 889 *from = (const char*)&lttng_param_call_site;
e90c7b86 890 align = sizeof(const void *);
891
4ea155a2 892 if (*len == 0) {
e90c7b86 893 *to += ltt_align(*to, align); /* align output */
894 } else {
895 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
896 }
897
898 *len += sizeof(const void *);
899
900 /* Flush pending memcpy */
4ea155a2 901 if (*len != 0) {
e90c7b86 902 memcpy(buffer+*to_base+*to, *from, *len);
903 *to += *len;
904 *len = 0;
905 }
906
e38295df 907 ret = ltt_trace_generic(ltt_facility_user_generic_B1865E44, event_user_generic_function_exit, buffer, reserve_size, LTT_BLOCKING, 0);
3d57eb5b 908 }
909
910 return ret;
911
912}
913#endif //LTT_TRACE
8a9103df 914#endif //!LTT_TRACE_FAST
915
916#ifdef LTT_TRACE_FAST
917static inline __attribute__((no_instrument_function)) int trace_user_generic_function_exit(
918 const void * lttng_param_this_fn,
919 const void * lttng_param_call_site)
920#ifndef LTT_TRACE
921{
922}
923#else
924{
925 unsigned int index;
926 struct ltt_trace_info *trace = thread_trace_info;
927 struct ltt_buf *ltt_buf;
895ad115 928 char *buffer = NULL;
8a9103df 929 size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
930 size_t *to_base = &real_to_base;
931 size_t real_to = 0;
932 size_t *to = &real_to;
933 size_t real_len = 0;
934 size_t *len = &real_len;
935 size_t reserve_size;
936 size_t slot_size;
937 size_t align;
895ad115 938 const char *real_from;
939 const char **from = &real_from;
8a9103df 940 uint64_t tsc;
4ea155a2 941 if (!trace) {
ba017bc3 942 ltt_thread_init();
943 trace = thread_trace_info;
944 }
945
8a9103df 946
947 /* For each field, calculate the field size. */
948 /* size = *to_base + *to + *len */
949 /* Assume that the padding for alignment starts at a
950 * sizeof(void *) address. */
951
895ad115 952 *from = (const char*)&lttng_param_this_fn;
8a9103df 953 align = sizeof(const void *);
954
4ea155a2 955 if (*len == 0) {
8a9103df 956 *to += ltt_align(*to, align); /* align output */
957 } else {
958 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
959 }
960
961 *len += sizeof(const void *);
962
895ad115 963 *from = (const char*)&lttng_param_call_site;
8a9103df 964 align = sizeof(const void *);
965
4ea155a2 966 if (*len == 0) {
8a9103df 967 *to += ltt_align(*to, align); /* align output */
968 } else {
969 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
970 }
971
972 *len += sizeof(const void *);
973
974 reserve_size = *to_base + *to + *len;
975 trace->nesting++;
e619eb4e 976 index = ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44,
8a9103df 977 event_user_generic_function_exit);
978
979 {
980 ltt_buf = ltt_get_channel_from_index(trace, index);
981 slot_size = 0;
982 buffer = ltt_reserve_slot(trace, ltt_buf,
4ea155a2 983 reserve_size, &slot_size, &tsc);
984 if (!buffer)
985 goto end; /* buffer full */
8a9103df 986
987 *to_base = *to = *len = 0;
988
4ea155a2 989 buffer = ltt_write_event_header(trace, ltt_buf, buffer,
e619eb4e 990 ltt_facility_user_generic_B1865E44, event_user_generic_function_exit,
4ea155a2 991 reserve_size, tsc);
895ad115 992 *from = (const char*)&lttng_param_this_fn;
8a9103df 993 align = sizeof(const void *);
994
4ea155a2 995 if (*len == 0) {
8a9103df 996 *to += ltt_align(*to, align); /* align output */
997 } else {
998 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
999 }
1000
1001 *len += sizeof(const void *);
1002
1003 /* Flush pending memcpy */
4ea155a2 1004 if (*len != 0) {
8a9103df 1005 memcpy(buffer+*to_base+*to, *from, *len);
1006 *to += *len;
1007 *len = 0;
1008 }
1009
895ad115 1010 *from = (const char*)&lttng_param_call_site;
8a9103df 1011 align = sizeof(const void *);
1012
4ea155a2 1013 if (*len == 0) {
8a9103df 1014 *to += ltt_align(*to, align); /* align output */
1015 } else {
1016 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
1017 }
1018
1019 *len += sizeof(const void *);
1020
1021 /* Flush pending memcpy */
4ea155a2 1022 if (*len != 0) {
8a9103df 1023 memcpy(buffer+*to_base+*to, *from, *len);
1024 *to += *len;
1025 *len = 0;
1026 }
1027
1028 ltt_commit_slot(ltt_buf, buffer, slot_size);
1029
1030}
1031
1032end:
1033 trace->nesting--;
1034}
1035#endif //LTT_TRACE
1036#endif //LTT_TRACE_FAST
3d57eb5b 1037
e619eb4e 1038/* Event thread_brand structures */
1039static inline void lttng_write_string_user_generic_thread_brand_name(
895ad115 1040 char *buffer,
e619eb4e 1041 size_t *to_base,
1042 size_t *to,
895ad115 1043 const char **from,
e619eb4e 1044 size_t *len,
1045 const char * obj)
1046{
1047 size_t size;
1048 size_t align;
1049
1050 /* Flush pending memcpy */
4ea155a2 1051 if (*len != 0) {
1052 if (buffer != NULL)
e619eb4e 1053 memcpy(buffer+*to_base+*to, *from, *len);
1054 }
1055 *to += *len;
1056 *len = 0;
1057
1058 align = sizeof(char);
1059
4ea155a2 1060 if (*len == 0) {
e619eb4e 1061 *to += ltt_align(*to, align); /* align output */
1062 } else {
1063 *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
1064 }
1065
1066 /* Contains variable sized fields : must explode the structure */
1067
1068 size = strlen(obj) + 1; /* Include final NULL char. */
4ea155a2 1069 if (buffer != NULL)
e619eb4e 1070 memcpy(buffer+*to_base+*to, obj, size);
1071 *to += size;
1072
1073 /* Realign the *to_base on arch size, set *to to 0 */
1074 *to += ltt_align(*to, sizeof(void *));
1075 *to_base = *to_base+*to;
1076 *to = 0;
1077
1078 /* Put source *from just after the C string */
1079 *from += size;
1080}
1081
1082
1083/* Event thread_brand logging function */
895ad115 1084static inline int trace_user_generic_thread_brand(
1085 const char * lttng_param_name);
1086
e619eb4e 1087#ifndef LTT_TRACE_FAST
1088static inline int trace_user_generic_thread_brand(
1089 const char * lttng_param_name)
1090#ifndef LTT_TRACE
1091{
1092}
1093#else
1094{
1095 int ret = 0;
895ad115 1096 char *buffer = NULL;
e619eb4e 1097 size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
1098 size_t *to_base = &real_to_base;
1099 size_t real_to = 0;
1100 size_t *to = &real_to;
1101 size_t real_len = 0;
1102 size_t *len = &real_len;
1103 size_t reserve_size;
1104 size_t slot_size;
895ad115 1105 const char *real_from;
1106 const char **from = &real_from;
e619eb4e 1107 /* For each field, calculate the field size. */
1108 /* size = *to_base + *to + *len */
1109 /* Assume that the padding for alignment starts at a
1110 * sizeof(void *) address. */
1111
895ad115 1112 *from = (const char*)lttng_param_name;
e619eb4e 1113 lttng_write_string_user_generic_thread_brand_name(buffer, to_base, to, from, len, lttng_param_name);
1114
1115 reserve_size = *to_base + *to + *len;
1116 {
1117 char stack_buffer[reserve_size];
1118 buffer = stack_buffer;
1119
1120 *to_base = *to = *len = 0;
1121
895ad115 1122 *from = (const char*)lttng_param_name;
e619eb4e 1123 lttng_write_string_user_generic_thread_brand_name(buffer, to_base, to, from, len, lttng_param_name);
1124
1125 /* Flush pending memcpy */
4ea155a2 1126 if (*len != 0) {
e619eb4e 1127 memcpy(buffer+*to_base+*to, *from, *len);
1128 *to += *len;
1129 *len = 0;
1130 }
1131
e38295df 1132 ret = ltt_trace_generic(ltt_facility_user_generic_B1865E44, event_user_generic_thread_brand, buffer, reserve_size, LTT_BLOCKING, 1);
e619eb4e 1133 }
1134
1135 return ret;
1136
1137}
1138#endif //LTT_TRACE
1139#endif //!LTT_TRACE_FAST
1140
1141#ifdef LTT_TRACE_FAST
1142static inline int trace_user_generic_thread_brand(
1143 const char * lttng_param_name)
1144#ifndef LTT_TRACE
1145{
1146}
1147#else
1148{
1149 unsigned int index;
1150 struct ltt_trace_info *trace = thread_trace_info;
1151 struct ltt_buf *ltt_buf;
895ad115 1152 char *buffer = NULL;
e619eb4e 1153 size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
1154 size_t *to_base = &real_to_base;
1155 size_t real_to = 0;
1156 size_t *to = &real_to;
1157 size_t real_len = 0;
1158 size_t *len = &real_len;
1159 size_t reserve_size;
1160 size_t slot_size;
895ad115 1161 const char *real_from;
1162 const char **from = &real_from;
e619eb4e 1163 uint64_t tsc;
4ea155a2 1164 if (!trace) {
e619eb4e 1165 ltt_thread_init();
1166 trace = thread_trace_info;
1167 }
1168
1169
1170 /* For each field, calculate the field size. */
1171 /* size = *to_base + *to + *len */
1172 /* Assume that the padding for alignment starts at a
1173 * sizeof(void *) address. */
1174
895ad115 1175 *from = (const char*)lttng_param_name;
e619eb4e 1176 lttng_write_string_user_generic_thread_brand_name(buffer, to_base, to, from, len, lttng_param_name);
1177
1178 reserve_size = *to_base + *to + *len;
1179 trace->nesting++;
1180 index = ltt_get_index_from_facility(ltt_facility_user_generic_B1865E44,
1181 event_user_generic_thread_brand);
1182
1183 {
1184 ltt_buf = ltt_get_channel_from_index(trace, index);
1185 slot_size = 0;
1186 buffer = ltt_reserve_slot(trace, ltt_buf,
4ea155a2 1187 reserve_size, &slot_size, &tsc);
1188 if (!buffer)
1189 goto end; /* buffer full */
e619eb4e 1190
1191 *to_base = *to = *len = 0;
1192
4ea155a2 1193 buffer = ltt_write_event_header(trace, ltt_buf, buffer,
e619eb4e 1194 ltt_facility_user_generic_B1865E44, event_user_generic_thread_brand,
4ea155a2 1195 reserve_size, tsc);
895ad115 1196 *from = (const char*)lttng_param_name;
e619eb4e 1197 lttng_write_string_user_generic_thread_brand_name(buffer, to_base, to, from, len, lttng_param_name);
1198
1199 /* Flush pending memcpy */
4ea155a2 1200 if (*len != 0) {
e619eb4e 1201 memcpy(buffer+*to_base+*to, *from, *len);
1202 *to += *len;
1203 *len = 0;
1204 }
1205
1206 ltt_commit_slot(ltt_buf, buffer, slot_size);
1207
1208}
1209
1210end:
1211 trace->nesting--;
1212}
1213#endif //LTT_TRACE
1214#endif //LTT_TRACE_FAST
1215
895ad115 1216#ifdef __cplusplus
1217} /* end of extern "C" */
1218#endif
1219
3d57eb5b 1220#endif //_LTT_FACILITY_USER_GENERIC_H_
This page took 0.097449 seconds and 4 git commands to generate.