trace-event.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _PERF_UTIL_TRACE_EVENT_H
  3. #define _PERF_UTIL_TRACE_EVENT_H
  4. #include <traceevent/event-parse.h>
  5. #include <traceevent/trace-seq.h>
  6. #include "parse-events.h"
  7. struct machine;
  8. struct perf_sample;
  9. union perf_event;
  10. struct perf_tool;
  11. struct thread;
  12. struct tep_plugin_list;
  13. struct trace_event {
  14. struct tep_handle *pevent;
  15. struct tep_plugin_list *plugin_list;
  16. };
  17. int trace_event__init(struct trace_event *t);
  18. void trace_event__cleanup(struct trace_event *t);
  19. int trace_event__register_resolver(struct machine *machine,
  20. tep_func_resolver_t *func);
  21. struct tep_event_format*
  22. trace_event__tp_format(const char *sys, const char *name);
  23. struct tep_event_format *trace_event__tp_format_id(int id);
  24. int bigendian(void);
  25. void event_format__fprintf(struct tep_event_format *event,
  26. int cpu, void *data, int size, FILE *fp);
  27. void event_format__print(struct tep_event_format *event,
  28. int cpu, void *data, int size);
  29. int parse_ftrace_file(struct tep_handle *pevent, char *buf, unsigned long size);
  30. int parse_event_file(struct tep_handle *pevent,
  31. char *buf, unsigned long size, char *sys);
  32. unsigned long long
  33. raw_field_value(struct tep_event_format *event, const char *name, void *data);
  34. void parse_proc_kallsyms(struct tep_handle *pevent, char *file, unsigned int size);
  35. void parse_ftrace_printk(struct tep_handle *pevent, char *file, unsigned int size);
  36. void parse_saved_cmdline(struct tep_handle *pevent, char *file, unsigned int size);
  37. ssize_t trace_report(int fd, struct trace_event *tevent, bool repipe);
  38. struct tep_event_format *trace_find_next_event(struct tep_handle *pevent,
  39. struct tep_event_format *event);
  40. unsigned long long read_size(struct tep_event_format *event, void *ptr, int size);
  41. unsigned long long eval_flag(const char *flag);
  42. int read_tracing_data(int fd, struct list_head *pattrs);
  43. struct tracing_data {
  44. /* size is only valid if temp is 'true' */
  45. ssize_t size;
  46. bool temp;
  47. char temp_file[50];
  48. };
  49. struct tracing_data *tracing_data_get(struct list_head *pattrs,
  50. int fd, bool temp);
  51. int tracing_data_put(struct tracing_data *tdata);
  52. struct addr_location;
  53. struct perf_session;
  54. struct perf_stat_config;
  55. struct scripting_ops {
  56. const char *name;
  57. int (*start_script) (const char *script, int argc, const char **argv);
  58. int (*flush_script) (void);
  59. int (*stop_script) (void);
  60. void (*process_event) (union perf_event *event,
  61. struct perf_sample *sample,
  62. struct perf_evsel *evsel,
  63. struct addr_location *al);
  64. void (*process_stat)(struct perf_stat_config *config,
  65. struct perf_evsel *evsel, u64 tstamp);
  66. void (*process_stat_interval)(u64 tstamp);
  67. int (*generate_script) (struct tep_handle *pevent, const char *outfile);
  68. };
  69. extern unsigned int scripting_max_stack;
  70. int script_spec_register(const char *spec, struct scripting_ops *ops);
  71. void setup_perl_scripting(void);
  72. void setup_python_scripting(void);
  73. struct scripting_context {
  74. struct tep_handle *pevent;
  75. void *event_data;
  76. };
  77. int common_pc(struct scripting_context *context);
  78. int common_flags(struct scripting_context *context);
  79. int common_lock_depth(struct scripting_context *context);
  80. #endif /* _PERF_UTIL_TRACE_EVENT_H */