From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751987AbcBUSb5 (ORCPT ); Sun, 21 Feb 2016 13:31:57 -0500 Received: from mail-pf0-f169.google.com ([209.85.192.169]:34373 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751508AbcBUSbz (ORCPT ); Sun, 21 Feb 2016 13:31:55 -0500 From: Namhyung Kim To: Arnaldo Carvalho de Melo Cc: Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , David Ahern , Andi Kleen Subject: [PATCH 3/5] perf tools: Update srcline/file if needed Date: Sun, 21 Feb 2016 23:22:36 +0900 Message-Id: <1456064558-13086-3-git-send-email-namhyung@kernel.org> X-Mailer: git-send-email 2.7.1 In-Reply-To: <1456064558-13086-1-git-send-email-namhyung@kernel.org> References: <1456064558-13086-1-git-send-email-namhyung@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Normally the hist entry's srcline and/or srcfile is set during sorting. However sometime it's possible to a hist entry's srcline is not set yet after the sorting. This is because the entry is so unique and other sort keys already make it distinct. Then the srcline/file sort didn't have a chance to be called during the sorting. In that case it has NULL srcline/srcfile field and shows nothing. Before: $ perf report -s comm,sym,srcline ... Overhead Command Symbol ----------------------------------------------------------------- 34.42% swapper [k] intel_idle intel_idle.c:0 2.44% perf [.] __poll_nocancel (null) 1.70% gnome-shell [k] fw_domains_get (null) 1.04% Xorg [k] sock_poll (null) After: 34.42% swapper [k] intel_idle intel_idle.c:0 2.44% perf [.] __poll_nocancel .:0 1.70% gnome-shell [k] fw_domains_get fw_domains_get+42 1.04% Xorg [k] sock_poll socket.c:0 Signed-off-by: Namhyung Kim --- tools/perf/util/sort.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 7daea71691df..6808d73164b5 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -315,6 +315,16 @@ sort__srcline_cmp(struct hist_entry *left, struct hist_entry *right) static int hist_entry__srcline_snprintf(struct hist_entry *he, char *bf, size_t size, unsigned int width) { + if (!he->srcline) { + if (!he->ms.map) + he->srcline = SRCLINE_UNKNOWN; + else { + struct map *map = he->ms.map; + he->srcline = get_srcline(map->dso, + map__rip_2objdump(map, he->ip), + he->ms.sym, true); + } + } return repsep_snprintf(bf, size, "%-*.*s", width, width, he->srcline); } @@ -368,6 +378,12 @@ sort__srcfile_cmp(struct hist_entry *left, struct hist_entry *right) static int hist_entry__srcfile_snprintf(struct hist_entry *he, char *bf, size_t size, unsigned int width) { + if (!he->srcfile) { + if (!he->ms.map) + he->srcfile = no_srcfile; + else + he->srcfile = get_srcfile(he); + } return repsep_snprintf(bf, size, "%-*.*s", width, width, he->srcfile); } -- 2.7.1