* [PATCH 1/3] perf annotate: Parse --asm-raw output properly @ 2012-11-09 1:10 Namhyung Kim 2012-11-09 1:10 ` [PATCH 2/3] perf annotate: Merge same lines in summary view Namhyung Kim 2012-11-09 1:10 ` [PATCH 3/3] perf annotate: Don't try to follow jump target on PLT symbols Namhyung Kim 0 siblings, 2 replies; 6+ messages in thread From: Namhyung Kim @ 2012-11-09 1:10 UTC (permalink / raw) To: Arnaldo Carvalho de Melo Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, LKML, Namhyung Kim From: Namhyung Kim <namhyung.kim@lge.com> If --asm-raw option was given, objdump output will contain hex numbers of the instruction before the symbolic name. However current parser code doesn't handle it properly. Fix it. Signed-off-by: Namhyung Kim <namhyung@kernel.org> --- tools/perf/ui/browsers/annotate.c | 2 ++ tools/perf/util/annotate.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 3eff17f703f3..aec11f34d394 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -117,6 +117,8 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int ab->addr_width, " "); slsmg_write_nstring(bf, printed); slsmg_write_nstring(dl->line, width - printed - 6); + } else if (!dl->name) { + slsmg_write_nstring(" ", width - 7); } else { u64 addr = dl->offset; int color = -1; diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index b14d4df9f149..83b1078260e3 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -492,6 +492,9 @@ int symbol__inc_addr_samples(struct symbol *sym, struct map *map, static void disasm_line__init_ins(struct disasm_line *dl) { + if (dl->name == NULL) + return; + dl->ins = ins__find(dl->name); if (dl->ins == NULL) @@ -514,6 +517,32 @@ static int disasm_line__parse(char *line, char **namep, char **rawp) if (name[0] == '\0') return -1; + if (symbol_conf.annotate_asm_raw) { + /* + * If --asm-raw option was given, objdump output will contain + * hex numbers of the instructions before the symbolic name. + * They are separated by at least two space characters: + * + * 400540: 48 c7 45 f8 00 00 00 movq $0x0,-0x8(%rbp) + * 400547: 00 + * + * It sometimes was broken to multiple lines due to a limited + * width. In this case following condition will be met: + * + * dl->offset != -1 && dl->name == NULL. + */ + name = strstr(name, " "); + if (name == NULL) + return 0; + + while (isspace(name[0])) + ++name; + + if (name[0] == '\0') + return -1; + + } + *rawp = name + 1; while ((*rawp)[0] != '\0' && !isspace((*rawp)[0])) -- 1.7.11.7 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/3] perf annotate: Merge same lines in summary view 2012-11-09 1:10 [PATCH 1/3] perf annotate: Parse --asm-raw output properly Namhyung Kim @ 2012-11-09 1:10 ` Namhyung Kim 2012-11-09 5:47 ` [PATCH v2 " Namhyung Kim 2012-11-09 1:10 ` [PATCH 3/3] perf annotate: Don't try to follow jump target on PLT symbols Namhyung Kim 1 sibling, 1 reply; 6+ messages in thread From: Namhyung Kim @ 2012-11-09 1:10 UTC (permalink / raw) To: Arnaldo Carvalho de Melo Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, LKML, Namhyung Kim From: Namhyung Kim <namhyung.kim@lge.com> The --print-line option of perf annotate command shows summary for each source line. But it didn't merge same lines so that it can appear multiple times. * before: Sorted summary for file /home/namhyung/bin/mcol ---------------------------------------------- 24.40 /home/namhyung/tmp/mcol.c:26 21.58 /home/namhyung/tmp/mcol.c:25 10.14 /home/namhyung/tmp/mcol.c:24 8.59 /home/namhyung/tmp/mcol.c:25 8.57 /home/namhyung/tmp/mcol.c:25 8.42 /home/namhyung/tmp/mcol.c:26 8.31 /home/namhyung/tmp/mcol.c:26 8.30 /home/namhyung/tmp/mcol.c:25 0.80 /home/namhyung/tmp/mcol.c:26 * after: Sorted summary for file /home/namhyung/bin/mcol ---------------------------------------------- 41.93 /home/namhyung/tmp/mcol.c:26 10.14 /home/namhyung/tmp/mcol.c:24 47.04 /home/namhyung/tmp/mcol.c:25 To do that, introduce percent_sum field so that the normal line-by-line output doesn't get changed. Signed-off-by: Namhyung Kim <namhyung@kernel.org> --- tools/perf/util/annotate.c | 53 ++++++++++++++++++++++++++++++++++++++++++++-- tools/perf/util/annotate.h | 1 + 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 83b1078260e3..d604a90c60ef 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -887,6 +887,35 @@ static void insert_source_line(struct rb_root *root, struct source_line *src_lin struct source_line *iter; struct rb_node **p = &root->rb_node; struct rb_node *parent = NULL; + int ret; + + while (*p != NULL) { + parent = *p; + iter = rb_entry(parent, struct source_line, node); + + ret = strcmp(iter->path, src_line->path); + if (ret == 0) { + iter->percent_sum += src_line->percent; + return; + } + + if (ret < 0) + p = &(*p)->rb_left; + else + p = &(*p)->rb_right; + } + + src_line->percent_sum = src_line->percent; + + rb_link_node(&src_line->node, parent, p); + rb_insert_color(&src_line->node, root); +} + +static void __resort_source_line(struct rb_root *root, struct source_line *src_line) +{ + struct source_line *iter; + struct rb_node **p = &root->rb_node; + struct rb_node *parent = NULL; while (*p != NULL) { parent = *p; @@ -902,6 +931,24 @@ static void insert_source_line(struct rb_root *root, struct source_line *src_lin rb_insert_color(&src_line->node, root); } +static void resort_source_line(struct rb_root *dest_root, struct rb_root *src_root) +{ + struct source_line *src_line; + struct rb_node *node; + + node = rb_first(src_root); + while (node) { + struct rb_node *next; + + src_line = rb_entry(node, struct source_line, node); + next = rb_next(node); + rb_erase(node, src_root); + + __resort_source_line(dest_root, src_line); + node = next; + } +} + static void symbol__free_source_line(struct symbol *sym, int len) { struct annotation *notes = symbol__annotation(sym); @@ -926,6 +973,7 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map, struct source_line *src_line; struct annotation *notes = symbol__annotation(sym); struct sym_hist *h = annotation__histogram(notes, evidx); + struct rb_root tmp_root = RB_ROOT; if (!h->sum) return 0; @@ -960,12 +1008,13 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map, goto next; strcpy(src_line[i].path, path); - insert_source_line(root, &src_line[i]); + insert_source_line(&tmp_root, &src_line[i]); next: pclose(fp); } + resort_source_line(root, &tmp_root); return 0; } @@ -989,7 +1038,7 @@ static void print_summary(struct rb_root *root, const char *filename) char *path; src_line = rb_entry(node, struct source_line, node); - percent = src_line->percent; + percent = src_line->percent_sum; color = get_percent_color(percent); path = src_line->path; diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index c6272011625a..8eec94358a4a 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -76,6 +76,7 @@ struct sym_hist { struct source_line { struct rb_node node; double percent; + double percent_sum; char *path; }; -- 1.7.11.7 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 2/3] perf annotate: Merge same lines in summary view 2012-11-09 1:10 ` [PATCH 2/3] perf annotate: Merge same lines in summary view Namhyung Kim @ 2012-11-09 5:47 ` Namhyung Kim 2012-11-09 5:58 ` [PATCH v3 " Namhyung Kim 0 siblings, 1 reply; 6+ messages in thread From: Namhyung Kim @ 2012-11-09 5:47 UTC (permalink / raw) To: Arnaldo Carvalho de Melo Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, LKML, Namhyung Kim From: Namhyung Kim <namhyung.kim@lge.com> The --print-line option of perf annotate command shows summary for each source line. But it didn't merge same lines so that it can appear multiple times. * before: Sorted summary for file /home/namhyung/bin/mcol ---------------------------------------------- 24.40 /home/namhyung/tmp/mcol.c:26 21.58 /home/namhyung/tmp/mcol.c:25 10.14 /home/namhyung/tmp/mcol.c:24 8.59 /home/namhyung/tmp/mcol.c:25 8.57 /home/namhyung/tmp/mcol.c:25 8.42 /home/namhyung/tmp/mcol.c:26 8.31 /home/namhyung/tmp/mcol.c:26 8.30 /home/namhyung/tmp/mcol.c:25 0.80 /home/namhyung/tmp/mcol.c:26 * after: Sorted summary for file /home/namhyung/bin/mcol ---------------------------------------------- 41.93 /home/namhyung/tmp/mcol.c:26 10.14 /home/namhyung/tmp/mcol.c:24 47.04 /home/namhyung/tmp/mcol.c:25 To do that, introduce percent_sum field so that the normal line-by-line output doesn't get changed. Signed-off-by: Namhyung Kim <namhyung@kernel.org> --- * v2: ->percent_sum should be used when resorting. tools/perf/util/annotate.c | 55 +++++++++++++++++++++++++++++++++++++++++++--- tools/perf/util/annotate.h | 1 + 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 83b1078260e3..180113b891a3 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -887,12 +887,41 @@ static void insert_source_line(struct rb_root *root, struct source_line *src_lin struct source_line *iter; struct rb_node **p = &root->rb_node; struct rb_node *parent = NULL; + int ret; while (*p != NULL) { parent = *p; iter = rb_entry(parent, struct source_line, node); - if (src_line->percent > iter->percent) + ret = strcmp(iter->path, src_line->path); + if (ret == 0) { + iter->percent_sum += src_line->percent; + return; + } + + if (ret < 0) + p = &(*p)->rb_left; + else + p = &(*p)->rb_right; + } + + src_line->percent_sum = src_line->percent; + + rb_link_node(&src_line->node, parent, p); + rb_insert_color(&src_line->node, root); +} + +static void __resort_source_line(struct rb_root *root, struct source_line *src_line) +{ + struct source_line *iter; + struct rb_node **p = &root->rb_node; + struct rb_node *parent = NULL; + + while (*p != NULL) { + parent = *p; + iter = rb_entry(parent, struct source_line, node); + + if (src_line->percent_sum > iter->percent_sum) p = &(*p)->rb_left; else p = &(*p)->rb_right; @@ -902,6 +931,24 @@ static void insert_source_line(struct rb_root *root, struct source_line *src_lin rb_insert_color(&src_line->node, root); } +static void resort_source_line(struct rb_root *dest_root, struct rb_root *src_root) +{ + struct source_line *src_line; + struct rb_node *node; + + node = rb_first(src_root); + while (node) { + struct rb_node *next; + + src_line = rb_entry(node, struct source_line, node); + next = rb_next(node); + rb_erase(node, src_root); + + __resort_source_line(dest_root, src_line); + node = next; + } +} + static void symbol__free_source_line(struct symbol *sym, int len) { struct annotation *notes = symbol__annotation(sym); @@ -926,6 +973,7 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map, struct source_line *src_line; struct annotation *notes = symbol__annotation(sym); struct sym_hist *h = annotation__histogram(notes, evidx); + struct rb_root tmp_root = RB_ROOT; if (!h->sum) return 0; @@ -960,12 +1008,13 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map, goto next; strcpy(src_line[i].path, path); - insert_source_line(root, &src_line[i]); + insert_source_line(&tmp_root, &src_line[i]); next: pclose(fp); } + resort_source_line(root, &tmp_root); return 0; } @@ -989,7 +1038,7 @@ static void print_summary(struct rb_root *root, const char *filename) char *path; src_line = rb_entry(node, struct source_line, node); - percent = src_line->percent; + percent = src_line->percent_sum; color = get_percent_color(percent); path = src_line->path; diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index c6272011625a..8eec94358a4a 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -76,6 +76,7 @@ struct sym_hist { struct source_line { struct rb_node node; double percent; + double percent_sum; char *path; }; -- 1.7.11.7 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 2/3] perf annotate: Merge same lines in summary view 2012-11-09 5:47 ` [PATCH v2 " Namhyung Kim @ 2012-11-09 5:58 ` Namhyung Kim 2012-11-14 7:44 ` [tip:perf/core] " tip-bot for Namhyung Kim 0 siblings, 1 reply; 6+ messages in thread From: Namhyung Kim @ 2012-11-09 5:58 UTC (permalink / raw) To: Arnaldo Carvalho de Melo Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, LKML, Namhyung Kim From: Namhyung Kim <namhyung.kim@lge.com> The --print-line option of perf annotate command shows summary for each source line. But it didn't merge same lines so that it can appear multiple times. * before: Sorted summary for file /home/namhyung/bin/mcol ---------------------------------------------- 21.71 /home/namhyung/tmp/mcol.c:26 20.66 /home/namhyung/tmp/mcol.c:25 9.53 /home/namhyung/tmp/mcol.c:24 7.68 /home/namhyung/tmp/mcol.c:25 7.67 /home/namhyung/tmp/mcol.c:25 7.66 /home/namhyung/tmp/mcol.c:26 7.49 /home/namhyung/tmp/mcol.c:26 6.92 /home/namhyung/tmp/mcol.c:25 6.81 /home/namhyung/tmp/mcol.c:25 1.07 /home/namhyung/tmp/mcol.c:26 0.52 /home/namhyung/tmp/mcol.c:25 0.51 /home/namhyung/tmp/mcol.c:25 0.51 /home/namhyung/tmp/mcol.c:24 * after: Sorted summary for file /home/namhyung/bin/mcol ---------------------------------------------- 50.77 /home/namhyung/tmp/mcol.c:25 37.94 /home/namhyung/tmp/mcol.c:26 10.04 /home/namhyung/tmp/mcol.c:24 To do that, introduce percent_sum field so that the normal line-by-line output doesn't get changed. Signed-off-by: Namhyung Kim <namhyung@kernel.org> --- * v3: Renew output in changelog * v2: ->percent_sum should be used when resorting. tools/perf/util/annotate.c | 55 +++++++++++++++++++++++++++++++++++++++++++--- tools/perf/util/annotate.h | 1 + 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 83b1078260e3..180113b891a3 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -887,12 +887,41 @@ static void insert_source_line(struct rb_root *root, struct source_line *src_lin struct source_line *iter; struct rb_node **p = &root->rb_node; struct rb_node *parent = NULL; + int ret; while (*p != NULL) { parent = *p; iter = rb_entry(parent, struct source_line, node); - if (src_line->percent > iter->percent) + ret = strcmp(iter->path, src_line->path); + if (ret == 0) { + iter->percent_sum += src_line->percent; + return; + } + + if (ret < 0) + p = &(*p)->rb_left; + else + p = &(*p)->rb_right; + } + + src_line->percent_sum = src_line->percent; + + rb_link_node(&src_line->node, parent, p); + rb_insert_color(&src_line->node, root); +} + +static void __resort_source_line(struct rb_root *root, struct source_line *src_line) +{ + struct source_line *iter; + struct rb_node **p = &root->rb_node; + struct rb_node *parent = NULL; + + while (*p != NULL) { + parent = *p; + iter = rb_entry(parent, struct source_line, node); + + if (src_line->percent_sum > iter->percent_sum) p = &(*p)->rb_left; else p = &(*p)->rb_right; @@ -902,6 +931,24 @@ static void insert_source_line(struct rb_root *root, struct source_line *src_lin rb_insert_color(&src_line->node, root); } +static void resort_source_line(struct rb_root *dest_root, struct rb_root *src_root) +{ + struct source_line *src_line; + struct rb_node *node; + + node = rb_first(src_root); + while (node) { + struct rb_node *next; + + src_line = rb_entry(node, struct source_line, node); + next = rb_next(node); + rb_erase(node, src_root); + + __resort_source_line(dest_root, src_line); + node = next; + } +} + static void symbol__free_source_line(struct symbol *sym, int len) { struct annotation *notes = symbol__annotation(sym); @@ -926,6 +973,7 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map, struct source_line *src_line; struct annotation *notes = symbol__annotation(sym); struct sym_hist *h = annotation__histogram(notes, evidx); + struct rb_root tmp_root = RB_ROOT; if (!h->sum) return 0; @@ -960,12 +1008,13 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map, goto next; strcpy(src_line[i].path, path); - insert_source_line(root, &src_line[i]); + insert_source_line(&tmp_root, &src_line[i]); next: pclose(fp); } + resort_source_line(root, &tmp_root); return 0; } @@ -989,7 +1038,7 @@ static void print_summary(struct rb_root *root, const char *filename) char *path; src_line = rb_entry(node, struct source_line, node); - percent = src_line->percent; + percent = src_line->percent_sum; color = get_percent_color(percent); path = src_line->path; diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index c6272011625a..8eec94358a4a 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -76,6 +76,7 @@ struct sym_hist { struct source_line { struct rb_node node; double percent; + double percent_sum; char *path; }; -- 1.7.11.7 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [tip:perf/core] perf annotate: Merge same lines in summary view 2012-11-09 5:58 ` [PATCH v3 " Namhyung Kim @ 2012-11-14 7:44 ` tip-bot for Namhyung Kim 0 siblings, 0 replies; 6+ messages in thread From: tip-bot for Namhyung Kim @ 2012-11-14 7:44 UTC (permalink / raw) To: linux-tip-commits Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra, namhyung.kim, namhyung, tglx Commit-ID: 411279658adf6a4f5bb25ec032a39ae905bcf234 Gitweb: http://git.kernel.org/tip/411279658adf6a4f5bb25ec032a39ae905bcf234 Author: Namhyung Kim <namhyung.kim@lge.com> AuthorDate: Fri, 9 Nov 2012 14:58:49 +0900 Committer: Arnaldo Carvalho de Melo <acme@redhat.com> CommitDate: Fri, 9 Nov 2012 16:50:18 -0300 perf annotate: Merge same lines in summary view The --print-line option of perf annotate command shows summary for each source line. But it didn't merge same lines so that it can appear multiple times. * before: Sorted summary for file /home/namhyung/bin/mcol ---------------------------------------------- 21.71 /home/namhyung/tmp/mcol.c:26 20.66 /home/namhyung/tmp/mcol.c:25 9.53 /home/namhyung/tmp/mcol.c:24 7.68 /home/namhyung/tmp/mcol.c:25 7.67 /home/namhyung/tmp/mcol.c:25 7.66 /home/namhyung/tmp/mcol.c:26 7.49 /home/namhyung/tmp/mcol.c:26 6.92 /home/namhyung/tmp/mcol.c:25 6.81 /home/namhyung/tmp/mcol.c:25 1.07 /home/namhyung/tmp/mcol.c:26 0.52 /home/namhyung/tmp/mcol.c:25 0.51 /home/namhyung/tmp/mcol.c:25 0.51 /home/namhyung/tmp/mcol.c:24 * after: Sorted summary for file /home/namhyung/bin/mcol ---------------------------------------------- 50.77 /home/namhyung/tmp/mcol.c:25 37.94 /home/namhyung/tmp/mcol.c:26 10.04 /home/namhyung/tmp/mcol.c:24 To do that, introduce percent_sum field so that the normal line-by-line output doesn't get changed. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1352440729-21848-1-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> --- tools/perf/util/annotate.c | 55 +++++++++++++++++++++++++++++++++++++++++-- tools/perf/util/annotate.h | 1 + 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 435bf6d..07aaeea 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -858,12 +858,41 @@ static void insert_source_line(struct rb_root *root, struct source_line *src_lin struct source_line *iter; struct rb_node **p = &root->rb_node; struct rb_node *parent = NULL; + int ret; while (*p != NULL) { parent = *p; iter = rb_entry(parent, struct source_line, node); - if (src_line->percent > iter->percent) + ret = strcmp(iter->path, src_line->path); + if (ret == 0) { + iter->percent_sum += src_line->percent; + return; + } + + if (ret < 0) + p = &(*p)->rb_left; + else + p = &(*p)->rb_right; + } + + src_line->percent_sum = src_line->percent; + + rb_link_node(&src_line->node, parent, p); + rb_insert_color(&src_line->node, root); +} + +static void __resort_source_line(struct rb_root *root, struct source_line *src_line) +{ + struct source_line *iter; + struct rb_node **p = &root->rb_node; + struct rb_node *parent = NULL; + + while (*p != NULL) { + parent = *p; + iter = rb_entry(parent, struct source_line, node); + + if (src_line->percent_sum > iter->percent_sum) p = &(*p)->rb_left; else p = &(*p)->rb_right; @@ -873,6 +902,24 @@ static void insert_source_line(struct rb_root *root, struct source_line *src_lin rb_insert_color(&src_line->node, root); } +static void resort_source_line(struct rb_root *dest_root, struct rb_root *src_root) +{ + struct source_line *src_line; + struct rb_node *node; + + node = rb_first(src_root); + while (node) { + struct rb_node *next; + + src_line = rb_entry(node, struct source_line, node); + next = rb_next(node); + rb_erase(node, src_root); + + __resort_source_line(dest_root, src_line); + node = next; + } +} + static void symbol__free_source_line(struct symbol *sym, int len) { struct annotation *notes = symbol__annotation(sym); @@ -897,6 +944,7 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map, struct source_line *src_line; struct annotation *notes = symbol__annotation(sym); struct sym_hist *h = annotation__histogram(notes, evidx); + struct rb_root tmp_root = RB_ROOT; if (!h->sum) return 0; @@ -931,12 +979,13 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map, goto next; strcpy(src_line[i].path, path); - insert_source_line(root, &src_line[i]); + insert_source_line(&tmp_root, &src_line[i]); next: pclose(fp); } + resort_source_line(root, &tmp_root); return 0; } @@ -960,7 +1009,7 @@ static void print_summary(struct rb_root *root, const char *filename) char *path; src_line = rb_entry(node, struct source_line, node); - percent = src_line->percent; + percent = src_line->percent_sum; color = get_percent_color(percent); path = src_line->path; diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index c627201..8eec943 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -76,6 +76,7 @@ struct sym_hist { struct source_line { struct rb_node node; double percent; + double percent_sum; char *path; }; ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/3] perf annotate: Don't try to follow jump target on PLT symbols 2012-11-09 1:10 [PATCH 1/3] perf annotate: Parse --asm-raw output properly Namhyung Kim 2012-11-09 1:10 ` [PATCH 2/3] perf annotate: Merge same lines in summary view Namhyung Kim @ 2012-11-09 1:10 ` Namhyung Kim 1 sibling, 0 replies; 6+ messages in thread From: Namhyung Kim @ 2012-11-09 1:10 UTC (permalink / raw) To: Arnaldo Carvalho de Melo Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, LKML, Namhyung Kim From: Namhyung Kim <namhyung.kim@lge.com> The perf annotate browser on TUI can identify a jump target for a selected instruction. It assumes that the jump target is within the function but it's not the case of PLT symbols which have offset out of the function as a target. Since it caused a segmentation fault, do not try to follow jump target on the PLT symbols. Signed-off-by: Namhyung Kim <namhyung@kernel.org> --- tools/perf/ui/browsers/annotate.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index aec11f34d394..bb393dd26ba2 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -190,6 +190,12 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser) struct disasm_line *cursor = ab->selection, *target; struct browser_disasm_line *btarget, *bcursor; unsigned int from, to; + struct map_symbol *ms = ab->b.priv; + struct symbol *sym = ms->sym; + + /* PLT symbols contain external offsets */ + if (strstr(sym->name, "@plt")) + return; if (!cursor || !cursor->ins || !ins__is_jump(cursor->ins) || !disasm_line__has_offset(cursor)) @@ -773,6 +779,12 @@ static void annotate_browser__mark_jump_targets(struct annotate_browser *browser size_t size) { u64 offset; + struct map_symbol *ms = browser->b.priv; + struct symbol *sym = ms->sym; + + /* PLT symbols contain external offsets */ + if (strstr(sym->name, "@plt")) + return; for (offset = 0; offset < size; ++offset) { struct disasm_line *dl = browser->offsets[offset], *dlt; -- 1.7.11.7 ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-11-14 8:45 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-11-09 1:10 [PATCH 1/3] perf annotate: Parse --asm-raw output properly Namhyung Kim 2012-11-09 1:10 ` [PATCH 2/3] perf annotate: Merge same lines in summary view Namhyung Kim 2012-11-09 5:47 ` [PATCH v2 " Namhyung Kim 2012-11-09 5:58 ` [PATCH v3 " Namhyung Kim 2012-11-14 7:44 ` [tip:perf/core] " tip-bot for Namhyung Kim 2012-11-09 1:10 ` [PATCH 3/3] perf annotate: Don't try to follow jump target on PLT symbols Namhyung Kim
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
Powered by JetHome