1 #ifndef __PERF_ANNOTATE_H 2 #define __PERF_ANNOTATE_H 3 4 #include <stdbool.h> 5 #include "types.h" 6 #include "symbol.h" 7 /* ANDROID_CHANGE_BEGIN */ 8 #if 0 9 #include <linux/list.h> 10 #include <linux/rbtree.h> 11 #else 12 #include "include/linux/list.h" 13 #include "include/linux/rbtree.h" 14 #if defined(__BIONIC__) || defined(__APPLE__) 15 #include <pthread.h> 16 #endif 17 #endif 18 /* ANDROID_CHANGE_END */ 19 20 struct objdump_line { 21 struct list_head node; 22 s64 offset; 23 char *line; 24 }; 25 26 void objdump_line__free(struct objdump_line *self); 27 struct objdump_line *objdump__get_next_ip_line(struct list_head *head, 28 struct objdump_line *pos); 29 30 struct sym_hist { 31 u64 sum; 32 u64 addr[0]; 33 }; 34 35 struct source_line { 36 struct rb_node node; 37 double percent; 38 char *path; 39 }; 40 41 /** struct annotated_source - symbols with hits have this attached as in sannotation 42 * 43 * @histogram: Array of addr hit histograms per event being monitored 44 * @lines: If 'print_lines' is specified, per source code line percentages 45 * @source: source parsed from objdump -dS 46 * 47 * lines is allocated, percentages calculated and all sorted by percentage 48 * when the annotation is about to be presented, so the percentages are for 49 * one of the entries in the histogram array, i.e. for the event/counter being 50 * presented. It is deallocated right after symbol__{tui,tty,etc}_annotate 51 * returns. 52 */ 53 struct annotated_source { 54 struct list_head source; 55 struct source_line *lines; 56 int nr_histograms; 57 int sizeof_sym_hist; 58 struct sym_hist histograms[0]; 59 }; 60 61 struct annotation { 62 pthread_mutex_t lock; 63 struct annotated_source *src; 64 }; 65 66 struct sannotation { 67 struct annotation annotation; 68 struct symbol symbol; 69 }; 70 71 static inline struct sym_hist *annotation__histogram(struct annotation *notes, int idx) 72 { 73 return (((void *)¬es->src->histograms) + 74 (notes->src->sizeof_sym_hist * idx)); 75 } 76 77 static inline struct annotation *symbol__annotation(struct symbol *sym) 78 { 79 struct sannotation *a = container_of(sym, struct sannotation, symbol); 80 return &a->annotation; 81 } 82 83 int symbol__inc_addr_samples(struct symbol *sym, struct map *map, 84 int evidx, u64 addr); 85 int symbol__alloc_hist(struct symbol *sym, int nevents); 86 void symbol__annotate_zero_histograms(struct symbol *sym); 87 88 /* ANDROID_CHANGE_BEGIN */ 89 #if 0 90 int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize); 91 #else 92 int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize, 93 bool print_lines); 94 #endif 95 /* ANDROID_CHANGE_END */ 96 int symbol__annotate_init(struct map *map __used, struct symbol *sym); 97 int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx, 98 bool full_paths, int min_pcnt, int max_lines, 99 int context); 100 void symbol__annotate_zero_histogram(struct symbol *sym, int evidx); 101 void symbol__annotate_decay_histogram(struct symbol *sym, int evidx); 102 void objdump_line_list__purge(struct list_head *head); 103 104 int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx, 105 bool print_lines, bool full_paths, int min_pcnt, 106 int max_lines); 107 108 #ifdef NO_NEWT_SUPPORT 109 static inline int symbol__tui_annotate(struct symbol *sym __used, 110 struct map *map __used, 111 int evidx __used, int refresh __used) 112 { 113 return 0; 114 } 115 #else 116 int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, 117 int refresh); 118 #endif 119 120 #endif /* __PERF_ANNOTATE_H */ 121