A dynamic tracer for Linux

type.h 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #ifndef _PLY_TYPE_H
  2. #define _PLY_TYPE_H
  3. #include <stddef.h>
  4. #include <stdio.h>
  5. typedef struct prog prog_t;
  6. typedef struct node node_t;
  7. typedef struct type type_t;
  8. struct t_tdef {
  9. char *name;
  10. type_t *type;
  11. };
  12. struct t_scalar {
  13. char *name;
  14. };
  15. struct t_pointer {
  16. type_t *type;
  17. };
  18. struct t_array {
  19. type_t *type;
  20. size_t len;
  21. };
  22. struct t_map {
  23. type_t *vtype;
  24. type_t *ktype;
  25. size_t len;
  26. };
  27. typedef struct field {
  28. char *name;
  29. type_t *type;
  30. size_t offset;
  31. /* function arguments */
  32. int optional:1;
  33. } field_t;
  34. struct t_sou {
  35. char *name;
  36. int packed:1;
  37. field_t *fields;
  38. };
  39. struct t_func {
  40. char *name;
  41. type_t *type;
  42. field_t *args;
  43. int (*generate_ir)(prog_t *prog, node_t *n);
  44. };
  45. typedef enum ttype {
  46. T_TYPEDEF,
  47. T_SCALAR,
  48. T_POINTER,
  49. T_ARRAY,
  50. T_MAP,
  51. T_STRUCT,
  52. T_UNION,
  53. T_FUNC,
  54. } ttype_t;
  55. struct type {
  56. size_t size;
  57. ttype_t ttype;
  58. union {
  59. struct t_tdef tdef;
  60. struct t_scalar scalar;
  61. struct t_pointer pointer;
  62. struct t_array array;
  63. struct t_map map;
  64. struct t_sou sou;
  65. struct t_func func;
  66. } t;
  67. };
  68. extern type_t t_void;
  69. extern type_t t_char;
  70. extern type_t t_uchar;
  71. extern type_t t_short;
  72. extern type_t t_ushort;
  73. extern type_t t_int;
  74. extern type_t t_uint;
  75. extern type_t t_long;
  76. extern type_t t_ulong;
  77. extern type_t t_llong;
  78. extern type_t t_ullong;
  79. type_t *type_map_of(type_t *ktype, type_t *vtype);
  80. type_t *type_ptr_of(type_t *type);
  81. int type_equal (type_t *a, type_t *b);
  82. int type_compatible(type_t *a, type_t *b);
  83. int type_add(type_t *t);
  84. int type_add_list(type_t **ts);
  85. void type_dump (type_t *t, FILE *fp);
  86. void type_dump_cdecl(type_t *t, FILE *fp);
  87. void types_dump_cdecl(FILE *fp);
  88. #endif /* _PLY_TYPE_H */