Skip to content

Commit 251083b

Browse files
committed
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 <dsterba@suse.com>
1 parent c1d3af6 commit 251083b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
# tsan - enable thread sanitizer compiler feature
3131
# ubsan - undefined behaviour sanitizer compiler feature
3232
# bcheck - extended build checks
33+
# gcov - enable GCOV support during build
3334
# W=123 build with warnings (default: off)
3435
# DEBUG_CFLAGS additional compiler flags for debugging build
3536
# EXTRA_CFLAGS additional compiler flags
@@ -284,6 +285,11 @@ ifeq ("$(origin D)", "command line")
284285
DEBUG_LDFLAGS_INTERNAL = $(DEBUG_LDFLAGS_DEFAULT) $(DEBUG_LDFLAGS)
285286
endif
286287

288+
ifneq (,$(findstring gcov,$(D)))
289+
DEBUG_CFLAGS_INTERNAL += -fprofile-arcs -ftest-coverage --coverage
290+
DEBUG_LDFLAGS_INTERNAL += -fprofile-generate --coverage
291+
endif
292+
287293
ifneq (,$(findstring verbose,$(D)))
288294
DEBUG_CFLAGS_INTERNAL += -DDEBUG_VERBOSE_ERROR=1
289295
endif
@@ -841,6 +847,7 @@ clean: $(CLEANDIRS)
841847
crypto/*.o crypto/.deps/*.o.d \
842848
tune/*.o tune/.deps/*.o.d \
843849
libbtrfs/*.o libbtrfs/.deps/*.o.d \
850+
*.gcno *.gcda *.gcov */*.gcno */*.gcda */*/.gcov \
844851
ioctl-test quick-test library-test library-test-static \
845852
mktables btrfs.static mkfs.btrfs.static fssum \
846853
btrfs.box btrfs.box.static json-formatter-test \

0 commit comments

Comments
 (0)