This task describes how to debug Python scripts.
These Arm® DDT features are supported in Python debugging:
This feature is useful when debugging a mixed C, C++, Fortran, and Python program.
Note
Python global variables are only shown in the Locals tab if the selected frame is at the module level. To see a global variable, you can add it in the Evaluate window. You can see all the global variables, if you add globals()
.
These Arm® DDT features are not supported in Python debugging:
multiprocessing
) because it forks separate processes.To debug Python scripts, specify the Python interpreter followed by %allinea_python_debug% and then the path to the script that you wish to debug. For example:
$ ddt python3 %allinea_python_debug% my-script.py
To debug Python scripts that use MPI, the same applies, except mpirun is also appended to the beginning:
$ ddt mpirun -np 4 python3 %allinea_python_debug% my-mpi-script.py
When passing arguments, they must appear after %allinea_python_debug% and the name of your script. To run the demo in the examples folder, change into the examples folder.
Run:
$ make -f python.makefile
Run:
$ ../bin/ddt python3 %allinea_python_debug% python-debugging.py
Note
On loading into DDT you will be inside the C code. This is normal as you are debugging the python binary. Depending on the interpreter that you are debugging you may also see a message about missing debug symbols. Clicking Play/Continue once after launching will bring you to the first line of your script.
Click Run.
Click Play/Continue to run to the first line of the script.
Set a breakpoint on a line inside the call_out_to_a_library
function.
Use the Add breakpoint dialog to set a breakpoint on the function name library_function.
Click Play/Continue to run to the Python function and observe that local variables are visible.
Click Play/Continue again to run to the native function and observe how the stack appears when calling out of the interpreter.
Note
To disable Python debugging, omit %allinea_python_debug% from the command line.