diff options
Diffstat (limited to 'tools/perf/util/header.c')
-rw-r--r-- | tools/perf/util/header.c | 59 |
1 files changed, 39 insertions, 20 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 158c787ce0c4..26f5b2fe5dc8 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -214,11 +214,11 @@ static int machine__hit_all_dsos(struct machine *machine) | |||
214 | { | 214 | { |
215 | int err; | 215 | int err; |
216 | 216 | ||
217 | err = __dsos__hit_all(&machine->kernel_dsos); | 217 | err = __dsos__hit_all(&machine->kernel_dsos.head); |
218 | if (err) | 218 | if (err) |
219 | return err; | 219 | return err; |
220 | 220 | ||
221 | return __dsos__hit_all(&machine->user_dsos); | 221 | return __dsos__hit_all(&machine->user_dsos.head); |
222 | } | 222 | } |
223 | 223 | ||
224 | int dsos__hit_all(struct perf_session *session) | 224 | int dsos__hit_all(struct perf_session *session) |
@@ -288,11 +288,12 @@ static int machine__write_buildid_table(struct machine *machine, int fd) | |||
288 | umisc = PERF_RECORD_MISC_GUEST_USER; | 288 | umisc = PERF_RECORD_MISC_GUEST_USER; |
289 | } | 289 | } |
290 | 290 | ||
291 | err = __dsos__write_buildid_table(&machine->kernel_dsos, machine, | 291 | err = __dsos__write_buildid_table(&machine->kernel_dsos.head, machine, |
292 | machine->pid, kmisc, fd); | 292 | machine->pid, kmisc, fd); |
293 | if (err == 0) | 293 | if (err == 0) |
294 | err = __dsos__write_buildid_table(&machine->user_dsos, machine, | 294 | err = __dsos__write_buildid_table(&machine->user_dsos.head, |
295 | machine->pid, umisc, fd); | 295 | machine, machine->pid, umisc, |
296 | fd); | ||
296 | return err; | 297 | return err; |
297 | } | 298 | } |
298 | 299 | ||
@@ -455,9 +456,10 @@ static int __dsos__cache_build_ids(struct list_head *head, | |||
455 | 456 | ||
456 | static int machine__cache_build_ids(struct machine *machine, const char *debugdir) | 457 | static int machine__cache_build_ids(struct machine *machine, const char *debugdir) |
457 | { | 458 | { |
458 | int ret = __dsos__cache_build_ids(&machine->kernel_dsos, machine, | 459 | int ret = __dsos__cache_build_ids(&machine->kernel_dsos.head, machine, |
459 | debugdir); | 460 | debugdir); |
460 | ret |= __dsos__cache_build_ids(&machine->user_dsos, machine, debugdir); | 461 | ret |= __dsos__cache_build_ids(&machine->user_dsos.head, machine, |
462 | debugdir); | ||
461 | return ret; | 463 | return ret; |
462 | } | 464 | } |
463 | 465 | ||
@@ -483,8 +485,10 @@ static int perf_session__cache_build_ids(struct perf_session *session) | |||
483 | 485 | ||
484 | static bool machine__read_build_ids(struct machine *machine, bool with_hits) | 486 | static bool machine__read_build_ids(struct machine *machine, bool with_hits) |
485 | { | 487 | { |
486 | bool ret = __dsos__read_build_ids(&machine->kernel_dsos, with_hits); | 488 | bool ret; |
487 | ret |= __dsos__read_build_ids(&machine->user_dsos, with_hits); | 489 | |
490 | ret = __dsos__read_build_ids(&machine->kernel_dsos.head, with_hits); | ||
491 | ret |= __dsos__read_build_ids(&machine->user_dsos.head, with_hits); | ||
488 | return ret; | 492 | return ret; |
489 | } | 493 | } |
490 | 494 | ||
@@ -575,16 +579,12 @@ static int write_version(int fd, struct perf_header *h __maybe_unused, | |||
575 | return do_write_string(fd, perf_version_string); | 579 | return do_write_string(fd, perf_version_string); |
576 | } | 580 | } |
577 | 581 | ||
578 | static int write_cpudesc(int fd, struct perf_header *h __maybe_unused, | 582 | static int __write_cpudesc(int fd, const char *cpuinfo_proc) |
579 | struct perf_evlist *evlist __maybe_unused) | ||
580 | { | 583 | { |
581 | #ifndef CPUINFO_PROC | ||
582 | #define CPUINFO_PROC NULL | ||
583 | #endif | ||
584 | FILE *file; | 584 | FILE *file; |
585 | char *buf = NULL; | 585 | char *buf = NULL; |
586 | char *s, *p; | 586 | char *s, *p; |
587 | const char *search = CPUINFO_PROC; | 587 | const char *search = cpuinfo_proc; |
588 | size_t len = 0; | 588 | size_t len = 0; |
589 | int ret = -1; | 589 | int ret = -1; |
590 | 590 | ||
@@ -634,6 +634,25 @@ done: | |||
634 | return ret; | 634 | return ret; |
635 | } | 635 | } |
636 | 636 | ||
637 | static int write_cpudesc(int fd, struct perf_header *h __maybe_unused, | ||
638 | struct perf_evlist *evlist __maybe_unused) | ||
639 | { | ||
640 | #ifndef CPUINFO_PROC | ||
641 | #define CPUINFO_PROC {"model name", } | ||
642 | #endif | ||
643 | const char *cpuinfo_procs[] = CPUINFO_PROC; | ||
644 | unsigned int i; | ||
645 | |||
646 | for (i = 0; i < ARRAY_SIZE(cpuinfo_procs); i++) { | ||
647 | int ret; | ||
648 | ret = __write_cpudesc(fd, cpuinfo_procs[i]); | ||
649 | if (ret >= 0) | ||
650 | return ret; | ||
651 | } | ||
652 | return -1; | ||
653 | } | ||
654 | |||
655 | |||
637 | static int write_nrcpus(int fd, struct perf_header *h __maybe_unused, | 656 | static int write_nrcpus(int fd, struct perf_header *h __maybe_unused, |
638 | struct perf_evlist *evlist __maybe_unused) | 657 | struct perf_evlist *evlist __maybe_unused) |
639 | { | 658 | { |
@@ -1548,7 +1567,7 @@ static int __event_process_build_id(struct build_id_event *bev, | |||
1548 | struct perf_session *session) | 1567 | struct perf_session *session) |
1549 | { | 1568 | { |
1550 | int err = -1; | 1569 | int err = -1; |
1551 | struct list_head *head; | 1570 | struct dsos *dsos; |
1552 | struct machine *machine; | 1571 | struct machine *machine; |
1553 | u16 misc; | 1572 | u16 misc; |
1554 | struct dso *dso; | 1573 | struct dso *dso; |
@@ -1563,22 +1582,22 @@ static int __event_process_build_id(struct build_id_event *bev, | |||
1563 | switch (misc) { | 1582 | switch (misc) { |
1564 | case PERF_RECORD_MISC_KERNEL: | 1583 | case PERF_RECORD_MISC_KERNEL: |
1565 | dso_type = DSO_TYPE_KERNEL; | 1584 | dso_type = DSO_TYPE_KERNEL; |
1566 | head = &machine->kernel_dsos; | 1585 | dsos = &machine->kernel_dsos; |
1567 | break; | 1586 | break; |
1568 | case PERF_RECORD_MISC_GUEST_KERNEL: | 1587 | case PERF_RECORD_MISC_GUEST_KERNEL: |
1569 | dso_type = DSO_TYPE_GUEST_KERNEL; | 1588 | dso_type = DSO_TYPE_GUEST_KERNEL; |
1570 | head = &machine->kernel_dsos; | 1589 | dsos = &machine->kernel_dsos; |
1571 | break; | 1590 | break; |
1572 | case PERF_RECORD_MISC_USER: | 1591 | case PERF_RECORD_MISC_USER: |
1573 | case PERF_RECORD_MISC_GUEST_USER: | 1592 | case PERF_RECORD_MISC_GUEST_USER: |
1574 | dso_type = DSO_TYPE_USER; | 1593 | dso_type = DSO_TYPE_USER; |
1575 | head = &machine->user_dsos; | 1594 | dsos = &machine->user_dsos; |
1576 | break; | 1595 | break; |
1577 | default: | 1596 | default: |
1578 | goto out; | 1597 | goto out; |
1579 | } | 1598 | } |
1580 | 1599 | ||
1581 | dso = __dsos__findnew(head, filename); | 1600 | dso = __dsos__findnew(dsos, filename); |
1582 | if (dso != NULL) { | 1601 | if (dso != NULL) { |
1583 | char sbuild_id[BUILD_ID_SIZE * 2 + 1]; | 1602 | char sbuild_id[BUILD_ID_SIZE * 2 + 1]; |
1584 | 1603 | ||