.. | .. |
---|
4 | 4 | |
---|
5 | 5 | #include <stdbool.h> |
---|
6 | 6 | #include <stdint.h> |
---|
| 7 | +#include <stdio.h> |
---|
7 | 8 | #include <linux/types.h> |
---|
8 | | -#include "symbol.h" |
---|
9 | | -#include "hist.h" |
---|
10 | | -#include "sort.h" |
---|
11 | 9 | #include <linux/list.h> |
---|
12 | 10 | #include <linux/rbtree.h> |
---|
13 | 11 | #include <pthread.h> |
---|
14 | 12 | #include <asm/bug.h> |
---|
| 13 | +#include "symbol_conf.h" |
---|
| 14 | +#include "spark.h" |
---|
15 | 15 | |
---|
| 16 | +struct hist_browser_timer; |
---|
| 17 | +struct hist_entry; |
---|
16 | 18 | struct ins_ops; |
---|
| 19 | +struct map; |
---|
| 20 | +struct map_symbol; |
---|
| 21 | +struct addr_map_symbol; |
---|
| 22 | +struct option; |
---|
| 23 | +struct perf_sample; |
---|
| 24 | +struct evsel; |
---|
| 25 | +struct symbol; |
---|
17 | 26 | |
---|
18 | 27 | struct ins { |
---|
19 | 28 | const char *name; |
---|
.. | .. |
---|
23 | 32 | struct ins_operands { |
---|
24 | 33 | char *raw; |
---|
25 | 34 | char *raw_comment; |
---|
| 35 | + char *raw_func_start; |
---|
26 | 36 | struct { |
---|
27 | 37 | char *raw; |
---|
28 | 38 | char *name; |
---|
.. | .. |
---|
51 | 61 | void (*free)(struct ins_operands *ops); |
---|
52 | 62 | int (*parse)(struct arch *arch, struct ins_operands *ops, struct map_symbol *ms); |
---|
53 | 63 | int (*scnprintf)(struct ins *ins, char *bf, size_t size, |
---|
54 | | - struct ins_operands *ops); |
---|
| 64 | + struct ins_operands *ops, int max_ins_name); |
---|
55 | 65 | }; |
---|
56 | 66 | |
---|
57 | 67 | bool ins__is_jump(const struct ins *ins); |
---|
58 | 68 | bool ins__is_call(const struct ins *ins); |
---|
59 | 69 | bool ins__is_ret(const struct ins *ins); |
---|
60 | 70 | bool ins__is_lock(const struct ins *ins); |
---|
61 | | -int ins__scnprintf(struct ins *ins, char *bf, size_t size, struct ins_operands *ops); |
---|
| 71 | +int ins__scnprintf(struct ins *ins, char *bf, size_t size, struct ins_operands *ops, int max_ins_name); |
---|
62 | 72 | bool ins__is_fused(struct arch *arch, const char *ins1, const char *ins2); |
---|
63 | 73 | |
---|
64 | 74 | #define ANNOTATION__IPC_WIDTH 6 |
---|
65 | 75 | #define ANNOTATION__CYCLES_WIDTH 6 |
---|
66 | 76 | #define ANNOTATION__MINMAX_CYCLES_WIDTH 19 |
---|
| 77 | +#define ANNOTATION__AVG_IPC_WIDTH 36 |
---|
| 78 | +#define ANNOTATION_DUMMY_LEN 256 |
---|
67 | 79 | |
---|
68 | 80 | struct annotation_options { |
---|
69 | 81 | bool hide_src_code, |
---|
.. | .. |
---|
73 | 85 | full_path, |
---|
74 | 86 | show_linenr, |
---|
75 | 87 | show_nr_jumps, |
---|
76 | | - show_nr_samples, |
---|
77 | | - show_total_period, |
---|
78 | 88 | show_minmax_cycle, |
---|
79 | 89 | show_asm_raw, |
---|
80 | 90 | annotate_src; |
---|
.. | .. |
---|
84 | 94 | int context; |
---|
85 | 95 | const char *objdump_path; |
---|
86 | 96 | const char *disassembler_style; |
---|
| 97 | + const char *prefix; |
---|
| 98 | + const char *prefix_strip; |
---|
87 | 99 | unsigned int percent_type; |
---|
88 | 100 | }; |
---|
89 | 101 | |
---|
.. | .. |
---|
129 | 141 | u64 cycles; |
---|
130 | 142 | u64 cycles_max; |
---|
131 | 143 | u64 cycles_min; |
---|
132 | | - size_t privsize; |
---|
133 | 144 | char *path; |
---|
134 | 145 | u32 idx; |
---|
135 | 146 | int idx_asm; |
---|
136 | 147 | int data_nr; |
---|
137 | | - struct annotation_data data[0]; |
---|
| 148 | + struct annotation_data data[]; |
---|
138 | 149 | }; |
---|
139 | 150 | |
---|
140 | 151 | struct disasm_line { |
---|
.. | .. |
---|
207 | 218 | |
---|
208 | 219 | int __annotation__scnprintf_samples_period(struct annotation *notes, |
---|
209 | 220 | char *bf, size_t size, |
---|
210 | | - struct perf_evsel *evsel, |
---|
| 221 | + struct evsel *evsel, |
---|
211 | 222 | bool show_freq); |
---|
212 | 223 | |
---|
213 | | -int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, bool raw); |
---|
| 224 | +int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, bool raw, int max_ins_name); |
---|
214 | 225 | size_t disasm__fprintf(struct list_head *head, FILE *fp); |
---|
215 | | -void symbol__calc_percent(struct symbol *sym, struct perf_evsel *evsel); |
---|
| 226 | +void symbol__calc_percent(struct symbol *sym, struct evsel *evsel); |
---|
216 | 227 | |
---|
217 | 228 | struct sym_hist { |
---|
218 | 229 | u64 nr_samples; |
---|
219 | 230 | u64 period; |
---|
220 | | - struct sym_hist_entry addr[0]; |
---|
| 231 | + struct sym_hist_entry addr[]; |
---|
221 | 232 | }; |
---|
222 | 233 | |
---|
223 | 234 | struct cyc_hist { |
---|
.. | .. |
---|
226 | 237 | u64 cycles_aggr; |
---|
227 | 238 | u64 cycles_max; |
---|
228 | 239 | u64 cycles_min; |
---|
| 240 | + s64 cycles_spark[NUM_SPARKS]; |
---|
229 | 241 | u32 num; |
---|
230 | 242 | u32 num_aggr; |
---|
231 | 243 | u8 have_start; |
---|
.. | .. |
---|
236 | 248 | /** struct annotated_source - symbols with hits have this attached as in sannotation |
---|
237 | 249 | * |
---|
238 | 250 | * @histograms: Array of addr hit histograms per event being monitored |
---|
239 | | - * nr_histograms: This may not be the same as evsel->evlist->nr_entries if |
---|
| 251 | + * nr_histograms: This may not be the same as evsel->evlist->core.nr_entries if |
---|
240 | 252 | * we have more than a group in a evlist, where we will want |
---|
241 | 253 | * to see each group separately, that is why symbol__annotate2() |
---|
242 | 254 | * sets src->nr_histograms to evsel->nr_members. |
---|
.. | .. |
---|
262 | 274 | pthread_mutex_t lock; |
---|
263 | 275 | u64 max_coverage; |
---|
264 | 276 | u64 start; |
---|
| 277 | + u64 hit_cycles; |
---|
| 278 | + u64 hit_insn; |
---|
| 279 | + unsigned int total_insn; |
---|
| 280 | + unsigned int cover_insn; |
---|
265 | 281 | struct annotation_options *options; |
---|
266 | 282 | struct annotation_line **offsets; |
---|
267 | 283 | int nr_events; |
---|
268 | | - int nr_jumps; |
---|
269 | 284 | int max_jump_sources; |
---|
270 | 285 | int nr_entries; |
---|
271 | 286 | int nr_asm_entries; |
---|
.. | .. |
---|
276 | 291 | u8 target; |
---|
277 | 292 | u8 min_addr; |
---|
278 | 293 | u8 max_addr; |
---|
| 294 | + u8 max_ins_name; |
---|
279 | 295 | } widths; |
---|
280 | 296 | bool have_cycles; |
---|
281 | 297 | struct annotated_source *src; |
---|
.. | .. |
---|
291 | 307 | |
---|
292 | 308 | static inline int annotation__pcnt_width(struct annotation *notes) |
---|
293 | 309 | { |
---|
294 | | - return (notes->options->show_total_period ? 12 : 7) * notes->nr_events; |
---|
| 310 | + return (symbol_conf.show_total_period ? 12 : 7) * notes->nr_events; |
---|
295 | 311 | } |
---|
296 | 312 | |
---|
297 | 313 | static inline bool annotation_line__filter(struct annotation_line *al, struct annotation *notes) |
---|
.. | .. |
---|
321 | 337 | } |
---|
322 | 338 | |
---|
323 | 339 | int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_sample *sample, |
---|
324 | | - struct perf_evsel *evsel); |
---|
| 340 | + struct evsel *evsel); |
---|
325 | 341 | |
---|
326 | 342 | int addr_map_symbol__account_cycles(struct addr_map_symbol *ams, |
---|
327 | 343 | struct addr_map_symbol *start, |
---|
328 | 344 | unsigned cycles); |
---|
329 | 345 | |
---|
330 | 346 | int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample *sample, |
---|
331 | | - struct perf_evsel *evsel, u64 addr); |
---|
| 347 | + struct evsel *evsel, u64 addr); |
---|
332 | 348 | |
---|
333 | 349 | struct annotated_source *symbol__hists(struct symbol *sym, int nr_hists); |
---|
334 | 350 | void symbol__annotate_zero_histograms(struct symbol *sym); |
---|
335 | 351 | |
---|
336 | | -int symbol__annotate(struct symbol *sym, struct map *map, |
---|
337 | | - struct perf_evsel *evsel, size_t privsize, |
---|
| 352 | +int symbol__annotate(struct map_symbol *ms, |
---|
| 353 | + struct evsel *evsel, |
---|
338 | 354 | struct annotation_options *options, |
---|
339 | 355 | struct arch **parch); |
---|
340 | | -int symbol__annotate2(struct symbol *sym, struct map *map, |
---|
341 | | - struct perf_evsel *evsel, |
---|
| 356 | +int symbol__annotate2(struct map_symbol *ms, |
---|
| 357 | + struct evsel *evsel, |
---|
342 | 358 | struct annotation_options *options, |
---|
343 | 359 | struct arch **parch); |
---|
344 | 360 | |
---|
.. | .. |
---|
355 | 371 | __SYMBOL_ANNOTATE_ERRNO__START = -10000, |
---|
356 | 372 | |
---|
357 | 373 | SYMBOL_ANNOTATE_ERRNO__NO_VMLINUX = __SYMBOL_ANNOTATE_ERRNO__START, |
---|
| 374 | + SYMBOL_ANNOTATE_ERRNO__NO_LIBOPCODES_FOR_BPF, |
---|
| 375 | + SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_CPUID_PARSING, |
---|
| 376 | + SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_REGEXP, |
---|
| 377 | + SYMBOL_ANNOTATE_ERRNO__BPF_INVALID_FILE, |
---|
| 378 | + SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF, |
---|
358 | 379 | |
---|
359 | 380 | __SYMBOL_ANNOTATE_ERRNO__END, |
---|
360 | 381 | }; |
---|
361 | 382 | |
---|
362 | | -int symbol__strerror_disassemble(struct symbol *sym, struct map *map, |
---|
363 | | - int errnum, char *buf, size_t buflen); |
---|
| 383 | +int symbol__strerror_disassemble(struct map_symbol *ms, int errnum, char *buf, size_t buflen); |
---|
364 | 384 | |
---|
365 | | -int symbol__annotate_printf(struct symbol *sym, struct map *map, |
---|
366 | | - struct perf_evsel *evsel, |
---|
| 385 | +int symbol__annotate_printf(struct map_symbol *ms, struct evsel *evsel, |
---|
367 | 386 | struct annotation_options *options); |
---|
368 | 387 | void symbol__annotate_zero_histogram(struct symbol *sym, int evidx); |
---|
369 | 388 | void symbol__annotate_decay_histogram(struct symbol *sym, int evidx); |
---|
370 | 389 | void annotated_source__purge(struct annotated_source *as); |
---|
371 | 390 | |
---|
372 | | -int map_symbol__annotation_dump(struct map_symbol *ms, struct perf_evsel *evsel, |
---|
| 391 | +int map_symbol__annotation_dump(struct map_symbol *ms, struct evsel *evsel, |
---|
373 | 392 | struct annotation_options *opts); |
---|
374 | 393 | |
---|
375 | 394 | bool ui__has_annotation(void); |
---|
376 | 395 | |
---|
377 | | -int symbol__tty_annotate(struct symbol *sym, struct map *map, |
---|
378 | | - struct perf_evsel *evsel, struct annotation_options *opts); |
---|
| 396 | +int symbol__tty_annotate(struct map_symbol *ms, struct evsel *evsel, struct annotation_options *opts); |
---|
379 | 397 | |
---|
380 | | -int symbol__tty_annotate2(struct symbol *sym, struct map *map, |
---|
381 | | - struct perf_evsel *evsel, struct annotation_options *opts); |
---|
| 398 | +int symbol__tty_annotate2(struct map_symbol *ms, struct evsel *evsel, struct annotation_options *opts); |
---|
382 | 399 | |
---|
383 | 400 | #ifdef HAVE_SLANG_SUPPORT |
---|
384 | | -int symbol__tui_annotate(struct symbol *sym, struct map *map, |
---|
385 | | - struct perf_evsel *evsel, |
---|
| 401 | +int symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel, |
---|
386 | 402 | struct hist_browser_timer *hbt, |
---|
387 | 403 | struct annotation_options *opts); |
---|
388 | 404 | #else |
---|
389 | | -static inline int symbol__tui_annotate(struct symbol *sym __maybe_unused, |
---|
390 | | - struct map *map __maybe_unused, |
---|
391 | | - struct perf_evsel *evsel __maybe_unused, |
---|
| 405 | +static inline int symbol__tui_annotate(struct map_symbol *ms __maybe_unused, |
---|
| 406 | + struct evsel *evsel __maybe_unused, |
---|
392 | 407 | struct hist_browser_timer *hbt __maybe_unused, |
---|
393 | 408 | struct annotation_options *opts __maybe_unused) |
---|
394 | 409 | { |
---|
.. | .. |
---|
396 | 411 | } |
---|
397 | 412 | #endif |
---|
398 | 413 | |
---|
399 | | -void annotation_config__init(void); |
---|
| 414 | +void annotation_config__init(struct annotation_options *opt); |
---|
400 | 415 | |
---|
401 | 416 | int annotate_parse_percent_type(const struct option *opt, const char *_str, |
---|
402 | 417 | int unset); |
---|
| 418 | + |
---|
| 419 | +int annotate_check_args(struct annotation_options *args); |
---|
| 420 | + |
---|
403 | 421 | #endif /* __PERF_ANNOTATE_H */ |
---|