-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Frame.f_trace, paving the way to support pdb debugging
#1918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Is guarded by a RwLock<PyObjectRef>. Is there a better option maybe? Could use an RwLock<Option<PyObjectRef>> and provide a vm.get_none() on each None::<PyObjectRef> found. I do not know what is better on memory & cpu
|
I think it would be a micro-optimization for |
|
I see. The part intriguing me is that Option::None codepath is followed by But storing PyNone lead to return |
|
I may be overthinking this all. Will keep pushing "just work" code until pdb.set_trace() works and then get back to optimize. What about the rwlock? Is it ok? The rational was that I expect it to be checked on every single line change, so should be fast. But also light on memory as will be on every frame created. |
|
...and thanks for the attention @coolreader18. |
|
Yeah, I think the RwLock is good, it makes sense since you might occasionally be reading the f_trace property concurrently. |
Is a frame, instead of None, but still not the _right_ frame
|
Implementation of sys.__displayhook__ from CPython 3.8.3 docs. Is the pseudocode inlined on the docs copy-pasted. See: https://docs.python.org/3/library/sys.html#sys.displayhook
This is the CPython behavior expected by bdb.py debugger. Had not understood how does it work on CPython. Here has implemented via frame.__delattr__ specially for f_trace. Other `del frame.*` are actually noops for now
|
And this is the end of PyCon US 2020 sprint:
Thanks @youknowone for the help on Gitter. Now may need support for a setter on Good night. |
vm/src/obj/objframe.rs
Outdated
| @@ -24,6 +24,15 @@ impl FrameRef { | |||
| "<frame object at .. >".to_owned() | |||
| } | |||
|
|
|||
| #[pymethod(name = "__delattr__")] | |||
| fn delattr(self, value: PyObjectRef, vm: &VirtualMachine) { | |||
| println!("Called: FrameRef::f_trace over {:?}", value); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice workaround for now. putting an incompatibility comment will be helpful for future work.
|
Do you want to work more for this or want to merge part of the work? |
|
Both 😬. Better to merge the actual progress for this to not get rotten when I find the time to finish it. |
|
Will you make a new PR with finished commits after rebase? |
I am not used to rebase stuff, but can learn to. Should I go cherry-picking over master and send a new PR? Is this the way? |
|
Oh, yep. Because this one is very aged, cherry-pick could be easier than rebase. That sounds very reasonable. |
Also got its pure-python dependencies bdb.py and cmd.py Also stubbed the C-based gc.py using `pystubber` (https://pypi.org/project/pystubber/)
|
Oh, right -- looks like the errors are from |
|
Is the |
bdb.py imports it to use somewhere, but I had not hit the case when it calls gc for real. Anyway I do not feel bad by stubbing C-based stuff that we want not to implement right now. (I need to say that sometimes I am missing the ability of calling rust code directly from python code. Maybe on future a custom importhook can do the trick.) |
|
@youknowone what do you think? |
My approach on this is to try to do the lowest number of changes possible on foreign code, if we want to get back to the original somewhere in future. That is why I am trying to provide a bogus gc instead of messing with bdb.py original code. Less changes to track upstream on bdb.py and keep patching here until a fully compatible gc is ready. |
|
https://github.com/RustPython/RustPython/pull/1918/checks?check_run_id=973313037#step:10:7685 What? I though that this was been fixed before 🤔. I saw a PR about this! |
This reverts commit c0b11de.
|
Looks like sys.displayhook was natively implemented in meantime. Removing my hack from For some reason my local tests passed without changes. I may have a local environment messed up. |
|
Yay! Got green. Now pdb.set_trace() "works" but stops on the wrong place.
Yet broken:
This PR is good to go. At least locals() and globals() variables inspection are working. Closure variables inspection seemed broken. Lets get this merged and open another to fix j(ump) and n(ext) |
|
I'm merging this manually to fix this weird lf->crlf change in frame.rs |
|
Alright, this is merged to master even though github doesn't show it. |
f_trace is initialized with PyNone. I do not know if it would be better on memory/cpu to handle Option::None instead.
No tests for now, just wanting a feedback. Specially on the RwLock used.