Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running gcov on shared library from python script

I am facing an issue with running gcov on shared library from python script.

I have the following scenario where i build my library:

  1. Compile a set of files (file1.c, file2.c) into a statically linked lib(.a). I use ar utility to do this and all the files are compiled using following options:

    -static -fprofile-arcs -ftest-coverage -coverage

  2. build a .so file using some other files (say file3.c) and the above specified .a file. I use the same options again while compiling and linking.

  3. Load the .so in python script and execute.

Issue : The coverage file that is generated contains code coverage only for file3.c. Files that are part of the .a library are not shown in the coverage report.

Am i missing any option while linking .a here.

like image 431
Dexter Avatar asked Nov 25 '22 11:11

Dexter


1 Answers

Found out the issue. I was not picking up all the .gcda files for generating the report. Use -object-directory option to search for all gcda files.

GCOV man page

like image 183
Dexter Avatar answered Dec 20 '22 04:12

Dexter