diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-12-11 18:24:02 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-12 01:42:12 -0500 |
commit | 94c744b6c0c6c5802a85ebfebbec429ac5851f2b (patch) | |
tree | e34dcaca54f1d7752ab1e7974bb73f94ff3cf94c /tools/perf/builtin-trace.c | |
parent | ea08d8cbd162fe3756e3e2298efbe0b8b12f92d1 (diff) |
perf tools: Introduce perf_session class
That does all the initialization boilerplate, opening the file,
reading the header, checking if it is valid, etc.
And that will as well have the threads list, kmap (now) global
variable, etc, so that we can handle two (or more) perf.data files
describing sessions to compare.
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: <1260573842-19720-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 | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index c2fcc34486f5..0756664666f1 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include "util/header.h" | 7 | #include "util/header.h" |
8 | #include "util/exec_cmd.h" | 8 | #include "util/exec_cmd.h" |
9 | #include "util/trace-event.h" | 9 | #include "util/trace-event.h" |
10 | #include "util/session.h" | ||
10 | 11 | ||
11 | static char const *script_name; | 12 | static char const *script_name; |
12 | static char const *generate_script_lang; | 13 | static char const *generate_script_lang; |
@@ -61,7 +62,7 @@ static int cleanup_scripting(void) | |||
61 | 62 | ||
62 | static char const *input_name = "perf.data"; | 63 | static char const *input_name = "perf.data"; |
63 | 64 | ||
64 | static struct perf_header *header; | 65 | static struct perf_session *session; |
65 | static u64 sample_type; | 66 | static u64 sample_type; |
66 | 67 | ||
67 | static int process_sample_event(event_t *event) | 68 | static int process_sample_event(event_t *event) |
@@ -126,11 +127,18 @@ static struct perf_file_handler file_handler = { | |||
126 | 127 | ||
127 | static int __cmd_trace(void) | 128 | static int __cmd_trace(void) |
128 | { | 129 | { |
130 | int err; | ||
131 | |||
132 | session = perf_session__new(input_name, O_RDONLY, 0); | ||
133 | if (session == NULL) | ||
134 | return -ENOMEM; | ||
135 | |||
129 | register_idle_thread(); | 136 | register_idle_thread(); |
130 | register_perf_file_handler(&file_handler); | 137 | register_perf_file_handler(&file_handler); |
131 | 138 | ||
132 | return mmap_dispatch_perf_file(&header, input_name, | 139 | err = perf_session__process_events(session, 0, &event__cwdlen, &event__cwd); |
133 | 0, 0, &event__cwdlen, &event__cwd); | 140 | perf_session__delete(session); |
141 | return err; | ||
134 | } | 142 | } |
135 | 143 | ||
136 | struct script_spec { | 144 | struct script_spec { |
@@ -348,11 +356,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used) | |||
348 | return -1; | 356 | return -1; |
349 | } | 357 | } |
350 | 358 | ||
351 | header = perf_header__new(); | 359 | perf_header__read(&session->header, input); |
352 | if (header == NULL) | ||
353 | return -1; | ||
354 | |||
355 | perf_header__read(header, input); | ||
356 | err = scripting_ops->generate_script("perf-trace"); | 360 | err = scripting_ops->generate_script("perf-trace"); |
357 | goto out; | 361 | goto out; |
358 | } | 362 | } |