1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _PERF_UTIL_TRACE_EVENT_H 3 #define _PERF_UTIL_TRACE_EVENT_H 4 5 #include <stdbool.h> 6 #include <stdio.h> 7 #include <sys/types.h> 8 #include <linux/types.h> 9 10 struct machine; 11 struct tep_format_field; 12 struct tep_plugin_list; 13 14 struct trace_event { 15 struct tep_handle *pevent; 16 struct tep_plugin_list *plugin_list; 17 }; 18 19 /* Computes a version number comparable with LIBTRACEEVENT_VERSION from Makefile.config. */ 20 #define MAKE_LIBTRACEEVENT_VERSION(a, b, c) ((a)*255*255+(b)*255+(c)) 21 22 typedef char *(tep_func_resolver_t)(void *priv, 23 unsigned long long *addrp, char **modp); 24 25 bool have_tracepoints(struct list_head *evlist); 26 27 int trace_event__init(struct trace_event *t); 28 void trace_event__cleanup(struct trace_event *t); 29 void trace_event__exit(void); 30 int trace_event__register_resolver(struct machine *machine, 31 tep_func_resolver_t *func); 32 struct tep_event* 33 trace_event__tp_format(const char *sys, const char *name); 34 35 struct tep_event *trace_event__tp_format_id(int id); 36 37 void event_format__fprintf(const struct tep_event *event, 38 int cpu, void *data, int size, FILE *fp); 39 40 int parse_ftrace_file(struct tep_handle *pevent, char *buf, unsigned long size); 41 int parse_event_file(struct tep_handle *pevent, 42 char *buf, unsigned long size, char *sys); 43 44 unsigned long long 45 raw_field_value(struct tep_event *event, const char *name, void *data); 46 47 const char *parse_task_states(struct tep_format_field *state_field); 48 49 void parse_proc_kallsyms(struct tep_handle *pevent, char *file, unsigned int size); 50 void parse_ftrace_printk(struct tep_handle *pevent, char *file, unsigned int size); 51 void parse_saved_cmdline(struct tep_handle *pevent, char *file, unsigned int size); 52 53 ssize_t trace_report(int fd, struct trace_event *tevent, bool repipe); 54 55 unsigned long long read_size(struct tep_event *event, void *ptr, int size); 56 unsigned long long eval_flag(const char *flag); 57 58 int read_tracing_data(int fd, struct list_head *pattrs); 59 60 /* 61 * Return the tracepoint name in the format "subsystem:event_name", 62 * callers should free the returned string. 63 */ 64 char *tracepoint_id_to_name(u64 config); 65 66 struct tracing_data { 67 /* size is only valid if temp is 'true' */ 68 ssize_t size; 69 bool temp; 70 char temp_file[50]; 71 }; 72 73 struct tracing_data *tracing_data_get(struct list_head *pattrs, 74 int fd, bool temp); 75 int tracing_data_put(struct tracing_data *tdata); 76 77 #if defined(LIBTRACEEVENT_VERSION) && LIBTRACEEVENT_VERSION >= MAKE_LIBTRACEEVENT_VERSION(1, 5, 0) 78 #include <event-parse.h> 79 80 static inline bool tep_field_is_relative(unsigned long flags) 81 { 82 return (flags & TEP_FIELD_IS_RELATIVE) != 0; 83 } 84 #else 85 #include <linux/compiler.h> 86 87 static inline bool tep_field_is_relative(unsigned long flags __maybe_unused) 88 { 89 return false; 90 } 91 #endif 92 93 #endif /* _PERF_UTIL_TRACE_EVENT_H */ 94