tags:

views:

59

answers:

2

I am trying to use GDB's reverse debugging with a Django application. I get it running in GDB, but I can't make it run backwards.

I stopped my Django app with Ctrl-Z and then entered reverse-next at the gdb prompt, getting the error message "Target multi-thread does not support this command."

Am I doing it wrong? Isn't this possible? Both?

A: 

That's an amazingly good question.

My first impulse would be to ensure I was using IPython as my shell for django and see if it's pdb support would help in this case. Pdb should have a very similar interface to gdb. As I recall, gdb is what's used to debug C/C++ programs, while django is being executed by a python interpreter. Using Pdb is here:

http://ericholscher.com/blog/2008/aug/31/using-pdb-python-debugger-django-debugging-series-/

Also you might want to try using django-extensions, for access to the werkzeug debugging view.

chiggsy
gdb has recently acquired the ability to debug Python programs at a source level. At least, the gdb shipped by Fedora supposedly is able to do this. I haven't tested it myself as I tend to not like debuggers. It's similar to how gdb knows what an STL string or vector looks like and so it can print it out nicely for you. It knows that you've attached to a Python interpreter, and in addition to debugging the interpreter, it can debug the program the interpreter is running.
Omnifarious
+1  A: 

Before you can use GDB for reverse debugging, you must tell it to record your program execution (so it can play it back) via target record command, as documented here.

I am not sure this will help you debug your Django application though -- GDB is well suited for debugging "native" code (compiled C/C++), and is not well suited for debugging "interpreted" code (in either forward or reverse direction).

Employed Russian