All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot]  [PATCH] kconfig: add CONFIG_CC_COVERAGE
@ 2018-03-29  7:49 Christian Gmeiner
  2018-04-04  6:31 ` Christian Gmeiner
  2018-04-08 14:30 ` Tom Rini
  0 siblings, 2 replies; 5+ messages in thread
From: Christian Gmeiner @ 2018-03-29  7:49 UTC (permalink / raw)
  To: u-boot

Make it possible to use gcc code coverage analysis.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
---
 .gitignore | 4 ++++
 Kconfig    | 8 ++++++++
 Makefile   | 6 ++++++
 3 files changed, 18 insertions(+)

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..f092f72b25 100644
--- a/Kconfig
+++ b/Kconfig
@@ -59,6 +59,14 @@ config CC_OPTIMIZE_FOR_SIZE
 
 	  This option is enabled by default for U-Boot.
 
+config CC_COVERAGE
+	bool "Enable code coverage analysis"
+	default n
+	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..d06193e8f4 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
 
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH] kconfig: add CONFIG_CC_COVERAGE
  2018-03-29  7:49 [U-Boot] [PATCH] kconfig: add CONFIG_CC_COVERAGE Christian Gmeiner
@ 2018-04-04  6:31 ` Christian Gmeiner
  2018-04-08 14:30 ` Tom Rini
  1 sibling, 0 replies; 5+ messages in thread
From: Christian Gmeiner @ 2018-04-04  6:31 UTC (permalink / raw)
  To: u-boot

Gentle ping..

2018-03-29 9:49 GMT+02:00 Christian Gmeiner <christian.gmeiner@gmail.com>:
> Make it possible to use gcc code coverage analysis.
>
> Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
> ---
>  .gitignore | 4 ++++
>  Kconfig    | 8 ++++++++
>  Makefile   | 6 ++++++
>  3 files changed, 18 insertions(+)
>
> 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..f092f72b25 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -59,6 +59,14 @@ config CC_OPTIMIZE_FOR_SIZE
>
>           This option is enabled by default for U-Boot.
>
> +config CC_COVERAGE
> +       bool "Enable code coverage analysis"
> +       default n
> +       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..d06193e8f4 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
>
> --
> 2.14.3
>



-- 
greets
--
Christian Gmeiner, MSc

https://christian-gmeiner.info

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH] kconfig: add CONFIG_CC_COVERAGE
  2018-03-29  7:49 [U-Boot] [PATCH] kconfig: add CONFIG_CC_COVERAGE Christian Gmeiner
  2018-04-04  6:31 ` Christian Gmeiner
@ 2018-04-08 14:30 ` Tom Rini
  2018-04-09  8:01   ` Christian Gmeiner
  1 sibling, 1 reply; 5+ messages in thread
From: Tom Rini @ 2018-04-08 14:30 UTC (permalink / raw)
  To: u-boot

On Thu, Mar 29, 2018 at 09:49:30AM +0200, Christian Gmeiner wrote:

> Make it possible to use gcc code coverage analysis.
> 
> Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
> ---
>  .gitignore | 4 ++++
>  Kconfig    | 8 ++++++++
>  Makefile   | 6 ++++++
>  3 files changed, 18 insertions(+)
> 
> 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..f092f72b25 100644
> --- a/Kconfig
> +++ b/Kconfig
> @@ -59,6 +59,14 @@ config CC_OPTIMIZE_FOR_SIZE
>  
>  	  This option is enabled by default for U-Boot.
>  
> +config CC_COVERAGE
> +	bool "Enable code coverage analysis"
> +	default n
> +	depends on SANDBOX
> +	help
> +	  Enabling this option will pass "--coverage" to gcc to compile
> +	  and link code instrumented for coverage analysis.

We shouldn't need default n, as that is the normal default.  And why is
this only on SANDBOX?

> +
>  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..d06193e8f4 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

Consistent spacing please, thanks!

-- 
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/20180408/d7d54c9e/attachment.sig>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH] kconfig: add CONFIG_CC_COVERAGE
  2018-04-08 14:30 ` Tom Rini
@ 2018-04-09  8:01   ` Christian Gmeiner
  2018-04-09 12:56     ` Tom Rini
  0 siblings, 1 reply; 5+ messages in thread
From: Christian Gmeiner @ 2018-04-09  8:01 UTC (permalink / raw)
  To: u-boot

Hi

2018-04-08 16:30 GMT+02:00 Tom Rini <trini@konsulko.com>:
> On Thu, Mar 29, 2018 at 09:49:30AM +0200, Christian Gmeiner wrote:
>
>> Make it possible to use gcc code coverage analysis.
>>
>> Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
>> ---
>>  .gitignore | 4 ++++
>>  Kconfig    | 8 ++++++++
>>  Makefile   | 6 ++++++
>>  3 files changed, 18 insertions(+)
>>
>> 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..f092f72b25 100644
>> --- a/Kconfig
>> +++ b/Kconfig
>> @@ -59,6 +59,14 @@ config CC_OPTIMIZE_FOR_SIZE
>>
>>         This option is enabled by default for U-Boot.
>>
>> +config CC_COVERAGE
>> +     bool "Enable code coverage analysis"
>> +     default n
>> +     depends on SANDBOX
>> +     help
>> +       Enabling this option will pass "--coverage" to gcc to compile
>> +       and link code instrumented for coverage analysis.
>
> We shouldn't need default n, as that is the normal default.  And why is
> this only on SANDBOX?
>

The default thing will get fixed in V2. If we want to record code coverage on
real hardware we need to add an infrastructure to store the generated analysis
data. In the sandbox case this information is stored in the local
filesystem (*.gcda).
To get a feeling what may be needs to be done for the real target patch have a
look at:
https://mcuoneclipse.com/2014/12/26/code-coverage-for-embedded-target-with-eclipse-gcc-and-gcov/

My goal is it to get some code coverage data for unit tests that are run in the
sandboxed environment.

Is it okay for you to only cover the sandbox case or do you want/need
the full blown
solution?

>> +
>>  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..d06193e8f4 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
>
> Consistent spacing please, thanks!

Opps.. will be fixed in V2.

-- 
greets
--
Christian Gmeiner, MSc

https://christian-gmeiner.info

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH] kconfig: add CONFIG_CC_COVERAGE
  2018-04-09  8:01   ` Christian Gmeiner
@ 2018-04-09 12:56     ` Tom Rini
  0 siblings, 0 replies; 5+ messages in thread
From: Tom Rini @ 2018-04-09 12:56 UTC (permalink / raw)
  To: u-boot

On Mon, Apr 09, 2018 at 10:01:59AM +0200, Christian Gmeiner wrote:
> Hi
> 
> 2018-04-08 16:30 GMT+02:00 Tom Rini <trini@konsulko.com>:
> > On Thu, Mar 29, 2018 at 09:49:30AM +0200, Christian Gmeiner wrote:
> >
> >> Make it possible to use gcc code coverage analysis.
> >>
> >> Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
> >> ---
> >>  .gitignore | 4 ++++
> >>  Kconfig    | 8 ++++++++
> >>  Makefile   | 6 ++++++
> >>  3 files changed, 18 insertions(+)
> >>
> >> 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..f092f72b25 100644
> >> --- a/Kconfig
> >> +++ b/Kconfig
> >> @@ -59,6 +59,14 @@ config CC_OPTIMIZE_FOR_SIZE
> >>
> >>         This option is enabled by default for U-Boot.
> >>
> >> +config CC_COVERAGE
> >> +     bool "Enable code coverage analysis"
> >> +     default n
> >> +     depends on SANDBOX
> >> +     help
> >> +       Enabling this option will pass "--coverage" to gcc to compile
> >> +       and link code instrumented for coverage analysis.
> >
> > We shouldn't need default n, as that is the normal default.  And why is
> > this only on SANDBOX?
> >
> 
> The default thing will get fixed in V2. If we want to record code coverage on
> real hardware we need to add an infrastructure to store the generated analysis
> data. In the sandbox case this information is stored in the local
> filesystem (*.gcda).
> To get a feeling what may be needs to be done for the real target patch have a
> look at:
> https://mcuoneclipse.com/2014/12/26/code-coverage-for-embedded-target-with-eclipse-gcc-and-gcov/
> 
> My goal is it to get some code coverage data for unit tests that are run in the
> sandboxed environment.
> 
> Is it okay for you to only cover the sandbox case or do you want/need
> the full blown
> solution?

While it would be cool to do this on real hardware, I guess that makes
sense to do in a follow up.  Thanks for explaining!

-- 
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/20180409/7e3e4cb4/attachment.sig>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-04-09 12:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-29  7:49 [U-Boot] [PATCH] kconfig: add CONFIG_CC_COVERAGE Christian Gmeiner
2018-04-04  6:31 ` Christian Gmeiner
2018-04-08 14:30 ` Tom Rini
2018-04-09  8:01   ` Christian Gmeiner
2018-04-09 12:56     ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.