probe-event.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. };
  81. /* Line range */
  82. struct line_range {
  83. char *file; /* File name */
  84. char *function; /* Function name */
  85. int start; /* Start line number */
  86. int end; /* End line number */
  87. int offset; /* Start line offset */
  88. char *path; /* Real path name */
  89. char *comp_dir; /* Compile directory */
  90. struct intlist *line_list; /* Visible lines */
  91. };
  92. /* List of variables */
  93. struct variable_list {
  94. struct probe_trace_point point; /* Actual probepoint */
  95. struct strlist *vars; /* Available variables */
  96. };
  97. struct map;
  98. /* Command string to events */
  99. extern int parse_perf_probe_command(const char *cmd,
  100. struct perf_probe_event *pev);
  101. extern int parse_probe_trace_command(const char *cmd,
  102. struct probe_trace_event *tev);
  103. /* Events to command string */
  104. extern char *synthesize_perf_probe_command(struct perf_probe_event *pev);
  105. extern char *synthesize_probe_trace_command(struct probe_trace_event *tev);
  106. extern int synthesize_perf_probe_arg(struct perf_probe_arg *pa, char *buf,
  107. size_t len);
  108. /* Check the perf_probe_event needs debuginfo */
  109. extern bool perf_probe_event_need_dwarf(struct perf_probe_event *pev);
  110. /* Release event contents */
  111. extern void clear_perf_probe_event(struct perf_probe_event *pev);
  112. extern void clear_probe_trace_event(struct probe_trace_event *tev);
  113. /* Command string to line-range */
  114. extern int parse_line_range_desc(const char *cmd, struct line_range *lr);
  115. /* Release line range members */
  116. extern void line_range__clear(struct line_range *lr);
  117. /* Initialize line range */
  118. extern int line_range__init(struct line_range *lr);
  119. extern int add_perf_probe_events(struct perf_probe_event *pevs, int npevs);
  120. extern int del_perf_probe_events(struct strfilter *filter);
  121. extern int show_perf_probe_events(struct strfilter *filter);
  122. extern int show_line_range(struct line_range *lr, const char *module,
  123. bool user);
  124. extern int show_available_vars(struct perf_probe_event *pevs, int npevs,
  125. struct strfilter *filter);
  126. extern int show_available_funcs(const char *module, struct strfilter *filter,
  127. bool user);
  128. bool arch__prefers_symtab(void);
  129. void arch__fix_tev_from_maps(struct perf_probe_event *pev,
  130. struct probe_trace_event *tev, struct map *map);
  131. /* If there is no space to write, returns -E2BIG. */
  132. int e_snprintf(char *str, size_t size, const char *format, ...)
  133. __attribute__((format(printf, 3, 4)));
  134. /* Maximum index number of event-name postfix */
  135. #define MAX_EVENT_INDEX 1024
  136. int copy_to_probe_trace_arg(struct probe_trace_arg *tvar,
  137. struct perf_probe_arg *pvar);
  138. #endif /*_PROBE_EVENT_H */