diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-03-24 15:40:19 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-03-26 03:52:57 -0400 |
commit | d5679ae4d2d4369477dc3b60027cca222aef33e9 (patch) | |
tree | e7c5e708e2537d40cb05ff0c7f35575a69c8dfa9 | |
parent | b3c9ac0846c654dea4df095999ee202e8b4cb253 (diff) |
perf report: Pass the DSO to 'perf annotate'
So that we ensure that the symbol asked for annotation really is
in the DSO we are interested in.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1269459619-982-6-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | tools/perf/util/newt.c | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c index f6953ca89bbc..e99bcc8d1939 100644 --- a/tools/perf/util/newt.c +++ b/tools/perf/util/newt.c | |||
@@ -157,7 +157,7 @@ static void __callchain__append_graph_browser(struct callchain_node *self, | |||
157 | indexes[depth + 2] = NEWT_ARG_LAST; | 157 | indexes[depth + 2] = NEWT_ARG_LAST; |
158 | ++chain_idx; | 158 | ++chain_idx; |
159 | } | 159 | } |
160 | newt_checkbox_tree__add(tree, str, chain->ms.sym, indexes); | 160 | newt_checkbox_tree__add(tree, str, &chain->ms, indexes); |
161 | free(alloc_str); | 161 | free(alloc_str); |
162 | ++printed; | 162 | ++printed; |
163 | } | 163 | } |
@@ -193,7 +193,7 @@ static void callchain__append_graph_browser(struct callchain_node *self, | |||
193 | continue; | 193 | continue; |
194 | 194 | ||
195 | str = callchain_list__sym_name(chain, ipstr, sizeof(ipstr)); | 195 | str = callchain_list__sym_name(chain, ipstr, sizeof(ipstr)); |
196 | newt_checkbox_tree__add(tree, str, chain->ms.sym, indexes); | 196 | newt_checkbox_tree__add(tree, str, &chain->ms, indexes); |
197 | } | 197 | } |
198 | 198 | ||
199 | indexes[1] = parent_idx; | 199 | indexes[1] = parent_idx; |
@@ -287,14 +287,14 @@ static size_t hist_entry__append_browser(struct hist_entry *self, | |||
287 | 287 | ||
288 | indexes[0] = NEWT_ARG_APPEND; | 288 | indexes[0] = NEWT_ARG_APPEND; |
289 | indexes[1] = NEWT_ARG_LAST; | 289 | indexes[1] = NEWT_ARG_LAST; |
290 | newt_checkbox_tree__add(tree, s, self->ms.sym, indexes); | 290 | newt_checkbox_tree__add(tree, s, &self->ms, indexes); |
291 | } else | 291 | } else |
292 | newtListboxAppendEntry(tree, s, self->ms.sym); | 292 | newtListboxAppendEntry(tree, s, &self->ms); |
293 | 293 | ||
294 | return strlen(s); | 294 | return strlen(s); |
295 | } | 295 | } |
296 | 296 | ||
297 | static void symbol__annotate_browser(const struct symbol *self) | 297 | static void map_symbol__annotate_browser(const struct map_symbol *self) |
298 | { | 298 | { |
299 | FILE *fp; | 299 | FILE *fp; |
300 | int cols, rows; | 300 | int cols, rows; |
@@ -305,10 +305,11 @@ static void symbol__annotate_browser(const struct symbol *self) | |||
305 | size_t max_usable_width; | 305 | size_t max_usable_width; |
306 | char *line = NULL; | 306 | char *line = NULL; |
307 | 307 | ||
308 | if (self == NULL) | 308 | if (self->sym == NULL) |
309 | return; | 309 | return; |
310 | 310 | ||
311 | if (asprintf(&str, "perf annotate %s 2>&1 | expand", self->name) < 0) | 311 | if (asprintf(&str, "perf annotate -d \"%s\" %s 2>&1 | expand", |
312 | self->map->dso->name, self->sym->name) < 0) | ||
312 | return; | 313 | return; |
313 | 314 | ||
314 | fp = popen(str, "r"); | 315 | fp = popen(str, "r"); |
@@ -338,7 +339,7 @@ static void symbol__annotate_browser(const struct symbol *self) | |||
338 | 339 | ||
339 | newtListboxSetWidth(tree, max_line_len); | 340 | newtListboxSetWidth(tree, max_line_len); |
340 | 341 | ||
341 | newtCenteredWindow(max_line_len + 2, rows - 5, self->name); | 342 | newtCenteredWindow(max_line_len + 2, rows - 5, self->sym->name); |
342 | form = newt_form__new(); | 343 | form = newt_form__new(); |
343 | newtFormAddComponents(form, tree, NULL); | 344 | newtFormAddComponents(form, tree, NULL); |
344 | 345 | ||
@@ -359,7 +360,7 @@ static const void *newt__symbol_tree_get_current(newtComponent self) | |||
359 | 360 | ||
360 | static void perf_session__selection(newtComponent self, void *data) | 361 | static void perf_session__selection(newtComponent self, void *data) |
361 | { | 362 | { |
362 | const struct symbol **symbol_ptr = data; | 363 | const struct map_symbol **symbol_ptr = data; |
363 | *symbol_ptr = newt__symbol_tree_get_current(self); | 364 | *symbol_ptr = newt__symbol_tree_get_current(self); |
364 | } | 365 | } |
365 | 366 | ||
@@ -376,7 +377,7 @@ void perf_session__browse_hists(struct rb_root *hists, u64 session_total, | |||
376 | char str[1024]; | 377 | char str[1024]; |
377 | newtComponent form, tree; | 378 | newtComponent form, tree; |
378 | struct newtExitStruct es; | 379 | struct newtExitStruct es; |
379 | const struct symbol *selection; | 380 | const struct map_symbol *selection; |
380 | 381 | ||
381 | snprintf(str, sizeof(str), "Samples: %Ld", session_total); | 382 | snprintf(str, sizeof(str), "Samples: %Ld", session_total); |
382 | newtDrawRootText(0, 0, str); | 383 | newtDrawRootText(0, 0, str); |
@@ -416,11 +417,8 @@ void perf_session__browse_hists(struct rb_root *hists, u64 session_total, | |||
416 | int len = hist_entry__append_browser(h, tree, session_total); | 417 | int len = hist_entry__append_browser(h, tree, session_total); |
417 | if (len > max_len) | 418 | if (len > max_len) |
418 | max_len = len; | 419 | max_len = len; |
419 | if (symbol_conf.use_callchain) { | 420 | if (symbol_conf.use_callchain) |
420 | hist_entry__append_callchain_browser(h, tree, session_total, idx++); | 421 | hist_entry__append_callchain_browser(h, tree, session_total, idx++); |
421 | if (idx > 3300) | ||
422 | break; | ||
423 | } | ||
424 | } | 422 | } |
425 | 423 | ||
426 | if (max_len > cols) | 424 | if (max_len > cols) |
@@ -441,14 +439,12 @@ void perf_session__browse_hists(struct rb_root *hists, u64 session_total, | |||
441 | while (1) { | 439 | while (1) { |
442 | char annotate[512]; | 440 | char annotate[512]; |
443 | const char *options[2]; | 441 | const char *options[2]; |
444 | int nr_options = 0, choice; | 442 | int nr_options = 0, choice = 0; |
445 | 443 | ||
446 | newtFormRun(form, &es); | 444 | newtFormRun(form, &es); |
447 | if (es.reason == NEWT_EXIT_HOTKEY) { | 445 | if (es.reason == NEWT_EXIT_HOTKEY) { |
448 | if (toupper(es.u.key) == 'A') { | 446 | if (toupper(es.u.key) == 'A') |
449 | symbol__annotate_browser(selection); | 447 | goto do_annotate; |
450 | continue; | ||
451 | } | ||
452 | if (es.u.key == NEWT_KEY_ESCAPE || | 448 | if (es.u.key == NEWT_KEY_ESCAPE || |
453 | toupper(es.u.key) == 'Q' || | 449 | toupper(es.u.key) == 'Q' || |
454 | es.u.key == CTRL('c')) { | 450 | es.u.key == CTRL('c')) { |
@@ -459,9 +455,9 @@ void perf_session__browse_hists(struct rb_root *hists, u64 session_total, | |||
459 | } | 455 | } |
460 | } | 456 | } |
461 | 457 | ||
462 | if (selection != NULL) { | 458 | if (selection->sym != NULL) { |
463 | snprintf(annotate, sizeof(annotate), | 459 | snprintf(annotate, sizeof(annotate), |
464 | "Annotate %s", selection->name); | 460 | "Annotate %s", selection->sym->name); |
465 | options[nr_options++] = annotate; | 461 | options[nr_options++] = annotate; |
466 | } | 462 | } |
467 | 463 | ||
@@ -469,8 +465,17 @@ void perf_session__browse_hists(struct rb_root *hists, u64 session_total, | |||
469 | choice = popup_menu(nr_options, options); | 465 | choice = popup_menu(nr_options, options); |
470 | if (choice == nr_options - 1) | 466 | if (choice == nr_options - 1) |
471 | break; | 467 | break; |
472 | else if (selection != NULL && choice >= 0) | 468 | do_annotate: |
473 | symbol__annotate_browser(selection); | 469 | if (selection->sym != NULL && choice >= 0) { |
470 | if (selection->map->dso->origin == DSO__ORIG_KERNEL) { | ||
471 | newtPopHelpLine(); | ||
472 | newtPushHelpLine("No vmlinux file found, can't " | ||
473 | "annotate with just a " | ||
474 | "kallsyms file"); | ||
475 | continue; | ||
476 | } | ||
477 | map_symbol__annotate_browser(selection); | ||
478 | } | ||
474 | } | 479 | } |
475 | 480 | ||
476 | newtFormDestroy(form); | 481 | newtFormDestroy(form); |