I am currently utilizing the coverage.py tool to collect coverage data for certain programs prone to crashing, and find that I cannot get the coverage data. I guess that this is due to the coverage process terminating when the programs crash. Is there a method to collect coverage for such programs using coverage.py? (e.g., manually processing the intermediate data files generated by coverage.py)
Ping @nedbat
Looking forward to your reply and thanks in advance.
I attempt to use coverage.py in a fault localization scenario, i.e., collecting the coverage information of the test cases and then using the coverage information to localize the fault of the software under test. However, some test cases (which might trigger potential bugs) can cause the software to crash, and as a result, I cannot collect the coverage.
For GCOV (a popular coverage tool for C/C++), I can manually process the .gcda files to obtain coverage information after the test cases crash. I am curious if there is a similar method to retrieve coverage information for the test cases that lead to a software crash using coverage.py.
Coverage.py collects data in memory and flushes it to the data file, usually at the end of the program. There isn’t a way now to force it to write every data item to the data file immediately, though I’ve thought about ways it could be done. It would probably drastically slow down the execution. I have no idea if that would affect the crashes you are trying to instrument.
Something you could try: python -m trace --trace your_program.py. It prints lines of code as they are executed. It will generate A LOT of output, but might help you find what you are looking for.