probe-finder.h 1.6 KB

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