probe-finder.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. void *origin; /* Inline origin addr */
  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. };
  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_Addr addr_s; /* Start address */
  69. Dwarf_Addr addr_e; /* End address */
  70. Dwarf_Die cu_die; /* Current CU */
  71. int found;
  72. };
  73. #endif /* NO_DWARF_SUPPORT */
  74. #endif /*_PROBE_FINDER_H */