Home | History | Annotate | Download | only in util
      1 #ifndef __PERF_HEADER_H
      2 #define __PERF_HEADER_H
      3 
      4 /* ANDROID_CHANGE_BEGIN */
      5 #if 0
      6 #include "../../../include/linux/perf_event.h"
      7 #else
      8 #include "include/linux/added/perf_event.h"
      9 #endif
     10 /* ANDROID_CHANGE_END */
     11 #include <sys/types.h>
     12 #include <stdbool.h>
     13 #include "types.h"
     14 #include "event.h"
     15 
     16 /* ANDROID_CHANGE_BEGIN */
     17 #if 0
     18 #include <linux/bitmap.h>
     19 #else
     20 #include "include/linux/bitmap.h"
     21 #endif
     22 /* ANDROID_CHANGE_END */
     23 
     24 enum {
     25 	HEADER_TRACE_INFO = 1,
     26 	HEADER_BUILD_ID,
     27 	HEADER_LAST_FEATURE,
     28 };
     29 
     30 #define HEADER_FEAT_BITS			256
     31 
     32 struct perf_file_section {
     33 	u64 offset;
     34 	u64 size;
     35 };
     36 
     37 struct perf_file_header {
     38 	u64				magic;
     39 	u64				size;
     40 	u64				attr_size;
     41 	struct perf_file_section	attrs;
     42 	struct perf_file_section	data;
     43 	struct perf_file_section	event_types;
     44 	DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS);
     45 };
     46 
     47 struct perf_pipe_file_header {
     48 	u64				magic;
     49 	u64				size;
     50 };
     51 
     52 struct perf_header;
     53 
     54 int perf_file_header__read(struct perf_file_header *header,
     55 			   struct perf_header *ph, int fd);
     56 
     57 struct perf_header {
     58 	int			frozen;
     59 	bool			needs_swap;
     60 	s64			attr_offset;
     61 	u64			data_offset;
     62 	u64			data_size;
     63 	u64			event_offset;
     64 	u64			event_size;
     65 	DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS);
     66 };
     67 
     68 struct perf_evlist;
     69 
     70 int perf_session__read_header(struct perf_session *session, int fd);
     71 int perf_session__write_header(struct perf_session *session,
     72 			       struct perf_evlist *evlist,
     73 			       int fd, bool at_exit);
     74 int perf_header__write_pipe(int fd);
     75 
     76 int perf_header__push_event(u64 id, const char *name);
     77 char *perf_header__find_event(u64 id);
     78 
     79 void perf_header__set_feat(struct perf_header *header, int feat);
     80 void perf_header__clear_feat(struct perf_header *header, int feat);
     81 bool perf_header__has_feat(const struct perf_header *header, int feat);
     82 
     83 int perf_header__process_sections(struct perf_header *header, int fd,
     84 				  int (*process)(struct perf_file_section *section,
     85 						 struct perf_header *ph,
     86 						 int feat, int fd));
     87 
     88 int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
     89 			  const char *name, bool is_kallsyms);
     90 int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir);
     91 
     92 int perf_event__synthesize_attr(struct perf_event_attr *attr, u16 ids, u64 *id,
     93 				perf_event__handler_t process,
     94 				struct perf_session *session);
     95 int perf_session__synthesize_attrs(struct perf_session *session,
     96 				   perf_event__handler_t process);
     97 int perf_event__process_attr(union perf_event *event, struct perf_session *session);
     98 
     99 int perf_event__synthesize_event_type(u64 event_id, char *name,
    100 				      perf_event__handler_t process,
    101 				      struct perf_session *session);
    102 int perf_event__synthesize_event_types(perf_event__handler_t process,
    103 				       struct perf_session *session);
    104 int perf_event__process_event_type(union perf_event *event,
    105 				   struct perf_session *session);
    106 
    107 int perf_event__synthesize_tracing_data(int fd, struct perf_evlist *evlist,
    108 					perf_event__handler_t process,
    109 					struct perf_session *session);
    110 int perf_event__process_tracing_data(union perf_event *event,
    111 				     struct perf_session *session);
    112 
    113 int perf_event__synthesize_build_id(struct dso *pos, u16 misc,
    114 				    perf_event__handler_t process,
    115 				    struct machine *machine,
    116 				    struct perf_session *session);
    117 int perf_event__process_build_id(union perf_event *event,
    118 				 struct perf_session *session);
    119 #endif /* __PERF_HEADER_H */
    120