diff mbox series

[U-Boot,v2] kconfig: add CONFIG_CC_COVERAGE

Message ID 20180409151145.21056-1-christian.gmeiner@gmail.com
State Accepted
Commit 52ff8020d02f312364ceaf0b1114759d3a1f357b
Delegated to: Tom Rini
Headers show
Series [U-Boot,v2] kconfig: add CONFIG_CC_COVERAGE | expand

Commit Message

Christian Gmeiner April 9, 2018, 3:11 p.m. UTC
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>
---
 .gitignore | 4 ++++
 Kconfig    | 7 +++++++
 Makefile   | 6 ++++++
 3 files changed, 17 insertions(+)

Comments

Tom Rini April 10, 2018, 2:08 p.m. UTC | #1
On Mon, Apr 09, 2018 at 05:11:45PM +0200, Christian Gmeiner wrote:

> 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>
Tom Rini April 13, 2018, 9:09 p.m. UTC | #2
On Mon, Apr 09, 2018 at 05:11:45PM +0200, Christian Gmeiner wrote:

> 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>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/.gitignore b/.gitignore
index 29757aa51e..f1b801579c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -85,3 +85,7 @@  GTAGS
 *.orig
 *~
 \#*#
+
+# gcc code coverage files
+*.gcda
+*.gcno
diff --git a/Kconfig b/Kconfig
index 6670913799..67b8c50cbd 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 5fa14789d9..5ca695650d 100644
--- a/Makefile
+++ b/Makefile
@@ -720,6 +720,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