perf annotate: Rename objdump_line to disasm_line
[linux-2.6-block.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
29ed6e76 10struct disasm_line {
78f7defe
ACM
11 struct list_head node;
12 s64 offset;
13 char *line;
14};
15
29ed6e76
ACM
16void disasm_line__free(struct disasm_line *dl);
17struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disasm_line *pos);
78f7defe
ACM
18
19struct sym_hist {
20 u64 sum;
21 u64 addr[0];
22};
23
24struct source_line {
25 struct rb_node node;
26 double percent;
27 char *path;
28};
29
ce6f4fab 30/** struct annotated_source - symbols with hits have this attached as in sannotation
2f525d01
ACM
31 *
32 * @histogram: Array of addr hit histograms per event being monitored
ce6f4fab 33 * @lines: If 'print_lines' is specified, per source code line percentages
29ed6e76 34 * @source: source parsed from a disassembler like objdump -dS
2f525d01 35 *
ce6f4fab 36 * lines is allocated, percentages calculated and all sorted by percentage
2f525d01
ACM
37 * when the annotation is about to be presented, so the percentages are for
38 * one of the entries in the histogram array, i.e. for the event/counter being
39 * presented. It is deallocated right after symbol__{tui,tty,etc}_annotate
40 * returns.
41 */
ce6f4fab
ACM
42struct annotated_source {
43 struct list_head source;
44 struct source_line *lines;
36532461 45 int nr_histograms;
2f525d01 46 int sizeof_sym_hist;
ce6f4fab
ACM
47 struct sym_hist histograms[0];
48};
49
50struct annotation {
51 pthread_mutex_t lock;
52 struct annotated_source *src;
78f7defe
ACM
53};
54
55struct sannotation {
56 struct annotation annotation;
57 struct symbol symbol;
58};
59
2f525d01
ACM
60static inline struct sym_hist *annotation__histogram(struct annotation *notes, int idx)
61{
ce6f4fab
ACM
62 return (((void *)&notes->src->histograms) +
63 (notes->src->sizeof_sym_hist * idx));
2f525d01
ACM
64}
65
78f7defe
ACM
66static inline struct annotation *symbol__annotation(struct symbol *sym)
67{
68 struct sannotation *a = container_of(sym, struct sannotation, symbol);
69 return &a->annotation;
70}
71
2f525d01
ACM
72int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
73 int evidx, u64 addr);
d04b35f8 74int symbol__alloc_hist(struct symbol *sym);
36532461 75void symbol__annotate_zero_histograms(struct symbol *sym);
78f7defe 76
ce6f4fab
ACM
77int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize);
78int symbol__annotate_init(struct map *map __used, struct symbol *sym);
79int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx,
d5e3d747
ACM
80 bool full_paths, int min_pcnt, int max_lines,
81 int context);
36532461 82void symbol__annotate_zero_histogram(struct symbol *sym, int evidx);
ce6f4fab 83void symbol__annotate_decay_histogram(struct symbol *sym, int evidx);
29ed6e76 84void disasm__purge(struct list_head *head);
78f7defe 85
2f525d01 86int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx,
d040bd36
ACM
87 bool print_lines, bool full_paths, int min_pcnt,
88 int max_lines);
78f7defe
ACM
89
90#ifdef NO_NEWT_SUPPORT
a2221796 91static inline int symbol__tui_annotate(struct symbol *sym __used,
c97cf422 92 struct map *map __used,
81cce8de
ACM
93 int evidx __used,
94 void(*timer)(void *arg) __used,
95 void *arg __used, int delay_secs __used)
78f7defe
ACM
96{
97 return 0;
98}
99#else
c97cf422 100int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
d04b35f8 101 void(*timer)(void *arg), void *arg, int delay_secs);
78f7defe
ACM
102#endif
103
f69b64f7
AK
104extern const char *disassembler_style;
105
78f7defe 106#endif /* __PERF_ANNOTATE_H */