probe-event.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _PROBE_EVENT_H
  3. #define _PROBE_EVENT_H
  4. #include <linux/compiler.h>
  5. #include <stdbool.h>
  6. #include "intlist.h"
  7. #include "namespaces.h"
  8. /* Probe related configurations */
  9. struct probe_conf {
  10. bool show_ext_vars;
  11. bool show_location_range;
  12. bool force_add;
  13. bool no_inlines;
  14. bool cache;
  15. int max_probes;
  16. };
  17. extern struct probe_conf probe_conf;
  18. extern bool probe_event_dry_run;
  19. struct symbol;
  20. /* kprobe-tracer and uprobe-tracer tracing point */
  21. struct probe_trace_point {
  22. char *realname; /* function real name (if needed) */
  23. char *symbol; /* Base symbol */
  24. char *module; /* Module name */
  25. unsigned long offset; /* Offset from symbol */
  26. unsigned long address; /* Actual address of the trace point */
  27. bool retprobe; /* Return probe flag */
  28. };
  29. /* probe-tracer tracing argument referencing offset */
  30. struct probe_trace_arg_ref {
  31. struct probe_trace_arg_ref *next; /* Next reference */
  32. long offset; /* Offset value */
  33. };
  34. /* kprobe-tracer and uprobe-tracer tracing argument */
  35. struct probe_trace_arg {
  36. char *name; /* Argument name */
  37. char *value; /* Base value */
  38. char *type; /* Type name */
  39. struct probe_trace_arg_ref *ref; /* Referencing offset */
  40. };
  41. /* kprobe-tracer and uprobe-tracer tracing event (point + arg) */
  42. struct probe_trace_event {
  43. char *event; /* Event name */
  44. char *group; /* Group name */
  45. struct probe_trace_point point; /* Trace point */
  46. int nargs; /* Number of args */
  47. bool uprobes; /* uprobes only */
  48. struct probe_trace_arg *args; /* Arguments */
  49. };
  50. /* Perf probe probing point */
  51. struct perf_probe_point {
  52. char *file; /* File path */
  53. char *function; /* Function name */
  54. int line; /* Line number */
  55. bool retprobe; /* Return probe flag */
  56. char *lazy_line; /* Lazy matching pattern */
  57. unsigned long offset; /* Offset from function entry */
  58. unsigned long abs_address; /* Absolute address of the point */
  59. };
  60. /* Perf probe probing argument field chain */
  61. struct perf_probe_arg_field {
  62. struct perf_probe_arg_field *next; /* Next field */
  63. char *name; /* Name of the field */
  64. long index; /* Array index number */
  65. bool ref; /* Referencing flag */
  66. };
  67. /* Perf probe probing argument */
  68. struct perf_probe_arg {
  69. char *name; /* Argument name */
  70. char *var; /* Variable name */
  71. char *type; /* Type name */
  72. struct perf_probe_arg_field *field; /* Structure fields */
  73. };
  74. /* Perf probe probing event (point + arg) */
  75. struct perf_probe_event {
  76. char *event; /* Event name */
  77. char *group; /* Group name */
  78. struct perf_probe_point point; /* Probe point */
  79. int nargs; /* Number of arguments */
  80. bool sdt; /* SDT/cached event flag */
  81. bool uprobes; /* Uprobe event flag */
  82. char *target; /* Target binary */
  83. struct perf_probe_arg *args; /* Arguments */
  84. struct probe_trace_event *tevs;
  85. int ntevs;
  86. struct nsinfo *nsi; /* Target namespace */
  87. };
  88. /* Line range */
  89. struct line_range {
  90. char *file; /* File name */
  91. char *function; /* Function name */
  92. int start; /* Start line number */
  93. int end; /* End line number */
  94. int offset; /* Start line offset */
  95. char *path; /* Real path name */
  96. char *comp_dir; /* Compile directory */
  97. struct intlist *line_list; /* Visible lines */
  98. };
  99. struct strlist;
  100. /* List of variables */
  101. struct variable_list {
  102. struct probe_trace_point point; /* Actual probepoint */
  103. struct strlist *vars; /* Available variables */
  104. };
  105. struct map;
  106. int init_probe_symbol_maps(bool user_only);
  107. void exit_probe_symbol_maps(void);
  108. /* Command string to events */
  109. int parse_perf_probe_command(const char *cmd, struct perf_probe_event *pev);
  110. int parse_probe_trace_command(const char *cmd, struct probe_trace_event *tev);
  111. /* Events to command string */
  112. char *synthesize_perf_probe_command(struct perf_probe_event *pev);
  113. char *synthesize_probe_trace_command(struct probe_trace_event *tev);
  114. char *synthesize_perf_probe_arg(struct perf_probe_arg *pa);
  115. char *synthesize_perf_probe_point(struct perf_probe_point *pp);
  116. int perf_probe_event__copy(struct perf_probe_event *dst,
  117. struct perf_probe_event *src);
  118. bool perf_probe_with_var(struct perf_probe_event *pev);
  119. /* Check the perf_probe_event needs debuginfo */
  120. bool perf_probe_event_need_dwarf(struct perf_probe_event *pev);
  121. /* Release event contents */
  122. void clear_perf_probe_event(struct perf_probe_event *pev);
  123. void clear_probe_trace_event(struct probe_trace_event *tev);
  124. /* Command string to line-range */
  125. int parse_line_range_desc(const char *cmd, struct line_range *lr);
  126. /* Release line range members */
  127. void line_range__clear(struct line_range *lr);
  128. /* Initialize line range */
  129. int line_range__init(struct line_range *lr);
  130. int add_perf_probe_events(struct perf_probe_event *pevs, int npevs);
  131. int convert_perf_probe_events(struct perf_probe_event *pevs, int npevs);
  132. int apply_perf_probe_events(struct perf_probe_event *pevs, int npevs);
  133. int show_probe_trace_events(struct perf_probe_event *pevs, int npevs);
  134. void cleanup_perf_probe_events(struct perf_probe_event *pevs, int npevs);
  135. struct strfilter;
  136. int del_perf_probe_events(struct strfilter *filter);
  137. int show_perf_probe_event(const char *group, const char *event,
  138. struct perf_probe_event *pev,
  139. const char *module, bool use_stdout);
  140. int show_perf_probe_events(struct strfilter *filter);
  141. int show_line_range(struct line_range *lr, const char *module,
  142. struct nsinfo *nsi, bool user);
  143. int show_available_vars(struct perf_probe_event *pevs, int npevs,
  144. struct strfilter *filter);
  145. int show_available_funcs(const char *module, struct nsinfo *nsi,
  146. struct strfilter *filter, bool user);
  147. void arch__fix_tev_from_maps(struct perf_probe_event *pev,
  148. struct probe_trace_event *tev, struct map *map,
  149. struct symbol *sym);
  150. /* If there is no space to write, returns -E2BIG. */
  151. int e_snprintf(char *str, size_t size, const char *format, ...) __printf(3, 4);
  152. /* Maximum index number of event-name postfix */
  153. #define MAX_EVENT_INDEX 1024
  154. int copy_to_probe_trace_arg(struct probe_trace_arg *tvar,
  155. struct perf_probe_arg *pvar);
  156. struct map *get_target_map(const char *target, struct nsinfo *nsi, bool user);
  157. void arch__post_process_probe_trace_events(struct perf_probe_event *pev,
  158. int ntevs);
  159. #endif /*_PROBE_EVENT_H */