probe-finder.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #ifndef _PROBE_FINDER_H
  2. #define _PROBE_FINDER_H
  3. #include "util.h"
  4. #define MAX_PATH_LEN 256
  5. #define MAX_PROBE_BUFFER 1024
  6. #define MAX_PROBES 128
  7. static inline int is_c_varname(const char *name)
  8. {
  9. /* TODO */
  10. return isalpha(name[0]) || name[0] == '_';
  11. }
  12. struct probe_point {
  13. char *event; /* Event name */
  14. char *group; /* Event group */
  15. /* Inputs */
  16. char *file; /* File name */
  17. int line; /* Line number */
  18. char *function; /* Function name */
  19. int offset; /* Offset bytes */
  20. int nr_args; /* Number of arguments */
  21. char **args; /* Arguments */
  22. int retprobe; /* Return probe */
  23. /* Output */
  24. int found; /* Number of found probe points */
  25. char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/
  26. };
  27. /* Line number container */
  28. struct line_node {
  29. struct list_head list;
  30. unsigned int line;
  31. };
  32. /* Line range */
  33. struct line_range {
  34. char *file; /* File name */
  35. char *function; /* Function name */
  36. unsigned int start; /* Start line number */
  37. unsigned int end; /* End line number */
  38. unsigned int offset; /* Start line offset */
  39. char *path; /* Real path name */
  40. struct list_head line_list; /* Visible lines */
  41. };
  42. #ifndef NO_LIBDWARF
  43. extern int find_probepoint(int fd, struct probe_point *pp);
  44. extern int find_line_range(int fd, struct line_range *lr);
  45. /* Workaround for undefined _MIPS_SZLONG bug in libdwarf.h: */
  46. #ifndef _MIPS_SZLONG
  47. # define _MIPS_SZLONG 0
  48. #endif
  49. #include <dwarf.h>
  50. #include <libdwarf.h>
  51. struct probe_finder {
  52. struct probe_point *pp; /* Target probe point */
  53. /* For function searching */
  54. Dwarf_Addr addr; /* Address */
  55. Dwarf_Unsigned fno; /* File number */
  56. Dwarf_Unsigned lno; /* Line number */
  57. Dwarf_Off inl_offs; /* Inline offset */
  58. Dwarf_Die cu_die; /* Current CU */
  59. /* For variable searching */
  60. Dwarf_Addr cu_base; /* Current CU base address */
  61. Dwarf_Locdesc fbloc; /* Location of Current Frame Base */
  62. const char *var; /* Current variable name */
  63. char *buf; /* Current output buffer */
  64. int len; /* Length of output buffer */
  65. };
  66. struct line_finder {
  67. struct line_range *lr; /* Target line range */
  68. Dwarf_Unsigned fno; /* File number */
  69. Dwarf_Unsigned lno_s; /* Start line number */
  70. Dwarf_Unsigned lno_e; /* End line number */
  71. Dwarf_Addr addr_s; /* Start address */
  72. Dwarf_Addr addr_e; /* End address */
  73. Dwarf_Die cu_die; /* Current CU */
  74. int found;
  75. };
  76. #endif /* NO_LIBDWARF */
  77. #endif /*_PROBE_FINDER_H */