diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-12-13 16:50:24 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-14 10:57:13 -0500 |
commit | d8f66248d6f25f7c935cc5307c43bf394db07272 (patch) | |
tree | f30b5512dd08e6a8713fa9fde158c75d57ce1d6b /tools/perf/builtin-trace.c | |
parent | 2cd9046cc53dd2625e2cf5854d6cbb1ba61de914 (diff) |
perf session: Pass the perf_session to the event handling operations
They will need it to get the right threads list, etc.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1260741029-4430-1-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-trace.c')
-rw-r--r-- | tools/perf/builtin-trace.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 0756664666f1..3057e1d387b9 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -62,10 +62,9 @@ static int cleanup_scripting(void) | |||
62 | 62 | ||
63 | static char const *input_name = "perf.data"; | 63 | static char const *input_name = "perf.data"; |
64 | 64 | ||
65 | static struct perf_session *session; | ||
66 | static u64 sample_type; | 65 | static u64 sample_type; |
67 | 66 | ||
68 | static int process_sample_event(event_t *event) | 67 | static int process_sample_event(event_t *event, struct perf_session *session __used) |
69 | { | 68 | { |
70 | struct sample_data data; | 69 | struct sample_data data; |
71 | struct thread *thread; | 70 | struct thread *thread; |
@@ -125,20 +124,12 @@ static struct perf_file_handler file_handler = { | |||
125 | .sample_type_check = sample_type_check, | 124 | .sample_type_check = sample_type_check, |
126 | }; | 125 | }; |
127 | 126 | ||
128 | static int __cmd_trace(void) | 127 | static int __cmd_trace(struct perf_session *session) |
129 | { | 128 | { |
130 | int err; | ||
131 | |||
132 | session = perf_session__new(input_name, O_RDONLY, 0); | ||
133 | if (session == NULL) | ||
134 | return -ENOMEM; | ||
135 | |||
136 | register_idle_thread(); | 129 | register_idle_thread(); |
137 | register_perf_file_handler(&file_handler); | 130 | register_perf_file_handler(&file_handler); |
138 | 131 | ||
139 | err = perf_session__process_events(session, 0, &event__cwdlen, &event__cwd); | 132 | return perf_session__process_events(session, 0, &event__cwdlen, &event__cwd); |
140 | perf_session__delete(session); | ||
141 | return err; | ||
142 | } | 133 | } |
143 | 134 | ||
144 | struct script_spec { | 135 | struct script_spec { |
@@ -313,6 +304,7 @@ static const struct option options[] = { | |||
313 | int cmd_trace(int argc, const char **argv, const char *prefix __used) | 304 | int cmd_trace(int argc, const char **argv, const char *prefix __used) |
314 | { | 305 | { |
315 | int err; | 306 | int err; |
307 | struct perf_session *session; | ||
316 | 308 | ||
317 | symbol__init(0); | 309 | symbol__init(0); |
318 | 310 | ||
@@ -330,6 +322,10 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used) | |||
330 | 322 | ||
331 | setup_pager(); | 323 | setup_pager(); |
332 | 324 | ||
325 | session = perf_session__new(input_name, O_RDONLY, 0); | ||
326 | if (session == NULL) | ||
327 | return -ENOMEM; | ||
328 | |||
333 | if (generate_script_lang) { | 329 | if (generate_script_lang) { |
334 | struct stat perf_stat; | 330 | struct stat perf_stat; |
335 | 331 | ||
@@ -367,8 +363,9 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used) | |||
367 | goto out; | 363 | goto out; |
368 | } | 364 | } |
369 | 365 | ||
370 | err = __cmd_trace(); | 366 | err = __cmd_trace(session); |
371 | 367 | ||
368 | perf_session__delete(session); | ||
372 | cleanup_scripting(); | 369 | cleanup_scripting(); |
373 | out: | 370 | out: |
374 | return err; | 371 | return err; |