]> git.ipfire.org Git - thirdparty/linux.git/blame - tools/perf/util/annotate.h
perf annotate browser: Handle NULL jump targets
[thirdparty/linux.git] / tools / perf / util / annotate.h
CommitLineData
78f7defe
ACM
1#ifndef __PERF_ANNOTATE_H
2#define __PERF_ANNOTATE_H
3
4#include <stdbool.h>
5#include "types.h"
6#include "symbol.h"
7#include <linux/list.h>
8#include <linux/rbtree.h>
9
28548d78
ACM
10struct ins;
11
c7e6ead7
ACM
12struct ins_operands {
13 char *raw;
d2232885 14 char *target_name;
c7e6ead7
ACM
15 u64 target;
16};
17
4f9d0325 18struct ins_ops {
c7e6ead7 19 int (*parse)(struct ins_operands *ops);
28548d78 20 int (*scnprintf)(struct ins *ins, char *bf, size_t size,
c7e6ead7 21 struct ins_operands *ops, bool addrs);
4f9d0325
ACM
22};
23
24struct ins {
25 const char *name;
26 struct ins_ops *ops;
27};
28
29bool ins__is_jump(const struct ins *ins);
d86b0597 30bool ins__is_call(const struct ins *ins);
4f9d0325 31
29ed6e76 32struct disasm_line {
c7e6ead7
ACM
33 struct list_head node;
34 s64 offset;
35 char *line;
36 char *name;
37 struct ins *ins;
38 struct ins_operands ops;
78f7defe
ACM
39};
40
29ed6e76
ACM
41void disasm_line__free(struct disasm_line *dl);
42struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disasm_line *pos);
5145418b 43size_t disasm__fprintf(struct list_head *head, FILE *fp);
78f7defe
ACM
44
45struct sym_hist {
46 u64 sum;
47 u64 addr[0];
48};
49
50struct source_line {
51 struct rb_node node;
52 double percent;
53 char *path;
54};
55
ce6f4fab 56/** struct annotated_source - symbols with hits have this attached as in sannotation
2f525d01
ACM
57 *
58 * @histogram: Array of addr hit histograms per event being monitored
ce6f4fab 59 * @lines: If 'print_lines' is specified, per source code line percentages
29ed6e76 60 * @source: source parsed from a disassembler like objdump -dS
2f525d01 61 *
ce6f4fab 62 * lines is allocated, percentages calculated and all sorted by percentage
2f525d01
ACM
63 * when the annotation is about to be presented, so the percentages are for
64 * one of the entries in the histogram array, i.e. for the event/counter being
65 * presented. It is deallocated right after symbol__{tui,tty,etc}_annotate
66 * returns.
67 */
ce6f4fab
ACM
68struct annotated_source {
69 struct list_head source;
70 struct source_line *lines;
36532461 71 int nr_histograms;
2f525d01 72 int sizeof_sym_hist;
ce6f4fab
ACM
73 struct sym_hist histograms[0];
74};
75
76struct annotation {
77 pthread_mutex_t lock;
78 struct annotated_source *src;
78f7defe
ACM
79};
80
81struct sannotation {
82 struct annotation annotation;
83 struct symbol symbol;
84};
85
2f525d01
ACM
86static inline struct sym_hist *annotation__histogram(struct annotation *notes, int idx)
87{
ce6f4fab
ACM
88 return (((void *)&notes->src->histograms) +
89 (notes->src->sizeof_sym_hist * idx));
2f525d01
ACM
90}
91
78f7defe
ACM
92static inline struct annotation *symbol__annotation(struct symbol *sym)
93{
94 struct sannotation *a = container_of(sym, struct sannotation, symbol);
95 return &a->annotation;
96}
97
2f525d01
ACM
98int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
99 int evidx, u64 addr);
d04b35f8 100int symbol__alloc_hist(struct symbol *sym);
36532461 101void symbol__annotate_zero_histograms(struct symbol *sym);
78f7defe 102
ce6f4fab
ACM
103int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize);
104int symbol__annotate_init(struct map *map __used, struct symbol *sym);
105int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx,
d5e3d747
ACM
106 bool full_paths, int min_pcnt, int max_lines,
107 int context);
36532461 108void symbol__annotate_zero_histogram(struct symbol *sym, int evidx);
ce6f4fab 109void symbol__annotate_decay_histogram(struct symbol *sym, int evidx);
29ed6e76 110void disasm__purge(struct list_head *head);
78f7defe 111
2f525d01 112int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx,
d040bd36
ACM
113 bool print_lines, bool full_paths, int min_pcnt,
114 int max_lines);
78f7defe
ACM
115
116#ifdef NO_NEWT_SUPPORT
a2221796 117static inline int symbol__tui_annotate(struct symbol *sym __used,
c97cf422 118 struct map *map __used,
81cce8de
ACM
119 int evidx __used,
120 void(*timer)(void *arg) __used,
121 void *arg __used, int delay_secs __used)
78f7defe
ACM
122{
123 return 0;
124}
125#else
c97cf422 126int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
d04b35f8 127 void(*timer)(void *arg), void *arg, int delay_secs);
78f7defe
ACM
128#endif
129
f69b64f7
AK
130extern const char *disassembler_style;
131
78f7defe 132#endif /* __PERF_ANNOTATE_H */