Lines Matching refs:cw
144 static __maybe_unused int value_set_##_name(struct ctf_writer *cw, \
149 struct bt_ctf_field_type *type = cw->data._name; \
163 value_set_string(struct ctf_writer *cw, struct bt_ctf_event *event, in value_set_string() argument
166 struct bt_ctf_field_type *type = cw->data.string; in value_set_string()
192 get_tracepoint_field_type(struct ctf_writer *cw, struct tep_format_field *field) in get_tracepoint_field_type() argument
197 return cw->data.string; in get_tracepoint_field_type()
202 return cw->data.u64_hex; in get_tracepoint_field_type()
207 return cw->data.s64; in get_tracepoint_field_type()
209 return cw->data.s32; in get_tracepoint_field_type()
213 return cw->data.u64; in get_tracepoint_field_type()
215 return cw->data.u32; in get_tracepoint_field_type()
293 static int add_tracepoint_field_value(struct ctf_writer *cw, in add_tracepoint_field_value() argument
347 type = get_tracepoint_field_type(cw, fmtf); in add_tracepoint_field_value()
405 static int add_tracepoint_fields_values(struct ctf_writer *cw, in add_tracepoint_fields_values() argument
415 ret = add_tracepoint_field_value(cw, event_class, event, sample, in add_tracepoint_fields_values()
423 static int add_tracepoint_values(struct ctf_writer *cw, in add_tracepoint_values() argument
433 ret = add_tracepoint_fields_values(cw, event_class, event, in add_tracepoint_values()
436 ret = add_tracepoint_fields_values(cw, event_class, event, in add_tracepoint_values()
595 static int add_generic_values(struct ctf_writer *cw, in add_generic_values() argument
615 ret = value_set_u64_hex(cw, event, "perf_ip", sample->ip); in add_generic_values()
621 ret = value_set_s32(cw, event, "perf_tid", sample->tid); in add_generic_values()
625 ret = value_set_s32(cw, event, "perf_pid", sample->pid); in add_generic_values()
632 ret = value_set_u64(cw, event, "perf_id", sample->id); in add_generic_values()
638 ret = value_set_u64(cw, event, "perf_stream_id", sample->stream_id); in add_generic_values()
644 ret = value_set_u64(cw, event, "perf_period", sample->period); in add_generic_values()
650 ret = value_set_u64(cw, event, "perf_weight", sample->weight); in add_generic_values()
656 ret = value_set_u64(cw, event, "perf_data_src", in add_generic_values()
663 ret = value_set_u64(cw, event, "perf_transaction", in add_generic_values()
690 static struct ctf_stream *ctf_stream__create(struct ctf_writer *cw, int cpu) in ctf_stream__create() argument
704 stream = bt_ctf_writer_create_stream(cw->writer, cw->stream_class); in ctf_stream__create()
753 static struct ctf_stream *ctf_stream(struct ctf_writer *cw, int cpu) in ctf_stream() argument
755 struct ctf_stream *cs = cw->stream[cpu]; in ctf_stream()
758 cs = ctf_stream__create(cw, cpu); in ctf_stream()
759 cw->stream[cpu] = cs; in ctf_stream()
765 static int get_sample_cpu(struct ctf_writer *cw, struct perf_sample *sample, in get_sample_cpu() argument
773 if (cpu > cw->stream_cnt) { in get_sample_cpu()
775 cpu, cw->stream_cnt); in get_sample_cpu()
803 struct ctf_writer *cw = &c->writer; in process_sample_event() local
827 bt_ctf_clock_set_time(cw->clock, sample->time); in process_sample_event()
829 ret = add_generic_values(cw, event, evsel, sample); in process_sample_event()
834 ret = add_tracepoint_values(cw, event_class, event, in process_sample_event()
853 cs = ctf_stream(cw, get_sample_cpu(cw, sample, evsel)); in process_sample_event()
868 ret = value_set_##_type(cw, event, #_field, _event->_name._field);\
880 struct ctf_writer *cw = &c->writer; \
881 struct bt_ctf_event_class *event_class = cw->_name##_class;\
894 bt_ctf_clock_set_time(cw->clock, sample->time); \
896 cs = ctf_stream(cw, 0); \
1020 static int add_tracepoint_fields_types(struct ctf_writer *cw, in add_tracepoint_fields_types() argument
1033 type = get_tracepoint_field_type(cw, field); in add_tracepoint_fields_types()
1063 static int add_tracepoint_types(struct ctf_writer *cw, in add_tracepoint_types() argument
1071 ret = add_tracepoint_fields_types(cw, common_fields, class); in add_tracepoint_types()
1073 ret = add_tracepoint_fields_types(cw, fields, class); in add_tracepoint_types()
1078 static int add_bpf_output_types(struct ctf_writer *cw, in add_bpf_output_types() argument
1081 struct bt_ctf_field_type *len_type = cw->data.u32; in add_bpf_output_types()
1082 struct bt_ctf_field_type *seq_base_type = cw->data.u32_hex; in add_bpf_output_types()
1097 static int add_generic_types(struct ctf_writer *cw, struct evsel *evsel, in add_generic_types() argument
1125 ADD_FIELD(event_class, cw->data.u64_hex, "perf_ip"); in add_generic_types()
1128 ADD_FIELD(event_class, cw->data.s32, "perf_tid"); in add_generic_types()
1129 ADD_FIELD(event_class, cw->data.s32, "perf_pid"); in add_generic_types()
1134 ADD_FIELD(event_class, cw->data.u64, "perf_id"); in add_generic_types()
1137 ADD_FIELD(event_class, cw->data.u64, "perf_stream_id"); in add_generic_types()
1140 ADD_FIELD(event_class, cw->data.u64, "perf_period"); in add_generic_types()
1143 ADD_FIELD(event_class, cw->data.u64, "perf_weight"); in add_generic_types()
1146 ADD_FIELD(event_class, cw->data.u64, "perf_data_src"); in add_generic_types()
1149 ADD_FIELD(event_class, cw->data.u64, "perf_transaction"); in add_generic_types()
1152 ADD_FIELD(event_class, cw->data.u32, "perf_callchain_size"); in add_generic_types()
1155 cw->data.u64_hex, "perf_callchain_size"), in add_generic_types()
1163 static int add_event(struct ctf_writer *cw, struct evsel *evsel) in add_event() argument
1176 ret = add_generic_types(cw, evsel, event_class); in add_event()
1181 ret = add_tracepoint_types(cw, evsel, event_class); in add_event()
1187 ret = add_bpf_output_types(cw, event_class); in add_event()
1192 ret = bt_ctf_stream_class_add_event_class(cw->stream_class, event_class); in add_event()
1212 static int setup_events(struct ctf_writer *cw, struct perf_session *session) in setup_events() argument
1219 ret = add_event(cw, evsel); in setup_events()
1229 if (bt_ctf_event_class_add_field(event_class, cw->data.t, #n)) {\
1236 static int add_##_name##_event(struct ctf_writer *cw) \
1247 ret = bt_ctf_stream_class_add_event_class(cw->stream_class, event_class);\
1253 cw->_name##_class = event_class; \
1296 static int setup_non_sample_events(struct ctf_writer *cw,
1301 ret = add_comm_event(cw);
1304 ret = add_exit_event(cw);
1307 ret = add_fork_event(cw);
1310 ret = add_mmap_event(cw);
1313 ret = add_mmap2_event(cw);
1336 static int setup_streams(struct ctf_writer *cw, struct perf_session *session) in setup_streams() argument
1354 cw->stream = stream; in setup_streams()
1355 cw->stream_cnt = ncpus; in setup_streams()
1359 static void free_streams(struct ctf_writer *cw) in free_streams() argument
1363 for (cpu = 0; cpu < cw->stream_cnt; cpu++) in free_streams()
1364 ctf_stream__delete(cw->stream[cpu]); in free_streams()
1366 zfree(&cw->stream); in free_streams()
1369 static int ctf_writer__setup_env(struct ctf_writer *cw, in ctf_writer__setup_env() argument
1373 struct bt_ctf_writer *writer = cw->writer; in ctf_writer__setup_env()
1393 static int ctf_writer__setup_clock(struct ctf_writer *cw, in ctf_writer__setup_clock() argument
1397 struct bt_ctf_clock *clock = cw->clock; in ctf_writer__setup_clock()
1461 static void ctf_writer__cleanup_data(struct ctf_writer *cw) in ctf_writer__cleanup_data() argument
1465 for (i = 0; i < ARRAY_SIZE(cw->data.array); i++) in ctf_writer__cleanup_data()
1466 bt_ctf_field_type_put(cw->data.array[i]); in ctf_writer__cleanup_data()
1469 static int ctf_writer__init_data(struct ctf_writer *cw) in ctf_writer__init_data() argument
1478 CREATE_INT_TYPE(cw->data.s64, 64, true, false); in ctf_writer__init_data()
1479 CREATE_INT_TYPE(cw->data.u64, 64, false, false); in ctf_writer__init_data()
1480 CREATE_INT_TYPE(cw->data.s32, 32, true, false); in ctf_writer__init_data()
1481 CREATE_INT_TYPE(cw->data.u32, 32, false, false); in ctf_writer__init_data()
1482 CREATE_INT_TYPE(cw->data.u32_hex, 32, false, true); in ctf_writer__init_data()
1483 CREATE_INT_TYPE(cw->data.u64_hex, 64, false, true); in ctf_writer__init_data()
1485 cw->data.string = bt_ctf_field_type_string_create(); in ctf_writer__init_data()
1486 if (cw->data.string) in ctf_writer__init_data()
1490 ctf_writer__cleanup_data(cw); in ctf_writer__init_data()
1495 static void ctf_writer__cleanup(struct ctf_writer *cw) in ctf_writer__cleanup() argument
1497 ctf_writer__cleanup_data(cw); in ctf_writer__cleanup()
1499 bt_ctf_clock_put(cw->clock); in ctf_writer__cleanup()
1500 free_streams(cw); in ctf_writer__cleanup()
1501 bt_ctf_stream_class_put(cw->stream_class); in ctf_writer__cleanup()
1502 bt_ctf_writer_put(cw->writer); in ctf_writer__cleanup()
1505 memset(cw, 0, sizeof(*cw)); in ctf_writer__cleanup()
1508 static int ctf_writer__init(struct ctf_writer *cw, const char *path, in ctf_writer__init() argument
1522 cw->writer = writer; in ctf_writer__init()
1531 cw->clock = clock; in ctf_writer__init()
1533 if (ctf_writer__setup_clock(cw, session, tod)) { in ctf_writer__init()
1545 cw->stream_class = stream_class; in ctf_writer__init()
1553 if (ctf_writer__init_data(cw)) in ctf_writer__init()
1561 ret = bt_ctf_field_type_structure_add_field(pkt_ctx_type, cw->data.u32, "cpu_id"); in ctf_writer__init()
1575 ctf_writer__cleanup(cw); in ctf_writer__init()
1581 static int ctf_writer__flush_streams(struct ctf_writer *cw) in ctf_writer__flush_streams() argument
1585 for (cpu = 0; cpu < cw->stream_cnt && !ret; cpu++) in ctf_writer__flush_streams()
1586 ret = ctf_stream__flush(cw->stream[cpu]); in ctf_writer__flush_streams()
1626 struct ctf_writer *cw = &c.writer; in bt_convert__perf2ctf() local
1648 if (ctf_writer__init(cw, path, session, opts->tod)) in bt_convert__perf2ctf()
1657 if (ctf_writer__setup_env(cw, session)) in bt_convert__perf2ctf()
1661 if (setup_events(cw, session)) in bt_convert__perf2ctf()
1664 if (opts->all && setup_non_sample_events(cw, session)) in bt_convert__perf2ctf()
1667 if (setup_streams(cw, session)) in bt_convert__perf2ctf()
1672 err = ctf_writer__flush_streams(cw); in bt_convert__perf2ctf()
1692 ctf_writer__cleanup(cw); in bt_convert__perf2ctf()
1697 ctf_writer__cleanup(cw); in bt_convert__perf2ctf()