probe-event.h 5.9 KB

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