probe-finder.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #ifndef _PROBE_FINDER_H
  2. #define _PROBE_FINDER_H
  3. #include <stdbool.h>
  4. #include "util.h"
  5. #include "intlist.h"
  6. #include "probe-event.h"
  7. #define MAX_PROBE_BUFFER 1024
  8. #define MAX_PROBES 128
  9. #define MAX_PROBE_ARGS 128
  10. #define PROBE_ARG_VARS "$vars"
  11. #define PROBE_ARG_PARAMS "$params"
  12. static inline int is_c_varname(const char *name)
  13. {
  14. /* TODO */
  15. return isalpha(name[0]) || name[0] == '_';
  16. }
  17. #ifdef HAVE_DWARF_SUPPORT
  18. #include "dwarf-aux.h"
  19. /* TODO: export debuginfo data structure even if no dwarf support */
  20. /* debug information structure */
  21. struct debuginfo {
  22. Dwarf *dbg;
  23. Dwfl_Module *mod;
  24. Dwfl *dwfl;
  25. Dwarf_Addr bias;
  26. };
  27. /* This also tries to open distro debuginfo */
  28. extern struct debuginfo *debuginfo__new(const char *path);
  29. extern void debuginfo__delete(struct debuginfo *dbg);
  30. /* Find probe_trace_events specified by perf_probe_event from debuginfo */
  31. extern int debuginfo__find_trace_events(struct debuginfo *dbg,
  32. struct perf_probe_event *pev,
  33. struct probe_trace_event **tevs);
  34. /* Find a perf_probe_point from debuginfo */
  35. extern int debuginfo__find_probe_point(struct debuginfo *dbg,
  36. unsigned long addr,
  37. struct perf_probe_point *ppt);
  38. /* Find a line range */
  39. extern int debuginfo__find_line_range(struct debuginfo *dbg,
  40. struct line_range *lr);
  41. /* Find available variables */
  42. extern int debuginfo__find_available_vars_at(struct debuginfo *dbg,
  43. struct perf_probe_event *pev,
  44. struct variable_list **vls);
  45. /* Find a src file from a DWARF tag path */
  46. int get_real_path(const char *raw_path, const char *comp_dir,
  47. char **new_path);
  48. struct probe_finder {
  49. struct perf_probe_event *pev; /* Target probe event */
  50. /* Callback when a probe point is found */
  51. int (*callback)(Dwarf_Die *sc_die, struct probe_finder *pf);
  52. /* For function searching */
  53. int lno; /* Line number */
  54. Dwarf_Addr addr; /* Address */
  55. const char *fname; /* Real file name */
  56. Dwarf_Die cu_die; /* Current CU */
  57. Dwarf_Die sp_die;
  58. struct intlist *lcache; /* Line cache for lazy match */
  59. /* For variable searching */
  60. #if _ELFUTILS_PREREQ(0, 142)
  61. Dwarf_CFI *cfi; /* Call Frame Information */
  62. #endif
  63. Dwarf_Op *fb_ops; /* Frame base attribute */
  64. struct perf_probe_arg *pvar; /* Current target variable */
  65. struct probe_trace_arg *tvar; /* Current result variable */
  66. };
  67. struct trace_event_finder {
  68. struct probe_finder pf;
  69. Dwfl_Module *mod; /* For solving symbols */
  70. struct probe_trace_event *tevs; /* Found trace events */
  71. int ntevs; /* Number of trace events */
  72. int max_tevs; /* Max number of trace events */
  73. };
  74. struct available_var_finder {
  75. struct probe_finder pf;
  76. Dwfl_Module *mod; /* For solving symbols */
  77. struct variable_list *vls; /* Found variable lists */
  78. int nvls; /* Number of variable lists */
  79. int max_vls; /* Max no. of variable lists */
  80. bool child; /* Search child scopes */
  81. };
  82. struct line_finder {
  83. struct line_range *lr; /* Target line range */
  84. const char *fname; /* File name */
  85. int lno_s; /* Start line number */
  86. int lno_e; /* End line number */
  87. Dwarf_Die cu_die; /* Current CU */
  88. Dwarf_Die sp_die;
  89. int found;
  90. };
  91. #endif /* HAVE_DWARF_SUPPORT */
  92. #endif /*_PROBE_FINDER_H */