]>
Commit | Line | Data |
---|---|---|
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 |
10 | struct ins; |
11 | ||
c7e6ead7 ACM |
12 | struct ins_operands { |
13 | char *raw; | |
d2232885 | 14 | char *target_name; |
c7e6ead7 ACM |
15 | u64 target; |
16 | }; | |
17 | ||
4f9d0325 | 18 | struct 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 | ||
24 | struct ins { | |
25 | const char *name; | |
26 | struct ins_ops *ops; | |
27 | }; | |
28 | ||
29 | bool ins__is_jump(const struct ins *ins); | |
d86b0597 | 30 | bool ins__is_call(const struct ins *ins); |
4f9d0325 | 31 | |
29ed6e76 | 32 | struct 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 |
41 | void disasm_line__free(struct disasm_line *dl); |
42 | struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disasm_line *pos); | |
5145418b | 43 | size_t disasm__fprintf(struct list_head *head, FILE *fp); |
78f7defe ACM |
44 | |
45 | struct sym_hist { | |
46 | u64 sum; | |
47 | u64 addr[0]; | |
48 | }; | |
49 | ||
50 | struct 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 |
68 | struct 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 | ||
76 | struct annotation { | |
77 | pthread_mutex_t lock; | |
78 | struct annotated_source *src; | |
78f7defe ACM |
79 | }; |
80 | ||
81 | struct sannotation { | |
82 | struct annotation annotation; | |
83 | struct symbol symbol; | |
84 | }; | |
85 | ||
2f525d01 ACM |
86 | static inline struct sym_hist *annotation__histogram(struct annotation *notes, int idx) |
87 | { | |
ce6f4fab ACM |
88 | return (((void *)¬es->src->histograms) + |
89 | (notes->src->sizeof_sym_hist * idx)); | |
2f525d01 ACM |
90 | } |
91 | ||
78f7defe ACM |
92 | static 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 |
98 | int symbol__inc_addr_samples(struct symbol *sym, struct map *map, |
99 | int evidx, u64 addr); | |
d04b35f8 | 100 | int symbol__alloc_hist(struct symbol *sym); |
36532461 | 101 | void symbol__annotate_zero_histograms(struct symbol *sym); |
78f7defe | 102 | |
ce6f4fab ACM |
103 | int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize); |
104 | int symbol__annotate_init(struct map *map __used, struct symbol *sym); | |
105 | int 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 | 108 | void symbol__annotate_zero_histogram(struct symbol *sym, int evidx); |
ce6f4fab | 109 | void symbol__annotate_decay_histogram(struct symbol *sym, int evidx); |
29ed6e76 | 110 | void disasm__purge(struct list_head *head); |
78f7defe | 111 | |
2f525d01 | 112 | int 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 | 117 | static 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 | 126 | int 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 |
130 | extern const char *disassembler_style; |
131 | ||
78f7defe | 132 | #endif /* __PERF_ANNOTATE_H */ |