diff options
Diffstat (limited to 'tools/perf/util/annotate.h')
-rw-r--r-- | tools/perf/util/annotate.h | 54 |
1 files changed, 40 insertions, 14 deletions
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index a4c0d91907e6..005a5fe8a8c6 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/list.h> | 11 | #include <linux/list.h> |
12 | #include <linux/rbtree.h> | 12 | #include <linux/rbtree.h> |
13 | #include <pthread.h> | 13 | #include <pthread.h> |
14 | #include <asm/bug.h> | ||
14 | 15 | ||
15 | struct ins_ops; | 16 | struct ins_ops; |
16 | 17 | ||
@@ -82,6 +83,7 @@ struct annotation_options { | |||
82 | int context; | 83 | int context; |
83 | const char *objdump_path; | 84 | const char *objdump_path; |
84 | const char *disassembler_style; | 85 | const char *disassembler_style; |
86 | unsigned int percent_type; | ||
85 | }; | 87 | }; |
86 | 88 | ||
87 | enum { | 89 | enum { |
@@ -101,8 +103,16 @@ struct sym_hist_entry { | |||
101 | u64 period; | 103 | u64 period; |
102 | }; | 104 | }; |
103 | 105 | ||
106 | enum { | ||
107 | PERCENT_HITS_LOCAL, | ||
108 | PERCENT_HITS_GLOBAL, | ||
109 | PERCENT_PERIOD_LOCAL, | ||
110 | PERCENT_PERIOD_GLOBAL, | ||
111 | PERCENT_MAX, | ||
112 | }; | ||
113 | |||
104 | struct annotation_data { | 114 | struct annotation_data { |
105 | double percent; | 115 | double percent[PERCENT_MAX]; |
106 | double percent_sum; | 116 | double percent_sum; |
107 | struct sym_hist_entry he; | 117 | struct sym_hist_entry he; |
108 | }; | 118 | }; |
@@ -122,8 +132,8 @@ struct annotation_line { | |||
122 | char *path; | 132 | char *path; |
123 | u32 idx; | 133 | u32 idx; |
124 | int idx_asm; | 134 | int idx_asm; |
125 | int samples_nr; | 135 | int data_nr; |
126 | struct annotation_data samples[0]; | 136 | struct annotation_data data[0]; |
127 | }; | 137 | }; |
128 | 138 | ||
129 | struct disasm_line { | 139 | struct disasm_line { |
@@ -134,6 +144,27 @@ struct disasm_line { | |||
134 | struct annotation_line al; | 144 | struct annotation_line al; |
135 | }; | 145 | }; |
136 | 146 | ||
147 | static inline double annotation_data__percent(struct annotation_data *data, | ||
148 | unsigned int which) | ||
149 | { | ||
150 | return which < PERCENT_MAX ? data->percent[which] : -1; | ||
151 | } | ||
152 | |||
153 | static inline const char *percent_type_str(unsigned int type) | ||
154 | { | ||
155 | static const char *str[PERCENT_MAX] = { | ||
156 | "local hits", | ||
157 | "global hits", | ||
158 | "local period", | ||
159 | "global period", | ||
160 | }; | ||
161 | |||
162 | if (WARN_ON(type >= PERCENT_MAX)) | ||
163 | return "N/A"; | ||
164 | |||
165 | return str[type]; | ||
166 | } | ||
167 | |||
137 | static inline struct disasm_line *disasm_line(struct annotation_line *al) | 168 | static inline struct disasm_line *disasm_line(struct annotation_line *al) |
138 | { | 169 | { |
139 | return al ? container_of(al, struct disasm_line, al) : NULL; | 170 | return al ? container_of(al, struct disasm_line, al) : NULL; |
@@ -169,22 +200,15 @@ struct annotation_write_ops { | |||
169 | void (*write_graph)(void *obj, int graph); | 200 | void (*write_graph)(void *obj, int graph); |
170 | }; | 201 | }; |
171 | 202 | ||
172 | double annotation_line__max_percent(struct annotation_line *al, struct annotation *notes); | ||
173 | void annotation_line__write(struct annotation_line *al, struct annotation *notes, | 203 | void annotation_line__write(struct annotation_line *al, struct annotation *notes, |
174 | struct annotation_write_ops *ops); | 204 | struct annotation_write_ops *ops, |
205 | struct annotation_options *opts); | ||
175 | 206 | ||
176 | int __annotation__scnprintf_samples_period(struct annotation *notes, | 207 | int __annotation__scnprintf_samples_period(struct annotation *notes, |
177 | char *bf, size_t size, | 208 | char *bf, size_t size, |
178 | struct perf_evsel *evsel, | 209 | struct perf_evsel *evsel, |
179 | bool show_freq); | 210 | bool show_freq); |
180 | 211 | ||
181 | static inline int annotation__scnprintf_samples_period(struct annotation *notes, | ||
182 | char *bf, size_t size, | ||
183 | struct perf_evsel *evsel) | ||
184 | { | ||
185 | return __annotation__scnprintf_samples_period(notes, bf, size, evsel, true); | ||
186 | } | ||
187 | |||
188 | int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, bool raw); | 212 | int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, bool raw); |
189 | size_t disasm__fprintf(struct list_head *head, FILE *fp); | 213 | size_t disasm__fprintf(struct list_head *head, FILE *fp); |
190 | void symbol__calc_percent(struct symbol *sym, struct perf_evsel *evsel); | 214 | void symbol__calc_percent(struct symbol *sym, struct perf_evsel *evsel); |
@@ -340,12 +364,12 @@ int symbol__strerror_disassemble(struct symbol *sym, struct map *map, | |||
340 | int symbol__annotate_printf(struct symbol *sym, struct map *map, | 364 | int symbol__annotate_printf(struct symbol *sym, struct map *map, |
341 | struct perf_evsel *evsel, | 365 | struct perf_evsel *evsel, |
342 | struct annotation_options *options); | 366 | struct annotation_options *options); |
343 | int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp); | ||
344 | void symbol__annotate_zero_histogram(struct symbol *sym, int evidx); | 367 | void symbol__annotate_zero_histogram(struct symbol *sym, int evidx); |
345 | void symbol__annotate_decay_histogram(struct symbol *sym, int evidx); | 368 | void symbol__annotate_decay_histogram(struct symbol *sym, int evidx); |
346 | void annotated_source__purge(struct annotated_source *as); | 369 | void annotated_source__purge(struct annotated_source *as); |
347 | 370 | ||
348 | int map_symbol__annotation_dump(struct map_symbol *ms, struct perf_evsel *evsel); | 371 | int map_symbol__annotation_dump(struct map_symbol *ms, struct perf_evsel *evsel, |
372 | struct annotation_options *opts); | ||
349 | 373 | ||
350 | bool ui__has_annotation(void); | 374 | bool ui__has_annotation(void); |
351 | 375 | ||
@@ -373,4 +397,6 @@ static inline int symbol__tui_annotate(struct symbol *sym __maybe_unused, | |||
373 | 397 | ||
374 | void annotation_config__init(void); | 398 | void annotation_config__init(void); |
375 | 399 | ||
400 | int annotate_parse_percent_type(const struct option *opt, const char *_str, | ||
401 | int unset); | ||
376 | #endif /* __PERF_ANNOTATE_H */ | 402 | #endif /* __PERF_ANNOTATE_H */ |