hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/tools/perf/util/annotate.h
....@@ -4,16 +4,25 @@
44
55 #include <stdbool.h>
66 #include <stdint.h>
7
+#include <stdio.h>
78 #include <linux/types.h>
8
-#include "symbol.h"
9
-#include "hist.h"
10
-#include "sort.h"
119 #include <linux/list.h>
1210 #include <linux/rbtree.h>
1311 #include <pthread.h>
1412 #include <asm/bug.h>
13
+#include "symbol_conf.h"
14
+#include "spark.h"
1515
16
+struct hist_browser_timer;
17
+struct hist_entry;
1618 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;
1726
1827 struct ins {
1928 const char *name;
....@@ -23,6 +32,7 @@
2332 struct ins_operands {
2433 char *raw;
2534 char *raw_comment;
35
+ char *raw_func_start;
2636 struct {
2737 char *raw;
2838 char *name;
....@@ -51,19 +61,21 @@
5161 void (*free)(struct ins_operands *ops);
5262 int (*parse)(struct arch *arch, struct ins_operands *ops, struct map_symbol *ms);
5363 int (*scnprintf)(struct ins *ins, char *bf, size_t size,
54
- struct ins_operands *ops);
64
+ struct ins_operands *ops, int max_ins_name);
5565 };
5666
5767 bool ins__is_jump(const struct ins *ins);
5868 bool ins__is_call(const struct ins *ins);
5969 bool ins__is_ret(const struct ins *ins);
6070 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);
6272 bool ins__is_fused(struct arch *arch, const char *ins1, const char *ins2);
6373
6474 #define ANNOTATION__IPC_WIDTH 6
6575 #define ANNOTATION__CYCLES_WIDTH 6
6676 #define ANNOTATION__MINMAX_CYCLES_WIDTH 19
77
+#define ANNOTATION__AVG_IPC_WIDTH 36
78
+#define ANNOTATION_DUMMY_LEN 256
6779
6880 struct annotation_options {
6981 bool hide_src_code,
....@@ -73,8 +85,6 @@
7385 full_path,
7486 show_linenr,
7587 show_nr_jumps,
76
- show_nr_samples,
77
- show_total_period,
7888 show_minmax_cycle,
7989 show_asm_raw,
8090 annotate_src;
....@@ -84,6 +94,8 @@
8494 int context;
8595 const char *objdump_path;
8696 const char *disassembler_style;
97
+ const char *prefix;
98
+ const char *prefix_strip;
8799 unsigned int percent_type;
88100 };
89101
....@@ -129,12 +141,11 @@
129141 u64 cycles;
130142 u64 cycles_max;
131143 u64 cycles_min;
132
- size_t privsize;
133144 char *path;
134145 u32 idx;
135146 int idx_asm;
136147 int data_nr;
137
- struct annotation_data data[0];
148
+ struct annotation_data data[];
138149 };
139150
140151 struct disasm_line {
....@@ -207,17 +218,17 @@
207218
208219 int __annotation__scnprintf_samples_period(struct annotation *notes,
209220 char *bf, size_t size,
210
- struct perf_evsel *evsel,
221
+ struct evsel *evsel,
211222 bool show_freq);
212223
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);
214225 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);
216227
217228 struct sym_hist {
218229 u64 nr_samples;
219230 u64 period;
220
- struct sym_hist_entry addr[0];
231
+ struct sym_hist_entry addr[];
221232 };
222233
223234 struct cyc_hist {
....@@ -226,6 +237,7 @@
226237 u64 cycles_aggr;
227238 u64 cycles_max;
228239 u64 cycles_min;
240
+ s64 cycles_spark[NUM_SPARKS];
229241 u32 num;
230242 u32 num_aggr;
231243 u8 have_start;
....@@ -236,7 +248,7 @@
236248 /** struct annotated_source - symbols with hits have this attached as in sannotation
237249 *
238250 * @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
240252 * we have more than a group in a evlist, where we will want
241253 * to see each group separately, that is why symbol__annotate2()
242254 * sets src->nr_histograms to evsel->nr_members.
....@@ -262,10 +274,13 @@
262274 pthread_mutex_t lock;
263275 u64 max_coverage;
264276 u64 start;
277
+ u64 hit_cycles;
278
+ u64 hit_insn;
279
+ unsigned int total_insn;
280
+ unsigned int cover_insn;
265281 struct annotation_options *options;
266282 struct annotation_line **offsets;
267283 int nr_events;
268
- int nr_jumps;
269284 int max_jump_sources;
270285 int nr_entries;
271286 int nr_asm_entries;
....@@ -276,6 +291,7 @@
276291 u8 target;
277292 u8 min_addr;
278293 u8 max_addr;
294
+ u8 max_ins_name;
279295 } widths;
280296 bool have_cycles;
281297 struct annotated_source *src;
....@@ -291,7 +307,7 @@
291307
292308 static inline int annotation__pcnt_width(struct annotation *notes)
293309 {
294
- return (notes->options->show_total_period ? 12 : 7) * notes->nr_events;
310
+ return (symbol_conf.show_total_period ? 12 : 7) * notes->nr_events;
295311 }
296312
297313 static inline bool annotation_line__filter(struct annotation_line *al, struct annotation *notes)
....@@ -321,24 +337,24 @@
321337 }
322338
323339 int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_sample *sample,
324
- struct perf_evsel *evsel);
340
+ struct evsel *evsel);
325341
326342 int addr_map_symbol__account_cycles(struct addr_map_symbol *ams,
327343 struct addr_map_symbol *start,
328344 unsigned cycles);
329345
330346 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);
332348
333349 struct annotated_source *symbol__hists(struct symbol *sym, int nr_hists);
334350 void symbol__annotate_zero_histograms(struct symbol *sym);
335351
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,
338354 struct annotation_options *options,
339355 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,
342358 struct annotation_options *options,
343359 struct arch **parch);
344360
....@@ -355,40 +371,39 @@
355371 __SYMBOL_ANNOTATE_ERRNO__START = -10000,
356372
357373 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,
358379
359380 __SYMBOL_ANNOTATE_ERRNO__END,
360381 };
361382
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);
364384
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,
367386 struct annotation_options *options);
368387 void symbol__annotate_zero_histogram(struct symbol *sym, int evidx);
369388 void symbol__annotate_decay_histogram(struct symbol *sym, int evidx);
370389 void annotated_source__purge(struct annotated_source *as);
371390
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,
373392 struct annotation_options *opts);
374393
375394 bool ui__has_annotation(void);
376395
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);
379397
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);
382399
383400 #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,
386402 struct hist_browser_timer *hbt,
387403 struct annotation_options *opts);
388404 #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,
392407 struct hist_browser_timer *hbt __maybe_unused,
393408 struct annotation_options *opts __maybe_unused)
394409 {
....@@ -396,8 +411,11 @@
396411 }
397412 #endif
398413
399
-void annotation_config__init(void);
414
+void annotation_config__init(struct annotation_options *opt);
400415
401416 int annotate_parse_percent_type(const struct option *opt, const char *_str,
402417 int unset);
418
+
419
+int annotate_check_args(struct annotation_options *args);
420
+
403421 #endif /* __PERF_ANNOTATE_H */