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