probe-event.h 5.9 KB

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