embedded-gcov icon indicating copy to clipboard operation
embedded-gcov copied to clipboard

GCC 12.2 changes

Open drgrandios opened this issue 1 year ago • 5 comments

Hi,

I tried to make your code run using GCC 12.2 (RISCV target).

It seems that the GCC people changed the internal gcov_info struct - between stamp and filename there is a new additional checksum field.

See here: https://github.com/gcc-mirror/gcc/blob/4d1e4ce986f84a853531ac9c51e37d101e28d15c/libgcc/libgcov.h#L232

After adding the checksum field, the lib worked also using the newer GCC.

drgrandios avatar Jun 06 '23 07:06 drgrandios

... unfortunately have to add that it now builds fine and spits out results, but the result evaluation ends up in zero line coverage all the time. Need to investigate a bit more....

drgrandios avatar Jun 06 '23 12:06 drgrandios

Besides having an additional checksum field in the gcov_info struct, the .gcda files also have this checksum added to their header, see this line:

https://github.com/gcc-mirror/gcc/blob/4d1e4ce986f84a853531ac9c51e37d101e28d15c/libgcc/libgcov-driver.c#LL519C50-L519C50

drgrandios avatar Jun 07 '23 04:06 drgrandios

Okay, eventually found the third difference:

The definition of GCOV_TAG_FUNCTION_LENGTH and GCOV_TAG_COUNTER_LENGTH has changed from words to bytes, see here:

https://github.com/gcc-mirror/gcc/blob/4d1e4ce986f84a853531ac9c51e37d101e28d15c/gcc/gcov-io.h#L258

After correction of these values, gcov & lcov could successfully create a valid coverage report.

Summary:

  • add checksum field to gcov_info
  • write checksum field after stamp when generating gcda header
  • correct sizes of GCOV_TAG_FUNCTION_LENGTH and GCOV_TAG_COUNTER_LENGTH

Not sure if this of interest for @KenPetersJPL ?

drgrandios avatar Jun 07 '23 10:06 drgrandios

With the modifications pointed out by @drgrandios I managed to make a cross-target GCOV work with GCC14. Given that GCC14 adds actual MC/DC coverage out of the box, this is a high-value ticket.

GigAnon avatar Jun 24 '24 15:06 GigAnon

@drgrandios You are the boss!

@GigAnon I am getting this error:

$ lcov --capture --initial --directory . -o coverage.info
Capturing coverage data from .
Found gcov version: 10.2.1
Using intermediate gcov format
Scanning . for .gcno files ...
Found 4 graph files in .
Processing gcov_public.c.gcno
/home/user/obj/gcov_public.c.gcno:version 'B22*', prefer 'B02*'
geninfo: ERROR: GCOV failed for /home/user/obj/gcov_public.c.gcno:version!

Does anyone know how to resolve this? I read in https://github.com/nasa-jpl/embedded-gcov/blob/main/scripts/lcov_baseline.sh that the gcov tool has to be compiled with gcc arm none eabi (in my case as I have a Cortex M7). Did you really have to do this? Where do I get the source of gcov?

Edit: Okay, I had to install the latest lcov (version 2.1) from here: https://github.com/linux-test-project/lcov/releases and then supply the property --gcov-tool to use bin/arm-none-eabi-gcov. Then I used lcov-2.1/bin/genhtml and everything worked fine!

Bresenham avatar Aug 28 '24 11:08 Bresenham