logo       

Re: Debugging wrapped code.: msg#00106

programming.swig

Subject: Re: Debugging wrapped code.

Hi

> I'm developing a library of functions and I use SWIG to call them
> from Python. However testing and debugging the code I've written
> is tedious and I miss something like gdb to test the code, watch
> what is going
>
> down in the core of my functions from with Python. Any suggestion
> about this issue?

you can run the Python interpreter under gdb and set breakpoints on
the wrapper functions. Your only problem is setting breakpoints on
the dynamically loaded module, but you can use this hack:

1) add this line to the python script you want to debug, after the
import statement for the SWIG generated module(s):

__break_me=2j+1 # <== to set a breakpoint on gdb

2) now run python under gdb:

$ gdb python

3) set a breakpoint for 'complex_add':

(gdb) b complex_add

4) now, run your script on the debugged python:

(gdb) set args your_script.py arg1 arg2 ...
(gdb) run

5) execution of your script will stop at the complex_add breakpoint.
The SWIG module will be already loaded and you will be able to set
breakpoints for the functions on it and for its wrappers.

(gdb) b foo
(gdb) b _wrap_foo

6) continue execution:
(gdb) c

7) etc.


Having a Python interpreter compiled with debugging information would
also help.

Bye,

- Salva

_______________________________________________
Swig maillist - Swig@xxxxxxxxxxxxxxx
http://mailman.cs.uchicago.edu/mailman/listinfo/swig



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise