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

perf test: Fix a compile error on pe-file-parsing.c

The dso__find_symbol_by_name() should be have idx pointer argument.
Found during the build-test.

$ make build-test
...
CC /tmp/tmp.6JwPK1xbWG/tests/pe-file-parsing.o
tests/pe-file-parsing.c: In function ‘run_dir’:
tests/pe-file-parsing.c:64:15: error: too few arguments to function ‘dso__find_symbol_by_name’
64 | sym = dso__find_symbol_by_name(dso, "main");
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from tests/pe-file-parsing.c:16:
/usr/local/google/home/namhyung/project/linux/tools/perf/util/symbol.h:135:16: note: declared here
135 | struct symbol *dso__find_symbol_by_name(struct dso *dso, const char *name, size_t *idx);
| ^~~~~~~~~~~~~~~~~~~~~~~~

Fixes: 259dce914e93 ("perf symbol: Remove symbol_name_rb_node")
Acked-by: Ian Rogers <irogers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20230627063257.549005-1-namhyung@kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

+12 -4
+10 -3
tools/perf/Makefile.config
··· 315 315 316 316 FEATURE_CHECK_LDFLAGS-libaio = -lrt 317 317 318 + FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl 319 + FEATURE_CHECK_LDFLAGS-disassembler-init-styled = -lbfd -lopcodes -ldl 320 + 318 321 CORE_CFLAGS += -fno-omit-frame-pointer 319 322 CORE_CFLAGS += -ggdb3 320 323 CORE_CFLAGS += -funwind-tables ··· 347 344 endif 348 345 349 346 ifeq ($(FEATURES_DUMP),) 350 - # We will display at the end of this Makefile.config, using $(call feature_display_entries), 351 - # as we may retry some feature detection here. 347 + # We will display at the end of this Makefile.config, using $(call feature_display_entries) 348 + # As we may retry some feature detection here, see the disassembler-four-args case, for instance 352 349 FEATURE_DISPLAY_DEFERRED := 1 353 350 include $(srctree)/tools/build/Makefile.feature 354 351 else ··· 910 907 911 908 ifeq ($(feature-libbfd-liberty), 1) 912 909 EXTLIBS += -lbfd -lopcodes -liberty 910 + FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -ldl 911 + FEATURE_CHECK_LDFLAGS-disassembler-init-styled += -liberty -ldl 913 912 else 914 913 ifeq ($(feature-libbfd-liberty-z), 1) 915 914 EXTLIBS += -lbfd -lopcodes -liberty -lz 915 + FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -lz -ldl 916 + FEATURE_CHECK_LDFLAGS-disassembler-init-styled += -liberty -lz -ldl 916 917 endif 917 918 endif 918 919 $(call feature_check,disassembler-four-args) ··· 1340 1333 1341 1334 # re-generate FEATURE-DUMP as we may have called feature_check, found out 1342 1335 # extra libraries to add to LDFLAGS of some other test and then redo those 1343 - # tests. 1336 + # tests, see the block about libbfd, disassembler-four-args, for instance. 1344 1337 $(shell rm -f $(FEATURE_DUMP_FILENAME)) 1345 1338 $(foreach feat,$(FEATURE_TESTS),$(shell echo "$(call feature_assign,$(feat))" >> $(FEATURE_DUMP_FILENAME)))
+2 -1
tools/perf/tests/pe-file-parsing.c
··· 34 34 struct dso *dso; 35 35 struct symbol *sym; 36 36 int ret; 37 + size_t idx; 37 38 38 39 scnprintf(filename, PATH_MAX, "%s/pe-file.exe", d); 39 40 ret = filename__read_build_id(filename, &bid); ··· 62 61 TEST_ASSERT_VAL("Failed to load symbols", ret == 0); 63 62 64 63 dso__sort_by_name(dso); 65 - sym = dso__find_symbol_by_name(dso, "main"); 64 + sym = dso__find_symbol_by_name(dso, "main", &idx); 66 65 TEST_ASSERT_VAL("Failed to find main", sym); 67 66 dso__delete(dso); 68 67