Gcov support in Covoar

Joel Sherrill joel at rtems.org
Fri Jul 6 18:20:16 UTC 2018


On Thu, Jul 5, 2018, 3:31 PM Vijay Kumar Banerjee <vijaykumar9597 at gmail.com>
wrote:

> I think that the whole gcov support needs to be reworked.
>

I am unsure the scope of what you have in mind.


> I was looking into how llvm outputs their gcov data in gcda file
> format here
> https://github.com/llvm-mirror/compiler-rt/blob/master/lib/profile/
> GCDAProfiling
>
> <https://github.com/llvm-mirror/compiler-rt/blob/master/lib/profile/GCDAProfiling.c>
>

For normal native coverage runs, the program itself is instrumented and
writes "records" into a buffer as it runs. On program exit, the records are
written to the gcda file.

Running cross, we don't want the object instrumented and nothing
can be written at program exit.

<https://github.com/llvm-mirror/compiler-rt/blob/master/lib/profile/GCDAProfiling.c>
>
> I need some help in understanding the workflow of how covoar
> gets the trace input and how that is dumped into a gcda file.
>

This is a purely logical description.

Based on the analysis before the point the gcov generation is reached,
you know what lines of code have been executed. This is 0/1 information
not count which might be useful for profiling in the future.

Each line is part of a basic block or arc. I am assuming that the gcno
file gives us information on the basic blocks/arcs. covoar uses this
information to figure out which basic block each covered instruction
range represents. Then it writes the corresponding gcda record for
that executed range.

That looks like all the "generate gcov data" block of code is doing
in covoar.cc.

NOTE: Every gcno file has to be processed. I assume that this code
has a loop buried under it somewhere.


>
> What files are involved in the process (other than GcovData.cc and
> GcovFunctionData.cc ) and what are their roles ?
>

That should be it from what I can tell.  You already have the
entire set of data on what was executed. This is just a translation
pass to saw "line x of file Y was executed". That corresponds to
some piece of data in the gcno file and that is used to write the
data into the gcda file which says that range was executed.

We may need Martin to help us with the details of mapping source file/line
to gcno data to gcda data but that's it.

>
> I feel that this is very difficult to be able to do the whole work within
> the GSoC period and the work will go on post GSoC as well.
> So we need to set milestones specific to GSoC and then continue
> from there post GSoC.
>

:) It's understandable. Let's just keep pushing and continue as needed.

This should just be a matter of threading the pieces of information
together.

--joel


>
> On 5 July 2018 at 00:50, Joel Sherrill <joel at rtems.org> wrote:
>
>>
>>
>> On Wed, Jul 4, 2018, 1:46 PM Vijay Kumar Banerjee <
>> vijaykumar9597 at gmail.com> wrote:
>>
>>> On 4 July 2018 at 22:37, Joel Sherrill <joel at rtems.org> wrote:
>>>
>>>>
>>>>
>>>> On Wed, Jul 4, 2018, 3:06 AM Chris Johns <chrisj at rtems.org> wrote:
>>>>
>>>>>
>>>>>
>>>>> On 4/7/18 5:55 pm, Vijay Kumar Banerjee wrote:
>>>>> > On 4 July 2018 at 13:09, Chris Johns <chrisj at rtems.org
>>>>> > <mailto:chrisj at rtems.org>> wrote:
>>>>> >
>>>>> >     On 4/7/18 5:38 pm, Chris Johns wrote:
>>>>> >     > On 4/7/18 4:52 pm, Vijay Kumar Banerjee wrote:
>>>>> >     >>
>>>>> >     >> I'm starting this thread for discussions on the gcov support
>>>>> >     >> in covoar.
>>>>> >     >>
>>>>> >     >> Current status is that the code in it (like in GcovData.cc)
>>>>> remained untouched
>>>>> >     >> for a long time and it had not been updated after the source
>>>>> tree reorganization
>>>>> >     >> which is why it runs into segmentation
>>>>> >     >> fault while trying to find the source files.
>>>>> >     >>
>>>>> >     >> Joel was suggesting to copy the file gcov-io.h from the gcc
>>>>> >     >> source after a license discussion here.
>>>>> >     >
>>>>> >     > What license the file's license?
>>>>> >
>>>>> >     Sorry .. What is the file's license?
>>>>> >
>>>>> > GPL version 3
>>>>>
>>>>> This license is not suitable.
>>>>>
>>>>
>>>> It has the runtime exception and is the only file that defines the
>>>> format of gcno and (need to double-check) gcda file. It does not
>>>> contaminate anything.
>>>>
>>>> I don't see anyway to interpret gcno or write gcda data otherwise.
>>>>
>>>> How does llvm address this? Don't that have the same issue?
>>>>
>>>> llvm defines it in GCOV.h file in llvm/ProfileData/ under the license
>>> it's mentioned there that it's distributed under University of Illinois
>>> Open Source License
>>> https://github.com/llvm-mirror/llvm/blob/master/
>>> include/llvm/ProfileData/GCOV.h
>>> <https://github.com/llvm-mirror/llvm/blob/master/include/llvm/ProfileData/GCOV.h>
>>>
>>
>> That would be the preferred way to get this header. Is it technically
>> acceptable?
>>
>> Chris.. license acceptable to you?
>>
>>>
>>> Ultimately we have two file formats that we have to deal with that GCC
>>>> for sure defines and llvm might also.
>>>>
>>>>
>>>>> >     > We are aiming to have all code under the RTEMS Tools under a
>>>>> BSD or compatible
>>>>> >     > license. Are there other options that have a more suitable
>>>>> license?
>>>>>
>>>>
>>>> Llvm would be the only option but this has the rules time exception
>>>> like the RTEMS historical license so it non-viral.
>>>>
>>>> A hack would be to ensure they are installed with the RTEMS GCC by the
>>>> RSB. But that would be lifting a file out of the GCC source and  one from
>>>> the build tree that are normally not installed. We could ask about GCC
>>>> doing that.
>>>>
>>>> >     >
>>>>> >     > Also, could you please explain how gcov fits into the coverage
>>>>> testing?
>>>>> >     >
>>>>> >
>>>>> > gcov is a test coverage program by gcc that generates
>>>>> statement-by-statement
>>>>> > profiling.
>>>>> > (https://gcc.gnu.org/onlinedocs/gcc/Gcov-Intro.html)
>>>>>
>>>>> Yes.
>>>>>
>>>>> > once we're able to generate gcov reports we can run graphical tools
>>>>> like lcov or
>>>>> > gcovr to generate html and xml reports with detailed coverage data.
>>>>> > an example of lcov report:
>>>>> > http://ltp.sourceforge.net/coverage/lcov/output/example/
>>>>> methods/iterate.c.gcov.html
>>>>> >
>>>>>
>>>>> Do you want to export gcov files from the other trace formats we
>>>>> handle?
>>>>>
>>>>
>>>> Gcov reads gcda files for execution information. Rather than the
>>>> executable being instrumented and writing this during execution (libgcov),
>>>> covoar generates gcda files for unmodified executables using simulator
>>>> trace information. But you have to read gcno files and write gcda files.
>>>>
>>>>
>>>>
>>>>> How does this fit into the RTEMS Tester tool?
>>>>>
>>>>
>>>> If you want to run gcov or lcov on uninstrumented executables, then
>>>> covoar has to read gcno and write gcda files. And we have to then run gcov
>>>> or lcov as normal.
>>>>
>>>> It is the path to another report format.
>>>>
>>>>>
>>>>> Chris
>>>>> _______________________________________________
>>>>> devel mailing list
>>>>> devel at rtems.org
>>>>> http://lists.rtems.org/mailman/listinfo/devel
>>>>
>>>>
>>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20180706/7705ec68/attachment-0002.html>


More information about the devel mailing list