Skip to contentSkip to conversation

kconfig: add CONFIG_CC_COVERAGE

PATCH New Christian Gmeiner 2 participants 3 messages Apr 9, 2018 – Apr 13, 2018 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 kconfig: add CONFIG_CC_COVERAGE

Make it possible to use gcc code coverage analysis.

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

---
 .gitignore | 4 ++++
 Kconfig    | 7 +++++++
 Makefile   | 6 ++++++
 3 files changed, 17 insertions(+)
.gitignore +4 -0
index 29757aa51e..f1b801579c 100644
@@ -85,3 +85,7 @@ GTAGS
 *.orig
 *~
 \#*#
+
+# gcc code coverage files
+*.gcda
+*.gcno
Kconfig +7 -0
index 6670913799..67b8c50cbd 100644
@@ -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
Makefile +6 -0
index 5fa14789d9..5ca695650d 100644
@@ -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
 
Signature · 1 line
2.14.3
#1 lore raw

PATCH v2 1/1 kconfig: add CONFIG_CC_COVERAGE

Quoted 7 lines · Christian Gmeiner

Make it possible to use gcc code coverage analysis.

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

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180410/ee58f23c/attachment.sig>
#2 lore raw

PATCH v2 1/1 kconfig: add CONFIG_CC_COVERAGE

In reply to Christian Gmeiner
Quoted 8 lines · Christian Gmeiner

Make it possible to use gcc code coverage analysis.

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

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180413/027f2bd7/attachment.sig>