From: Nicholas N. <nj...@ca...> - 2003-04-10 17:01:13
|
On 10 Apr 2003, Tom Roeder wrote: > I have a question to which I hope the answer is simple, but I haven't > managed to find any way to do it short of hacking the code myself. I > have a program (it happens to be ns, the network simulator) that I have > been working on for a while. There's a memory leak, and it ends up > getting a signal and dying on an out of memory error. The problem is > that when it dies, valgrind gives up too! I would much rather have > valgrind catch that signal and print out what it knows about the memory > problems already. Similarly, it has occasionally happened that I have > wanted to stop valgrind short in a run and tell it to print out what it > knows. Unfortunately, at least when I did it, Ctrl-C just causes it to > quit and not tell me anything. All of this could be solved if there > were some sort of command-line option like > > "--catch-signal-and-report=<signals>" > > where I could give it a list of signals and it would report on memory > problems before giving up when receiving them. I have a good knowledge > of C and C++, but I don't have much time to try to understand the > valgrind code and figure it out and add this option in a way that > doesn't interfere with other valgrind signal functionality. If this has > already been implemented, so much the better. If not, could anyone give > me a pointer into where this might be done in the code, so I can try to > add the signal handlers myself? Can you catch the signal with the client program? If so, in the signal handler, you could call the VALGRIND_DO_LEAK_CHECK macro (just #include memcheck.h) to do a leak check at that point. N |