wiki:Debugging
Last modified 5 years ago Last modified on 10/17/2013 09:35:34 AM

Table of Contents

  1. Python
  2. C/C++

Python

For a general guide to python debugging, see: http://scipy-lectures.github.io/advanced/debugging/

The easiest way of getting a debugger in a place of interest (but only available if you control the code you're debugging) is to set an explicit break point directly in the code: import pdb;pdb.set_trace(). Otherwise you'll have to run the code under the debugger and set a break point before running it.

If you're debugging an exception (that propagates all the way up and terminates the program; you may need a --doraise flag so the exception doesn't get caught), run:

python -m pdb `which myProgram.py` <arguments>

If you're debugging a segfault or similar coming from python code, run the program under gdb and use the .gdbinit-python macros provided for debugging python (e.g., pyframe command gives the file, line number and function of a python frame, pystack to print the entire python call stack, pyo to print information about a python object).

C/C++

Several .gdbinit files are available in the LSST/DMS/devenv/build git repo, in the debugging directory:

To use the debugger, run:

gdb --args myProgram <arguments>