probe-finder.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. /* Find probe_trace_events specified by perf_probe_event from debuginfo */
  16. extern int find_probe_trace_events(int fd, struct perf_probe_event *pev,
  17. struct probe_trace_event **tevs,
  18. int max_tevs);
  19. /* Find a perf_probe_point from debuginfo */
  20. extern int find_perf_probe_point(unsigned long addr,
  21. struct perf_probe_point *ppt);
  22. /* Find a line range */
  23. extern int find_line_range(int fd, struct line_range *lr);
  24. /* Find available variables */
  25. extern int find_available_vars_at(int fd, struct perf_probe_event *pev,
  26. struct variable_list **vls, int max_points,
  27. bool externs);
  28. #include <dwarf.h>
  29. #include <elfutils/libdw.h>
  30. #include <elfutils/libdwfl.h>
  31. #include <elfutils/version.h>
  32. struct probe_finder {
  33. struct perf_probe_event *pev; /* Target probe event */
  34. /* Callback when a probe point is found */
  35. int (*callback)(Dwarf_Die *sp_die, struct probe_finder *pf);
  36. /* For function searching */
  37. int lno; /* Line number */
  38. Dwarf_Addr addr; /* Address */
  39. const char *fname; /* Real file name */
  40. Dwarf_Die cu_die; /* Current CU */
  41. Dwarf_Die sp_die;
  42. struct list_head lcache; /* Line cache for lazy match */
  43. /* For variable searching */
  44. #if _ELFUTILS_PREREQ(0, 142)
  45. Dwarf_CFI *cfi; /* Call Frame Information */
  46. #endif
  47. Dwarf_Op *fb_ops; /* Frame base attribute */
  48. struct perf_probe_arg *pvar; /* Current target variable */
  49. struct probe_trace_arg *tvar; /* Current result variable */
  50. };
  51. struct trace_event_finder {
  52. struct probe_finder pf;
  53. struct probe_trace_event *tevs; /* Found trace events */
  54. int ntevs; /* Number of trace events */
  55. int max_tevs; /* Max number of trace events */
  56. };
  57. struct available_var_finder {
  58. struct probe_finder pf;
  59. struct variable_list *vls; /* Found variable lists */
  60. int nvls; /* Number of variable lists */
  61. int max_vls; /* Max no. of variable lists */
  62. bool externs; /* Find external vars too */
  63. bool child; /* Search child scopes */
  64. };
  65. struct line_finder {
  66. struct line_range *lr; /* Target line range */
  67. const char *fname; /* File name */
  68. int lno_s; /* Start line number */
  69. int lno_e; /* End line number */
  70. Dwarf_Die cu_die; /* Current CU */
  71. Dwarf_Die sp_die;
  72. int found;
  73. };
  74. #endif /* DWARF_SUPPORT */
  75. #endif /*_PROBE_FINDER_H */