12 #include <linux/compiler.h> 13 #include <linux/kernel.h> 14 #include <babeltrace/ctf-writer/writer.h> 15 #include <babeltrace/ctf-writer/clock.h> 16 #include <babeltrace/ctf-writer/stream.h> 17 #include <babeltrace/ctf-writer/event.h> 18 #include <babeltrace/ctf-writer/event-types.h> 19 #include <babeltrace/ctf-writer/event-fields.h> 20 #include <babeltrace/ctf-ir/utils.h> 21 #include <babeltrace/ctf/events.h> 22 #include <traceevent/event-parse.h> 35 #define pr_N(n, fmt, ...) \ 36 eprintf(n, debug_data_convert, fmt, ##__VA_ARGS__) 38 #define pr(fmt, ...) pr_N(1, pr_fmt(fmt), ##__VA_ARGS__) 39 #define pr2(fmt, ...) pr_N(2, pr_fmt(fmt), ##__VA_ARGS__) 41 #define pr_time2(t, fmt, ...) pr_time_N(2, debug_data_convert, t, pr_fmt(fmt), ##__VA_ARGS__) 66 struct bt_ctf_field_type *
s64;
67 struct bt_ctf_field_type *
u64;
68 struct bt_ctf_field_type *
s32;
69 struct bt_ctf_field_type *
u32;
74 struct bt_ctf_field_type *
array[6];
95 static int value_set(
struct bt_ctf_field_type *type,
96 struct bt_ctf_event *
event,
99 struct bt_ctf_field *
field;
100 bool sign = bt_ctf_field_type_integer_get_signed(type);
103 field = bt_ctf_field_create(type);
105 pr_err(
"failed to create a field %s\n", name);
110 ret = bt_ctf_field_signed_integer_set_value(field, val);
112 pr_err(
"failed to set field value %s\n", name);
116 ret = bt_ctf_field_unsigned_integer_set_value(field, val);
118 pr_err(
"failed to set field value %s\n", name);
123 ret = bt_ctf_event_set_payload(event, name, field);
125 pr_err(
"failed to set payload %s\n", name);
129 pr2(
" SET [%s = %" PRIu64
"]\n", name, val);
132 bt_ctf_field_put(field);
136 #define __FUNC_VALUE_SET(_name, _val_type) \ 137 static __maybe_unused int value_set_##_name(struct ctf_writer *cw, \ 138 struct bt_ctf_event *event, \ 142 struct bt_ctf_field_type *type = cw->data._name; \ 143 return value_set(type, event, name, (u64) val); \ 146 #define FUNC_VALUE_SET(_name) __FUNC_VALUE_SET(_name, _name) 155 static __maybe_unused
int 157 const char *
name,
const char *
string)
159 struct bt_ctf_field_type *type = cw->
data.
string;
160 struct bt_ctf_field *
field;
163 field = bt_ctf_field_create(type);
165 pr_err(
"failed to create a field %s\n", name);
171 pr_err(
"failed to set value %s\n", name);
175 ret = bt_ctf_event_set_payload(event, name, field);
177 pr_err(
"failed to set payload %s\n", name);
180 bt_ctf_field_put(field);
184 static struct bt_ctf_field_type*
187 unsigned long flags = field->flags;
189 if (flags & FIELD_IS_STRING)
192 if (!(flags & FIELD_IS_SIGNED)) {
194 if (flags & FIELD_IS_LONG || flags & FIELD_IS_POINTER)
198 if (flags & FIELD_IS_SIGNED) {
199 if (field->size == 8)
205 if (field->size == 8)
213 unsigned long long value_mask;
221 value_mask = 0x7fULL;
224 value_mask = 0x7fffULL;
227 value_mask = 0x7fffffffULL;
241 if ((value_int & (~0ULL - value_mask)) == 0)
245 return (value_int & value_mask) | ~value_mask;
251 size_t len = strlen(
string), i, p;
254 for (i = p = 0; i < len; i++, p++) {
258 buffer[p] =
string[i];
262 snprintf(numstr,
sizeof(numstr),
"\\x%02x",
263 (
unsigned int)(
string[i]) & 0xff);
266 buffer =
zalloc(i + (len - i) * 4 + 2);
268 pr_err(
"failed to set unprintable string '%s'\n",
string);
269 return bt_ctf_field_string_set_value(field,
"UNPRINTABLE-STRING");
272 strncpy(buffer,
string, i);
274 strncat(buffer + p, numstr, 4);
280 return bt_ctf_field_string_set_value(field,
string);
281 err = bt_ctf_field_string_set_value(field, buffer);
288 struct bt_ctf_event *
event,
290 struct format_field *fmtf)
292 struct bt_ctf_field_type *type;
293 struct bt_ctf_field *array_field;
294 struct bt_ctf_field *
field;
295 const char *
name = fmtf->name;
297 unsigned long flags = fmtf->flags;
298 unsigned int n_items;
305 offset = fmtf->offset;
307 if (flags & FIELD_IS_STRING)
308 flags &= ~FIELD_IS_ARRAY;
310 if (flags & FIELD_IS_DYNAMIC) {
311 unsigned long long tmp_val;
313 tmp_val = pevent_read_number(fmtf->event->pevent,
320 if (flags & FIELD_IS_ARRAY) {
322 type = bt_ctf_event_class_get_field_by_name(
324 array_field = bt_ctf_field_create(type);
325 bt_ctf_field_type_put(type);
327 pr_err(
"Failed to create array type %s\n", name);
331 len = fmtf->size / fmtf->arraylen;
332 n_items = fmtf->arraylen;
340 for (i = 0; i < n_items; i++) {
341 if (flags & FIELD_IS_ARRAY)
342 field = bt_ctf_field_array_get_field(array_field, i);
344 field = bt_ctf_field_create(type);
347 pr_err(
"failed to create a field %s\n", name);
351 if (flags & FIELD_IS_STRING)
354 unsigned long long value_int;
356 value_int = pevent_read_number(
358 data + offset + i * len, len);
360 if (!(flags & FIELD_IS_SIGNED))
361 ret = bt_ctf_field_unsigned_integer_set_value(
364 ret = bt_ctf_field_signed_integer_set_value(
369 pr_err(
"failed to set file value %s\n", name);
372 if (!(flags & FIELD_IS_ARRAY)) {
373 ret = bt_ctf_event_set_payload(event, name, field);
375 pr_err(
"failed to set payload %s\n", name);
379 bt_ctf_field_put(field);
381 if (flags & FIELD_IS_ARRAY) {
382 ret = bt_ctf_event_set_payload(event, name, array_field);
384 pr_err(
"Failed add payload array %s\n", name);
387 bt_ctf_field_put(array_field);
392 bt_ctf_field_put(field);
398 struct bt_ctf_event *
event,
399 struct format_field *
fields,
402 struct format_field *
field;
405 for (field = fields; field; field = field->next) {
416 struct bt_ctf_event *
event,
420 struct format_field *common_fields = evsel->
tp_format->format.common_fields;
425 common_fields, sample);
435 struct bt_ctf_event *
event,
438 struct bt_ctf_field_type *len_type, *seq_type;
439 struct bt_ctf_field *len_field, *seq_field;
440 unsigned int raw_size = sample->
raw_size;
441 unsigned int nr_elements = raw_size /
sizeof(u32);
445 if (nr_elements *
sizeof(u32) != raw_size)
446 pr_warning(
"Incorrect raw_size (%u) in bpf output event, skip %zu bytes\n",
447 raw_size, nr_elements *
sizeof(u32) - raw_size);
449 len_type = bt_ctf_event_class_get_field_by_name(event_class,
"raw_len");
450 len_field = bt_ctf_field_create(len_type);
452 pr_err(
"failed to create 'raw_len' for bpf output event\n");
457 ret = bt_ctf_field_unsigned_integer_set_value(len_field, nr_elements);
459 pr_err(
"failed to set field value for raw_len\n");
462 ret = bt_ctf_event_set_payload(event,
"raw_len", len_field);
464 pr_err(
"failed to set payload to raw_len\n");
468 seq_type = bt_ctf_event_class_get_field_by_name(event_class,
"raw_data");
469 seq_field = bt_ctf_field_create(seq_type);
471 pr_err(
"failed to create 'raw_data' for bpf output event\n");
476 ret = bt_ctf_field_sequence_set_length(seq_field, len_field);
478 pr_err(
"failed to set length of 'raw_data'\n");
482 for (i = 0; i < nr_elements; i++) {
483 struct bt_ctf_field *elem_field =
484 bt_ctf_field_sequence_get_field(seq_field, i);
486 ret = bt_ctf_field_unsigned_integer_set_value(elem_field,
489 bt_ctf_field_put(elem_field);
491 pr_err(
"failed to set raw_data[%d]\n", i);
496 ret = bt_ctf_event_set_payload(event,
"raw_data", seq_field);
498 pr_err(
"failed to set payload for raw_data\n");
501 bt_ctf_field_put(seq_field);
503 bt_ctf_field_type_put(seq_type);
505 bt_ctf_field_put(len_field);
507 bt_ctf_field_type_put(len_type);
513 struct bt_ctf_event *
event,
516 struct bt_ctf_field_type *len_type, *seq_type;
517 struct bt_ctf_field *len_field, *seq_field;
518 unsigned int nr_elements = callchain->
nr;
522 len_type = bt_ctf_event_class_get_field_by_name(
523 event_class,
"perf_callchain_size");
524 len_field = bt_ctf_field_create(len_type);
526 pr_err(
"failed to create 'perf_callchain_size' for callchain output event\n");
531 ret = bt_ctf_field_unsigned_integer_set_value(len_field, nr_elements);
533 pr_err(
"failed to set field value for perf_callchain_size\n");
536 ret = bt_ctf_event_set_payload(event,
"perf_callchain_size", len_field);
538 pr_err(
"failed to set payload to perf_callchain_size\n");
542 seq_type = bt_ctf_event_class_get_field_by_name(
543 event_class,
"perf_callchain");
544 seq_field = bt_ctf_field_create(seq_type);
546 pr_err(
"failed to create 'perf_callchain' for callchain output event\n");
551 ret = bt_ctf_field_sequence_set_length(seq_field, len_field);
553 pr_err(
"failed to set length of 'perf_callchain'\n");
557 for (i = 0; i < nr_elements; i++) {
558 struct bt_ctf_field *elem_field =
559 bt_ctf_field_sequence_get_field(seq_field, i);
561 ret = bt_ctf_field_unsigned_integer_set_value(elem_field,
562 ((u64 *)(callchain->
ips))[i]);
564 bt_ctf_field_put(elem_field);
566 pr_err(
"failed to set callchain[%d]\n", i);
571 ret = bt_ctf_event_set_payload(event,
"perf_callchain", seq_field);
573 pr_err(
"failed to set payload for raw_data\n");
576 bt_ctf_field_put(seq_field);
578 bt_ctf_field_type_put(seq_type);
580 bt_ctf_field_put(len_field);
582 bt_ctf_field_type_put(len_type);
587 struct bt_ctf_event *
event,
591 u64 type = evsel->
attr.sample_type;
605 if (type & PERF_SAMPLE_IP) {
606 ret = value_set_u64_hex(cw, event,
"perf_ip", sample->
ip);
611 if (type & PERF_SAMPLE_TID) {
612 ret = value_set_s32(cw, event,
"perf_tid", sample->
tid);
616 ret = value_set_s32(cw, event,
"perf_pid", sample->
pid);
621 if ((type & PERF_SAMPLE_ID) ||
622 (type & PERF_SAMPLE_IDENTIFIER)) {
623 ret = value_set_u64(cw, event,
"perf_id", sample->
id);
628 if (type & PERF_SAMPLE_STREAM_ID) {
629 ret = value_set_u64(cw, event,
"perf_stream_id", sample->
stream_id);
634 if (type & PERF_SAMPLE_PERIOD) {
635 ret = value_set_u64(cw, event,
"perf_period", sample->
period);
640 if (type & PERF_SAMPLE_WEIGHT) {
641 ret = value_set_u64(cw, event,
"perf_weight", sample->
weight);
646 if (type & PERF_SAMPLE_DATA_SRC) {
647 ret = value_set_u64(cw, event,
"perf_data_src",
653 if (type & PERF_SAMPLE_TRANSACTION) {
654 ret = value_set_u64(cw, event,
"perf_transaction",
668 err = bt_ctf_stream_flush(cs->
stream);
670 pr_err(
"CTF stream %d flush failed\n", cs->
cpu);
672 pr(
"Flush stream for cpu %d (%u samples)\n",
684 struct bt_ctf_field *pkt_ctx = NULL;
685 struct bt_ctf_field *cpu_field = NULL;
686 struct bt_ctf_stream *stream = NULL;
691 pr_err(
"Failed to allocate ctf stream\n");
697 pr_err(
"Failed to create CTF stream\n");
701 pkt_ctx = bt_ctf_stream_get_packet_context(stream);
703 pr_err(
"Failed to obtain packet context\n");
707 cpu_field = bt_ctf_field_structure_get_field(pkt_ctx,
"cpu_id");
708 bt_ctf_field_put(pkt_ctx);
710 pr_err(
"Failed to obtain cpu field\n");
714 ret = bt_ctf_field_unsigned_integer_set_value(cpu_field, (u32) cpu);
716 pr_err(
"Failed to update CPU number\n");
720 bt_ctf_field_put(cpu_field);
728 bt_ctf_field_put(cpu_field);
730 bt_ctf_stream_put(stream);
739 bt_ctf_stream_put(cs->
stream);
761 if (evsel->
attr.sample_type & PERF_SAMPLE_CPU)
765 pr_err(
"Event was recorded for CPU %d, limit is at %d.\n",
773 #define STREAM_FLUSH_COUNT 100000 797 struct bt_ctf_event *
event;
799 unsigned long type = evsel->
attr.sample_type;
801 if (WARN_ONCE(!priv,
"Failed to setup all events.\n"))
812 event = bt_ctf_event_create(event_class);
814 pr_err(
"Failed to create an CTF event\n");
818 bt_ctf_clock_set_time(cw->
clock, sample->
time);
824 if (evsel->
attr.type == PERF_TYPE_TRACEPOINT) {
831 if (type & PERF_SAMPLE_CALLCHAIN) {
850 bt_ctf_stream_append_event(cs->
stream, event);
853 bt_ctf_event_put(event);
857 #define __NON_SAMPLE_SET_FIELD(_name, _type, _field) \ 859 ret = value_set_##_type(cw, event, #_field, _event->_name._field);\ 864 #define __FUNC_PROCESS_NON_SAMPLE(_name, body) \ 865 static int process_##_name##_event(struct perf_tool *tool, \ 866 union perf_event *_event, \ 867 struct perf_sample *sample, \ 868 struct machine *machine) \ 870 struct convert *c = container_of(tool, struct convert, tool);\ 871 struct ctf_writer *cw = &c->writer; \ 872 struct bt_ctf_event_class *event_class = cw->_name##_class;\ 873 struct bt_ctf_event *event; \ 874 struct ctf_stream *cs; \ 877 c->non_sample_count++; \ 878 c->events_size += _event->header.size; \ 879 event = bt_ctf_event_create(event_class); \ 881 pr_err("Failed to create an CTF event\n"); \ 885 bt_ctf_clock_set_time(cw->clock, sample->time); \ 887 cs = ctf_stream(cw, 0); \ 889 if (is_flush_needed(cs)) \ 890 ctf_stream__flush(cs); \ 893 bt_ctf_stream_append_event(cs->stream, event); \ 895 bt_ctf_event_put(event); \ 897 return perf_event__process_##_name(tool, _event, sample, machine);\ 936 static char *change_name(
char *
name,
char *orig_name,
int dup)
938 char *new_name = NULL;
952 len = strlen(name) +
sizeof(
"_");
954 len = strlen(orig_name) +
sizeof(
"_dupl_X");
961 snprintf(new_name, len,
"_%s", name);
963 snprintf(new_name, len,
"%s_dupl_%d", orig_name, dup);
966 if (name != orig_name)
972 struct bt_ctf_field_type *type,
973 struct format_field *
field)
975 struct bt_ctf_field_type *t = NULL;
981 if (field->alias != field->name)
982 return bt_ctf_event_class_add_field(event_class, type,
983 (
char *)field->alias);
988 if (bt_ctf_validate_identifier(name))
989 name = change_name(name, field->name, -1);
992 pr_err(
"Failed to fix invalid identifier.");
995 while ((t = bt_ctf_event_class_get_field_by_name(event_class, name))) {
996 bt_ctf_field_type_put(t);
997 name = change_name(name, field->name, dup++);
999 pr_err(
"Failed to create dup name for '%s'\n", field->name);
1004 ret = bt_ctf_event_class_add_field(event_class, type, name);
1006 field->alias =
name;
1012 struct format_field *
fields,
1015 struct format_field *
field;
1018 for (field = fields; field; field = field->next) {
1019 struct bt_ctf_field_type *type;
1020 unsigned long flags = field->flags;
1022 pr2(
" field '%s'\n", field->name);
1033 if (flags & FIELD_IS_STRING)
1034 flags &= ~FIELD_IS_ARRAY;
1036 if (flags & FIELD_IS_ARRAY)
1037 type = bt_ctf_field_type_array_create(type, field->arraylen);
1041 if (flags & FIELD_IS_ARRAY)
1042 bt_ctf_field_type_put(type);
1045 pr_err(
"Failed to add field '%s': %d\n",
1056 struct bt_ctf_event_class *
class)
1058 struct format_field *common_fields = evsel->
tp_format->format.common_fields;
1070 struct bt_ctf_event_class *
class)
1072 struct bt_ctf_field_type *len_type = cw->
data.
u32;
1073 struct bt_ctf_field_type *seq_base_type = cw->
data.
u32_hex;
1074 struct bt_ctf_field_type *seq_type;
1077 ret = bt_ctf_event_class_add_field(
class, len_type,
"raw_len");
1081 seq_type = bt_ctf_field_type_sequence_create(seq_base_type,
"raw_len");
1085 return bt_ctf_event_class_add_field(
class, seq_type,
"raw_data");
1091 u64 type = evsel->
attr.sample_type;
1106 #define ADD_FIELD(cl, t, n) \ 1108 pr2(" field '%s'\n", n); \ 1109 if (bt_ctf_event_class_add_field(cl, t, n)) { \ 1110 pr_err("Failed to add field '%s';\n", n); \ 1115 if (type & PERF_SAMPLE_IP)
1118 if (type & PERF_SAMPLE_TID) {
1123 if ((type & PERF_SAMPLE_ID) ||
1124 (type & PERF_SAMPLE_IDENTIFIER))
1127 if (type & PERF_SAMPLE_STREAM_ID)
1130 if (type & PERF_SAMPLE_PERIOD)
1133 if (type & PERF_SAMPLE_WEIGHT)
1136 if (type & PERF_SAMPLE_DATA_SRC)
1139 if (type & PERF_SAMPLE_TRANSACTION)
1142 if (type & PERF_SAMPLE_CALLCHAIN) {
1145 bt_ctf_field_type_sequence_create(
1161 pr(
"Adding event '%s' (type %d)\n", name, evsel->
attr.type);
1163 event_class = bt_ctf_event_class_create(name);
1171 if (evsel->
attr.type == PERF_TYPE_TRACEPOINT) {
1183 ret = bt_ctf_stream_class_add_event_class(cw->
stream_class, event_class);
1185 pr(
"Failed to add event class into stream.\n");
1189 priv =
malloc(
sizeof(*priv));
1198 bt_ctf_event_class_put(event_class);
1199 pr_err(
"Failed to add event '%s'.\n", name);
1217 #define __NON_SAMPLE_ADD_FIELD(t, n) \ 1219 pr2(" field '%s'\n", #n); \ 1220 if (bt_ctf_event_class_add_field(event_class, cw->data.t, #n)) {\ 1221 pr_err("Failed to add field '%s';\n", #n);\ 1226 #define __FUNC_ADD_NON_SAMPLE_EVENT_CLASS(_name, body) \ 1227 static int add_##_name##_event(struct ctf_writer *cw) \ 1229 struct bt_ctf_event_class *event_class; \ 1232 pr("Adding "#_name" event\n"); \ 1233 event_class = bt_ctf_event_class_create("perf_" #_name);\ 1238 ret = bt_ctf_stream_class_add_event_class(cw->stream_class, event_class);\ 1240 pr("Failed to add event class '"#_name"' into stream.\n");\ 1244 cw->_name##_class = event_class; \ 1245 bt_ctf_event_class_put(event_class); \ 1287 static int setup_non_sample_events(
struct ctf_writer *cw,
1292 ret = add_comm_event(cw);
1295 ret = add_exit_event(cw);
1298 ret = add_fork_event(cw);
1301 ret = add_mmap_event(cw);
1304 ret = add_mmap2_event(cw);
1339 stream =
zalloc(
sizeof(*stream) * ncpus);
1341 pr_err(
"Failed to allocate streams.\n");
1364 struct bt_ctf_writer *writer = cw->
writer;
1366 #define ADD(__n, __v) \ 1368 if (bt_ctf_writer_add_environment_field(writer, __n, __v)) \ 1373 ADD(
"sysname",
"Linux");
1377 ADD(
"domain",
"kernel");
1378 ADD(
"tracer_name",
"perf");
1386 struct bt_ctf_clock *clock = cw->
clock;
1388 bt_ctf_clock_set_description(clock,
"perf clock");
1390 #define SET(__n, __v) \ 1392 if (bt_ctf_clock_set_##__n(clock, __v)) \ 1396 SET(frequency, 1000000000);
1400 SET(is_absolute, 0);
1408 struct bt_ctf_field_type *type;
1410 type = bt_ctf_field_type_integer_create(size);
1415 bt_ctf_field_type_integer_set_signed(type, 1))
1419 bt_ctf_field_type_integer_set_base(type, BT_CTF_INTEGER_BASE_HEXADECIMAL))
1422 #if __BYTE_ORDER == __BIG_ENDIAN 1423 bt_ctf_field_type_set_byte_order(type, BT_CTF_BYTE_ORDER_BIG_ENDIAN);
1425 bt_ctf_field_type_set_byte_order(type, BT_CTF_BYTE_ORDER_LITTLE_ENDIAN);
1428 pr2(
"Created type: INTEGER %d-bit %ssigned %s\n",
1429 size, sign ?
"un" :
"", hex ?
"hex" :
"");
1433 bt_ctf_field_type_put(type);
1441 for (i = 0; i < ARRAY_SIZE(cw->
data.
array); i++)
1442 bt_ctf_field_type_put(cw->
data.
array[i]);
1447 #define CREATE_INT_TYPE(type, size, sign, hex) \ 1449 (type) = create_int_type(size, sign, hex); \ 1461 cw->
data.
string = bt_ctf_field_type_string_create();
1467 pr_err(
"Failed to create data types.\n");
1475 bt_ctf_clock_put(cw->
clock);
1478 bt_ctf_writer_put(cw->
writer);
1481 memset(cw, 0,
sizeof(*cw));
1486 struct bt_ctf_writer *writer;
1487 struct bt_ctf_stream_class *stream_class;
1488 struct bt_ctf_clock *clock;
1489 struct bt_ctf_field_type *pkt_ctx_type;
1493 writer = bt_ctf_writer_create(path);
1500 clock = bt_ctf_clock_create(
"perf_clock");
1502 pr(
"Failed to create CTF clock.\n");
1509 pr(
"Failed to setup CTF clock.\n");
1514 stream_class = bt_ctf_stream_class_create(
"perf_stream");
1515 if (!stream_class) {
1516 pr(
"Failed to create CTF stream class.\n");
1523 if (bt_ctf_stream_class_set_clock(stream_class, clock)) {
1524 pr(
"Failed to assign CTF clock to stream class.\n");
1532 pkt_ctx_type = bt_ctf_stream_class_get_packet_context_type(stream_class);
1536 ret = bt_ctf_field_type_structure_add_field(pkt_ctx_type, cw->
data.
u32,
"cpu_id");
1537 bt_ctf_field_type_put(pkt_ctx_type);
1542 if (bt_ctf_writer_add_clock(writer, clock)) {
1543 pr(
"Failed to assign CTF clock to writer.\n");
1552 pr_err(
"Failed to setup CTF writer.\n");
1560 for (cpu = 0; cpu < cw->
stream_cnt && !ret; cpu++)
1570 if (!strcmp(var,
"convert.queue-size"))
1583 .force = opts->
force,
1597 .ordered_events =
true,
1598 .ordering_requires_timestamps =
true,
1639 if (opts->
all && setup_non_sample_events(cw, session))
1649 pr_err(
"Error during conversion.\n");
1652 "[ perf data convert: Converted '%s' into CTF data '%s' ]\n",
1656 "[ perf data convert: Converted and wrote %.3f MB (%" PRIu64
" samples",
1661 fprintf(stderr,
") ]\n");
1675 pr_err(
"Error during conversion setup.\n");
struct bt_ctf_event_class * comm_class
static void ordered_events__set_alloc_size(struct ordered_events *oe, u64 size)
struct perf_evlist * evlist
static unsigned int hex(char c)
struct ordered_events ordered_events
struct bt_ctf_stream * stream
static int convert__config(const char *var, const char *value, void *cb)
struct bt_ctf_writer * writer
static int add_bpf_output_values(struct bt_ctf_event_class *event_class, struct bt_ctf_event *event, struct perf_sample *sample)
static struct bt_ctf_field_type * get_tracepoint_field_type(struct ctf_writer *cw, struct format_field *field)
static struct ctf_stream * ctf_stream(struct ctf_writer *cw, int cpu)
int perf_event__process_mmap(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine)
struct bt_ctf_field_type * u64_hex
static unsigned long long adjust_signedness(unsigned long long value_int, int size)
static bool perf_evsel__is_bpf_output(struct perf_evsel *evsel)
#define __NON_SAMPLE_ADD_FIELD(t, n)
struct ip_callchain * callchain
static bool is_flush_needed(struct ctf_stream *cs)
static int add_tracepoint_fields_types(struct ctf_writer *cw, struct format_field *fields, struct bt_ctf_event_class *event_class)
static int input(yyscan_t yyscanner)
static int add_bpf_output_types(struct ctf_writer *cw, struct bt_ctf_event_class *class)
struct perf_data_file file
void perf_evlist__delete(struct perf_evlist *evlist)
int perf_event__process_comm(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine)
int perf_event__process_exit(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine)
static void cleanup_events(struct perf_session *session)
static int process_exit_event(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine)
struct bt_ctf_event_class * event_class
static int get_sample_cpu(struct ctf_writer *cw, struct perf_sample *sample, struct perf_evsel *evsel)
static int process_mmap_event(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine)
int perf_event__process_fork(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine)
static void ctf_writer__cleanup(struct ctf_writer *cw)
x86 movsq based memset() in arch/x86/lib/memset_64.S") MEMSET_FN(memset_erms
static int ctf_writer__flush_streams(struct ctf_writer *cw)
void perf_session__delete(struct perf_session *session)
static int ctf_stream__flush(struct ctf_stream *cs)
static int ctf_writer__init(struct ctf_writer *cw, const char *path)
static struct ctf_stream * ctf_stream__create(struct ctf_writer *cw, int cpu)
static int add_generic_types(struct ctf_writer *cw, struct perf_evsel *evsel, struct bt_ctf_event_class *event_class)
struct bt_ctf_event_class * exit_class
struct bt_ctf_field_type * string
#define __NON_SAMPLE_SET_FIELD(_name, _type, _field)
#define STREAM_FLUSH_COUNT
#define ADD_FIELD(cl, t, n)
static void ctf_writer__cleanup_data(struct ctf_writer *cw)
static struct perf_session * session
#define evlist__for_each_entry(evlist, evsel)
struct bt_ctf_field_type * s64
struct bt_ctf_event_class * mmap2_class
struct bt_ctf_event_class * mmap_class
struct bt_ctf_field_type * u32
static int process_sample_event(struct perf_tool *tool, union perf_event *_event, struct perf_sample *sample, struct perf_evsel *evsel, struct machine *machine __maybe_unused)
static int ctf_writer__setup_env(struct ctf_writer *cw, struct perf_session *session)
static struct perf_tool tool
struct event_format * tp_format
struct bt_ctf_field_type * array[6]
int perf_config_u64(u64 *dest, const char *name, const char *value)
static void free_streams(struct ctf_writer *cw)
static int process_fork_event(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine)
static int ctf_writer__setup_clock(struct ctf_writer *cw)
struct bt_ctf_field_type * u64
#define __FUNC_ADD_NON_SAMPLE_EVENT_CLASS(_name, body)
static int process_comm_event(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine)
static int add_event(struct ctf_writer *cw, struct perf_evsel *evsel)
static int add_tracepoint_field_value(struct ctf_writer *cw, struct bt_ctf_event_class *event_class, struct bt_ctf_event *event, struct perf_sample *sample, struct format_field *fmtf)
static struct bt_ctf_field_type * create_int_type(int size, bool sign, bool hex)
const char * perf_evsel__name(struct perf_evsel *evsel)
struct bt_ctf_stream_class * stream_class
static int string_set_value(struct bt_ctf_field *field, const char *string)
struct perf_event_header header
struct perf_session * perf_session__new(struct perf_data *data, bool repipe, struct perf_tool *tool)
int perf_event__process_mmap2(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine)
static int add_tracepoint_types(struct ctf_writer *cw, struct perf_evsel *evsel, struct bt_ctf_event_class *class)
static void ctf_stream__delete(struct ctf_stream *cs)
union ctf_writer::@63 data
int perf_config(config_fn_t fn, void *data)
int perf_session__process_events(struct perf_session *session)
static int event_class_add_field(struct bt_ctf_event_class *event_class, struct bt_ctf_field_type *type, struct format_field *field)
static __maybe_unused int value_set_string(struct ctf_writer *cw, struct bt_ctf_event *event, const char *name, const char *string)
struct bt_ctf_field_type * u32_hex
static int process_mmap2_event(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct machine *machine)
struct bt_ctf_event_class * fork_class
int bt_convert__perf2ctf(const char *input, const char *path, struct perf_data_convert_opts *opts)
static unsigned int ncpus
struct perf_header header
static int setup_events(struct ctf_writer *cw, struct perf_session *session)
#define CREATE_INT_TYPE(type, size, sign, hex)
struct ctf_stream ** stream
static int add_tracepoint_values(struct ctf_writer *cw, struct bt_ctf_event_class *event_class, struct bt_ctf_event *event, struct perf_evsel *evsel, struct perf_sample *sample)
int perf_event__process_lost(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine)
#define __FUNC_PROCESS_NON_SAMPLE(_name, body)
static int add_generic_values(struct ctf_writer *cw, struct bt_ctf_event *event, struct perf_evsel *evsel, struct perf_sample *sample)
#define __FUNC_VALUE_SET(_name, _val_type)
static int ctf_writer__init_data(struct ctf_writer *cw)
#define pr_warning(fmt,...)
static int setup_streams(struct ctf_writer *cw, struct perf_session *session)
#define FUNC_VALUE_SET(_name)
static int value_set(struct bt_ctf_field_type *type, struct bt_ctf_event *event, const char *name, u64 val)
int perf_event__process_namespaces(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine)
struct bt_ctf_clock * clock
struct bt_ctf_field_type * s32
static int add_tracepoint_fields_values(struct ctf_writer *cw, struct bt_ctf_event_class *event_class, struct bt_ctf_event *event, struct format_field *fields, struct perf_sample *sample)
#define pr_time2(t, fmt,...)
struct perf_event_attr attr
void static void * zalloc(size_t size)
static int add_callchain_output_values(struct bt_ctf_event_class *event_class, struct bt_ctf_event *event, struct ip_callchain *callchain)