|
From: Tony W. <ton...@so...> - 2003-10-22 17:43:06
|
Ummm, never mind. :) This is a case of user error. In my small test program, my "leaked" memory block was still reachable (since main() had not terminated) and I had neglected to use the --show-reachable=yes command-line flag, so this leaked block was not detailed. So, writing a signal handler (or some other triggering device to call exit()) appears to work just fine. Sorry to have wasted your time. --- Tony Wetmore Raytheon Solipsys mailto:ton...@so... http://www.solipsys.com -----Original Message----- From: Tony Wetmore [mailto:ton...@so...] Sent: Wednesday, October 22, 2003 11:41 AM To: Valgrind Mailing List (val...@li...) Subject: Can I force output of a detailed leak report? 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 |