probe-finder.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef _PROBE_FINDER_H
  2. #define _PROBE_FINDER_H
  3. #include <stdbool.h>
  4. #include "util.h"
  5. #define MAX_PATH_LEN 256
  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. struct probe_point {
  14. char *event; /* Event name */
  15. char *group; /* Event group */
  16. /* Inputs */
  17. char *file; /* File name */
  18. int line; /* Line number */
  19. char *lazy_line; /* Lazy line pattern */
  20. char *function; /* Function name */
  21. int offset; /* Offset bytes */
  22. int nr_args; /* Number of arguments */
  23. char **args; /* Arguments */
  24. int retprobe; /* Return probe */
  25. /* Output */
  26. int found; /* Number of found probe points */
  27. char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/
  28. };
  29. /* Line number container */
  30. struct line_node {
  31. struct list_head list;
  32. unsigned int line;
  33. };
  34. /* Line range */
  35. struct line_range {
  36. char *file; /* File name */
  37. char *function; /* Function name */
  38. unsigned int start; /* Start line number */
  39. unsigned int end; /* End line number */
  40. int offset; /* Start line offset */
  41. char *path; /* Real path name */
  42. struct list_head line_list; /* Visible lines */
  43. };
  44. #ifndef NO_DWARF_SUPPORT
  45. extern int find_probe_point(int fd, struct probe_point *pp);
  46. extern int find_line_range(int fd, struct line_range *lr);
  47. #include <dwarf.h>
  48. #include <libdw.h>
  49. struct probe_finder {
  50. struct probe_point *pp; /* Target probe point */
  51. /* For function searching */
  52. Dwarf_Addr addr; /* Address */
  53. const char *fname; /* File name */
  54. int lno; /* Line number */
  55. Dwarf_Die cu_die; /* Current CU */
  56. /* For variable searching */
  57. Dwarf_Op *fb_ops; /* Frame base attribute */
  58. Dwarf_Addr cu_base; /* Current CU base address */
  59. const char *var; /* Current variable name */
  60. char *buf; /* Current output buffer */
  61. int len; /* Length of output buffer */
  62. struct list_head lcache; /* Line cache for lazy match */
  63. };
  64. struct line_finder {
  65. struct line_range *lr; /* Target line range */
  66. const char *fname; /* File name */
  67. int lno_s; /* Start line number */
  68. int lno_e; /* End line number */
  69. Dwarf_Die cu_die; /* Current CU */
  70. int found;
  71. };
  72. #endif /* NO_DWARF_SUPPORT */
  73. #endif /*_PROBE_FINDER_H */