Results 1 to 3 of 3
Inside GNU/GCC, gcov is a tool used to code coverage analysis. That is, when compiling the code with gcov-related options, the code would generate the coverage information after its execution. ...
- 05-08-2008 #1Just Joined!
- Join Date
- May 2008
- Posts
- 17
How to use gcov to collect the statistic for a background deamon?
Inside GNU/GCC, gcov is a tool used to code coverage analysis. That is, when compiling the code with gcov-related options, the code would generate the coverage information after its execution. I had tested it and have a good result for the user application.
However, if my application is running at the backgroud, it would not be terminated for a long period. How do I use gcov to collect the statistic for it?
I try to kill the process to terminate that application. But, in this case, the coverage information would not be generated.
Please share your experiences and good idea to me. Thanks a lot.
- 05-08-2008 #2
Catch a signal, say SIGUSR1 or SIGUSR2. In your signal handler, call exit(). In theory this isn't quite legal, because you could already be calling exit() for other reasons and then suddenly receive the appropriate signal. You can avoid that difficulty by disabling your signal catcher just before calling exit() anywhere in your program.
Then use the command line kill command to send signal SIGUSR1 (or whatever) to your program.
Hope this helps.--
Bill
Old age and treachery will overcome youth and skill.
- 05-09-2008 #3Just Joined!
- Join Date
- May 2008
- Posts
- 17
Dear Bill,
Thanks very much for your reply. I try to add a signal hander is my program and then use kill to send that signal to terminate the background process. It is ok and the statistical information is saved for gcov analysis. Thanks!
Best Regards,
Rike_Lin.


Reply With Quote