probe-finder.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. const char *var; /* Current variable name */
  59. char *buf; /* Current output buffer */
  60. int len; /* Length of output buffer */
  61. struct list_head lcache; /* Line cache for lazy match */
  62. };
  63. struct line_finder {
  64. struct line_range *lr; /* Target line range */
  65. const char *fname; /* File name */
  66. int lno_s; /* Start line number */
  67. int lno_e; /* End line number */
  68. Dwarf_Die cu_die; /* Current CU */
  69. int found;
  70. };
  71. #endif /* NO_DWARF_SUPPORT */
  72. #endif /*_PROBE_FINDER_H */