probe-event.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #ifndef _PROBE_EVENT_H
  2. #define _PROBE_EVENT_H
  3. #include <stdbool.h>
  4. #include "strlist.h"
  5. #include "strfilter.h"
  6. extern bool probe_event_dry_run;
  7. /* kprobe-tracer and uprobe-tracer tracing point */
  8. struct probe_trace_point {
  9. char *symbol; /* Base symbol */
  10. char *module; /* Module name */
  11. unsigned long offset; /* Offset from symbol */
  12. unsigned long address; /* Actual address of the trace point */
  13. bool retprobe; /* Return probe flag */
  14. };
  15. /* probe-tracer tracing argument referencing offset */
  16. struct probe_trace_arg_ref {
  17. struct probe_trace_arg_ref *next; /* Next reference */
  18. long offset; /* Offset value */
  19. };
  20. /* kprobe-tracer and uprobe-tracer tracing argument */
  21. struct probe_trace_arg {
  22. char *name; /* Argument name */
  23. char *value; /* Base value */
  24. char *type; /* Type name */
  25. struct probe_trace_arg_ref *ref; /* Referencing offset */
  26. };
  27. /* kprobe-tracer and uprobe-tracer tracing event (point + arg) */
  28. struct probe_trace_event {
  29. char *event; /* Event name */
  30. char *group; /* Group name */
  31. struct probe_trace_point point; /* Trace point */
  32. int nargs; /* Number of args */
  33. bool uprobes; /* uprobes only */
  34. struct probe_trace_arg *args; /* Arguments */
  35. };
  36. /* Perf probe probing point */
  37. struct perf_probe_point {
  38. char *file; /* File path */
  39. char *function; /* Function name */
  40. int line; /* Line number */
  41. bool retprobe; /* Return probe flag */
  42. char *lazy_line; /* Lazy matching pattern */
  43. unsigned long offset; /* Offset from function entry */
  44. };
  45. /* Perf probe probing argument field chain */
  46. struct perf_probe_arg_field {
  47. struct perf_probe_arg_field *next; /* Next field */
  48. char *name; /* Name of the field */
  49. long index; /* Array index number */
  50. bool ref; /* Referencing flag */
  51. };
  52. /* Perf probe probing argument */
  53. struct perf_probe_arg {
  54. char *name; /* Argument name */
  55. char *var; /* Variable name */
  56. char *type; /* Type name */
  57. struct perf_probe_arg_field *field; /* Structure fields */
  58. };
  59. /* Perf probe probing event (point + arg) */
  60. struct perf_probe_event {
  61. char *event; /* Event name */
  62. char *group; /* Group name */
  63. struct perf_probe_point point; /* Probe point */
  64. int nargs; /* Number of arguments */
  65. bool uprobes;
  66. struct perf_probe_arg *args; /* Arguments */
  67. };
  68. /* Line number container */
  69. struct line_node {
  70. struct list_head list;
  71. int line;
  72. };
  73. /* Line range */
  74. struct line_range {
  75. char *file; /* File name */
  76. char *function; /* Function name */
  77. int start; /* Start line number */
  78. int end; /* End line number */
  79. int offset; /* Start line offset */
  80. char *path; /* Real path name */
  81. char *comp_dir; /* Compile directory */
  82. struct list_head line_list; /* Visible lines */
  83. };
  84. /* List of variables */
  85. struct variable_list {
  86. struct probe_trace_point point; /* Actual probepoint */
  87. struct strlist *vars; /* Available variables */
  88. };
  89. /* Command string to events */
  90. extern int parse_perf_probe_command(const char *cmd,
  91. struct perf_probe_event *pev);
  92. /* Events to command string */
  93. extern char *synthesize_perf_probe_command(struct perf_probe_event *pev);
  94. extern char *synthesize_probe_trace_command(struct probe_trace_event *tev);
  95. extern int synthesize_perf_probe_arg(struct perf_probe_arg *pa, char *buf,
  96. size_t len);
  97. /* Check the perf_probe_event needs debuginfo */
  98. extern bool perf_probe_event_need_dwarf(struct perf_probe_event *pev);
  99. /* Release event contents */
  100. extern void clear_perf_probe_event(struct perf_probe_event *pev);
  101. /* Command string to line-range */
  102. extern int parse_line_range_desc(const char *cmd, struct line_range *lr);
  103. /* Release line range members */
  104. extern void line_range__clear(struct line_range *lr);
  105. /* Initialize line range */
  106. extern void line_range__init(struct line_range *lr);
  107. /* Internal use: Return kernel/module path */
  108. extern const char *kernel_get_module_path(const char *module);
  109. extern int add_perf_probe_events(struct perf_probe_event *pevs, int npevs,
  110. int max_probe_points, const char *module,
  111. bool force_add);
  112. extern int del_perf_probe_events(struct strlist *dellist);
  113. extern int show_perf_probe_events(void);
  114. extern int show_line_range(struct line_range *lr, const char *module);
  115. extern int show_available_vars(struct perf_probe_event *pevs, int npevs,
  116. int max_probe_points, const char *module,
  117. struct strfilter *filter, bool externs);
  118. extern int show_available_funcs(const char *module, struct strfilter *filter,
  119. bool user);
  120. /* Maximum index number of event-name postfix */
  121. #define MAX_EVENT_INDEX 1024
  122. #endif /*_PROBE_EVENT_H */