A dynamic tracer for Linux

type.h 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #ifndef _PLY_TYPE_H
  2. #define _PLY_TYPE_H
  3. #include <stddef.h>
  4. #include <stdio.h>
  5. struct ttdef {
  6. char *name;
  7. struct type *type;
  8. };
  9. struct tscalar {
  10. size_t size;
  11. int is_signed:1;
  12. char *name;
  13. };
  14. struct tptr {
  15. struct type *type;
  16. };
  17. struct tarray {
  18. struct type *type;
  19. size_t len;
  20. };
  21. struct tmap {
  22. struct type *vtype;
  23. struct type *ktype;
  24. size_t len;
  25. };
  26. struct tfield {
  27. char *name;
  28. struct type *type;
  29. /* function arguments */
  30. int optional:1;
  31. };
  32. struct tstruct {
  33. char *name;
  34. int packed:1;
  35. struct tfield *fields;
  36. };
  37. struct tfunc {
  38. struct type *type;
  39. struct tfield *args;
  40. };
  41. enum ttype {
  42. T_VOID,
  43. T_TYPEDEF,
  44. T_SCALAR,
  45. T_POINTER,
  46. T_ARRAY,
  47. T_MAP,
  48. T_STRUCT,
  49. T_UNION,
  50. T_FUNC,
  51. };
  52. struct type {
  53. enum ttype ttype;
  54. union {
  55. struct ttdef tdef;
  56. struct tscalar scalar;
  57. struct tptr ptr;
  58. struct tarray array;
  59. struct tmap map;
  60. struct tstruct sou;
  61. struct tfunc func;
  62. };
  63. };
  64. /* struct type *type_map_of(struct type *ktype, struct type *vtype); */
  65. /* struct type *type_ptr_of(struct type *type); */
  66. int type_equal (struct type *a, struct type *b);
  67. int type_compatible(struct type *a, struct type *b);
  68. void type_dump (struct type *t, FILE *fp);
  69. void type_dump_cdecl(struct type *t, FILE *fp);
  70. ssize_t type_alignof(struct type *t);
  71. ssize_t type_sizeof(struct type *t);
  72. /* typedef int (*twalk_fn)(struct type *, void *); */
  73. /* int type_walk(struct type *t, twalk_fn pre, twalk_fn post, void *ctx); */
  74. int type_add(struct type *t);
  75. int type_add_list(struct type **ts);
  76. /* built-in types */
  77. extern struct type t_void;
  78. extern struct type t_char;
  79. extern struct type t_schar;
  80. extern struct type t_uchar;
  81. extern struct type t_short;
  82. extern struct type t_sshort;
  83. extern struct type t_ushort;
  84. extern struct type t_int;
  85. extern struct type t_sint;
  86. extern struct type t_uint;
  87. extern struct type t_long;
  88. extern struct type t_slong;
  89. extern struct type t_ulong;
  90. extern struct type t_llong;
  91. extern struct type t_sllong;
  92. extern struct type t_ullong;
  93. #endif /* _PLY_TYPE_H */