aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2014-11-03 20:14:30 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-11-05 08:14:07 -0500
commite195fac8077f034b0160bf420bdf450ae476701d (patch)
tree8bc86ad75813040279138fffdf6f0f663ad86511
parent714c9c4a98f722115e10d021ea80600f4427b71e (diff)
perf build-id: Move build-id related functions to util/build-id.c
It'd be better managing those functions in a separate place as util/header.c file is already big. It now exports following 3 functions to others: bool perf_session__read_build_ids(struct perf_session *session, bool with_hits); int perf_session__write_buildid_table(struct perf_session *session, int fd); int perf_session__cache_build_ids(struct perf_session *session); Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Link: http://lkml.kernel.org/r/545733E7.6010105@intel.com Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung.kim@lge.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1415063674-17206-5-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/build-id.c334
-rw-r--r--tools/perf/util/build-id.h11
-rw-r--r--tools/perf/util/header.c337
-rw-r--r--tools/perf/util/header.h8
4 files changed, 349 insertions, 341 deletions
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index 2e7c68e39330..dd2a3e52ada1 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -15,6 +15,8 @@
15#include "debug.h" 15#include "debug.h"
16#include "session.h" 16#include "session.h"
17#include "tool.h" 17#include "tool.h"
18#include "header.h"
19#include "vdso.h"
18 20
19int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused, 21int build_id__mark_dso_hit(struct perf_tool *tool __maybe_unused,
20 union perf_event *event, 22 union perf_event *event,
@@ -105,3 +107,335 @@ char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size)
105 build_id_hex, build_id_hex + 2); 107 build_id_hex, build_id_hex + 2);
106 return bf; 108 return bf;
107} 109}
110
111#define dsos__for_each_with_build_id(pos, head) \
112 list_for_each_entry(pos, head, node) \
113 if (!pos->has_build_id) \
114 continue; \
115 else
116
117static int write_buildid(const char *name, size_t name_len, u8 *build_id,
118 pid_t pid, u16 misc, int fd)
119{
120 int err;
121 struct build_id_event b;
122 size_t len;
123
124 len = name_len + 1;
125 len = PERF_ALIGN(len, NAME_ALIGN);
126
127 memset(&b, 0, sizeof(b));
128 memcpy(&b.build_id, build_id, BUILD_ID_SIZE);
129 b.pid = pid;
130 b.header.misc = misc;
131 b.header.size = sizeof(b) + len;
132
133 err = writen(fd, &b, sizeof(b));
134 if (err < 0)
135 return err;
136
137 return write_padded(fd, name, name_len + 1, len);
138}
139
140static int __dsos__write_buildid_table(struct list_head *head,
141 struct machine *machine,
142 pid_t pid, u16 misc, int fd)
143{
144 char nm[PATH_MAX];
145 struct dso *pos;
146
147 dsos__for_each_with_build_id(pos, head) {
148 int err;
149 const char *name;
150 size_t name_len;
151
152 if (!pos->hit)
153 continue;
154
155 if (dso__is_vdso(pos)) {
156 name = pos->short_name;
157 name_len = pos->short_name_len + 1;
158 } else if (dso__is_kcore(pos)) {
159 machine__mmap_name(machine, nm, sizeof(nm));
160 name = nm;
161 name_len = strlen(nm) + 1;
162 } else {
163 name = pos->long_name;
164 name_len = pos->long_name_len + 1;
165 }
166
167 err = write_buildid(name, name_len, pos->build_id,
168 pid, misc, fd);
169 if (err)
170 return err;
171 }
172
173 return 0;
174}
175
176static int machine__write_buildid_table(struct machine *machine, int fd)
177{
178 int err;
179 u16 kmisc = PERF_RECORD_MISC_KERNEL,
180 umisc = PERF_RECORD_MISC_USER;
181
182 if (!machine__is_host(machine)) {
183 kmisc = PERF_RECORD_MISC_GUEST_KERNEL;
184 umisc = PERF_RECORD_MISC_GUEST_USER;
185 }
186
187 err = __dsos__write_buildid_table(&machine->kernel_dsos.head, machine,
188 machine->pid, kmisc, fd);
189 if (err == 0)
190 err = __dsos__write_buildid_table(&machine->user_dsos.head,
191 machine, machine->pid, umisc,
192 fd);
193 return err;
194}
195
196int perf_session__write_buildid_table(struct perf_session *session, int fd)
197{
198 struct rb_node *nd;
199 int err = machine__write_buildid_table(&session->machines.host, fd);
200
201 if (err)
202 return err;
203
204 for (nd = rb_first(&session->machines.guests); nd; nd = rb_next(nd)) {
205 struct machine *pos = rb_entry(nd, struct machine, rb_node);
206 err = machine__write_buildid_table(pos, fd);
207 if (err)
208 break;
209 }
210 return err;
211}
212
213static int __dsos__hit_all(struct list_head *head)
214{
215 struct dso *pos;
216
217 list_for_each_entry(pos, head, node)
218 pos->hit = true;
219
220 return 0;
221}
222
223static int machine__hit_all_dsos(struct machine *machine)
224{
225 int err;
226
227 err = __dsos__hit_all(&machine->kernel_dsos.head);
228 if (err)
229 return err;
230
231 return __dsos__hit_all(&machine->user_dsos.head);
232}
233
234int dsos__hit_all(struct perf_session *session)
235{
236 struct rb_node *nd;
237 int err;
238
239 err = machine__hit_all_dsos(&session->machines.host);
240 if (err)
241 return err;
242
243 for (nd = rb_first(&session->machines.guests); nd; nd = rb_next(nd)) {
244 struct machine *pos = rb_entry(nd, struct machine, rb_node);
245
246 err = machine__hit_all_dsos(pos);
247 if (err)
248 return err;
249 }
250
251 return 0;
252}
253
254int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
255 const char *name, bool is_kallsyms, bool is_vdso)
256{
257 const size_t size = PATH_MAX;
258 char *realname, *filename = zalloc(size),
259 *linkname = zalloc(size), *targetname;
260 int len, err = -1;
261 bool slash = is_kallsyms || is_vdso;
262
263 if (is_kallsyms) {
264 if (symbol_conf.kptr_restrict) {
265 pr_debug("Not caching a kptr_restrict'ed /proc/kallsyms\n");
266 err = 0;
267 goto out_free;
268 }
269 realname = (char *) name;
270 } else
271 realname = realpath(name, NULL);
272
273 if (realname == NULL || filename == NULL || linkname == NULL)
274 goto out_free;
275
276 len = scnprintf(filename, size, "%s%s%s",
277 debugdir, slash ? "/" : "",
278 is_vdso ? DSO__NAME_VDSO : realname);
279 if (mkdir_p(filename, 0755))
280 goto out_free;
281
282 snprintf(filename + len, size - len, "/%s", sbuild_id);
283
284 if (access(filename, F_OK)) {
285 if (is_kallsyms) {
286 if (copyfile("/proc/kallsyms", filename))
287 goto out_free;
288 } else if (link(realname, filename) && copyfile(name, filename))
289 goto out_free;
290 }
291
292 len = scnprintf(linkname, size, "%s/.build-id/%.2s",
293 debugdir, sbuild_id);
294
295 if (access(linkname, X_OK) && mkdir_p(linkname, 0755))
296 goto out_free;
297
298 snprintf(linkname + len, size - len, "/%s", sbuild_id + 2);
299 targetname = filename + strlen(debugdir) - 5;
300 memcpy(targetname, "../..", 5);
301
302 if (symlink(targetname, linkname) == 0)
303 err = 0;
304out_free:
305 if (!is_kallsyms)
306 free(realname);
307 free(filename);
308 free(linkname);
309 return err;
310}
311
312static int build_id_cache__add_b(const u8 *build_id, size_t build_id_size,
313 const char *name, const char *debugdir,
314 bool is_kallsyms, bool is_vdso)
315{
316 char sbuild_id[BUILD_ID_SIZE * 2 + 1];
317
318 build_id__sprintf(build_id, build_id_size, sbuild_id);
319
320 return build_id_cache__add_s(sbuild_id, debugdir, name,
321 is_kallsyms, is_vdso);
322}
323
324int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir)
325{
326 const size_t size = PATH_MAX;
327 char *filename = zalloc(size),
328 *linkname = zalloc(size);
329 int err = -1;
330
331 if (filename == NULL || linkname == NULL)
332 goto out_free;
333
334 snprintf(linkname, size, "%s/.build-id/%.2s/%s",
335 debugdir, sbuild_id, sbuild_id + 2);
336
337 if (access(linkname, F_OK))
338 goto out_free;
339
340 if (readlink(linkname, filename, size - 1) < 0)
341 goto out_free;
342
343 if (unlink(linkname))
344 goto out_free;
345
346 /*
347 * Since the link is relative, we must make it absolute:
348 */
349 snprintf(linkname, size, "%s/.build-id/%.2s/%s",
350 debugdir, sbuild_id, filename);
351
352 if (unlink(linkname))
353 goto out_free;
354
355 err = 0;
356out_free:
357 free(filename);
358 free(linkname);
359 return err;
360}
361
362static int dso__cache_build_id(struct dso *dso, struct machine *machine,
363 const char *debugdir)
364{
365 bool is_kallsyms = dso->kernel && dso->long_name[0] != '/';
366 bool is_vdso = dso__is_vdso(dso);
367 const char *name = dso->long_name;
368 char nm[PATH_MAX];
369
370 if (dso__is_kcore(dso)) {
371 is_kallsyms = true;
372 machine__mmap_name(machine, nm, sizeof(nm));
373 name = nm;
374 }
375 return build_id_cache__add_b(dso->build_id, sizeof(dso->build_id), name,
376 debugdir, is_kallsyms, is_vdso);
377}
378
379static int __dsos__cache_build_ids(struct list_head *head,
380 struct machine *machine, const char *debugdir)
381{
382 struct dso *pos;
383 int err = 0;
384
385 dsos__for_each_with_build_id(pos, head)
386 if (dso__cache_build_id(pos, machine, debugdir))
387 err = -1;
388
389 return err;
390}
391
392static int machine__cache_build_ids(struct machine *machine, const char *debugdir)
393{
394 int ret = __dsos__cache_build_ids(&machine->kernel_dsos.head, machine,
395 debugdir);
396 ret |= __dsos__cache_build_ids(&machine->user_dsos.head, machine,
397 debugdir);
398 return ret;
399}
400
401int perf_session__cache_build_ids(struct perf_session *session)
402{
403 struct rb_node *nd;
404 int ret;
405 char debugdir[PATH_MAX];
406
407 snprintf(debugdir, sizeof(debugdir), "%s", buildid_dir);
408
409 if (mkdir(debugdir, 0755) != 0 && errno != EEXIST)
410 return -1;
411
412 ret = machine__cache_build_ids(&session->machines.host, debugdir);
413
414 for (nd = rb_first(&session->machines.guests); nd; nd = rb_next(nd)) {
415 struct machine *pos = rb_entry(nd, struct machine, rb_node);
416 ret |= machine__cache_build_ids(pos, debugdir);
417 }
418 return ret ? -1 : 0;
419}
420
421static bool machine__read_build_ids(struct machine *machine, bool with_hits)
422{
423 bool ret;
424
425 ret = __dsos__read_build_ids(&machine->kernel_dsos.head, with_hits);
426 ret |= __dsos__read_build_ids(&machine->user_dsos.head, with_hits);
427 return ret;
428}
429
430bool perf_session__read_build_ids(struct perf_session *session, bool with_hits)
431{
432 struct rb_node *nd;
433 bool ret = machine__read_build_ids(&session->machines.host, with_hits);
434
435 for (nd = rb_first(&session->machines.guests); nd; nd = rb_next(nd)) {
436 struct machine *pos = rb_entry(nd, struct machine, rb_node);
437 ret |= machine__read_build_ids(pos, with_hits);
438 }
439
440 return ret;
441}
diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h
index ae392561470b..666a3bd4f64e 100644
--- a/tools/perf/util/build-id.h
+++ b/tools/perf/util/build-id.h
@@ -15,4 +15,15 @@ char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size);
15int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event, 15int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event,
16 struct perf_sample *sample, struct perf_evsel *evsel, 16 struct perf_sample *sample, struct perf_evsel *evsel,
17 struct machine *machine); 17 struct machine *machine);
18
19int dsos__hit_all(struct perf_session *session);
20
21bool perf_session__read_build_ids(struct perf_session *session, bool with_hits);
22int perf_session__write_buildid_table(struct perf_session *session, int fd);
23int perf_session__cache_build_ids(struct perf_session *session);
24
25int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
26 const char *name, bool is_kallsyms, bool is_vdso);
27int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir);
28
18#endif 29#endif
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index be8d02eb97e9..3e2c156d9c64 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -79,10 +79,7 @@ static int do_write(int fd, const void *buf, size_t size)
79 return 0; 79 return 0;
80} 80}
81 81
82#define NAME_ALIGN 64 82int write_padded(int fd, const void *bf, size_t count, size_t count_aligned)
83
84static int write_padded(int fd, const void *bf, size_t count,
85 size_t count_aligned)
86{ 83{
87 static const char zero_buf[NAME_ALIGN]; 84 static const char zero_buf[NAME_ALIGN];
88 int err = do_write(fd, bf, count); 85 int err = do_write(fd, bf, count);
@@ -171,338 +168,6 @@ perf_header__set_cmdline(int argc, const char **argv)
171 return 0; 168 return 0;
172} 169}
173 170
174#define dsos__for_each_with_build_id(pos, head) \
175 list_for_each_entry(pos, head, node) \
176 if (!pos->has_build_id) \
177 continue; \
178 else
179
180static int write_buildid(const char *name, size_t name_len, u8 *build_id,
181 pid_t pid, u16 misc, int fd)
182{
183 int err;
184 struct build_id_event b;
185 size_t len;
186
187 len = name_len + 1;
188 len = PERF_ALIGN(len, NAME_ALIGN);
189
190 memset(&b, 0, sizeof(b));
191 memcpy(&b.build_id, build_id, BUILD_ID_SIZE);
192 b.pid = pid;
193 b.header.misc = misc;
194 b.header.size = sizeof(b) + len;
195
196 err = do_write(fd, &b, sizeof(b));
197 if (err < 0)
198 return err;
199
200 return write_padded(fd, name, name_len + 1, len);
201}
202
203static int __dsos__hit_all(struct list_head *head)
204{
205 struct dso *pos;
206
207 list_for_each_entry(pos, head, node)
208 pos->hit = true;
209
210 return 0;
211}
212
213static int machine__hit_all_dsos(struct machine *machine)
214{
215 int err;
216
217 err = __dsos__hit_all(&machine->kernel_dsos.head);
218 if (err)
219 return err;
220
221 return __dsos__hit_all(&machine->user_dsos.head);
222}
223
224int dsos__hit_all(struct perf_session *session)
225{
226 struct rb_node *nd;
227 int err;
228
229 err = machine__hit_all_dsos(&session->machines.host);
230 if (err)
231 return err;
232
233 for (nd = rb_first(&session->machines.guests); nd; nd = rb_next(nd)) {
234 struct machine *pos = rb_entry(nd, struct machine, rb_node);
235
236 err = machine__hit_all_dsos(pos);
237 if (err)
238 return err;
239 }
240
241 return 0;
242}
243
244static int __dsos__write_buildid_table(struct list_head *head,
245 struct machine *machine,
246 pid_t pid, u16 misc, int fd)
247{
248 char nm[PATH_MAX];
249 struct dso *pos;
250
251 dsos__for_each_with_build_id(pos, head) {
252 int err;
253 const char *name;
254 size_t name_len;
255
256 if (!pos->hit)
257 continue;
258
259 if (dso__is_vdso(pos)) {
260 name = pos->short_name;
261 name_len = pos->short_name_len + 1;
262 } else if (dso__is_kcore(pos)) {
263 machine__mmap_name(machine, nm, sizeof(nm));
264 name = nm;
265 name_len = strlen(nm) + 1;
266 } else {
267 name = pos->long_name;
268 name_len = pos->long_name_len + 1;
269 }
270
271 err = write_buildid(name, name_len, pos->build_id,
272 pid, misc, fd);
273 if (err)
274 return err;
275 }
276
277 return 0;
278}
279
280static int machine__write_buildid_table(struct machine *machine, int fd)
281{
282 int err;
283 u16 kmisc = PERF_RECORD_MISC_KERNEL,
284 umisc = PERF_RECORD_MISC_USER;
285
286 if (!machine__is_host(machine)) {
287 kmisc = PERF_RECORD_MISC_GUEST_KERNEL;
288 umisc = PERF_RECORD_MISC_GUEST_USER;
289 }
290
291 err = __dsos__write_buildid_table(&machine->kernel_dsos.head, machine,
292 machine->pid, kmisc, fd);
293 if (err == 0)
294 err = __dsos__write_buildid_table(&machine->user_dsos.head,
295 machine, machine->pid, umisc,
296 fd);
297 return err;
298}
299
300static int perf_session__write_buildid_table(struct perf_session *session, int fd)
301{
302 struct rb_node *nd;
303 int err = machine__write_buildid_table(&session->machines.host, fd);
304
305 if (err)
306 return err;
307
308 for (nd = rb_first(&session->machines.guests); nd; nd = rb_next(nd)) {
309 struct machine *pos = rb_entry(nd, struct machine, rb_node);
310 err = machine__write_buildid_table(pos, fd);
311 if (err)
312 break;
313 }
314 return err;
315}
316
317int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
318 const char *name, bool is_kallsyms, bool is_vdso)
319{
320 const size_t size = PATH_MAX;
321 char *realname, *filename = zalloc(size),
322 *linkname = zalloc(size), *targetname;
323 int len, err = -1;
324 bool slash = is_kallsyms || is_vdso;
325
326 if (is_kallsyms) {
327 if (symbol_conf.kptr_restrict) {
328 pr_debug("Not caching a kptr_restrict'ed /proc/kallsyms\n");
329 err = 0;
330 goto out_free;
331 }
332 realname = (char *) name;
333 } else
334 realname = realpath(name, NULL);
335
336 if (realname == NULL || filename == NULL || linkname == NULL)
337 goto out_free;
338
339 len = scnprintf(filename, size, "%s%s%s",
340 debugdir, slash ? "/" : "",
341 is_vdso ? DSO__NAME_VDSO : realname);
342 if (mkdir_p(filename, 0755))
343 goto out_free;
344
345 snprintf(filename + len, size - len, "/%s", sbuild_id);
346
347 if (access(filename, F_OK)) {
348 if (is_kallsyms) {
349 if (copyfile("/proc/kallsyms", filename))
350 goto out_free;
351 } else if (link(realname, filename) && copyfile(name, filename))
352 goto out_free;
353 }
354
355 len = scnprintf(linkname, size, "%s/.build-id/%.2s",
356 debugdir, sbuild_id);
357
358 if (access(linkname, X_OK) && mkdir_p(linkname, 0755))
359 goto out_free;
360
361 snprintf(linkname + len, size - len, "/%s", sbuild_id + 2);
362 targetname = filename + strlen(debugdir) - 5;
363 memcpy(targetname, "../..", 5);
364
365 if (symlink(targetname, linkname) == 0)
366 err = 0;
367out_free:
368 if (!is_kallsyms)
369 free(realname);
370 free(filename);
371 free(linkname);
372 return err;
373}
374
375static int build_id_cache__add_b(const u8 *build_id, size_t build_id_size,
376 const char *name, const char *debugdir,
377 bool is_kallsyms, bool is_vdso)
378{
379 char sbuild_id[BUILD_ID_SIZE * 2 + 1];
380
381 build_id__sprintf(build_id, build_id_size, sbuild_id);
382
383 return build_id_cache__add_s(sbuild_id, debugdir, name,
384 is_kallsyms, is_vdso);
385}
386
387int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir)
388{
389 const size_t size = PATH_MAX;
390 char *filename = zalloc(size),
391 *linkname = zalloc(size);
392 int err = -1;
393
394 if (filename == NULL || linkname == NULL)
395 goto out_free;
396
397 snprintf(linkname, size, "%s/.build-id/%.2s/%s",
398 debugdir, sbuild_id, sbuild_id + 2);
399
400 if (access(linkname, F_OK))
401 goto out_free;
402
403 if (readlink(linkname, filename, size - 1) < 0)
404 goto out_free;
405
406 if (unlink(linkname))
407 goto out_free;
408
409 /*
410 * Since the link is relative, we must make it absolute:
411 */
412 snprintf(linkname, size, "%s/.build-id/%.2s/%s",
413 debugdir, sbuild_id, filename);
414
415 if (unlink(linkname))
416 goto out_free;
417
418 err = 0;
419out_free:
420 free(filename);
421 free(linkname);
422 return err;
423}
424
425static int dso__cache_build_id(struct dso *dso, struct machine *machine,
426 const char *debugdir)
427{
428 bool is_kallsyms = dso->kernel && dso->long_name[0] != '/';
429 bool is_vdso = dso__is_vdso(dso);
430 const char *name = dso->long_name;
431 char nm[PATH_MAX];
432
433 if (dso__is_kcore(dso)) {
434 is_kallsyms = true;
435 machine__mmap_name(machine, nm, sizeof(nm));
436 name = nm;
437 }
438 return build_id_cache__add_b(dso->build_id, sizeof(dso->build_id), name,
439 debugdir, is_kallsyms, is_vdso);
440}
441
442static int __dsos__cache_build_ids(struct list_head *head,
443 struct machine *machine, const char *debugdir)
444{
445 struct dso *pos;
446 int err = 0;
447
448 dsos__for_each_with_build_id(pos, head)
449 if (dso__cache_build_id(pos, machine, debugdir))
450 err = -1;
451
452 return err;
453}
454
455static int machine__cache_build_ids(struct machine *machine, const char *debugdir)
456{
457 int ret = __dsos__cache_build_ids(&machine->kernel_dsos.head, machine,
458 debugdir);
459 ret |= __dsos__cache_build_ids(&machine->user_dsos.head, machine,
460 debugdir);
461 return ret;
462}
463
464static int perf_session__cache_build_ids(struct perf_session *session)
465{
466 struct rb_node *nd;
467 int ret;
468 char debugdir[PATH_MAX];
469
470 snprintf(debugdir, sizeof(debugdir), "%s", buildid_dir);
471
472 if (mkdir(debugdir, 0755) != 0 && errno != EEXIST)
473 return -1;
474
475 ret = machine__cache_build_ids(&session->machines.host, debugdir);
476
477 for (nd = rb_first(&session->machines.guests); nd; nd = rb_next(nd)) {
478 struct machine *pos = rb_entry(nd, struct machine, rb_node);
479 ret |= machine__cache_build_ids(pos, debugdir);
480 }
481 return ret ? -1 : 0;
482}
483
484static bool machine__read_build_ids(struct machine *machine, bool with_hits)
485{
486 bool ret;
487
488 ret = __dsos__read_build_ids(&machine->kernel_dsos.head, with_hits);
489 ret |= __dsos__read_build_ids(&machine->user_dsos.head, with_hits);
490 return ret;
491}
492
493static bool perf_session__read_build_ids(struct perf_session *session, bool with_hits)
494{
495 struct rb_node *nd;
496 bool ret = machine__read_build_ids(&session->machines.host, with_hits);
497
498 for (nd = rb_first(&session->machines.guests); nd; nd = rb_next(nd)) {
499 struct machine *pos = rb_entry(nd, struct machine, rb_node);
500 ret |= machine__read_build_ids(pos, with_hits);
501 }
502
503 return ret;
504}
505
506static int write_tracing_data(int fd, struct perf_header *h __maybe_unused, 171static int write_tracing_data(int fd, struct perf_header *h __maybe_unused,
507 struct perf_evlist *evlist) 172 struct perf_evlist *evlist)
508{ 173{
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
index 8f5cbaea64a5..3bb90ac172a1 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -122,10 +122,6 @@ int perf_header__process_sections(struct perf_header *header, int fd,
122 122
123int perf_header__fprintf_info(struct perf_session *s, FILE *fp, bool full); 123int perf_header__fprintf_info(struct perf_session *s, FILE *fp, bool full);
124 124
125int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
126 const char *name, bool is_kallsyms, bool is_vdso);
127int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir);
128
129int perf_event__synthesize_attr(struct perf_tool *tool, 125int perf_event__synthesize_attr(struct perf_tool *tool,
130 struct perf_event_attr *attr, u32 ids, u64 *id, 126 struct perf_event_attr *attr, u32 ids, u64 *id,
131 perf_event__handler_t process); 127 perf_event__handler_t process);
@@ -151,7 +147,9 @@ int perf_event__process_build_id(struct perf_tool *tool,
151 struct perf_session *session); 147 struct perf_session *session);
152bool is_perf_magic(u64 magic); 148bool is_perf_magic(u64 magic);
153 149
154int dsos__hit_all(struct perf_session *session); 150#define NAME_ALIGN 64
151
152int write_padded(int fd, const void *bf, size_t count, size_t count_aligned);
155 153
156/* 154/*
157 * arch specific callback 155 * arch specific callback