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/util/header.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/util/header.c')
-rw-r--r-- | tools/perf/util/header.c | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 59a9c0b3033e..f2e8d8715111 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -58,35 +58,19 @@ int perf_header_attr__add_id(struct perf_header_attr *self, u64 id) | |||
58 | return 0; | 58 | return 0; |
59 | } | 59 | } |
60 | 60 | ||
61 | /* | 61 | int perf_header__init(struct perf_header *self) |
62 | * Create new perf.data header: | ||
63 | */ | ||
64 | struct perf_header *perf_header__new(void) | ||
65 | { | 62 | { |
66 | struct perf_header *self = zalloc(sizeof(*self)); | 63 | self->size = 1; |
67 | 64 | self->attr = malloc(sizeof(void *)); | |
68 | if (self != NULL) { | 65 | return self->attr == NULL ? -ENOMEM : 0; |
69 | self->size = 1; | ||
70 | self->attr = malloc(sizeof(void *)); | ||
71 | |||
72 | if (self->attr == NULL) { | ||
73 | free(self); | ||
74 | self = NULL; | ||
75 | } | ||
76 | } | ||
77 | |||
78 | return self; | ||
79 | } | 66 | } |
80 | 67 | ||
81 | void perf_header__delete(struct perf_header *self) | 68 | void perf_header__exit(struct perf_header *self) |
82 | { | 69 | { |
83 | int i; | 70 | int i; |
84 | |||
85 | for (i = 0; i < self->attrs; ++i) | 71 | for (i = 0; i < self->attrs; ++i) |
86 | perf_header_attr__delete(self->attr[i]); | 72 | perf_header_attr__delete(self->attr[i]); |
87 | |||
88 | free(self->attr); | 73 | free(self->attr); |
89 | free(self); | ||
90 | } | 74 | } |
91 | 75 | ||
92 | int perf_header__add_attr(struct perf_header *self, | 76 | int perf_header__add_attr(struct perf_header *self, |