header.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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_TRACE_INFO = 1,
  11. HEADER_BUILD_ID,
  12. HEADER_LAST_FEATURE,
  13. };
  14. #define HEADER_FEAT_BITS 256
  15. struct perf_file_section {
  16. u64 offset;
  17. u64 size;
  18. };
  19. struct perf_file_header {
  20. u64 magic;
  21. u64 size;
  22. u64 attr_size;
  23. struct perf_file_section attrs;
  24. struct perf_file_section data;
  25. struct perf_file_section event_types;
  26. DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS);
  27. };
  28. struct perf_pipe_file_header {
  29. u64 magic;
  30. u64 size;
  31. };
  32. struct perf_header;
  33. int perf_file_header__read(struct perf_file_header *header,
  34. struct perf_header *ph, int fd);
  35. struct perf_header {
  36. int frozen;
  37. bool needs_swap;
  38. s64 attr_offset;
  39. u64 data_offset;
  40. u64 data_size;
  41. u64 event_offset;
  42. u64 event_size;
  43. DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS);
  44. };
  45. struct perf_evlist;
  46. int perf_session__read_header(struct perf_session *session, int fd);
  47. int perf_session__write_header(struct perf_session *session,
  48. struct perf_evlist *evlist,
  49. int fd, bool at_exit);
  50. int perf_header__write_pipe(int fd);
  51. int perf_header__push_event(u64 id, const char *name);
  52. char *perf_header__find_event(u64 id);
  53. void perf_header__set_feat(struct perf_header *header, int feat);
  54. void perf_header__clear_feat(struct perf_header *header, int feat);
  55. bool perf_header__has_feat(const struct perf_header *header, int feat);
  56. int perf_header__process_sections(struct perf_header *header, int fd,
  57. int (*process)(struct perf_file_section *section,
  58. struct perf_header *ph,
  59. int feat, int fd));
  60. int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
  61. const char *name, bool is_kallsyms);
  62. int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir);
  63. int perf_event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id,
  64. perf_event__handler_t process,
  65. struct perf_session *session);
  66. int perf_session__synthesize_attrs(struct perf_session *session,
  67. perf_event__handler_t process);
  68. int perf_event__process_attr(union perf_event *event, struct perf_session *session);
  69. int perf_event__synthesize_event_type(u64 event_id, char *name,
  70. perf_event__handler_t process,
  71. struct perf_session *session);
  72. int perf_event__synthesize_event_types(perf_event__handler_t process,
  73. struct perf_session *session);
  74. int perf_event__process_event_type(union perf_event *event,
  75. struct perf_session *session);
  76. int perf_event__synthesize_tracing_data(int fd, struct perf_evlist *evlist,
  77. perf_event__handler_t process,
  78. struct perf_session *session);
  79. int perf_event__process_tracing_data(union perf_event *event,
  80. struct perf_session *session);
  81. int perf_event__synthesize_build_id(struct dso *pos, u16 misc,
  82. perf_event__handler_t process,
  83. struct machine *machine,
  84. struct perf_session *session);
  85. int perf_event__process_build_id(union perf_event *event,
  86. struct perf_session *session);
  87. #endif /* __PERF_HEADER_H */