diff options
-rw-r--r-- | tools/perf/util/dso.h | 1 | ||||
-rw-r--r-- | tools/perf/util/header.c | 1 | ||||
-rw-r--r-- | tools/perf/util/map.c | 20 |
3 files changed, 19 insertions, 3 deletions
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index 011da3924fc1..3a9fd4d389b5 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -167,6 +167,7 @@ struct dso { enum dso_load_errno load_errno; u8 adjust_symbols:1; u8 has_build_id:1; + u8 header_build_id:1; u8 has_srcline:1; u8 hit:1; u8 annotate_warned:1; diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 6da12e522edc..571d73d4f976 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -2200,6 +2200,7 @@ static int __event_process_build_id(struct perf_record_header_build_id *bev, build_id__init(&bid, bev->data, size); dso__set_build_id(dso, &bid); + dso->header_build_id = 1; if (dso_space != DSO_SPACE__USER) { struct kmod_path m = { .name = NULL, }; diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 1803d3887afe..e0aa4a254583 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -127,7 +127,7 @@ struct map *map__new(struct machine *machine, u64 start, u64 len, if (map != NULL) { char newfilename[PATH_MAX]; - struct dso *dso; + struct dso *dso, *header_bid_dso; int anon, no_dso, vdso, android; android = is_android_lib(filename); @@ -183,9 +183,23 @@ struct map *map__new(struct machine *machine, u64 start, u64 len, } dso->nsinfo = nsi; - if (build_id__is_defined(bid)) + if (build_id__is_defined(bid)) { dso__set_build_id(dso, bid); - + } else { + /* + * If the mmap event had no build ID, search for an existing dso from the + * build ID header by name. Otherwise only the dso loaded at the time of + * reading the header will have the build ID set and all future mmaps will + * have it missing. + */ + down_read(&machine->dsos.lock); + header_bid_dso = __dsos__find(&machine->dsos, filename, false); + up_read(&machine->dsos.lock); + if (header_bid_dso && header_bid_dso->header_build_id) { + dso__set_build_id(dso, &header_bid_dso->bid); + dso->header_build_id = 1; + } + } dso__put(dso); } return map; |