Is it possible to use GDB's reverse debugging with Python? How?
Asked Answered
K

3

7

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?

Kana answered 27/9, 2010 at 4:22 Comment(0)
G
3

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).

Greenlaw answered 29/9, 2010 at 3:0 Comment(0)
F
3

RevDB

https://bitbucket.org/pypy/revdb

https://morepypy.blogspot.co.uk/2016/07/reverse-debugging-for-python.html

This project aims to allow pdb-like reverse debugging, which is likely what you want unless you are debugging the Python interpreter itself.

It is still in early stages as of 2017, and you must build from source.

How to question that does not mention GDB: Is it possible to step backwards in pdb?

Finally, GDB reverse debugging is quite immature, e.g. does not deal with AVX extensions Disable AVX-optimized functions in glibc (LD_HWCAP_MASK, /etc/ld.so.nohwcap) for valgrind & gdb record , so I strongly recommend using rr instead: https://github.com/mozilla/rr (on which RevDB claims to take inspiration from).

Related for JavaScript: How to go backwards while debugging Javascript in Chrome sources debugging?

Felicefelicia answered 11/9, 2017 at 9:37 Comment(0)
U
0

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.

Unalloyed answered 27/9, 2010 at 5:26 Comment(1)
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.Janettajanette

© 2022 - 2024 — McMap. All rights reserved.