probe-event.h 5.7 KB

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