header.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #ifndef __PERF_HEADER_H
  2. #define __PERF_HEADER_H
  3. #include "../../../include/linux/perf_event.h"
  4. #include <sys/types.h>
  5. #include <stdbool.h>
  6. #include "types.h"
  7. #include "event.h"
  8. #include <linux/bitmap.h>
  9. enum {
  10. HEADER_RESERVED = 0, /* always cleared */
  11. HEADER_FIRST_FEATURE = 1,
  12. HEADER_TRACE_INFO = 1,
  13. HEADER_BUILD_ID,
  14. HEADER_HOSTNAME,
  15. HEADER_OSRELEASE,
  16. HEADER_VERSION,
  17. HEADER_ARCH,
  18. HEADER_NRCPUS,
  19. HEADER_CPUDESC,
  20. HEADER_CPUID,
  21. HEADER_TOTAL_MEM,
  22. HEADER_CMDLINE,
  23. HEADER_EVENT_DESC,
  24. HEADER_CPU_TOPOLOGY,
  25. HEADER_NUMA_TOPOLOGY,
  26. HEADER_BRANCH_STACK,
  27. HEADER_LAST_FEATURE,
  28. HEADER_FEAT_BITS = 256,
  29. };
  30. struct perf_file_section {
  31. u64 offset;
  32. u64 size;
  33. };
  34. struct perf_file_header {
  35. u64 magic;
  36. u64 size;
  37. u64 attr_size;
  38. struct perf_file_section attrs;
  39. struct perf_file_section data;
  40. struct perf_file_section event_types;
  41. DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS);
  42. };
  43. struct perf_pipe_file_header {
  44. u64 magic;
  45. u64 size;
  46. };
  47. struct perf_header;
  48. int perf_file_header__read(struct perf_file_header *header,
  49. struct perf_header *ph, int fd);
  50. struct perf_header {
  51. int frozen;
  52. bool needs_swap;
  53. s64 attr_offset;
  54. u64 data_offset;
  55. u64 data_size;
  56. u64 event_offset;
  57. u64 event_size;
  58. DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS);
  59. };
  60. struct perf_evlist;
  61. struct perf_session;
  62. int perf_session__read_header(struct perf_session *session, int fd);
  63. int perf_session__write_header(struct perf_session *session,
  64. struct perf_evlist *evlist,
  65. int fd, bool at_exit);
  66. int perf_header__write_pipe(int fd);
  67. int perf_header__push_event(u64 id, const char *name);
  68. char *perf_header__find_event(u64 id);
  69. void perf_header__set_feat(struct perf_header *header, int feat);
  70. void perf_header__clear_feat(struct perf_header *header, int feat);
  71. bool perf_header__has_feat(const struct perf_header *header, int feat);
  72. int perf_header__set_cmdline(int argc, const char **argv);
  73. int perf_header__process_sections(struct perf_header *header, int fd,
  74. void *data,
  75. int (*process)(struct perf_file_section *section,
  76. struct perf_header *ph,
  77. int feat, int fd, void *data));
  78. int perf_header__fprintf_info(struct perf_session *s, FILE *fp, bool full);
  79. int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
  80. const char *name, bool is_kallsyms);
  81. int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir);
  82. int perf_event__synthesize_attr(struct perf_tool *tool,
  83. struct perf_event_attr *attr, u16 ids, u64 *id,
  84. perf_event__handler_t process);
  85. int perf_event__synthesize_attrs(struct perf_tool *tool,
  86. struct perf_session *session,
  87. perf_event__handler_t process);
  88. int perf_event__process_attr(union perf_event *event, struct perf_evlist **pevlist);
  89. int perf_event__synthesize_event_type(struct perf_tool *tool,
  90. u64 event_id, char *name,
  91. perf_event__handler_t process,
  92. struct machine *machine);
  93. int perf_event__synthesize_event_types(struct perf_tool *tool,
  94. perf_event__handler_t process,
  95. struct machine *machine);
  96. int perf_event__process_event_type(struct perf_tool *tool,
  97. union perf_event *event);
  98. int perf_event__synthesize_tracing_data(struct perf_tool *tool,
  99. int fd, struct perf_evlist *evlist,
  100. perf_event__handler_t process);
  101. int perf_event__process_tracing_data(union perf_event *event,
  102. struct perf_session *session);
  103. int perf_event__synthesize_build_id(struct perf_tool *tool,
  104. struct dso *pos, u16 misc,
  105. perf_event__handler_t process,
  106. struct machine *machine);
  107. int perf_event__process_build_id(struct perf_tool *tool,
  108. union perf_event *event,
  109. struct perf_session *session);
  110. /*
  111. * arch specific callback
  112. */
  113. int get_cpuid(char *buffer, size_t sz);
  114. #endif /* __PERF_HEADER_H */