aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/header.c
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-11-11 04:51:04 +0100
committerIngo Molnar <mingo@elte.hu>2009-11-11 07:30:18 +0100
commit57f395a7eabb913d3605d7392be5bdb0837c9f3d (patch)
tree141135524cbdb9fa27b48f361443a91b10726f7d /tools/perf/util/header.c
parentperf tools: Move the build-id storage operations to headers (diff)
downloadlinux-dev-57f395a7eabb913d3605d7392be5bdb0837c9f3d.tar.xz
linux-dev-57f395a7eabb913d3605d7392be5bdb0837c9f3d.zip
perf tools: Split up build id saving into fetch and write
We are saving the build id once we stop the profiling. And only after doing that we know if we need to set that feature in the header through the feature bitmap. But if we want a proper feature support in the headers, using a rule of offset/size pairs in sections, we need to know in advance how many features we need to set in the headers, so that we can reserve rooms for their section headers. The current state doesn't allow that, as it forces us to first save the build-ids to the file right after the datas instead of planning any structured layout. That's why this splits up the build-ids processing in two parts: one that fetches the build-ids from the Dso objects, and one that saves them into the file. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp> LKML-Reference: <1257911467-28276-3-git-send-email-fweisbec@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/header.c')
-rw-r--r--tools/perf/util/header.c41
1 files changed, 17 insertions, 24 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index a4d0bbef9a43..2f702c23f71a 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -174,29 +174,18 @@ static void do_write(int fd, void *buf, size_t size)
}
}
-static bool write_buildid_table(int fd)
+static void write_buildid_table(int fd, struct list_head *id_head)
{
- struct dso *pos;
- bool have_buildid = false;
-
- list_for_each_entry(pos, &dsos, node) {
- struct build_id_event b;
- size_t len;
-
- if (filename__read_build_id(pos->long_name,
- &b.build_id,
- sizeof(b.build_id)) < 0)
- continue;
- have_buildid = true;
- memset(&b.header, 0, sizeof(b.header));
- len = strlen(pos->long_name) + 1;
- len = ALIGN(len, 64);
- b.header.size = sizeof(b) + len;
- do_write(fd, &b, sizeof(b));
- do_write(fd, pos->long_name, len);
- }
+ struct build_id_list *iter, *next;
+
+ list_for_each_entry_safe(iter, next, id_head, list) {
+ struct build_id_event *b = &iter->event;
- return have_buildid;
+ do_write(fd, b, sizeof(*b));
+ do_write(fd, (void *)iter->dso_name, iter->len);
+ list_del(&iter->list);
+ free(iter);
+ }
}
static void
@@ -226,10 +215,14 @@ perf_header__adds_write(struct perf_header *self, int fd, bool at_exit)
}
if (at_exit) {
- lseek(fd, self->data_offset + self->data_size, SEEK_SET);
- if (write_buildid_table(fd))
+ LIST_HEAD(id_list);
+
+ if (fetch_build_id_table(&id_list)) {
+ lseek(fd, self->data_offset + self->data_size, SEEK_SET);
perf_header__set_feat(self, HEADER_BUILD_ID);
- lseek(fd, cur_offset, SEEK_SET);
+ write_buildid_table(fd, &id_list);
+ lseek(fd, cur_offset, SEEK_SET);
+ }
}
};