install tracer.h, add new ust/ust.h
[ust.git] / libust / serialize.c
1 /*
2 * LTTng serializing code.
3 *
4 * Copyright Mathieu Desnoyers, March 2007.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 *
21 * See this discussion about weirdness about passing va_list and then va_list to
22 * functions. (related to array argument passing). va_list seems to be
23 * implemented as an array on x86_64, but not on i386... This is why we pass a
24 * va_list * to ltt_vtrace.
25 */
26
27 #include <stdarg.h>
28 //ust// #include <linux/ctype.h>
29 //ust// #include <linux/string.h>
30 //ust// #include <linux/module.h>
31 //ust// #include <linux/ltt-tracer.h>
32 #include <string.h>
33 #include <stdint.h>
34 #include <stdio.h>
35
36 #include <ust/kernelcompat.h>
37 #define _LGPL_SOURCE
38 #include <urcu-bp.h>
39 #include <urcu/rculist.h>
40
41 #include "relay.h"
42 #include <ust/tracer.h>
43 //#include "list.h"
44 #include "usterr.h"
45
46 enum ltt_type {
47 LTT_TYPE_SIGNED_INT,
48 LTT_TYPE_UNSIGNED_INT,
49 LTT_TYPE_STRING,
50 LTT_TYPE_NONE,
51 };
52
53 #define LTT_ATTRIBUTE_NETWORK_BYTE_ORDER (1<<1)
54
55 /*
56 * Inspired from vsnprintf
57 *
58 * The serialization format string supports the basic printf format strings.
59 * In addition, it defines new formats that can be used to serialize more
60 * complex/non portable data structures.
61 *
62 * Typical use:
63 *
64 * field_name %ctype
65 * field_name #tracetype %ctype
66 * field_name #tracetype %ctype1 %ctype2 ...
67 *
68 * A conversion is performed between format string types supported by GCC and
69 * the trace type requested. GCC type is used to perform type checking on format
70 * strings. Trace type is used to specify the exact binary representation
71 * in the trace. A mapping is done between one or more GCC types to one trace
72 * type. Sign extension, if required by the conversion, is performed following
73 * the trace type.
74 *
75 * If a gcc format is not declared with a trace format, the gcc format is
76 * also used as binary representation in the trace.
77 *
78 * Strings are supported with %s.
79 * A single tracetype (sequence) can take multiple c types as parameter.
80 *
81 * c types:
82 *
83 * see printf(3).
84 *
85 * Note: to write a uint32_t in a trace, the following expression is recommended
86 * si it can be portable:
87 *
88 * ("#4u%lu", (unsigned long)var)
89 *
90 * trace types:
91 *
92 * Serialization specific formats :
93 *
94 * Fixed size integers
95 * #1u writes uint8_t
96 * #2u writes uint16_t
97 * #4u writes uint32_t
98 * #8u writes uint64_t
99 * #1d writes int8_t
100 * #2d writes int16_t
101 * #4d writes int32_t
102 * #8d writes int64_t
103 * i.e.:
104 * #1u%lu #2u%lu #4d%lu #8d%lu #llu%hu #d%lu
105 *
106 * * Attributes:
107 *
108 * n: (for network byte order)
109 * #ntracetype%ctype
110 * is written in the trace in network byte order.
111 *
112 * i.e.: #bn4u%lu, #n%lu, #b%u
113 *
114 * TODO (eventually)
115 * Variable length sequence
116 * #a #tracetype1 #tracetype2 %array_ptr %elem_size %num_elems
117 * In the trace:
118 * #a specifies that this is a sequence
119 * #tracetype1 is the type of elements in the sequence
120 * #tracetype2 is the type of the element count
121 * GCC input:
122 * array_ptr is a pointer to an array that contains members of size
123 * elem_size.
124 * num_elems is the number of elements in the array.
125 * i.e.: #a #lu #lu %p %lu %u
126 *
127 * Callback
128 * #k callback (taken from the probe data)
129 * The following % arguments are exepected by the callback
130 *
131 * i.e.: #a #lu #lu #k %p
132 *
133 * Note: No conversion is done from floats to integers, nor from integers to
134 * floats between c types and trace types. float conversion from double to float
135 * or from float to double is also not supported.
136 *
137 * REMOVE
138 * %*b expects sizeof(data), data
139 * where sizeof(data) is 1, 2, 4 or 8
140 *
141 * Fixed length struct, union or array.
142 * FIXME: unable to extract those sizes statically.
143 * %*r expects sizeof(*ptr), ptr
144 * %*.*r expects sizeof(*ptr), __alignof__(*ptr), ptr
145 * struct and unions removed.
146 * Fixed length array:
147 * [%p]#a[len #tracetype]
148 * i.e.: [%p]#a[12 #lu]
149 *
150 * Variable length sequence
151 * %*.*:*v expects sizeof(*ptr), __alignof__(*ptr), elem_num, ptr
152 * where elem_num is the number of elements in the sequence
153 */
154 static inline const char *parse_trace_type(const char *fmt,
155 char *trace_size, enum ltt_type *trace_type,
156 unsigned long *attributes)
157 {
158 int qualifier; /* 'h', 'l', or 'L' for integer fields */
159 /* 'z' support added 23/7/1999 S.H. */
160 /* 'z' changed to 'Z' --davidm 1/25/99 */
161 /* 't' added for ptrdiff_t */
162
163 /* parse attributes. */
164 repeat:
165 switch (*fmt) {
166 case 'n':
167 *attributes |= LTT_ATTRIBUTE_NETWORK_BYTE_ORDER;
168 ++fmt;
169 goto repeat;
170 }
171
172 /* get the conversion qualifier */
173 qualifier = -1;
174 if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' ||
175 *fmt == 'Z' || *fmt == 'z' || *fmt == 't' ||
176 *fmt == 'S' || *fmt == '1' || *fmt == '2' ||
177 *fmt == '4' || *fmt == 8) {
178 qualifier = *fmt;
179 ++fmt;
180 if (qualifier == 'l' && *fmt == 'l') {
181 qualifier = 'L';
182 ++fmt;
183 }
184 }
185
186 switch (*fmt) {
187 case 'c':
188 *trace_type = LTT_TYPE_UNSIGNED_INT;
189 *trace_size = sizeof(unsigned char);
190 goto parse_end;
191 case 's':
192 *trace_type = LTT_TYPE_STRING;
193 goto parse_end;
194 case 'p':
195 *trace_type = LTT_TYPE_UNSIGNED_INT;
196 *trace_size = sizeof(void *);
197 goto parse_end;
198 case 'd':
199 case 'i':
200 *trace_type = LTT_TYPE_SIGNED_INT;
201 break;
202 case 'o':
203 case 'u':
204 case 'x':
205 case 'X':
206 *trace_type = LTT_TYPE_UNSIGNED_INT;
207 break;
208 default:
209 if (!*fmt)
210 --fmt;
211 goto parse_end;
212 }
213 switch (qualifier) {
214 case 'L':
215 *trace_size = sizeof(long long);
216 break;
217 case 'l':
218 *trace_size = sizeof(long);
219 break;
220 case 'Z':
221 case 'z':
222 *trace_size = sizeof(size_t);
223 break;
224 //ust// case 't':
225 //ust// *trace_size = sizeof(ptrdiff_t);
226 //ust// break;
227 case 'h':
228 *trace_size = sizeof(short);
229 break;
230 case '1':
231 *trace_size = sizeof(uint8_t);
232 break;
233 case '2':
234 *trace_size = sizeof(uint16_t);
235 break;
236 case '4':
237 *trace_size = sizeof(uint32_t);
238 break;
239 case '8':
240 *trace_size = sizeof(uint64_t);
241 break;
242 default:
243 *trace_size = sizeof(int);
244 }
245
246 parse_end:
247 return fmt;
248 }
249
250 /*
251 * Restrictions:
252 * Field width and precision are *not* supported.
253 * %n not supported.
254 */
255 static inline const char *parse_c_type(const char *fmt,
256 char *c_size, enum ltt_type *c_type)
257 {
258 int qualifier; /* 'h', 'l', or 'L' for integer fields */
259 /* 'z' support added 23/7/1999 S.H. */
260 /* 'z' changed to 'Z' --davidm 1/25/99 */
261 /* 't' added for ptrdiff_t */
262
263 /* process flags : ignore standard print formats for now. */
264 repeat:
265 switch (*fmt) {
266 case '-':
267 case '+':
268 case ' ':
269 case '#':
270 case '0':
271 ++fmt;
272 goto repeat;
273 }
274
275 /* get the conversion qualifier */
276 qualifier = -1;
277 if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' ||
278 *fmt == 'Z' || *fmt == 'z' || *fmt == 't' ||
279 *fmt == 'S') {
280 qualifier = *fmt;
281 ++fmt;
282 if (qualifier == 'l' && *fmt == 'l') {
283 qualifier = 'L';
284 ++fmt;
285 }
286 }
287
288 switch (*fmt) {
289 case 'c':
290 *c_type = LTT_TYPE_UNSIGNED_INT;
291 *c_size = sizeof(unsigned char);
292 goto parse_end;
293 case 's':
294 *c_type = LTT_TYPE_STRING;
295 goto parse_end;
296 case 'p':
297 *c_type = LTT_TYPE_UNSIGNED_INT;
298 *c_size = sizeof(void *);
299 goto parse_end;
300 case 'd':
301 case 'i':
302 *c_type = LTT_TYPE_SIGNED_INT;
303 break;
304 case 'o':
305 case 'u':
306 case 'x':
307 case 'X':
308 *c_type = LTT_TYPE_UNSIGNED_INT;
309 break;
310 default:
311 if (!*fmt)
312 --fmt;
313 goto parse_end;
314 }
315 switch (qualifier) {
316 case 'L':
317 *c_size = sizeof(long long);
318 break;
319 case 'l':
320 *c_size = sizeof(long);
321 break;
322 case 'Z':
323 case 'z':
324 *c_size = sizeof(size_t);
325 break;
326 //ust// case 't':
327 //ust// *c_size = sizeof(ptrdiff_t);
328 //ust// break;
329 case 'h':
330 *c_size = sizeof(short);
331 break;
332 default:
333 *c_size = sizeof(int);
334 }
335
336 parse_end:
337 return fmt;
338 }
339
340 static inline size_t serialize_trace_data(struct rchan_buf *buf,
341 size_t buf_offset,
342 char trace_size, enum ltt_type trace_type,
343 char c_size, enum ltt_type c_type,
344 int *largest_align, va_list *args)
345 {
346 union {
347 unsigned long v_ulong;
348 uint64_t v_uint64;
349 struct {
350 const char *s;
351 size_t len;
352 } v_string;
353 } tmp;
354
355 /*
356 * Be careful about sign extension here.
357 * Sign extension is done with the destination (trace) type.
358 */
359 switch (trace_type) {
360 case LTT_TYPE_SIGNED_INT:
361 switch (c_size) {
362 case 1:
363 tmp.v_ulong = (long)(int8_t)va_arg(*args, int);
364 break;
365 case 2:
366 tmp.v_ulong = (long)(int16_t)va_arg(*args, int);
367 break;
368 case 4:
369 tmp.v_ulong = (long)(int32_t)va_arg(*args, int);
370 break;
371 case 8:
372 tmp.v_uint64 = va_arg(*args, int64_t);
373 break;
374 default:
375 BUG();
376 }
377 break;
378 case LTT_TYPE_UNSIGNED_INT:
379 switch (c_size) {
380 case 1:
381 tmp.v_ulong = (unsigned long)(uint8_t)
382 va_arg(*args, unsigned int);
383 break;
384 case 2:
385 tmp.v_ulong = (unsigned long)(uint16_t)
386 va_arg(*args, unsigned int);
387 break;
388 case 4:
389 tmp.v_ulong = (unsigned long)(uint32_t)
390 va_arg(*args, unsigned int);
391 break;
392 case 8:
393 tmp.v_uint64 = va_arg(*args, uint64_t);
394 break;
395 default:
396 BUG();
397 }
398 break;
399 case LTT_TYPE_STRING:
400 tmp.v_string.s = va_arg(*args, const char *);
401 if ((unsigned long)tmp.v_string.s < PAGE_SIZE)
402 tmp.v_string.s = "<NULL>";
403 tmp.v_string.len = strlen(tmp.v_string.s)+1;
404 if (buf)
405 ltt_relay_write(buf, buf_offset, tmp.v_string.s,
406 tmp.v_string.len);
407 buf_offset += tmp.v_string.len;
408 goto copydone;
409 default:
410 BUG();
411 }
412
413 /*
414 * If trace_size is lower or equal to 4 bytes, there is no sign
415 * extension to do because we are already encoded in a long. Therefore,
416 * we can combine signed and unsigned ops. 4 bytes float also works
417 * with this, because we do a simple copy of 4 bytes into 4 bytes
418 * without manipulation (and we do not support conversion from integers
419 * to floats).
420 * It is also the case if c_size is 8 bytes, which is the largest
421 * possible integer.
422 */
423 if (ltt_get_alignment()) {
424 buf_offset += ltt_align(buf_offset, trace_size);
425 if (largest_align)
426 *largest_align = max_t(int, *largest_align, trace_size);
427 }
428 if (trace_size <= 4 || c_size == 8) {
429 if (buf) {
430 switch (trace_size) {
431 case 1:
432 if (c_size == 8)
433 ltt_relay_write(buf, buf_offset,
434 (uint8_t[]){ (uint8_t)tmp.v_uint64 },
435 sizeof(uint8_t));
436 else
437 ltt_relay_write(buf, buf_offset,
438 (uint8_t[]){ (uint8_t)tmp.v_ulong },
439 sizeof(uint8_t));
440 break;
441 case 2:
442 if (c_size == 8)
443 ltt_relay_write(buf, buf_offset,
444 (uint16_t[]){ (uint16_t)tmp.v_uint64 },
445 sizeof(uint16_t));
446 else
447 ltt_relay_write(buf, buf_offset,
448 (uint16_t[]){ (uint16_t)tmp.v_ulong },
449 sizeof(uint16_t));
450 break;
451 case 4:
452 if (c_size == 8)
453 ltt_relay_write(buf, buf_offset,
454 (uint32_t[]){ (uint32_t)tmp.v_uint64 },
455 sizeof(uint32_t));
456 else
457 ltt_relay_write(buf, buf_offset,
458 (uint32_t[]){ (uint32_t)tmp.v_ulong },
459 sizeof(uint32_t));
460 break;
461 case 8:
462 /*
463 * c_size cannot be other than 8 here because
464 * trace_size > 4.
465 */
466 ltt_relay_write(buf, buf_offset,
467 (uint64_t[]){ (uint64_t)tmp.v_uint64 },
468 sizeof(uint64_t));
469 break;
470 default:
471 BUG();
472 }
473 }
474 buf_offset += trace_size;
475 goto copydone;
476 } else {
477 /*
478 * Perform sign extension.
479 */
480 if (buf) {
481 switch (trace_type) {
482 case LTT_TYPE_SIGNED_INT:
483 ltt_relay_write(buf, buf_offset,
484 (int64_t[]){ (int64_t)tmp.v_ulong },
485 sizeof(int64_t));
486 break;
487 case LTT_TYPE_UNSIGNED_INT:
488 ltt_relay_write(buf, buf_offset,
489 (uint64_t[]){ (uint64_t)tmp.v_ulong },
490 sizeof(uint64_t));
491 break;
492 default:
493 BUG();
494 }
495 }
496 buf_offset += trace_size;
497 goto copydone;
498 }
499
500 copydone:
501 return buf_offset;
502 }
503
504 static notrace void skip_space(const char **ps)
505 {
506 while(**ps == ' ')
507 (*ps)++;
508 }
509
510 static notrace void copy_token(char **out, const char **in)
511 {
512 while(**in != ' ' && **in != '\0') {
513 **out = **in;
514 (*out)++;
515 (*in)++;
516 }
517 }
518
519 /* serialize_to_text
520 *
521 * Given a format string and a va_list of arguments, convert them to a
522 * human-readable string.
523 *
524 * @outbuf: the buffer to output the string to
525 * @bufsize: the max size that can be used in outbuf
526 * @fmt: the marker format string
527 * @ap: a va_list that contains the arguments corresponding to fmt
528 *
529 * Return value: the number of chars that have been put in outbuf, excluding
530 * the final \0, or, if the buffer was too small, the number of chars that
531 * would have been written in outbuf if it had been large enough.
532 *
533 * outbuf may be NULL. The return value may then be used be allocate an
534 * appropriate outbuf.
535 *
536 */
537
538 notrace
539 int serialize_to_text(char *outbuf, int bufsize, const char *fmt, va_list ap)
540 {
541 int fmt_len = strlen(fmt);
542 char *new_fmt = alloca(fmt_len + 1);
543 const char *orig_fmt_p = fmt;
544 char *new_fmt_p = new_fmt;
545 char false_buf;
546 int result;
547 enum { none, cfmt, tracefmt, argname } prev_token = none;
548
549 while(*orig_fmt_p != '\0') {
550 if(*orig_fmt_p == '%') {
551 prev_token = cfmt;
552 copy_token(&new_fmt_p, &orig_fmt_p);
553 }
554 else if(*orig_fmt_p == '#') {
555 prev_token = tracefmt;
556 do {
557 orig_fmt_p++;
558 } while(*orig_fmt_p != ' ' && *orig_fmt_p != '\0');
559 }
560 else if(*orig_fmt_p == ' ') {
561 if(prev_token == argname) {
562 *new_fmt_p = '=';
563 new_fmt_p++;
564 }
565 else if(prev_token == cfmt) {
566 *new_fmt_p = ' ';
567 new_fmt_p++;
568 }
569
570 skip_space(&orig_fmt_p);
571 }
572 else {
573 prev_token = argname;
574 copy_token(&new_fmt_p, &orig_fmt_p);
575 }
576 }
577
578 *new_fmt_p = '\0';
579
580 if(outbuf == NULL) {
581 /* use this false_buffer for compatibility with pre-C99 */
582 outbuf = &false_buf;
583 bufsize = 1;
584 }
585 result = vsnprintf(outbuf, bufsize, new_fmt, ap);
586
587 return result;
588 }
589
590 notrace size_t ltt_serialize_data(struct rchan_buf *buf, size_t buf_offset,
591 struct ltt_serialize_closure *closure,
592 void *serialize_private, int *largest_align,
593 const char *fmt, va_list *args)
594 {
595 char trace_size = 0, c_size = 0; /*
596 * 0 (unset), 1, 2, 4, 8 bytes.
597 */
598 enum ltt_type trace_type = LTT_TYPE_NONE, c_type = LTT_TYPE_NONE;
599 unsigned long attributes = 0;
600
601 for (; *fmt ; ++fmt) {
602 switch (*fmt) {
603 case '#':
604 /* tracetypes (#) */
605 ++fmt; /* skip first '#' */
606 if (*fmt == '#') /* Escaped ## */
607 break;
608 attributes = 0;
609 fmt = parse_trace_type(fmt, &trace_size, &trace_type,
610 &attributes);
611 break;
612 case '%':
613 /* c types (%) */
614 ++fmt; /* skip first '%' */
615 if (*fmt == '%') /* Escaped %% */
616 break;
617 fmt = parse_c_type(fmt, &c_size, &c_type);
618 /*
619 * Output c types if no trace types has been
620 * specified.
621 */
622 if (!trace_size)
623 trace_size = c_size;
624 if (trace_type == LTT_TYPE_NONE)
625 trace_type = c_type;
626 if (c_type == LTT_TYPE_STRING)
627 trace_type = LTT_TYPE_STRING;
628 /* perform trace write */
629 buf_offset = serialize_trace_data(buf,
630 buf_offset, trace_size,
631 trace_type, c_size, c_type,
632 largest_align, args);
633 trace_size = 0;
634 c_size = 0;
635 trace_type = LTT_TYPE_NONE;
636 c_size = LTT_TYPE_NONE;
637 attributes = 0;
638 break;
639 /* default is to skip the text, doing nothing */
640 }
641 }
642 return buf_offset;
643 }
644
645 /*
646 * Calculate data size
647 * Assume that the padding for alignment starts at a sizeof(void *) address.
648 */
649 static notrace size_t ltt_get_data_size(struct ltt_serialize_closure *closure,
650 void *serialize_private, int *largest_align,
651 const char *fmt, va_list *args)
652 {
653 ltt_serialize_cb cb = closure->callbacks[0];
654 closure->cb_idx = 0;
655 return (size_t)cb(NULL, 0, closure, serialize_private,
656 largest_align, fmt, args);
657 }
658
659 static notrace
660 void ltt_write_event_data(struct rchan_buf *buf, size_t buf_offset,
661 struct ltt_serialize_closure *closure,
662 void *serialize_private, int largest_align,
663 const char *fmt, va_list *args)
664 {
665 ltt_serialize_cb cb = closure->callbacks[0];
666 closure->cb_idx = 0;
667 buf_offset += ltt_align(buf_offset, largest_align);
668 cb(buf, buf_offset, closure, serialize_private, NULL, fmt, args);
669 }
670
671
672 notrace void ltt_vtrace(const struct marker *mdata, void *probe_data,
673 struct registers *regs, void *call_data,
674 const char *fmt, va_list *args)
675 {
676 int largest_align, ret;
677 struct ltt_active_marker *pdata;
678 uint16_t eID;
679 size_t data_size, slot_size;
680 unsigned int chan_index;
681 struct ltt_channel_struct *channel;
682 struct ltt_trace_struct *trace, *dest_trace = NULL;
683 struct rchan_buf *buf;
684 void *transport_data;
685 u64 tsc;
686 long buf_offset;
687 va_list args_copy;
688 struct ltt_serialize_closure closure;
689 struct ltt_probe_private_data *private_data = call_data;
690 void *serialize_private = NULL;
691 //ust// int cpu;
692 unsigned int rflags;
693
694 /*
695 * This test is useful for quickly exiting static tracing when no trace
696 * is active. We expect to have an active trace when we get here.
697 */
698 if (unlikely(ltt_traces.num_active_traces == 0))
699 return;
700
701 rcu_read_lock(); //ust// rcu_read_lock_sched_notrace();
702 //ust// cpu = smp_processor_id();
703 //ust// __get_cpu_var(ltt_nesting)++;
704 ltt_nesting++;
705
706 pdata = (struct ltt_active_marker *)probe_data;
707 eID = mdata->event_id;
708 chan_index = mdata->channel_id;
709 closure.callbacks = pdata->probe->callbacks;
710
711 if (unlikely(private_data)) {
712 dest_trace = private_data->trace;
713 if (private_data->serializer)
714 closure.callbacks = &private_data->serializer;
715 serialize_private = private_data->serialize_private;
716 }
717
718 va_copy(args_copy, *args);
719 /*
720 * Assumes event payload to start on largest_align alignment.
721 */
722 largest_align = 1; /* must be non-zero for ltt_align */
723 data_size = ltt_get_data_size(&closure, serialize_private,
724 &largest_align, fmt, &args_copy);
725 largest_align = min_t(int, largest_align, sizeof(void *));
726 va_end(args_copy);
727
728 /* Iterate on each trace */
729 list_for_each_entry_rcu(trace, &ltt_traces.head, list) {
730 /*
731 * Expect the filter to filter out events. If we get here,
732 * we went through tracepoint activation as a first step.
733 */
734 if (unlikely(dest_trace && trace != dest_trace))
735 continue;
736 if (unlikely(!trace->active))
737 continue;
738 if (unlikely(!ltt_run_filter(trace, eID)))
739 continue;
740 #ifdef CONFIG_LTT_DEBUG_EVENT_SIZE
741 rflags = LTT_RFLAG_ID_SIZE;
742 #else
743 if (unlikely(eID >= LTT_FREE_EVENTS))
744 rflags = LTT_RFLAG_ID;
745 else
746 rflags = 0;
747 #endif
748 /*
749 * Skip channels added after trace creation.
750 */
751 if (unlikely(chan_index >= trace->nr_channels))
752 continue;
753 channel = &trace->channels[chan_index];
754 if (!channel->active)
755 continue;
756
757 /* reserve space : header and data */
758 ret = ltt_reserve_slot(trace, channel, &transport_data,
759 data_size, &slot_size, &buf_offset,
760 &tsc, &rflags,
761 largest_align);
762 if (unlikely(ret < 0))
763 continue; /* buffer full */
764
765 va_copy(args_copy, *args);
766 /* FIXME : could probably encapsulate transport better. */
767 //ust// buf = ((struct rchan *)channel->trans_channel_data)->buf[cpu];
768 buf = ((struct rchan *)channel->trans_channel_data)->buf;
769 /* Out-of-order write : header and data */
770 buf_offset = ltt_write_event_header(trace,
771 channel, buf, buf_offset,
772 eID, data_size, tsc, rflags);
773 ltt_write_event_data(buf, buf_offset, &closure,
774 serialize_private,
775 largest_align, fmt, &args_copy);
776 va_end(args_copy);
777 /* Out-of-order commit */
778 ltt_commit_slot(channel, &transport_data, buf_offset,
779 data_size, slot_size);
780 DBG("just commited event at offset %ld and size %zd", buf_offset, slot_size);
781 }
782 //ust// __get_cpu_var(ltt_nesting)--;
783 ltt_nesting--;
784 rcu_read_unlock(); //ust// rcu_read_unlock_sched_notrace();
785 }
786
787 notrace void ltt_trace(const struct marker *mdata, void *probe_data,
788 struct registers *regs, void *call_data,
789 const char *fmt, ...)
790 {
791 va_list args;
792
793 va_start(args, fmt);
794 ltt_vtrace(mdata, probe_data, regs, call_data, fmt, &args);
795 va_end(args);
796 }
797
798 //ust// MODULE_LICENSE("GPL");
799 //ust// MODULE_AUTHOR("Mathieu Desnoyers");
800 //ust// MODULE_DESCRIPTION("Linux Trace Toolkit Next Generation Serializer");
This page took 0.044751 seconds and 5 git commands to generate.