Can it be used to collect coverage for programs that might crash (core dump)?

I am currently utilizing the 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 (e.g., manually processing the intermediate data files generated by

Ping @nedbat
Looking forward to your reply and thanks in advance. :slight_smile:

On general no as will not run the code to save its data.
You can code explicit calls to start and stop coverage so that you get some data.

But why not just fix the crash first?

Thank you for your response.

I attempt to use 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

If you have a crash then its unusal to want coverage data to help fix the issue.

If you cannot run the test under gdb then turn on core dumps and run gdb on the core dump to see want happened. 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.

Thank you for your time! @barry-scott @nedbat

Something you could try: python -m trace --trace 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.