Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf buildid-cache: Don't skip 16-byte build-ids

lsdir_bid_tail_filter() ignored any build-id that wasn't exactly 20
bytes. This worked only for SHA-1 build-ids. The build-id for a PE file
is always a 16-byte GUID and ELF files can also have MD5 or UUID
build-ids.

This fix changes the filter to allow build-ids between 16 and 20 bytes.

Signed-off-by: Nicholas Fraser <nfraser@codeweavers.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Frank Ch. Eigler <fche@redhat.com>
Cc: Huw Davies <huw@codeweavers.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Kim Phillips <kim.phillips@amd.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Remi Bernon <rbernon@codeweavers.com>
Cc: Song Liu <songliubraving@fb.com>
Cc: Tommi Rantala <tommi.t.rantala@nokia.com>
Cc: Ulrich Czekalla <uczekalla@codeweavers.com>
Link: http://lore.kernel.org/lkml/597788e4-661d-633f-857c-3de700115d02@codeweavers.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Nicholas Fraser and committed by
Arnaldo Carvalho de Melo
3027ce36 206236d3

+6 -3
+3 -2
tools/perf/util/build-id.c
··· 448 448 int i = 0; 449 449 while (isxdigit(d->d_name[i]) && i < SBUILD_ID_SIZE - 3) 450 450 i++; 451 - return (i == SBUILD_ID_SIZE - 3) && (d->d_name[i] == '\0'); 451 + return (i >= SBUILD_ID_MIN_SIZE - 3) && (i <= SBUILD_ID_SIZE - 3) && 452 + (d->d_name[i] == '\0'); 452 453 } 453 454 454 455 struct strlist *build_id_cache__list_all(bool validonly) ··· 491 490 } 492 491 strlist__for_each_entry(nd2, linklist) { 493 492 if (snprintf(sbuild_id, SBUILD_ID_SIZE, "%s%s", 494 - nd->s, nd2->s) != SBUILD_ID_SIZE - 1) 493 + nd->s, nd2->s) > SBUILD_ID_SIZE - 1) 495 494 goto err_out; 496 495 if (validonly && !build_id_cache__valid_id(sbuild_id)) 497 496 continue;
+3 -1
tools/perf/util/build-id.h
··· 2 2 #ifndef PERF_BUILD_ID_H_ 3 3 #define PERF_BUILD_ID_H_ 1 4 4 5 - #define BUILD_ID_SIZE 20 5 + #define BUILD_ID_SIZE 20 /* SHA-1 length in bytes */ 6 + #define BUILD_ID_MIN_SIZE 16 /* MD5/UUID/GUID length in bytes */ 6 7 #define SBUILD_ID_SIZE (BUILD_ID_SIZE * 2 + 1) 8 + #define SBUILD_ID_MIN_SIZE (BUILD_ID_MIN_SIZE * 2 + 1) 7 9 8 10 #include "machine.h" 9 11 #include "tool.h"