Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1338943

[PATCH 3/5] perf tools: Update srcline/file if needed

From Namhyung Kim <namhyung@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 3/5] perf tools: Update srcline/file if needed
Date 2016-02-21 19:40 +0100
Message-ID <r4G9d-XY-15@gated-at.bofh.it> (permalink)
References <r4FZw-Tg-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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 <namhyung@kernel.org>
---
 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

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 1/5] perf tools: Fix assertion failure on dynamic entry Namhyung Kim <namhyung@kernel.org> - 2016-02-21 18:30 +0100
  Re: [PATCH 1/5] perf tools: Fix assertion failure on dynamic entry Jiri Olsa <jolsa@redhat.com> - 2016-02-21 18:40 +0100
    Re: [PATCH 1/5] perf tools: Fix assertion failure on dynamic entry Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-02-22 16:10 +0100
  Re: [PATCH 3/5] perf tools: Update srcline/file if needed Jiri Olsa <jolsa@redhat.com> - 2016-02-21 18:40 +0100
    [PATCH v2 3/5] perf tools: Update srcline/file if needed Namhyung Kim <namhyung@kernel.org> - 2016-02-22 01:40 +0100
      Re: [PATCH v2 3/5] perf tools: Update srcline/file if needed Jiri Olsa <jolsa@redhat.com> - 2016-02-22 07:50 +0100
  Re: [PATCH 2/5] perf tools: Fix segfault on dynamic entries Jiri Olsa <jolsa@redhat.com> - 2016-02-21 18:40 +0100
  Re: [PATCH 5/5] perf tools: Fix column width setting on 'trace' sort  key Jiri Olsa <jolsa@redhat.com> - 2016-02-21 18:50 +0100
  Re: [PATCH 4/5] perf tools: Fix alignment on some sort keys Jiri Olsa <jolsa@redhat.com> - 2016-02-21 18:50 +0100
    [PATCH v2 4/5] perf tools: Fix alignment on some sort keys Namhyung Kim <namhyung@kernel.org> - 2016-02-22 01:40 +0100
  [PATCH 2/5] perf tools: Fix segfault on dynamic entries Namhyung Kim <namhyung@kernel.org> - 2016-02-21 19:30 +0100
  [PATCH 4/5] perf tools: Fix alignment on some sort keys Namhyung Kim <namhyung@kernel.org> - 2016-02-21 19:30 +0100
  [PATCH 5/5] perf tools: Fix column width setting on 'trace' sort key Namhyung Kim <namhyung@kernel.org> - 2016-02-21 19:30 +0100
  [PATCH 3/5] perf tools: Update srcline/file if needed Namhyung Kim <namhyung@kernel.org> - 2016-02-21 19:40 +0100

csiph-web