Skip to contentSkip to conversation

Gcov and lcov

PATCH Michal Simek 2 participants 2 messages Aug 25, 2009 – Aug 26, 2009 Documentation

lore
Share & tools
lore
#0 lore raw

Hi All,

I am trying to run gcov to see source code coverage.

First of all there should be DEBUG_FS instead of DEBUG in documentation.

Documentation/gcov.txt +1 -1
index 40ec633..e7ca647 100644
@@ -47,7 +47,7 @@ Possible uses:
 
 Configure the kernel with:
 
-        CONFIG_DEBUGFS=y
+        CONFIG_DEBUG_FS=y
         CONFIG_GCOV_KERNEL=y
 
 

I am missing any option to be possible to stop capture coveradge data. I am running in on Microblaze and it takes me a lot of time to grap all gcda data from debugfs.

I can't run gcov on Microblaze that's why I have to run option b in doc "gcov is run on the BUILD machine"

I copied gcda to kernel source code and currently I am able to generate statistic for every file.
That copy I have to do because I need to connect counters value with source file

[root@monstr linux-monstr_eu-commit]# mb-linux-gcov -o arch/microblaze/kernel/ heartbeat.c
File 'arch/microblaze/kernel/heartbeat.c'
Lines executed:100.00% of 24 arch/microblaze/kernel/heartbeat.c:creating 'heartbeat.c.gcov'

File '/home/projects/xils/_full/software/linux-monstr_eu-commit/arch/microblaze/include/asm/io.h' Lines executed:100.00% of 3 /home/projects/xils/_full/software/linux-monstr_eu-commit/arch/microblaze/include/asm/io.h:creating 'io.h.gcov'

And content of that file

[root@monstr linux-monstr_eu-commit]# cat heartbeat.c.gcov

        -:    0:Source:arch/microblaze/kernel/heartbeat.c
        -:    0:Graph:arch/microblaze/kernel/heartbeat.gcno
        -:    0:Data:arch/microblaze/kernel/heartbeat.gcda
        -:    0:Runs:0
        -:    0:Programs:0
        -:    1:/*
        -:    2: * Copyright (C) 2007-2009 Michal Simek <[email protected]>
        -:    3: * Copyright (C) 2007-2009 PetaLogix
        -:    4: * Copyright (C) 2006 Atmark Techno, Inc.
        -:    5: *
        -:    6: * This file is subject to the terms and conditions of
the GNU General Public
        -:    7: * License. See the file "COPYING" in the main directory
of this archive
        -:    8: * for more details.
        -:    9: */
        -:   10:
        -:   11:#include <linux/sched.h>
        -:   12:#include <linux/io.h>
        -:   13:
        -:   14:#include <asm/setup.h>
        -:   15:#include <asm/page.h>
        -:   16:#include <asm/prom.h>
        -:   17:
        -:   18:static unsigned int base_addr;
        -:   19:
        -:   20:void heartbeat(void)
    69918:   21:{
        -:   22:        static unsigned int cnt, period, dist;
        -:   23:
    69918:   24:        if (base_addr) {
    71379:   25:                if (cnt == 0 || cnt == dist)
     1461:   26:                        out_be32(base_addr, 1);
    68457:   27:                else if (cnt == 7 || cnt == dist + 7)
     1460:   28:                        out_be32(base_addr, 0);
        -:   29:
    69918:   30:                if (++cnt > period) {
      730:   31:                        cnt = 0;
        -:   32:                        /*
        -:   33:                         * The hyperbolic function below

modifies the heartbeat
-: 34: * period length in dependency of t
....

Then I would like to use lcov and generate html sites. This could be possible but I haven't found
a way how to do it.

I used lcov --capture --directory . --output-file out

There is this mishmash in version string /home/projects/xils/_full/software/linux-monstr_eu-commit/kernel/spinlock.gcno:version '401*', prefer '401p' /home/projects/xils/_full/software/linux-monstr_eu-commit/kernel/spinlock.gcda:version '401*', prefer version '401p'

and then genhtml out which end with fault because my out file contain wrong patches where is part of path repeated. arch/microblaze/kernel/arch/microblaze/kernel

It is a little bit mess but I hope that you understand what I mean. If not please let me know.
Can you give me any hint how to do it?

Thanks,
Michal

Signature · 3 lines
Michal Simek, Ing. (M.Eng)
PetaLogix - Linux Solutions for a Reconfigurable World
w: www.petalogix.com p: +61-7-30090663,+42-0-721842854 f: +61-7-30090663
#1 lore raw

Hi,

Documentation/gcov.txt Possible uses: · line 51

Quoted 12 lines · Michal Simek

First of all there should be DEBUG_FS instead of DEBUG in documentation.

Documentation/gcov.txt +1 -1
index 40ec633..e7ca647 100644
@@ -47,7 +47,7 @@ Possible uses:
 
 Configure the kernel with:
 
-        CONFIG_DEBUGFS=y
+        CONFIG_DEBUG_FS=y
         CONFIG_GCOV_KERNEL=y

Thanks for pointing this out. This was reported before and will be fixed in a future kernel release.

Quoted 1 line

I am missing any option to be possible to stop capture coveradge data.

There is currently no way to turn gcov-based profiling off during run-time.

Quoted 2 lines

I am running in on Microblaze and it takes me a lot of time to grap all gcda data from debugfs.

If you don't need coverage data for all of the kernel source, you can turn off option CONFIG_GCOV_PROFILE_ALL and only enable profiling for those directories or files which are of interest to you. This should greatly reduce the number of files that you need to copy and also the overall kernel-slowdown.

See the help text for configuration option CONFIG_GCOV_KERNEL for a description of how to turn profiling on for single directories or files.

Quoted 12 lines

Then I would like to use lcov and generate html sites. This could be possible but I haven't found
a way how to do it.

I used lcov --capture --directory . --output-file out

There is this mishmash in version string /home/projects/xils/_full/software/linux-monstr_eu-commit/kernel/spinlock.gcno:version '401*', prefer '401p' /home/projects/xils/_full/software/linux-monstr_eu-commit/kernel/spinlock.gcda:version '401*', prefer version '401p'

Quoted 3 lines

and then genhtml out which end with fault because my out file contain wrong patches where is part of path repeated. arch/microblaze/kernel/arch/microblaze/kernel

The warning messages you are seeing indicate that the version of gcov used for analyzing and the version of gcc used for compiling differ. You need to specify the correct gcov tool binary (the one that comes with the compiler used to compile the kernel) by using lcov's --gcov-tool option.

Also current lcov releases only contain support for the gcov-kernel infrastructure as provided by the external gcov-kernel patch. I added support for the new upstream infrastructure to the CVS version[*] of lcov.

Using the CVS version, you can do the following:

On the test machine:

	lcov -c --to-package coveragedata

This will create a file coveragedata which includes all .gcda files. Copy this file to the build machine and do:

	lcov -c --from-package coveragedata -o data.info

This will allow you to do the actual analysis of coverage data on the build machine. See the man page for lcov for a detailed description of this approach.

Regards,
Peter Oberparleiter

[*] See http://ltp.sourceforge.net/coverage/lcov.php for instructions on how to obtain the CVS version of lcov