I am new to a c/c++ and I have recently came across coverity static analysis tool and at the build end I can see that it says number of files that got emitted and it will also have a percentage of files emitted.
I just want to know how it concluded that this is the percentage. Because if we can calculate the total files they are way more
Please help me if somebody has any Idea on this.
When cov-build
reports its final status, something like:
933 C/C++ compilation units (62%) are ready for analysis
(example taken from this random build-log.txt
), it means that the Coverity compiler (cov-emit
) successfully compiled 933 files. The percentage 62% means there was a larger number of compilation attempts (in this case, approximately 1504), but 1504-933=511 of them failed to compile, and hence will not be analyzed.
To deal with failed compilation, look in build-log.txt
for "[ERROR]". You will see lines like:
[ERROR] 5 errors detected in the compilation of "../src/tests/common_check.c".
with specific errors listed above that line. You might be able to figure out a workaround on your own based on the errors; otherwise, you could ask Coverity Support for help.
If the total number of files (here, ~1504) seems too small, then probably you are missing a compiler configuration, and therefore cov-build
is failing to recognize invocations of your normal compiler. In build-log.txt
, look for lines that say "EXECUTING:", and if you see a command line for the normal compiler, and it is not followed by "COMPILING:", then that's the problem. Use cov-configure
to add compiler configurations; see the Command Reference for usage details.
For some more information about cov-build
, see the Synopsys article Coverity "cov-build" finishes with "No files emitted" for C/C++ code.
For a mostly tool-agnostic overview of why static analysis tools do "build capture" at all, see the SO question When using a SAST tool, why do we have to use a "build wrapper" for compiled languages (e.g. C/C++)?.