diff options
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 | } |