Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932889AbdCIRim (ORCPT ); Thu, 9 Mar 2017 12:38:42 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:33205 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932193AbdCIRhc (ORCPT ); Thu, 9 Mar 2017 12:37:32 -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 v3 5/7] perf annotate: Get correct line numbers matched with addr Date: Fri, 10 Mar 2017 02:35:39 +0900 Message-Id: <1489080941-3965-6-git-send-email-treeze.taeung@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489080941-3965-1-git-send-email-treeze.taeung@gmail.com> References: <1489080941-3965-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 Content-Length: 1579 Lines: 64 Currently perf-annotate show wrong line numbers. For example, Actual source code is as below ... 21 }; 22 23 unsigned int limited_wgt; 24 25 unsigned int get_cond_maxprice(int wgt) 26 { ... However, the output of perf-annotate is as below. 4 Disassembly of section .text: 6 0000000000400966 : 7 get_cond_maxprice(): 26 }; 28 unsigned int limited_wgt; 30 unsigned int get_cond_maxprice(int wgt) 31 { So remove the wrong way counting line numbers and match correct line numbers to each addr of asm lines Cc: Namhyung Kim Cc: Jiri Olsa Signed-off-by: Taeung Song --- tools/perf/util/annotate.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index e49eb7e..a50d949 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -823,11 +823,11 @@ static struct disasm_line *disasm_line__new(s64 offset, char *line, if (dl != NULL) { dl->offset = offset; dl->line = strdup(line); - dl->line_nr = line_nr; if (dl->line == NULL) goto out_delete; if (offset != -1) { + dl->line_nr = line_nr; if (disasm_line__parse(dl->line, &dl->ins.name, &dl->ops.raw) < 0) goto out_free_line; @@ -1207,7 +1207,6 @@ static int symbol__parse_objdump_line(struct symbol *sym, struct map *map, dl = disasm_line__new(offset, parsed_line, privsize, *line_nr, arch, map); free(line); - (*line_nr)++; if (dl == NULL) return -1; -- 2.7.4