A dynamic tracer for Linux

type.h 1.4KB

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