probe-finder.h 2.9 KB

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