View Full Version : Memory debugging and attaching to processes

07-17-2006, 11:21 AM
[/url]The Memory Debugger needs to interpose its agent between your program and its calls to the malloc library. In most cases (except when running on AIX), this is pretty easy for programs that use just one process-you just enable memory debugging from within TotalView.
[br]Things aren't so simple when you are debugging programs that create additional processes or when you have to attach to the process. This includes MPI programs. In these cases, TotalView only attaches to created processes after they begin executing. This is too late for the Memory Debugger. Once the process begin executing, TotalView can't interpose its agent.
[br]You can get around this problem by explicitly linking your program with the agent. Chapter 4 of the Debugging Memory Problems Using TotalView (http://www.etnus.com/Documentation/latest/pdf/Memory.pdf) Guide shows how to do this.
[br]Here's an example of linking a Linux program (pathnames were edited to keep them short):

gcc -g -o leakypi cpi.c -I/usr/local/mpich. \
-L/usr/local/mpich. \
-L/opt/tv/linux-x86/lib/ \
-ltvheap -lmpich -Wl,-rpath /opt/tv/linux-x86/lib