gdb can attached later to the running process, which speeds things up. We use this in athena:[code]def hookDebugger(debugger=‘gdb’):
""“debugging helper, hooks debugger to running interpreter process
”""
import os
pid = os.spawnvp(os.P_NOWAIT,
debugger, [debugger, ‘-q’, ‘python’, str(os.getpid())])
# give debugger some time to attach to the python process
import time
time.sleep( 1 )
# verify the process' existence (will raise OSError if failed)
os.waitpid( pid, os.WNOHANG )
os.kill( pid, 0 )
return[/code]
which can then be attached programmatically from the python script.
yes to the first question, no to the second. It is possible to “focus” valgrind on specific pieces of code, for some of its tools, but that would have to be done from C++, using the valgrind API.