This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients ammar2, gwk, vstinner, xdegaye
Date 2017-02-01.21:51:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1485985886.2.0.350853680857.issue29400@psf.upfronthosting.co.za>
In-reply-to
Content
inst-tracing-2.diff:

* Rebased patch applied on Mercurial, I had to fix a conflict in sys_settrace()
* I replaced your PyEval_SetTraceInstructions() function with a new private _PyEval_SetTraceEx() method
* I changed sys.settrace() API to convert the trace_instructions parameter to keyword only: sys.settrace(func, True) raises a TypeError (I added an unit test for that).

About the API, I see an issue: the "old=sys.gettrace(); sys.settrace(old)" pattern doesn't work anymore, since old doesn't contain the trace_instructions flag :-/ So I suggest to add a new method and make it exclusive with sys.settrace(), sys.settraceinstr() / sys.gettraceinstr():

* sys.settrace() raises an exception of sys.gettraceinstr() is not None
* sys.settraceinstr() raises an exception of sys.gettrace() is not None

The sys module is a critical module, so the API should probably be discussed on python-dev (later?).

About performances: it's fine to add anything to maybe_call_line_trace(), it cannot impact performances when tracing is not used.

Can you please try to reimplement something like __lltrace__ on top of sys.settraceinstr()? It would be a nice example of the API, but also a good reason to add sys.settraceinstr().

See the issue #25571 "Improve the lltrace feature with the Py_Debug mode".

Currently, the __lltrace__ feature requires a Python compiled in debug mode, which is not convenient. Moreover, it requires to put a __ltrace__ variable in global variables.

The best would be able to add an instruction level debugger inside pdb! It would be a cool tool to learn Python and to play with the bytecode!
History
Date User Action Args
2017-02-01 21:51:26vstinnersetrecipients: + vstinner, xdegaye, gwk, ammar2
2017-02-01 21:51:26vstinnersetmessageid: <1485985886.2.0.350853680857.issue29400@psf.upfronthosting.co.za>
2017-02-01 21:51:26vstinnerlinkissue29400 messages
2017-02-01 21:51:26vstinnercreate