how to debug python extensions.

Michael Stahl mstahl at redhat.com
Tue Mar 22 20:46:31 UTC 2016


On 20.03.2016 14:48, meilin wrote:
> Hi, I have a question that how to debug python extensions. for example
> how to debug 4.3.3.2_build/instdir/program/pythonscript.py,
> Now i debug the file by write debug information in log.txt, but it's too
> trouble.
> src/pyuno/README file say that
> To have much joy debugging python extensions you need to:
>   a) edit pythonloader.py in your install setting DEBUG=1 at the top
>   b) touch pyuno/source/module/pyuno_runtime.cxx and 'make debug=true'
> in pyuno
> 
> Then you'll start to see your exceptions on the console instead of them
> getting lost at the UNO interface.
> I have done it like this , but it's useless.

i'm not sure if it was covered by other replies, but you can edit the
python code to insert "import pdb; pdb.set_trace()" in some
initialization function (somewhere so that it is always executed), then
run from a terminal and when it is executed a command-line python
debugger appears.

for a somewhat integrated C++/python debugging experience on Linux you
can even use gdb, the bundled python comes with a
libpython3.3m.so-gdb.py that should be auto-loaded by gdb and provide
commands like "py-bt" to get python-level backtrace.  but it's clearly
not very comfortable and i'm not aware of any way to set a breakpoint,
other than editing the python code to send itself signals...

> another question
> in src/scripting/source/pyprov/pythonscript.py.
> why the parameters of out and outindex have not been used.

apparently the python script provider does not support XScript::invoke
out-parameters; no idea if that is intentional or just a missing feature.




More information about the LibreOffice mailing list