views:

175

answers:

2

I have a server program, which doesn't have a very clean/graceful shutdown (not supposed to terminate in general). When tracing memory leaks, I run it under valgrind, but finally have to kill the process by a signal (^C). Generally I try to terminate the process when the ambiance is quiet but still then some threads might have been busy processing jobs and memory held by them cause false alarms. To assist such analysis, is there any way (tool) in valgrind, so that it can print the backtrace of threads when the program exits (by a signal?).

A: 

Don't sure I quite understand your question, but you can print backtrace of all pthreads by gdb:

thread apply all bt
dimba
Actually the program is running under valgrind, and I want something /equivalent/ as a tool's exit hook.
Kousik Nandy
+1  A: 

I know it's inconvenient, but could you get your program to dump core when it gets this signal, then diagnose the core dump with gdb?

Norman Ramsey