kconfig: add CONFIG_CC_COVERAGE
authorChristian Gmeiner <christian.gmeiner@gmail.com>
Mon, 9 Apr 2018 15:11:45 +0000 (17:11 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 13 Apr 2018 17:02:50 +0000 (13:02 -0400)
Make it possible to use gcc code coverage analysis.

v1 -> v2:
 - Kconfig: remove not needed 'default n'
 - Makefile: use consistent spacing

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
.gitignore
Kconfig
Makefile

index 29757aa51e32364015a29ceff1deafab02365df3..f1b801579ce7f4969d1268570e13ce8a8df7e194 100644 (file)
@@ -85,3 +85,7 @@ GTAGS
 *.orig
 *~
 \#*#
+
+# gcc code coverage files
+*.gcda
+*.gcno
diff --git a/Kconfig b/Kconfig
index 6670913799fa9e3033528461769aef26801fb271..67b8c50cbd0116ebcbc43c84bffde0b4cff29786 100644 (file)
--- a/Kconfig
+++ b/Kconfig
@@ -59,6 +59,13 @@ config CC_OPTIMIZE_FOR_SIZE
 
          This option is enabled by default for U-Boot.
 
+config CC_COVERAGE
+       bool "Enable code coverage analysis"
+       depends on SANDBOX
+       help
+         Enabling this option will pass "--coverage" to gcc to compile
+         and link code instrumented for coverage analysis.
+
 config DISTRO_DEFAULTS
        bool "Select defaults suitable for booting general purpose Linux distributions"
        default y if ARCH_SUNXI || TEGRA
index bfe115cf18de0e2b2460f5435404c995cdea8952..9eb7e5bf34d8e2173b1f31efbd70d389a60639ca 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -725,6 +725,12 @@ else
 PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(c_flags) -print-libgcc-file-name`) -lgcc
 endif
 PLATFORM_LIBS += $(PLATFORM_LIBGCC)
+
+ifdef CONFIG_CC_COVERAGE
+KBUILD_CFLAGS += --coverage
+PLATFORM_LIBGCC += -lgcov
+endif
+
 export PLATFORM_LIBS
 export PLATFORM_LIBGCC