From f2b3170c3b80d58c7d0a5afc7ade3ab7d8dd3b7c Mon Sep 17 00:00:00 2001 From: David Sterba Date: Tue, 11 Jul 2023 16:01:13 +0200 Subject: [PATCH] btrfs-progs: build: add support for gcov With 'make D=gcov' the files are built with gcov support. After running the workload, the results can be viewed by 'gcov file.c' or by lcov+genhtml. Signed-off-by: David Sterba --- Makefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Makefile b/Makefile index cc6db02b..30d48ef2 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,7 @@ # tsan - enable thread sanitizer compiler feature # ubsan - undefined behaviour sanitizer compiler feature # bcheck - extended build checks +# gcov - enable GCOV support during build # W=123 build with warnings (default: off) # DEBUG_CFLAGS additional compiler flags for debugging build # EXTRA_CFLAGS additional compiler flags @@ -283,6 +284,11 @@ ifeq ("$(origin D)", "command line") DEBUG_LDFLAGS_INTERNAL = $(DEBUG_LDFLAGS_DEFAULT) $(DEBUG_LDFLAGS) endif +ifneq (,$(findstring gcov,$(D))) + DEBUG_CFLAGS_INTERNAL += -fprofile-arcs -ftest-coverage --coverage + DEBUG_LDFLAGS_INTERNAL += -fprofile-generate --coverage +endif + ifneq (,$(findstring verbose,$(D))) DEBUG_CFLAGS_INTERNAL += -DDEBUG_VERBOSE_ERROR=1 endif @@ -840,6 +846,7 @@ clean: $(CLEANDIRS) crypto/*.o crypto/.deps/*.o.d \ tune/*.o tune/.deps/*.o.d \ libbtrfs/*.o libbtrfs/.deps/*.o.d \ + *.gcno *.gcda *.gcov */*.gcno */*.gcda */*/.gcov \ ioctl-test quick-test library-test library-test-static \ mktables btrfs.static mkfs.btrfs.static fssum \ btrfs.box btrfs.box.static json-formatter-test \