Open 3d4m-volodymyr opened 3 years ago
I don't think we have any direct support for that today, but its sounds like it would be fairly easy to add.
Sounds like it would involve a new option and new compiler-rt variant added to tools/system_libs.py
Is this the place to start looking at https://github.com/emscripten-core/emscripten/blob/master/tools/system_libs.py#L642 ?
I never dealt with the internals of emscripten. Probably will have lots of questions.
I took an initial stab at getting this to work: https://github.com/emscripten-core/emscripten/pull/13072
It works up until llvm-cov fails to parse the data sections in the wasm executable.
It seems that the gcc-like coverage tool will get worked with #13072.
Adding compile option -fprofile-arcs -ftest-coverage
generates vaild .gcdo into physical file system and .gcda into virtual file system.
llvm-cov gcov
is also working completely using these .gcdo, gcda files.
Therefore, I think that we have already a good reason to merge #13072.
Hello, is there any update on this effort? (We're looking into ways to set up coverage analysis for Google Smart Card Connector, and IIUC currently the only workaround is to switch to the regular clang/gcc, but this doesn't let test the code in the WebAssembly environment.)
emcc -fprofile-instr-generate -fcoverage-mapping demo.cpp
wasm-ld: error: /var/folders/61/x35v93n50_5g1dfjrtprr2dw0000gn/T/emscripten_tempxjrzk63/demo_0.o: undefined symbol: __llvm_profile_runtime
have emcc supported code coverage? need help :)
No, emcc does not yet support this method of doing code coverage. #13072 is a start, but that has yet to land.
It looks like SanitizerCoverage works. I've tried the demo by replacing clang++ to em++
em++ -g -fsanitize-coverage=trace-pc-guard trace-pc-guard-example.cc -c
em++ trace-pc-guard-cb.cc trace-pc-guard-example.o -fsanitize=address -sNO_EXIT_RUNTIME -o trace-pc-guard-cb.html
And the result can be printed as expected.
@junyuecao this is not the same.
Hey. I've created a tutorial how to generate code coverage for webassembly projects. This one is dedicated for blockchains using WASM VM, however I think it may be useful to you too - https://github.com/hknio/code-coverage-for-webassembly
Is there anything done in emscripten for enabling Tests Code Coverage reports generation?
I found this very interesting article on how to do it manually. Requires to recompile compiler-rt.