diff --git a/.gitignore b/.gitignore index 29757aa51e32364015a29ceff1deafab02365df3..f1b801579ce7f4969d1268570e13ce8a8df7e194 100644 --- a/.gitignore +++ b/.gitignore @@ -85,3 +85,7 @@ GTAGS *.orig *~ \#*# + +# gcc code coverage files +*.gcda +*.gcno diff --git a/Kconfig b/Kconfig index 6670913799fa9e3033528461769aef26801fb271..67b8c50cbd0116ebcbc43c84bffde0b4cff29786 100644 --- 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 diff --git a/Makefile b/Makefile index bfe115cf18de0e2b2460f5435404c995cdea8952..9eb7e5bf34d8e2173b1f31efbd70d389a60639ca 100644 --- 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