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