How to get .gcda files when the process is killed?

I have a binary assembly with -fprofile-arcsand -ftest-coverage. The binary file is controlled by a process monitor, which starts the process as a child process. Then, when I want the process to exit, I have to go through the process monitor. It sends SIGKILLto the process. I found that in this case the files are .gcdanot generated. What can I do?

EDIT: Actually, the process monitor first tries to terminate the process. However, the ProcessMonitor library (used in each process) calls _exitinstead exitwhen the user issues a command to stop the process. This is the cause of all the trouble.

+3
source share
3 answers

SIGKILLis a "hard" kill signal that cannot be captured by the application. Therefore, the application does not have the ability to write a file .gcda.

I see two options:

  • To catch signals other than SIGKILL: any sensible process monitor must first send SIGTERM. initand the package managers I came across do this. SIGKILL- last resort, so it should be sent only after SIGTERM, followed by a grace period.
  • : , SIGKILL; ( ), , , .
+2

: http://nixcraft.com/coding-general/12544-gcov-g.html

: __gcov_flush() , , .

++- "C" extern .

- ifdef, , .

+4

Afaik compilers (IntelC too) only store profiling statistics in the output handler. So how about somehow saying that the process is gone, and not kill it? Like, for example, adding a SIGKILL handler with exit () in it?

0
source

Source: https://habr.com/ru/post/1779124/


All Articles