diff options
| author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-02-22 10:02:07 -0500 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-02-22 10:02:07 -0500 |
| commit | c97cf42219b7b6037d2f96c27a5f114f2383f828 (patch) | |
| tree | 2180e3eae063a217d1681074a813eed42ad91a86 /tools/perf/util | |
| parent | 8635bf6ea3402154eec64763e6ed14972013c1c1 (diff) | |
perf top: Live TUI Annotation
Now one has just to press the right key, 'a' or Enter on the main 'perf
top --tui' screen to live annotate the symbol under the cursor.
The annotate window starts centered on the hottest line (the one with
most samples so far) then TAB and shift+TAB can be used to go to the
prev/next hot line.
Pressing 'H' at any point will center again the screen on the hottest
line.
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
| -rw-r--r-- | tools/perf/util/annotate.h | 6 | ||||
| -rw-r--r-- | tools/perf/util/top.h | 1 | ||||
| -rw-r--r-- | tools/perf/util/ui/browsers/annotate.c | 126 | ||||
| -rw-r--r-- | tools/perf/util/ui/browsers/top.c | 45 |
4 files changed, 138 insertions, 40 deletions
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index e848803fcd48..c2c286896801 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h | |||
| @@ -90,12 +90,14 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx, | |||
| 90 | 90 | ||
| 91 | #ifdef NO_NEWT_SUPPORT | 91 | #ifdef NO_NEWT_SUPPORT |
| 92 | static inline int symbol__tui_annotate(struct symbol *sym __used, | 92 | static inline int symbol__tui_annotate(struct symbol *sym __used, |
| 93 | struct map *map __used, int evidx __used) | 93 | struct map *map __used, |
| 94 | int evidx __used, int refresh __used) | ||
| 94 | { | 95 | { |
| 95 | return 0; | 96 | return 0; |
| 96 | } | 97 | } |
| 97 | #else | 98 | #else |
| 98 | int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx); | 99 | int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, |
| 100 | int refresh); | ||
| 99 | #endif | 101 | #endif |
| 100 | 102 | ||
| 101 | #endif /* __PERF_ANNOTATE_H */ | 103 | #endif /* __PERF_ANNOTATE_H */ |
diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h index 4f769f47e19a..e8d28e2ecdba 100644 --- a/tools/perf/util/top.h +++ b/tools/perf/util/top.h | |||
| @@ -44,6 +44,7 @@ struct perf_top { | |||
| 44 | pid_t target_pid, target_tid; | 44 | pid_t target_pid, target_tid; |
| 45 | bool hide_kernel_symbols, hide_user_symbols, zero; | 45 | bool hide_kernel_symbols, hide_user_symbols, zero; |
| 46 | const char *cpu_list; | 46 | const char *cpu_list; |
| 47 | struct sym_entry *sym_filter_entry; | ||
| 47 | struct perf_evsel *sym_evsel; | 48 | struct perf_evsel *sym_evsel; |
| 48 | }; | 49 | }; |
| 49 | 50 | ||
diff --git a/tools/perf/util/ui/browsers/annotate.c b/tools/perf/util/ui/browsers/annotate.c index cfb5a27f15d2..8c17a8730e4a 100644 --- a/tools/perf/util/ui/browsers/annotate.c +++ b/tools/perf/util/ui/browsers/annotate.c | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include "../../sort.h" | 6 | #include "../../sort.h" |
| 7 | #include "../../symbol.h" | 7 | #include "../../symbol.h" |
| 8 | #include "../../annotate.h" | 8 | #include "../../annotate.h" |
| 9 | #include <pthread.h> | ||
| 9 | 10 | ||
| 10 | static void ui__error_window(const char *fmt, ...) | 11 | static void ui__error_window(const char *fmt, ...) |
| 11 | { | 12 | { |
| @@ -138,46 +139,108 @@ static void annotate_browser__set_top(struct annotate_browser *self, | |||
| 138 | self->curr_hot = nd; | 139 | self->curr_hot = nd; |
| 139 | } | 140 | } |
| 140 | 141 | ||
| 141 | static int annotate_browser__run(struct annotate_browser *self) | 142 | static void annotate_browser__calc_percent(struct annotate_browser *browser, |
| 143 | int evidx) | ||
| 142 | { | 144 | { |
| 143 | struct rb_node *nd; | 145 | struct symbol *sym = browser->b.priv; |
| 146 | struct annotation *notes = symbol__annotation(sym); | ||
| 147 | struct objdump_line *pos; | ||
| 148 | |||
| 149 | browser->entries = RB_ROOT; | ||
| 150 | |||
| 151 | pthread_mutex_lock(¬es->lock); | ||
| 152 | |||
| 153 | list_for_each_entry(pos, ¬es->src->source, node) { | ||
| 154 | struct objdump_line_rb_node *rbpos = objdump_line__rb(pos); | ||
| 155 | rbpos->percent = objdump_line__calc_percent(pos, sym, evidx); | ||
| 156 | if (rbpos->percent < 0.01) { | ||
| 157 | RB_CLEAR_NODE(&rbpos->rb_node); | ||
| 158 | continue; | ||
| 159 | } | ||
| 160 | objdump__insert_line(&browser->entries, rbpos); | ||
| 161 | } | ||
| 162 | pthread_mutex_unlock(¬es->lock); | ||
| 163 | |||
| 164 | browser->curr_hot = rb_last(&browser->entries); | ||
| 165 | } | ||
| 166 | |||
| 167 | static int annotate_browser__run(struct annotate_browser *self, int evidx, | ||
| 168 | int refresh) | ||
| 169 | { | ||
| 170 | struct rb_node *nd = NULL; | ||
| 144 | struct symbol *sym = self->b.priv; | 171 | struct symbol *sym = self->b.priv; |
| 172 | /* | ||
| 173 | * RIGHT To allow builtin-annotate to cycle thru multiple symbols by | ||
| 174 | * examining the exit key for this function. | ||
| 175 | */ | ||
| 176 | int exit_keys[] = { 'H', NEWT_KEY_TAB, NEWT_KEY_UNTAB, | ||
| 177 | NEWT_KEY_RIGHT, 0 }; | ||
| 145 | int key; | 178 | int key; |
| 146 | 179 | ||
| 147 | if (ui_browser__show(&self->b, sym->name, | 180 | if (ui_browser__show(&self->b, sym->name, |
| 148 | "<-, -> or ESC: exit, TAB/shift+TAB: cycle thru samples") < 0) | 181 | "<-, -> or ESC: exit, TAB/shift+TAB: " |
| 182 | "cycle hottest lines, H: Hottest") < 0) | ||
| 149 | return -1; | 183 | return -1; |
| 150 | /* | 184 | |
| 151 | * To allow builtin-annotate to cycle thru multiple symbols by | 185 | ui_browser__add_exit_keys(&self->b, exit_keys); |
| 152 | * examining the exit key for this function. | 186 | annotate_browser__calc_percent(self, evidx); |
| 153 | */ | 187 | |
| 154 | ui_browser__add_exit_key(&self->b, NEWT_KEY_RIGHT); | 188 | if (self->curr_hot) |
| 189 | annotate_browser__set_top(self, self->curr_hot); | ||
| 155 | 190 | ||
| 156 | nd = self->curr_hot; | 191 | nd = self->curr_hot; |
| 157 | if (nd) { | 192 | |
| 158 | int tabs[] = { NEWT_KEY_TAB, NEWT_KEY_UNTAB, 0 }; | 193 | if (refresh != 0) |
| 159 | ui_browser__add_exit_keys(&self->b, tabs); | 194 | newtFormSetTimer(self->b.form, refresh); |
| 160 | } | ||
| 161 | 195 | ||
| 162 | while (1) { | 196 | while (1) { |
| 163 | key = ui_browser__run(&self->b); | 197 | key = ui_browser__run(&self->b); |
| 164 | 198 | ||
| 199 | if (refresh != 0) { | ||
| 200 | annotate_browser__calc_percent(self, evidx); | ||
| 201 | /* | ||
| 202 | * Current line focus got out of the list of most active | ||
| 203 | * lines, NULL it so that if TAB|UNTAB is pressed, we | ||
| 204 | * move to curr_hot (current hottest line). | ||
| 205 | */ | ||
| 206 | if (nd != NULL && RB_EMPTY_NODE(nd)) | ||
| 207 | nd = NULL; | ||
| 208 | } | ||
| 209 | |||
| 165 | switch (key) { | 210 | switch (key) { |
| 211 | case -1: | ||
| 212 | /* | ||
| 213 | * FIXME we need to check if it was | ||
| 214 | * es.reason == NEWT_EXIT_TIMER | ||
| 215 | */ | ||
| 216 | if (refresh != 0) | ||
| 217 | symbol__annotate_decay_histogram(sym, evidx); | ||
| 218 | continue; | ||
| 166 | case NEWT_KEY_TAB: | 219 | case NEWT_KEY_TAB: |
| 167 | nd = rb_prev(nd); | 220 | if (nd != NULL) { |
| 168 | if (nd == NULL) | 221 | nd = rb_prev(nd); |
| 169 | nd = rb_last(&self->entries); | 222 | if (nd == NULL) |
| 170 | annotate_browser__set_top(self, nd); | 223 | nd = rb_last(&self->entries); |
| 224 | } else | ||
| 225 | nd = self->curr_hot; | ||
| 171 | break; | 226 | break; |
| 172 | case NEWT_KEY_UNTAB: | 227 | case NEWT_KEY_UNTAB: |
| 173 | nd = rb_next(nd); | 228 | if (nd != NULL) |
| 174 | if (nd == NULL) | 229 | nd = rb_next(nd); |
| 175 | nd = rb_first(&self->entries); | 230 | if (nd == NULL) |
| 176 | annotate_browser__set_top(self, nd); | 231 | nd = rb_first(&self->entries); |
| 232 | else | ||
| 233 | nd = self->curr_hot; | ||
| 234 | break; | ||
| 235 | case 'H': | ||
| 236 | nd = self->curr_hot; | ||
| 177 | break; | 237 | break; |
| 178 | default: | 238 | default: |
| 179 | goto out; | 239 | goto out; |
| 180 | } | 240 | } |
| 241 | |||
| 242 | if (nd != NULL) | ||
