diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-11-18 17:20:51 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-11-19 02:28:12 -0500 |
commit | e30a3d12ddf04add3268bfceb0e57ffe47f254c6 (patch) | |
tree | 421a5726e0f7f87fff772efd7a83ce15c82ba859 /tools/perf/util/header.c | |
parent | d3379ab9050e5522da2aac53d413651fc06be562 (diff) |
perf symbols: Kill struct build_id_list and die() another day
No need for this struct and its allocations, we can just use the
->build_id member we already have in struct dso, then ask for it
to be read, and later traverse the dsos list, writing the
buildid table to the perf.data file.
As a bonus, one more die() function got killed.
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: <1258582853-8579-2-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 | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index b01a9537977f..31731f1606b2 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -176,18 +176,24 @@ static int do_write(int fd, const void *buf, size_t size) | |||
176 | return 0; | 176 | return 0; |
177 | } | 177 | } |
178 | 178 | ||
179 | static int write_buildid_table(int fd, struct list_head *id_head) | 179 | static int dsos__write_buildid_table(int fd) |
180 | { | 180 | { |
181 | struct build_id_list *iter, *next; | 181 | struct dso *pos; |
182 | 182 | ||
183 | list_for_each_entry_safe(iter, next, id_head, list) { | 183 | list_for_each_entry(pos, &dsos, node) { |
184 | struct build_id_event *b = &iter->event; | 184 | struct build_id_event b; |
185 | 185 | size_t len; | |
186 | if (do_write(fd, b, sizeof(*b)) < 0 || | 186 | |
187 | do_write(fd, iter->dso_name, iter->len) < 0) | 187 | if (!pos->has_build_id) |
188 | continue; | ||
189 | len = pos->long_name_len + 1; | ||
190 | len = ALIGN(len, 64); | ||
191 | memset(&b, 0, sizeof(b)); | ||
192 | memcpy(&b.build_id, pos->build_id, sizeof(pos->build_id)); | ||
193 | b.header.size = sizeof(b) + len; | ||
194 | if (do_write(fd, &b, sizeof(b)) < 0 || | ||
195 | do_write(fd, pos->long_name, len) < 0) | ||
188 | return -1; | 196 | return -1; |
189 | list_del(&iter->list); | ||
190 | free(iter); | ||
191 | } | 197 | } |
192 | 198 | ||
193 | return 0; | 199 | return 0; |
@@ -196,14 +202,13 @@ static int write_buildid_table(int fd, struct list_head *id_head) | |||
196 | static void | 202 | static void |
197 | perf_header__adds_write(struct perf_header *self, int fd) | 203 | perf_header__adds_write(struct perf_header *self, int fd) |
198 | { | 204 | { |
199 | LIST_HEAD(id_list); | ||
200 | int nr_sections; | 205 | int nr_sections; |
201 | struct perf_file_section *feat_sec; | 206 | struct perf_file_section *feat_sec; |
202 | int sec_size; | 207 | int sec_size; |
203 | u64 sec_start; | 208 | u64 sec_start; |
204 | int idx = 0; | 209 | int idx = 0; |
205 | 210 | ||
206 | if (fetch_build_id_table(&id_list)) | 211 | if (dsos__read_build_ids()) |
207 | perf_header__set_feat(self, HEADER_BUILD_ID); | 212 | perf_header__set_feat(self, HEADER_BUILD_ID); |
208 | 213 | ||
209 | nr_sections = bitmap_weight(self->adds_features, HEADER_FEAT_BITS); | 214 | nr_sections = bitmap_weight(self->adds_features, HEADER_FEAT_BITS); |
@@ -238,7 +243,7 @@ perf_header__adds_write(struct perf_header *self, int fd) | |||
238 | 243 | ||
239 | /* Write build-ids */ | 244 | /* Write build-ids */ |
240 | buildid_sec->offset = lseek(fd, 0, SEEK_CUR); | 245 | buildid_sec->offset = lseek(fd, 0, SEEK_CUR); |
241 | if (write_buildid_table(fd, &id_list) < 0) | 246 | if (dsos__write_buildid_table(fd) < 0) |
242 | die("failed to write buildid table"); | 247 | die("failed to write buildid table"); |
243 | buildid_sec->size = lseek(fd, 0, SEEK_CUR) - buildid_sec->offset; | 248 | buildid_sec->size = lseek(fd, 0, SEEK_CUR) - buildid_sec->offset; |
244 | } | 249 | } |