trace-event.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. #ifndef _PARSE_EVENTS_H
  2. #define _PARSE_EVENTS_H
  3. #define __unused __attribute__((unused))
  4. #ifndef PAGE_MASK
  5. #define PAGE_MASK (page_size - 1)
  6. #endif
  7. enum {
  8. RINGBUF_TYPE_PADDING = 29,
  9. RINGBUF_TYPE_TIME_EXTEND = 30,
  10. RINGBUF_TYPE_TIME_STAMP = 31,
  11. };
  12. #ifndef TS_SHIFT
  13. #define TS_SHIFT 27
  14. #endif
  15. #define NSECS_PER_SEC 1000000000ULL
  16. #define NSECS_PER_USEC 1000ULL
  17. enum format_flags {
  18. FIELD_IS_ARRAY = 1,
  19. FIELD_IS_POINTER = 2,
  20. };
  21. struct format_field {
  22. struct format_field *next;
  23. char *type;
  24. char *name;
  25. int offset;
  26. int size;
  27. unsigned long flags;
  28. };
  29. struct format {
  30. int nr_common;
  31. int nr_fields;
  32. struct format_field *common_fields;
  33. struct format_field *fields;
  34. };
  35. struct print_arg_atom {
  36. char *atom;
  37. };
  38. struct print_arg_string {
  39. char *string;
  40. };
  41. struct print_arg_field {
  42. char *name;
  43. struct format_field *field;
  44. };
  45. struct print_flag_sym {
  46. struct print_flag_sym *next;
  47. char *value;
  48. char *str;
  49. };
  50. struct print_arg_typecast {
  51. char *type;
  52. struct print_arg *item;
  53. };
  54. struct print_arg_flags {
  55. struct print_arg *field;
  56. char *delim;
  57. struct print_flag_sym *flags;
  58. };
  59. struct print_arg_symbol {
  60. struct print_arg *field;
  61. struct print_flag_sym *symbols;
  62. };
  63. struct print_arg;
  64. struct print_arg_op {
  65. char *op;
  66. int prio;
  67. struct print_arg *left;
  68. struct print_arg *right;
  69. };
  70. struct print_arg_func {
  71. char *name;
  72. struct print_arg *args;
  73. };
  74. enum print_arg_type {
  75. PRINT_NULL,
  76. PRINT_ATOM,
  77. PRINT_FIELD,
  78. PRINT_FLAGS,
  79. PRINT_SYMBOL,
  80. PRINT_TYPE,
  81. PRINT_STRING,
  82. PRINT_OP,
  83. };
  84. struct print_arg {
  85. struct print_arg *next;
  86. enum print_arg_type type;
  87. union {
  88. struct print_arg_atom atom;
  89. struct print_arg_field field;
  90. struct print_arg_typecast typecast;
  91. struct print_arg_flags flags;
  92. struct print_arg_symbol symbol;
  93. struct print_arg_func func;
  94. struct print_arg_string string;
  95. struct print_arg_op op;
  96. };
  97. };
  98. struct print_fmt {
  99. char *format;
  100. struct print_arg *args;
  101. };
  102. struct event {
  103. struct event *next;
  104. char *name;
  105. int id;
  106. int flags;
  107. struct format format;
  108. struct print_fmt print_fmt;
  109. };
  110. enum {
  111. EVENT_FL_ISFTRACE = 1,
  112. EVENT_FL_ISPRINT = 2,
  113. EVENT_FL_ISBPRINT = 4,
  114. EVENT_FL_ISFUNC = 8,
  115. EVENT_FL_ISFUNCENT = 16,
  116. EVENT_FL_ISFUNCRET = 32,
  117. };
  118. struct record {
  119. unsigned long long ts;
  120. int size;
  121. void *data;
  122. };
  123. struct record *trace_peek_data(int cpu);
  124. struct record *trace_read_data(int cpu);
  125. void parse_set_info(int nr_cpus, int long_sz);
  126. void trace_report(void);
  127. void *malloc_or_die(unsigned int size);
  128. void parse_cmdlines(char *file, int size);
  129. void parse_proc_kallsyms(char *file, unsigned int size);
  130. void parse_ftrace_printk(char *file, unsigned int size);
  131. void print_funcs(void);
  132. void print_printk(void);
  133. int parse_ftrace_file(char *buf, unsigned long size);
  134. int parse_event_file(char *buf, unsigned long size, char *system);
  135. void print_event(int cpu, void *data, int size, unsigned long long nsecs,
  136. char *comm);
  137. extern int file_bigendian;
  138. extern int host_bigendian;
  139. int bigendian(void);
  140. static inline unsigned short __data2host2(unsigned short data)
  141. {
  142. unsigned short swap;
  143. if (host_bigendian == file_bigendian)
  144. return data;
  145. swap = ((data & 0xffULL) << 8) |
  146. ((data & (0xffULL << 8)) >> 8);
  147. return swap;
  148. }
  149. static inline unsigned int __data2host4(unsigned int data)
  150. {
  151. unsigned int swap;
  152. if (host_bigendian == file_bigendian)
  153. return data;
  154. swap = ((data & 0xffULL) << 24) |
  155. ((data & (0xffULL << 8)) << 8) |
  156. ((data & (0xffULL << 16)) >> 8) |
  157. ((data & (0xffULL << 24)) >> 24);
  158. return swap;
  159. }
  160. static inline unsigned long long __data2host8(unsigned long long data)
  161. {
  162. unsigned long long swap;
  163. if (host_bigendian == file_bigendian)
  164. return data;
  165. swap = ((data & 0xffULL) << 56) |
  166. ((data & (0xffULL << 8)) << 40) |
  167. ((data & (0xffULL << 16)) << 24) |
  168. ((data & (0xffULL << 24)) << 8) |
  169. ((data & (0xffULL << 32)) >> 8) |
  170. ((data & (0xffULL << 40)) >> 24) |
  171. ((data & (0xffULL << 48)) >> 40) |
  172. ((data & (0xffULL << 56)) >> 56);
  173. return swap;
  174. }
  175. #define data2host2(ptr) __data2host2(*(unsigned short *)ptr)
  176. #define data2host4(ptr) __data2host4(*(unsigned int *)ptr)
  177. #define data2host8(ptr) __data2host8(*(unsigned long long *)ptr)
  178. extern int header_page_ts_offset;
  179. extern int header_page_ts_size;
  180. extern int header_page_size_offset;
  181. extern int header_page_size_size;
  182. extern int header_page_data_offset;
  183. extern int header_page_data_size;
  184. int parse_header_page(char *buf, unsigned long size);
  185. void read_tracing_data(void);
  186. #endif /* _PARSE_EVENTS_H */