summary refs log tree commit diff
path: root/tools/perf/util/evsel.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2016-04-14 14:48:07 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-04-14 14:48:07 -0300
commit91d7b2de318ff701451dfc7ede1c029b150ef0e9 (patch)
tree98440b6dfabaf5dc1490bd64f6d5993eea9bf3eb /tools/perf/util/evsel.c
parentbbf86c43eace367e805199f94ad8b5a45636f805 (diff)
downloadlinux-91d7b2de318ff701451dfc7ede1c029b150ef0e9.tar.gz
perf callchain: Start moving away from global per thread cursors
The recent perf_evsel__fprintf_callchain() move to evsel.c added several
new symbol requirements to the python binding, for instance:

  # perf test -v python
  16: Try 'import perf' in python, checking link problems      :
  --- start ---
  test child forked, pid 18030
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
  ImportError: /tmp/build/perf/python/perf.so: undefined symbol:
  callchain_cursor
  test child finished with -1
  ---- end ----
  Try 'import perf' in python, checking link problems: FAILED!
  #

This would require linking against callchain.c to access to the global
callchain_cursor variables.

Since lots of functions already receive as a parameter a
callchain_cursor struct pointer, make that be the case for some more
function so that we can start phasing out usage of yet another global
variable.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-djko3097eyg2rn66v2qcqfvn@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/evsel.c')
-rw-r--r--tools/perf/util/evsel.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 6e86598682be..38f464a4fa04 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -2349,6 +2349,7 @@ int perf_evsel__fprintf_callchain(struct perf_evsel *evsel, struct perf_sample *
 				  FILE *fp)
 {
 	int printed = 0;
+	struct callchain_cursor cursor;
 	struct callchain_cursor_node *node;
 	int print_ip = print_opts & EVSEL__PRINT_IP;
 	int print_sym = print_opts & EVSEL__PRINT_SYM;
@@ -2362,14 +2363,14 @@ int perf_evsel__fprintf_callchain(struct perf_evsel *evsel, struct perf_sample *
 	if (sample->callchain) {
 		struct addr_location node_al;
 
-		if (thread__resolve_callchain(al->thread, evsel,
+		if (thread__resolve_callchain(al->thread, &cursor, evsel,
 					      sample, NULL, NULL,
 					      stack_depth) != 0) {
 			if (verbose)
 				error("Failed to resolve callchain. Skipping\n");
 			return printed;
 		}
-		callchain_cursor_commit(&callchain_cursor);
+		callchain_cursor_commit(&cursor);
 
 		if (print_symoffset)
 			node_al = *al;
@@ -2377,7 +2378,7 @@ int perf_evsel__fprintf_callchain(struct perf_evsel *evsel, struct perf_sample *
 		while (stack_depth) {
 			u64 addr = 0;
 
-			node = callchain_cursor_current(&callchain_cursor);
+			node = callchain_cursor_current(&cursor);
 			if (!node)
 				break;
 
@@ -2420,7 +2421,7 @@ int perf_evsel__fprintf_callchain(struct perf_evsel *evsel, struct perf_sample *
 
 			stack_depth--;
 next:
-			callchain_cursor_advance(&callchain_cursor);
+			callchain_cursor_advance(&cursor);
 		}
 	}