probe-finder.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef _PROBE_FINDER_H
  2. #define _PROBE_FINDER_H
  3. #define _stringify(n) #n
  4. #define stringify(n) _stringify(n)
  5. #define ERR_IF(cnd) \
  6. do { if (cnd) { \
  7. fprintf(stderr, "Error (" __FILE__ ":" stringify(__LINE__) \
  8. "): " stringify(cnd) "\n"); \
  9. exit(1); \
  10. } } while (0)
  11. #define MAX_PATH_LEN 256
  12. #define MAX_PROBE_BUFFER 1024
  13. #define MAX_PROBES 128
  14. static inline int is_c_varname(const char *name)
  15. {
  16. /* TODO */
  17. return isalpha(name[0]) || name[0] == '_';
  18. }
  19. struct probe_point {
  20. /* Inputs */
  21. char *file; /* File name */
  22. int line; /* Line number */
  23. char *function; /* Function name */
  24. int offset; /* Offset bytes */
  25. int nr_args; /* Number of arguments */
  26. char **args; /* Arguments */
  27. /* Output */
  28. int found; /* Number of found probe points */
  29. char *probes[MAX_PROBES]; /* Output buffers (will be allocated)*/
  30. };
  31. #ifndef NO_LIBDWARF
  32. extern int find_probepoint(int fd, struct probe_point *pp);
  33. #include <libdwarf/dwarf.h>
  34. #include <libdwarf/libdwarf.h>
  35. struct probe_finder {
  36. struct probe_point *pp; /* Target probe point */
  37. /* For function searching */
  38. Dwarf_Addr addr; /* Address */
  39. Dwarf_Unsigned fno; /* File number */
  40. Dwarf_Off inl_offs; /* Inline offset */
  41. /* For variable searching */
  42. Dwarf_Addr cu_base; /* Current CU base address */
  43. Dwarf_Locdesc fbloc; /* Location of Current Frame Base */
  44. const char *var; /* Current variable name */
  45. char *buf; /* Current output buffer */
  46. int len; /* Length of output buffer */
  47. };
  48. #endif /* NO_LIBDWARF */
  49. #endif /*_PROBE_FINDER_H */