Since --buildid-mmap became the default, perf record doesn't add the vDSO to the build ID cache. Caching a DSO requires its build ID, but the vDSO doesn't have a file so the kernel can't add one to its mmap event. Build IDs that are missing from mmap events were previously read when writing the build ID table to the header, but the table isn't written in build ID mmap mode.
This breaks decoding of hardware trace through the vDSO after perf inject -b. Inject adds a build ID for the vDSO, so perf script looks it up in the build ID cache and can't find it:
CS ETM Trace: Debug data not found for address 0xffff95edb310 in [vdso]
Fix it by reading the vDSO's build ID from perf's copy of the vDSO before caching it.
Fixes: 53b00ff358dc ("perf record: Make --buildid-mmap the default") Signed-off-by: James Clark james.clark@linaro.org --- tools/perf/util/build-id.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 02233ef0eaff..cc813f421c9b 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -886,6 +886,18 @@ static int dso__cache_build_id(struct dso *dso, struct machine *machine, char *allocated_name = NULL; int ret = 0;
+ /* + * The kernel can't add the vDSO's build ID to mmap events because it + * doesn't have a file, so read it from the copy that perf made. That + * copy is of the host's vDSO, so it can't be used for guests. + */ + if (is_vdso && machine__is_host(machine) && !dso__has_build_id(dso)) { + struct build_id bid = { .size = 0, }; + + if (filename__read_build_id(name, &bid) > 0) + dso__set_build_id(dso, &bid); + } + if (!dso__has_build_id(dso) || !dso__hit(dso)) return 0;