Stated most simply, I'm unable to hit a breakpoint or step into code from a shared library that gets called from my django web application. Below is relevant information about what I'm trying to do.
- I wrote a shared library in c++
- Thought it would be nice to use its functionallity in a web site/app
- Created an 'extern "C"' interface to the library
- Created the python wrapper using ctypes
- Wrote a django web app, which makes use of the python wrapper to my library
I'm running the django test server (python manage.py runserver) and I get a segfault at the first place in the app where I'm passing a pointer to an object created by the shared library back through the shared library interface.
If I just fire up python (no django, no server), and try to mimick what the web app code does, I cannot reproduce the segfault. The library code works as expected.
I can do this:
Code:
$ gdb python
(gdb) break namespace::class::function
Function "namespace::class::function" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
(gdb) run
...
Where namespace::class::function is from my shared library, and gdb will hit the breakpoint and I can step through my c++ code. However, I also cannot reproduce the error like this.
However, I cannot get this to work with the test server (where the error exists).
Code:
$ gdb python
(gdb) break namespace::class::function
Function "namespace::class::function" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
(gdb) run manage.py runserver
The server segfaults, my breakpoint is never hit, and the backtrace does not show any of the calls inside my library.
Is it possible to debug this code while the server is running? I'm not sure what I'm looking for. I'm hoping that at the time an object is first created in the shared library and passed through the library interface to python, that I can inspect it and verify everything is in order, and find some place where things get out of order. So my immediate problem is getting the debugger working.
Thanks in advance.