|
From: Tony W. <ton...@so...> - 2003-10-22 17:58:20
|
Hi,
I have just recently begun using Valgrind and have (what I believe is) a
simple question...
I apologize if this is answered elsewhere. I saw no mention of it in
the documentation and I checked the mailing list archive but could find
no mechanism to search it. I gave up after browsing through a bunch of
messages that looked promising but were not.
Is it possible to force Valgrind to generate a detailed leak
report (block-by-block listing) in the case of an "abnormal"
shutdown (ie. one where main() does not return)?
I have a server process which runs until I kill it via SIGINT or
whatever. When I kill it, Valgrind generates no output whatsoever.
I am running Valgrind with the --leak-check=yes command-line flag.
I have tried several of my "usual" work arounds for forcing memory
debuggers to generate output, with limited success:
1) Register a signal handler for SIGINT which calls exit()
This causes Valgrind to generate "summary" reports
(ERROR SUMMARY and LEAK SUMMARY), but not the detailed,
block-by-block listing of leaked memory that is shown
at a "normal" terminate (return from main()).
2) Have signal handler do VALGRIND_DO_LEAK_CHECK before calling exit()
This causes Valgrind to generate the LEAK_SUMMARY
report, then ERROR SUMMARY and LEAK SUMMARY (again).
3) Register an atexit() function to do VALGRIND_DO_LEAK_CHECK
Like the signal handler above, this causes Valgrind to generate
the LEAK_SUMMARY report, then ERROR SUMMARY and LEAK SUMMARY
(again). Of course, this only works if I also use a signal
handler to call exit().
Based on this, it would appear that something "else" happens during a
normal shutdown to generate the detailed leak report. Is this something
that I can trigger from my program?
The only way I have managed to get this to work in a test program is to
have my signal handler set a flag which terminates my process' main loop
and causes main() to return normally. However, this is a is a
non-trivial thing to do in my actual project, so I would like to avoid
it if possible. :)
If it matters, I am using gcc-3.3.1 to build my code, and
valgrind-20030725. My platform is Red Hat Linux 8 (kernel 2.4.18).
Thank you very much!
---
Tony Wetmore
Raytheon Solipsys
mailto:ton...@so...
http://www.solipsys.com
|
|
From: Jeremy F. <je...@go...> - 2003-10-22 20:42:13
|
On Wed, 2003-10-22 at 08:41, Tony Wetmore wrote: > Is it possible to force Valgrind to generate a detailed leak > report (block-by-block listing) in the case of an "abnormal" > shutdown (ie. one where main() does not return)? The current CVS valgrind will always try to print the exit messages, even for abnormal termination. Obviously there are some cases where it can't (SIGKILL), but it tries pretty hard. J |