GCOV for SpiderMonkey

I wonder whether there is a way that I can do a coverage test for SpiderMonkey (e.g., using gcov). I see lines in “js/src/shell/js.cpp” to support gcov, but I am not certain how I can enable this opinion when compiling the js executable (i.e., using the make command) and using gcov to do a code coverage. If someone can lead me in the right direction, that would be much appreciated. (FYI. I’m on Ubuntu 20).

I see that Firefox configuration system exposes --enable-coverage option. Would this help?

Another related question: Are you hoping to get coverage information for JS (which we do support) or the C++ inside SM?

Thanks for the suggestion. I tried the configuration with the --enable-coverage option ($configure --enable-coverage) and compiled using make. The configuration was successful, but compiling failed with multiple errors mainly with error: undefined symbol errors. I believe it has to do with the LLVM symbols. I am not so sure why that is and if you can give some suggestions, that would be very appreciated.

Example errors:

ld.lld: error: undefined symbol: llvm_gcda_start_file
ld.lld: error: undefined symbol: llvm_gcda_emit_function
ld.lld: error: undefined symbol: llvm_gcda_summary_info

I am specifically interested in the C++ code coverage, i.e., SpiderMonkey’s source code (parser, interpreter, jit compiler, etc.). Thank you for asking.

Could you open a bug here – something is definitely wonky, and we should look into it, as if we have the --enable-coverage option, it should at least work.

In case it helps, you can also browse coverage data for js/src generated by Firefox CI builds here: