aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/header.c
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-11-10 22:51:04 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-11 01:30:18 -0500
commit57f395a7eabb913d3605d7392be5bdb0837c9f3d (patch)
tree141135524cbdb9fa27b48f361443a91b10726f7d /tools/perf/util/header.c
parent8671dab9d5b2f0b444b8d09792384dccbfd43d14 (diff)
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)
174 } 174 }
175} 175}
176 176
177static bool write_buildid_table(int fd) 177static void write_buildid_table(int fd, struct list_head *id_head)
178{ 178{
179 struct dso *pos; 179 struct build_id_list *iter, *next;
180 bool have_buildid = false; 180
181 181 list_for_each_entry_safe(iter, next, id_head, list) {
182 list_for_each_entry(pos, &dsos, node) { 182 struct build_id_event *b = &iter->event;
183 struct build_id_event b;
184 size_t len;
185
186 if (filename__read_build_id(pos->long_name,
187 &b.build_id,
188 sizeof(b.build_id)) < 0)
189 continue;
190 have_buildid = true;
191 memset(&b.header, 0, sizeof(b.header));
192 len = strlen(pos->long_name) + 1;
193 len = ALIGN(len, 64);
194 b.header.size = sizeof(b) + len;
195 do_write(fd, &b, sizeof(b));
196 do_write(fd, pos->long_name, len);
197 }
198 183
199 return have_buildid; 184 do_write(fd, b, sizeof(*b));
185 do_write(fd, (void *)iter->dso_name, iter->len);
186 list_del(&iter->list);
187 free(iter);
188 }
200} 189}
201 190
202static void 191static void
@@ -226,10 +215,14 @@ perf_header__adds_write(struct perf_header *self, int fd, bool at_exit)
226 } 215 }
227 216
228 if (at_exit) { 217 if (at_exit) {
229 lseek(fd, self->data_offset + self->data_size, SEEK_SET); 218 LIST_HEAD(id_list);
230 if (write_buildid_table(fd)) 219
220 if (fetch_build_id_table(&id_list)) {
221 lseek(fd, self->data_offset + self->data_size, SEEK_SET);
231 perf_header__set_feat(self, HEADER_BUILD_ID); 222 perf_header__set_feat(self, HEADER_BUILD_ID);
232 lseek(fd, cur_offset, SEEK_SET); 223 write_buildid_table(fd, &id_list);
224 lseek(fd, cur_offset, SEEK_SET);
225 }
233 } 226 }
234}; 227};
235 228