[CIG-SHORT] Python debugging
Brad Aagaard
baagaard at usgs.gov
Tue Apr 24 18:55:16 PDT 2012
On 4/24/12 6:31 PM, Birendra jha wrote:
> Hi developers,
>
> 1. What is technique to debug both Python and C++ code together at
> runtime? When I uncomment start-in-debugger in pylithapp.cfg, it
> opens gdb window where I can debug c++ code. But what about debugging
> python code? Is there a different tool?
It is difficult. If you want debugging with both then you need to use
the python debugger and then attach a gdb process. Usually, I limit
myself to one or the other.
> 2. How do I print contents of a SwigPyObject array pointer? The
> arrays returned by SWIG modules to Python are PyObjects. How to
> visualize them? Writing to a file will also work.
If the array is converted to a numpy array, then you can print from
Python. If it is C++, there is no easy way to access it from python.
> 3. Implicit.py has a disp object. How do I visualize its content at
> runtime? print disp of course doesn't work and gives:
> <pylith.topology.topology.MeshField; proxy of<Swig Object of type
> 'pylith::topology::Field< pylith::topology::Mesh> *' at 0x2d9fba0>
Use the view("label") method to view the contents of meshes and sections
(disp is a section). The python dir(object) is very helpful to see what
methods are accessible.
Brad
More information about the CIG-SHORT
mailing list