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