2 #define _PERF_BRANCH_H 1
4 * The linux/stddef.h isn't need here, but is needed for __always_inline used
5 * in files included from uapi/linux/perf_event.h such as
6 * /usr/include/linux/swab.h and /usr/include/linux/byteorder/little_endian.h,
7 * detected in at least musl libc, used in Alpine Linux. -acme
10 #include <linux/perf_event.h>
11 #include <linux/types.h>
12 #include "util/map_symbol.h"
13 #include "util/sample.h"
34 struct addr_map_symbol from;
35 struct addr_map_symbol to;
36 struct branch_flags flags;
37 u64 branch_stack_cntr;
45 struct branch_flags flags;
51 struct branch_entry entries[];
55 * The hw_idx is only available when PERF_SAMPLE_BRANCH_HW_INDEX is applied.
56 * Otherwise, the output format of a sample with branch stack is
57 * struct branch_stack {
59 * struct branch_entry entries[0];
61 * Check whether the hw_idx is available,
62 * and return the corresponding pointer of entries[0].
64 static inline struct branch_entry *perf_sample__branch_entries(struct perf_sample *sample)
66 u64 *entry = (u64 *)sample->branch_stack;
69 if (sample->no_hw_idx)
70 return (struct branch_entry *)entry;
71 return (struct branch_entry *)(++entry);
74 struct branch_type_stat {
76 u64 counts[PERF_BR_MAX];
77 u64 new_counts[PERF_BR_NEW_MAX];
84 void branch_type_count(struct branch_type_stat *st, struct branch_flags *flags,
87 const char *branch_type_name(int type);
88 const char *branch_new_type_name(int new_type);
89 const char *get_branch_type(struct branch_entry *e);
90 void branch_type_stat_display(FILE *fp, const struct branch_type_stat *st);
91 int branch_type_str(const struct branch_type_stat *st, char *bf, int bfsize);
93 const char *branch_spec_desc(int spec);
95 #endif /* _PERF_BRANCH_H */