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