diff options
Diffstat (limited to 'tools/perf/builtin-record.c')
-rw-r--r-- | tools/perf/builtin-record.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 0e519c667e3a..4decbd14eaed 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include "util/header.h" | 17 | #include "util/header.h" |
18 | #include "util/event.h" | 18 | #include "util/event.h" |
19 | #include "util/debug.h" | 19 | #include "util/debug.h" |
20 | #include "util/session.h" | ||
20 | #include "util/symbol.h" | 21 | #include "util/symbol.h" |
21 | 22 | ||
22 | #include <unistd.h> | 23 | #include <unistd.h> |
@@ -62,7 +63,7 @@ static int nr_cpu = 0; | |||
62 | 63 | ||
63 | static int file_new = 1; | 64 | static int file_new = 1; |
64 | 65 | ||
65 | struct perf_header *header = NULL; | 66 | static struct perf_session *session; |
66 | 67 | ||
67 | struct mmap_data { | 68 | struct mmap_data { |
68 | int counter; | 69 | int counter; |
@@ -216,12 +217,12 @@ static struct perf_header_attr *get_header_attr(struct perf_event_attr *a, int n | |||
216 | { | 217 | { |
217 | struct perf_header_attr *h_attr; | 218 | struct perf_header_attr *h_attr; |
218 | 219 | ||
219 | if (nr < header->attrs) { | 220 | if (nr < session->header.attrs) { |
220 | h_attr = header->attr[nr]; | 221 | h_attr = session->header.attr[nr]; |
221 | } else { | 222 | } else { |
222 | h_attr = perf_header_attr__new(a); | 223 | h_attr = perf_header_attr__new(a); |
223 | if (h_attr != NULL) | 224 | if (h_attr != NULL) |
224 | if (perf_header__add_attr(header, h_attr) < 0) { | 225 | if (perf_header__add_attr(&session->header, h_attr) < 0) { |
225 | perf_header_attr__delete(h_attr); | 226 | perf_header_attr__delete(h_attr); |
226 | h_attr = NULL; | 227 | h_attr = NULL; |
227 | } | 228 | } |
@@ -395,9 +396,9 @@ static void open_counters(int cpu, pid_t pid) | |||
395 | 396 | ||
396 | static void atexit_header(void) | 397 | static void atexit_header(void) |
397 | { | 398 | { |
398 | header->data_size += bytes_written; | 399 | session->header.data_size += bytes_written; |
399 | 400 | ||
400 | perf_header__write(header, output, true); | 401 | perf_header__write(&session->header, output, true); |
401 | } | 402 | } |
402 | 403 | ||
403 | static int __cmd_record(int argc, const char **argv) | 404 | static int __cmd_record(int argc, const char **argv) |
@@ -440,24 +441,24 @@ static int __cmd_record(int argc, const char **argv) | |||
440 | exit(-1); | 441 | exit(-1); |
441 | } | 442 | } |
442 | 443 | ||
443 | header = perf_header__new(); | 444 | session = perf_session__new(output_name, O_WRONLY, force); |
444 | if (header == NULL) { | 445 | if (session == NULL) { |
445 | pr_err("Not enough memory for reading perf file header\n"); | 446 | pr_err("Not enough memory for reading perf file header\n"); |
446 | return -1; | 447 | return -1; |
447 | } | 448 | } |
448 | 449 | ||
449 | if (!file_new) { | 450 | if (!file_new) { |
450 | err = perf_header__read(header, output); | 451 | err = perf_header__read(&session->header, output); |
451 | if (err < 0) | 452 | if (err < 0) |
452 | return err; | 453 | return err; |
453 | } | 454 | } |
454 | 455 | ||
455 | if (raw_samples) { | 456 | if (raw_samples) { |
456 | perf_header__set_feat(header, HEADER_TRACE_INFO); | 457 | perf_header__set_feat(&session->header, HEADER_TRACE_INFO); |
457 | } else { | 458 | } else { |
458 | for (i = 0; i < nr_counters; i++) { | 459 | for (i = 0; i < nr_counters; i++) { |
459 | if (attrs[i].sample_type & PERF_SAMPLE_RAW) { | 460 | if (attrs[i].sample_type & PERF_SAMPLE_RAW) { |
460 | perf_header__set_feat(header, HEADER_TRACE_INFO); | 461 | perf_header__set_feat(&session->header, HEADER_TRACE_INFO); |
461 | break; | 462 | break; |
462 | } | 463 | } |
463 | } | 464 | } |
@@ -481,7 +482,7 @@ static int __cmd_record(int argc, const char **argv) | |||
481 | } | 482 | } |
482 | 483 | ||
483 | if (file_new) { | 484 | if (file_new) { |
484 | err = perf_header__write(header, output, false); | 485 | err = perf_header__write(&session->header, output, false); |
485 | if (err < 0) | 486 | if (err < 0) |
486 | return err; | 487 | return err; |
487 | } | 488 | } |