Seamless debugging between python and Rust? #2997
Replies: 2 comments 11 replies
-
This will not improve the debugging experience w.r.t. the Python code, but you should be able to attach GDB to the CPython process executing your top-level Python code and it still place break points within any native extensions the interpreter loaded. (This should also work with But you can certainly also apply "printf-style" debugging to the Rust code itself which should be visible on standard output like calling Python's |
Beta Was this translation helpful? Give feedback.
-
Do you mean that you want to set the breakpoint in Python code and jump into Rust code from that break point? I don't know whether there's any Python debugger that works like that. |
Beta Was this translation helpful? Give feedback.
-
Hello, I just started looking into a project that appears to use PyO3 and I've never used Rust before so wondering how people are going about debugging such projects.
I read through the debugging section of the docs, but it seems the gdb usecase there is running a rust binary as the entry point rather than python. And the python example is just a single function test and I can't access the python source from within rust-gdb it seems.
I'm no expert, but I am somewhat familiar with the debugging tools available in gdb, PyCharm and VSCode, but not sure if there is a way to inline debug (or even print things) seamlessly between the python and rust code.
Taking the README example of
sum_as_string
, I can start the Pycharm debugger and step into the generated stub ofstring_sum.py
, but its just a stub. I'm looking for some kind of debugging tools that would allow me to either inline debug and go from python to rust and back again, or some way to print things (variable values, types, etc.) from rust while running from python.The
string_sum
example is fairly straightforward to understand, but I'm trying to get a grasp on a MUCH larger project. I don't necessarily need to know all the innards of the project, as I just want to create a PR to fix one bug affecting me as an end user. Trying to find a good way to track down the source of such a bug by creating breakpoints near the identified methods controlling the user-input and following them thereafter.Without being intimately familiar with a given project, what is a good way to step through the code of a PyO3 project like this to get a feel for how it works?
Beta Was this translation helpful? Give feedback.
All reactions