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

perf build: Combine test-dwarf-getlocations into test-libdw

dwarf_getlocations support in libdw is more than 10 years old. Make
libdw imply dwarf_getlocations support and simplify build logic.

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Leo Yan <leo.yan@arm.com>
Cc: Anup Patel <anup@brainfault.org>
Cc: Yang Jihong <yangjihong@bytedance.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Shenlin Liang <liangshenlin@eswincomputing.com>
Cc: Nick Terrell <terrelln@fb.com>
Cc: Guilherme Amadio <amadio@gentoo.org>
Cc: Steinar H. Gunderson <sesse@google.com>
Cc: Changbin Du <changbin.du@huawei.com>
Cc: Alexander Lobakin <aleksander.lobakin@intel.com>
Cc: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Guo Ren <guoren@kernel.org>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Cc: Will Deacon <will@kernel.org>
Cc: James Clark <james.clark@linaro.org>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Chen Pei <cp0613@linux.alibaba.com>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Oliver Upton <oliver.upton@linux.dev>
Cc: Aditya Gupta <adityag@linux.ibm.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-riscv@lists.infradead.org
Cc: Bibo Mao <maobibo@loongson.cn>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Atish Patra <atishp@rivosinc.com>
Cc: Dima Kogan <dima@secretsauce.net>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Dr. David Alan Gilbert <linux@treblig.org>
Cc: linux-csky@vger.kernel.org
Link: https://lore.kernel.org/r/20241017001354.56973-7-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
23580d7b 3034b48a

+15 -33
-2
tools/build/Makefile.feature
··· 31 31 FEATURE_TESTS_BASIC := \ 32 32 backtrace \ 33 33 libdw \ 34 - dwarf_getlocations \ 35 34 dwarf_getcfi \ 36 35 eventfd \ 37 36 fortify-source \ ··· 119 120 120 121 FEATURE_DISPLAY ?= \ 121 122 libdw \ 122 - dwarf_getlocations \ 123 123 glibc \ 124 124 libbfd \ 125 125 libbfd-buildid \
-4
tools/build/feature/Makefile
··· 6 6 test-backtrace.bin \ 7 7 test-bionic.bin \ 8 8 test-libdw.bin \ 9 - test-dwarf_getlocations.bin \ 10 9 test-dwarf_getcfi.bin \ 11 10 test-eventfd.bin \ 12 11 test-fortify-source.bin \ ··· 185 186 endif 186 187 187 188 $(OUTPUT)test-libdw.bin: 188 - $(BUILD) $(DWLIBS) 189 - 190 - $(OUTPUT)test-dwarf_getlocations.bin: 191 189 $(BUILD) $(DWLIBS) 192 190 193 191 $(OUTPUT)test-dwarf_getcfi.bin:
-5
tools/build/feature/test-all.c
··· 42 42 # include "test-libdw.c" 43 43 #undef main 44 44 45 - #define main main_test_dwarf_getlocations 46 - # include "test-dwarf_getlocations.c" 47 - #undef main 48 - 49 45 #define main main_test_eventfd 50 46 # include "test-eventfd.c" 51 47 #undef main ··· 180 184 main_test_gettid(); 181 185 main_test_glibc(); 182 186 main_test_libdw(); 183 - main_test_dwarf_getlocations(); 184 187 main_test_eventfd(); 185 188 main_test_libelf_getphdrnum(); 186 189 main_test_libelf_gelf_getnote();
-13
tools/build/feature/test-dwarf_getlocations.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - #include <stdlib.h> 3 - #include <elfutils/libdw.h> 4 - 5 - int main(void) 6 - { 7 - Dwarf_Addr base, start, end; 8 - Dwarf_Attribute attr; 9 - Dwarf_Op *op; 10 - size_t nops; 11 - ptrdiff_t offset = 0; 12 - return (int)dwarf_getlocations(&attr, offset, &base, &start, &end, &op, &nops); 13 - }
+13 -1
tools/build/feature/test-libdw.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 + #include <stdlib.h> 2 3 #include <dwarf.h> 3 4 #include <elfutils/libdw.h> 4 5 #include <elfutils/libdwfl.h> ··· 23 22 return 0; 24 23 } 25 24 25 + int test_libdw_getlocations(void) 26 + { 27 + Dwarf_Addr base, start, end; 28 + Dwarf_Attribute attr; 29 + Dwarf_Op *op; 30 + size_t nops; 31 + ptrdiff_t offset = 0; 32 + 33 + return (int)dwarf_getlocations(&attr, offset, &base, &start, &end, &op, &nops); 34 + } 35 + 26 36 int main(void) 27 37 { 28 - return test_libdw() + test_libdw_unwind(); 38 + return test_libdw() + test_libdw_unwind() + test_libdw_getlocations(); 29 39 }
+2 -8
tools/perf/Makefile.config
··· 164 164 endif 165 165 FEATURE_CHECK_CFLAGS-libdw := $(LIBDW_CFLAGS) 166 166 FEATURE_CHECK_LDFLAGS-libdw := $(LIBDW_LDFLAGS) $(DWARFLIBS) 167 - FEATURE_CHECK_CFLAGS-dwarf_getlocations := $(LIBDW_CFLAGS) 168 - FEATURE_CHECK_LDFLAGS-dwarf_getlocations := $(LIBDW_LDFLAGS) $(DWARFLIBS) 169 167 FEATURE_CHECK_CFLAGS-dwarf_getcfi := $(LIBDW_CFLAGS) 170 168 FEATURE_CHECK_LDFLAGS-dwarf_getcfi := $(LIBDW_LDFLAGS) $(DWARFLIBS) 171 169 ··· 465 467 else 466 468 ifneq ($(feature-libdw), 1) 467 469 ifndef NO_LIBDW 468 - $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev) 470 + $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.157, disables dwarf support. Please install new elfutils-devel/libdw-dev) 469 471 NO_LIBDW := 1 470 472 endif 471 473 else 472 - ifneq ($(feature-dwarf_getlocations), 1) 473 - $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.157) 474 - else 475 - CFLAGS += -DHAVE_DWARF_GETLOCATIONS_SUPPORT 476 - endif # dwarf_getlocations 474 + CFLAGS += -DHAVE_DWARF_GETLOCATIONS_SUPPORT 477 475 ifneq ($(feature-dwarf_getcfi), 1) 478 476 $(warning Old libdw.h, finding variables at given 'perf probe' point will not work, install elfutils-devel/libdw-dev >= 0.142) 479 477 else