1 /* SPDX-License-Identifier: LGPL-2.1 */ 2 /* 3 * Copyright (C) 2008, 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com> 4 * 5 */ 6 #ifndef _TRACE_CMD_H 7 #define _TRACE_CMD_H 8 9 #include "event-parse.h" 10 #include "tracefs.h" 11 12 #ifdef __cplusplus 13 extern "C" { 14 #endif 15 16 struct tracecmd_input; 17 18 enum tracecmd_open_flags { 19 TRACECMD_FL_LOAD_NO_PLUGINS = 1 << 0, /* Do not load plugins */ 20 TRACECMD_FL_LOAD_NO_SYSTEM_PLUGINS = 1 << 1, /* Do not load system plugins */ 21 }; 22 23 enum tracecmd_section_flags { 24 TRACECMD_SEC_FL_COMPRESS = 1 << 0, /* the section is compressed */ 25 }; 26 27 struct tracecmd_input *tracecmd_open_head(const char *file, int flags); 28 struct tracecmd_input *tracecmd_open(const char *file, int flags); 29 struct tracecmd_input *tracecmd_open_fd(int fd, int flags); 30 31 void tracecmd_close(struct tracecmd_input *handle); 32 33 int tracecmd_init_data(struct tracecmd_input *handle); 34 struct tep_record * 35 tracecmd_read_cpu_first(struct tracecmd_input *handle, int cpu); 36 struct tep_record * 37 tracecmd_read_data(struct tracecmd_input *handle, int cpu); 38 struct tep_record * 39 tracecmd_read_at(struct tracecmd_input *handle, unsigned long long offset, 40 int *cpu); 41 void tracecmd_free_record(struct tep_record *record); 42 43 struct tep_handle *tracecmd_get_tep(struct tracecmd_input *handle); 44 unsigned long long tracecmd_get_traceid(struct tracecmd_input *handle); 45 int tracecmd_get_guest_cpumap(struct tracecmd_input *handle, 46 unsigned long long trace_id, 47 const char **name, 48 int *vcpu_count, const int **cpu_pid); 49 unsigned long long tracecmd_get_first_ts(struct tracecmd_input *handle); 50 void tracecmd_add_ts_offset(struct tracecmd_input *handle, long long offset); 51 int tracecmd_get_tsc2nsec(struct tracecmd_input *handle, 52 int *mult, int *shift, unsigned long long *offset); 53 int tracecmd_buffer_instances(struct tracecmd_input *handle); 54 const char *tracecmd_buffer_instance_name(struct tracecmd_input *handle, int indx); 55 struct tracecmd_input *tracecmd_buffer_instance_handle(struct tracecmd_input *handle, int indx); 56 57 void tracecmd_set_private(struct tracecmd_input *handle, void *data); 58 void *tracecmd_get_private(struct tracecmd_input *handle); 59 60 int tracecmd_follow_event(struct tracecmd_input *handle, 61 const char *system, const char *event_name, 62 int (*callback)(struct tracecmd_input *handle, 63 struct tep_event *, 64 struct tep_record *, 65 int, void *), 66 void *callback_data); 67 68 int tracecmd_follow_missed_events(struct tracecmd_input *handle, 69 int (*callback)(struct tracecmd_input *handle, 70 struct tep_event *, 71 struct tep_record *, 72 int, void *), 73 void *callback_data); 74 75 int tracecmd_iterate_reset(struct tracecmd_input *handle); 76 77 int tracecmd_iterate_events(struct tracecmd_input *handle, 78 cpu_set_t *cpus, int cpu_size, 79 int (*callback)(struct tracecmd_input *handle, 80 struct tep_record *, 81 int, void *), 82 void *callback_data); 83 int tracecmd_iterate_events_multi(struct tracecmd_input **handles, 84 int nr_handles, 85 int (*callback)(struct tracecmd_input *handle, 86 struct tep_record *, 87 int, void *), 88 void *callback_data); 89 int tracecmd_iterate_events_reverse(struct tracecmd_input *handle, 90 cpu_set_t *cpus, int cpu_size, 91 int (*callback)(struct tracecmd_input *handle, 92 struct tep_record *, 93 int, void *), 94 void *callback_data, bool cont); 95 96 void tracecmd_set_loglevel(enum tep_loglevel level); 97 98 enum tracecmd_filters { 99 TRACECMD_FILTER_NONE = TEP_ERRNO__NO_FILTER, 100 TRACECMD_FILTER_NOT_FOUND = TEP_ERRNO__FILTER_NOT_FOUND, 101 TRACECMD_FILTER_MISS = TEP_ERRNO__FILTER_MISS, 102 TRACECMD_FILTER_MATCH = TEP_ERRNO__FILTER_MATCH, 103 }; 104 105 struct tracecmd_filter; 106 struct tracecmd_filter *tracecmd_filter_add(struct tracecmd_input *handle, 107 const char *filter_str, bool neg); 108 109 struct tracecmd_cpu_map; 110 int tracecmd_map_vcpus(struct tracecmd_input **handles, int nr_handles); 111 struct tracecmd_cpu_map *tracecmd_get_cpu_map(struct tracecmd_input *handle, int cpu); 112 struct tracecmd_cpu_map *tracecmd_map_find_by_host_pid(struct tracecmd_input *handle, 113 int host_pid); 114 struct tracecmd_input *tracecmd_map_get_guest(struct tracecmd_cpu_map *map); 115 int tracecmd_map_get_host_pid(struct tracecmd_cpu_map *map); 116 void tracecmd_map_set_private(struct tracecmd_cpu_map *map, void *priv); 117 void *tracecmd_map_get_private(struct tracecmd_cpu_map *map); 118 119 #ifdef __cplusplus 120 } 121 #endif 122 123 #endif /* _TRACE_CMD_H */ 124