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.

classification
Title: f_trace_opcodes frame attribute to switch to per-opcode tracing
Type: enhancement Stage: resolved
Components: Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ncoghlan Nosy List: gregory.p.smith, ncoghlan, nedbat, njs, serhiy.storchaka, steve.dower
Priority: normal Keywords:

Created on 2017-09-04 22:03 by ncoghlan, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 3417 merged ncoghlan, 2017-09-07 03:29
Messages (6)
msg301273 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2017-09-04 22:03
In order to test issue 29988 reliably, we want the ability to run trace hooks for every opcode in a frame, rather than for every line.

The simplest API we've been able to come up with for that is a "f_trace_opcodes" attribute on the frame which we set from the trace hook the first time that it runs.
msg301362 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-09-05 19:20
The f_trace attribute is writable from a tracing function. There are different restrictions, for example you can't jump inside a 'for' loop from outside. The code of the setter is complex and hard for modifications (see the discussion on PR 2827). Allowing to trace opcodes can make it more complex.
msg301366 - (view) Author: Nathaniel Smith (njs) * (Python committer) Date: 2017-09-05 20:05
Adding Ned to CC in case he wants to comment on the utility of per-opcode tracing from the perspective of coverage.py.
msg301374 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2017-09-05 21:05
Steve's also requested the ability to *turn off* line debugging, and I'm thinking it may make sense to allow all four configurations:

* both line and opcode events disabled
* only getting one or the other
* getting both kinds of event

Opcode events would definitely be off by default, and if you do turn them on, then you'd be in a situation similar to importing ctypes: the interpreter is no longer guaranteed to work correctly. (Although unlike ctypes, you shouldn't get segfaults because of it)
msg301565 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2017-09-07 03:31
My posted PR implements the "independent flags" option, where f_trace_lines and f_trace_opcodes allow per-line and per-opcode events to be requested independently.

The default is to emit per-line events (as has historically been the case).
msg301655 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2017-09-08 00:14
New changeset 5a8516701f5140c8c989c40e261a4f4e20e8af86 by Nick Coghlan in branch 'master':
bpo-31344: Per-frame control of trace events (GH-3417)
https://github.com/python/cpython/commit/5a8516701f5140c8c989c40e261a4f4e20e8af86
History
Date User Action Args
2022-04-11 14:58:51adminsetgithub: 75525
2017-09-08 00:14:59ncoghlansetstatus: open -> closed
resolution: fixed
stage: commit review -> resolved
2017-09-08 00:14:18ncoghlansetmessages: + msg301655
2017-09-07 03:31:25ncoghlansetmessages: + msg301565
stage: needs patch -> commit review
2017-09-07 03:29:12ncoghlansetpull_requests: + pull_request3415
2017-09-07 00:55:32ncoghlansetassignee: ncoghlan
2017-09-05 21:06:03ncoghlansetnosy: + steve.dower
2017-09-05 21:05:46ncoghlansetmessages: + msg301374
2017-09-05 20:05:36njssetnosy: + nedbat, njs
messages: + msg301366
2017-09-05 19:20:19serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg301362
2017-09-04 22:04:42ncoghlanlinkissue29988 dependencies
2017-09-04 22:03:40ncoghlancreate