perf tools: Generalize perf_header__adds_read()

Renaming it to perf_header__process_sections() and passing a
callback to handle each feature.

The next changesets will introduce 'perf buildid-list' that will
handle just the HEADER_BUILD_ID table, ignoring all the other
features.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
LKML-Reference: <1258396365-29217-3-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
Arnaldo Carvalho de Melo
2009-11-16 16:32:43 -02:00
committed by Ingo Molnar
parent 8f41146aed
commit 37562eac37
2 changed files with 99 additions and 57 deletions

View File

@@ -15,11 +15,34 @@ struct perf_header_attr {
off_t id_offset;
};
#define HEADER_TRACE_INFO 1
#define HEADER_BUILD_ID 2
enum {
HEADER_TRACE_INFO = 1,
HEADER_BUILD_ID,
HEADER_LAST_FEATURE,
};
#define HEADER_FEAT_BITS 256
struct perf_file_section {
u64 offset;
u64 size;
};
struct perf_file_header {
u64 magic;
u64 size;
u64 attr_size;
struct perf_file_section attrs;
struct perf_file_section data;
struct perf_file_section event_types;
DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS);
};
struct perf_header;
int perf_file_header__read(struct perf_file_header *self,
struct perf_header *ph, int fd);
struct perf_header {
int frozen;
int attrs, size;
@@ -54,4 +77,8 @@ bool perf_header__has_feat(const struct perf_header *self, int feat);
struct perf_header *perf_header__new(void);
int perf_header__process_sections(struct perf_header *self, int fd,
int (*process)(struct perf_file_section *self,
int feat, int fd));
#endif /* __PERF_HEADER_H */