diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c index e0881b0ac38f..5555f5dcefe4 100644 --- a/tools/perf/builtin-buildid-list.c +++ b/tools/perf/builtin-buildid-list.c @@ -87,6 +87,7 @@ static bool dso__skip_buildid(struct dso *dso, int with_hits) static int perf_session__list_build_ids(bool force, bool with_hits) { struct perf_session *session; + bool has_auxtrace, has_build_id; struct perf_data data = { .path = input_name, .mode = PERF_DATA_MODE_READ, @@ -118,11 +119,19 @@ static int perf_session__list_build_ids(bool force, bool with_hits) * We take all buildids when the file contains AUX area tracing data * because we do not decode the trace because it would take too long. */ - if (!perf_data__is_pipe(&data) && - perf_header__has_feat(&session->header, HEADER_AUXTRACE)) + has_auxtrace = !perf_data__is_pipe(&data) && + perf_header__has_feat(&session->header, HEADER_AUXTRACE); + has_build_id = perf_header__has_feat(&session->header, HEADER_BUILD_ID); + + if (has_auxtrace) with_hits = false; - if (!perf_header__has_feat(&session->header, HEADER_BUILD_ID)) + /* + * Without a build-ID header, the event stream is processed below to find + * build IDs in MMAP2 records. For AUX data keep all DSOs because the trace + * is not decoded and consequently none of them can be marked as hit. + */ + if (!has_build_id && !has_auxtrace) with_hits = true; if (zstd_init(&(session->zstd_data), 0) < 0) @@ -132,7 +141,7 @@ static int perf_session__list_build_ids(bool force, bool with_hits) * in pipe-mode, the only way to get the buildids is to parse * the record stream. Buildids are stored as RECORD_HEADER_BUILD_ID */ - if (with_hits || perf_data__is_pipe(&data)) + if (with_hits || perf_data__is_pipe(&data) || !has_build_id) perf_session__process_events(session); perf_session__fprintf_dsos_buildid(session, stdout, dso__skip_buildid, with_hits);