A dynamic tracer for Linux

ply.h 1.1KB

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