From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754700AbdBVKIs (ORCPT ); Wed, 22 Feb 2017 05:08:48 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:33268 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754679AbdBVKIi (ORCPT ); Wed, 22 Feb 2017 05:08:38 -0500 From: Taeung Song To: Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, Jiri Olsa , Namhyung Kim , Ingo Molnar , Peter Zijlstra , Wang Nan , Masami Hiramatsu , Taeung Song , Jiri Olsa Subject: [PATCH 2/4] perf annotate: Align filename:linenr and more correct summary Date: Wed, 22 Feb 2017 19:08:21 +0900 Message-Id: <1487758103-7953-3-git-send-email-treeze.taeung@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487758103-7953-1-git-send-email-treeze.taeung@gmail.com> References: <1487758103-7953-1-git-send-email-treeze.taeung@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the stdio interface, currently 'filename:linenr' infos are confusedly printed in the intervals of assembly code. So fix it. The cause was a 0.5% filter of if statement. After fixed, additionally summary of overhead per srcline is more correct. Before: # perf annotate --stdio -l Sorted summary for file /home/taeung/workspace/perf-test/test ---------------------------------------------- 36.57 test.c:38 28.72 test.c:37 ... Percent | Source code & Disassembly of test ... ... 0.21 : 400816: push %rbp test.c:26 1.86 : 400817: mov %rsp,%rbp 0.21 : 40081a: mov %edi,-0x24(%rbp) 0.21 : 40081d: mov %rsi,-0x30(%rbp) After: # perf annotate --stdio -l Sorted summary for file /home/taeung/workspace/perf-test/test ---------------------------------------------- 37.40 test.c:38 29.34 test.c:37 ... Percent | Source code & Disassembly of test ... ... test.c:26 0.21 : 400816: push %rbp 1.86 : 400817: mov %rsp,%rbp 0.21 : 40081a: mov %edi,-0x24(%rbp) 0.21 : 40081d: mov %rsi,-0x30(%rbp) Cc: Namhyung Kim Cc: Jiri Olsa Signed-off-by: Taeung Song --- tools/perf/util/annotate.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index bc54e41..9d0aa50 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1002,7 +1002,6 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st int max_lines, struct disasm_line *queue) { static const char *prev_line; - static const char *prev_color; if (dl->offset != -1) { const char *path = NULL; @@ -1059,17 +1058,10 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st color = get_percent_color(max_percent); - /* - * Also color the filename and line if needed, with - * the same color than the percentage. Don't print it - * twice for close colored addr with the same filename:line - */ if (path) { - if (!prev_line || strcmp(prev_line, path) - || color != prev_color) { - color_fprintf(stdout, color, " %s", path); + if (!prev_line || strcmp(prev_line, path)) { + fprintf(stdout, " %s\n", path); prev_line = path; - prev_color = color; } } @@ -1650,14 +1642,9 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map, percent_max = src_line->samples[k].percent; } - if (percent_max <= 0.5) - goto next; - offset = start + i; src_line->path = get_srcline(map->dso, offset, NULL, false); insert_source_line(&tmp_root, src_line); - - next: src_line = (void *)src_line + sizeof_src_line; } -- 2.7.4