Profiling python code with valgrind produces empty log file
Hi all,
I am running 12 ROS nodes (ROS kinetic) and starting the system with a roslaunch file. I would like to profile one of the nodes, while the whol system is running. From my search it seems that I can use valgrind.
I set the roslaunch file as below (as shown here):
<launch>
<param name="use_sim_time" value="true"/>
<arg name="seedval"/>
<param name="seed" value="$(arg seedval)"/>
<group ns="robot1">
<node pkg="pkg_name" name="agent" type="agent.py" launch-prefix="valgrind --tool=callgrind --separate-threads=yes --callgrind-out-file='callgrind.sim1.%p'">
<param name="myID" value="1"/>
......
</node>
</group>
.....
</launch>
I build the package in debug mode like so:
catkin_make -DCMAKE_BUILD_TYPE=Debug
Now from what I have read, valgrind will dump the data when the program terminates. And the issue might lie here, because the nodes exit with sys.exit(), raising a SystemExit exception. I have tried adding the --dump-before=function option, but to no avail:
launch-prefix="valgrind --tool=callgrind --dump-before=name_of_function_as_in_script --separate-threads=yes --callgrind-out-file='callgrind.sim1.%p'"
Any ideas, I am not quite sure how to proceed.
Thanks!
hW
Do you mean you don't have the file
~/.ros/callgrind.sim1.PID_NUMBER
?Also I'm not sure that vallgrind can be used with python as it's said in the introduction of the tutorial :
Hi, I get the file, but it is empty. From here it seems I might have to do compile python itself in debug mode, such that it is valgrind friendly.