>
> > 3. Another example: I'm working right now on a feature to step into a
> > method. To do that right now my approach is:
> >      - Compute the function call names and bytecode offsets in a given
> > frame.
> >      - When a frame is called (during a frame.f_trace call), check the
> > parent frame bytecode offset (frame.f_lasti) to detect if the last thing
> > was the expected call (and if it was, break the execution).
> >
> > This seems reasonable given the current implementation, where bytecodes
> > are all fixed and there's a mapping from the frame.f_lasti ... Will that
> > still work with the specializing adaptive interpreter?
>
> If you are implementing this in Python, then everything should work as
> it does now.
>

Ok... this part is all done in Python, so, if frame.f_lasti is still
updated properly according to the original bytecode while executing the
super instructions, then all seems to work properly on my side ;).

>
> OOI, would inserting a breakpoint at offset 0 in the callee function
> work?
>

Yes... if you're curious, for the breakpoint to actually work, what is done
is generate bytecode which calls a function to set the tracing and later
generates a spurious line event (so that the tracing function is then able
to make the pause. The related code that generates this bytecode would be:
https://github.com/fabioz/PyDev.Debugger/blob/pydev_debugger_2_4_1/_pydevd_frame_eval/pydevd_modify_bytecode.py#L74
).


>
> >
> > 4. Will it still be possible to change the frame.f_code prior to
> > execution from a callback set in `PyThreadState.interp.eval_frame`
> > (which will change the code to add a breakpoint to the bytecode and
> > later call `_PyEval_EvalFrameDefault`)? Note: this is done in the
> > debugger so that Python can run without any tracing until the breakpoint
> > is hit (tracing is set afterwards to actually pause the execution as
> > well as doing step operations).
>
> Since frame.f_code is read-only in Python, I assume you mean in C.
>
> I can make no guarantees about the layout or meaning of fields in the C
> frame struct, I'm afraid.
> But I'm sure we can get something to work for you.
>

Yes, it's indeed done in C (cython in this case... the related code for
reference is:
https://github.com/fabioz/PyDev.Debugger/blob/pydev_debugger_2_4_1/_pydevd_frame_eval/pydevd_frame_evaluator.template.pyx#L591
).

I'm fine in going through some other way or using some other API (this is
quite specific to a debugger after all), I just wanted to let you know of
the use case so that something along those lines can still be supported
(currently on CPython, this is as low-overhead for debugging as I can think
of, but since there'll be an adaptive bytecode specializer, using any other
custom API would also be reasonable).

Cheers,

Fabio
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/4GJ7W4PHK7XUPLHJPH5LEADRNIBZQXCS/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to