A dynamic tracer for Linux

ply.h 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef _PLY_H
  2. #define _PLY_H
  3. #include <stdio.h>
  4. struct node;
  5. struct symtab;
  6. struct prog {
  7. const char *probe;
  8. struct node *ast;
  9. struct symtab *locals;
  10. struct symtab *globals;
  11. /* symtab_t *locals; */
  12. /* symtab_t *globals; */
  13. struct provider *provider;
  14. void *provider_data;
  15. /* ir_t *ir; */
  16. };
  17. struct ctx {
  18. struct prog **progs;
  19. struct symtab *globals;
  20. };
  21. struct func;
  22. struct provider {
  23. const char *name;
  24. int (*probe)(struct prog *);
  25. int (*sym_alloc)(struct prog *, struct node *);
  26. /* int (*resolve)(struct prog *, struct node *); */
  27. /* int (*rewrite_node)(struct prog *, struct node *); */
  28. /* int (*ir_prologue)(struct prog *); */
  29. /* int (*ir_epilogue)(struct prog *); */
  30. };
  31. void provider_register(struct provider *p);
  32. /* utils */
  33. void ast_fprint(FILE *fp, struct node *root);
  34. #include "printxf.h"
  35. #define _d(fmt, ...) fprintxf(NULL, stderr, fmt, ##__VA_ARGS__)
  36. #define _i(fmt, ...) fprintxf(NULL, stderr, fmt, ##__VA_ARGS__)
  37. #define _w(fmt, ...) fprintxf(NULL, stderr, fmt, ##__VA_ARGS__)
  38. #define _e(fmt, ...) fprintxf(NULL, stderr, fmt, ##__VA_ARGS__)
  39. #endif /* _PLY_H */