aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/header.c
diff options
context:
space:
mode:
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