Skip to content
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

f_trace_opcodes frame attribute to switch to per-opcode tracing #75525

Closed
ncoghlan opened this issue Sep 4, 2017 · 6 comments
Closed

f_trace_opcodes frame attribute to switch to per-opcode tracing #75525

ncoghlan opened this issue Sep 4, 2017 · 6 comments
Assignees
Labels
3.7 (EOL) end of life type-feature A feature request or enhancement

Comments

@ncoghlan
Copy link
Contributor

ncoghlan commented Sep 4, 2017

BPO 31344
Nosy @gpshead, @ncoghlan, @nedbat, @njsmith, @serhiy-storchaka, @zooba
PRs
  • bpo-31344: Per-frame control of trace events #3417
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/ncoghlan'
    closed_at = <Date 2017-09-08.00:14:59.760>
    created_at = <Date 2017-09-04.22:03:40.531>
    labels = ['type-feature', '3.7']
    title = 'f_trace_opcodes frame attribute to switch to per-opcode tracing'
    updated_at = <Date 2017-09-08.00:14:59.759>
    user = 'https://github.com/ncoghlan'

    bugs.python.org fields:

    activity = <Date 2017-09-08.00:14:59.759>
    actor = 'ncoghlan'
    assignee = 'ncoghlan'
    closed = True
    closed_date = <Date 2017-09-08.00:14:59.760>
    closer = 'ncoghlan'
    components = []
    creation = <Date 2017-09-04.22:03:40.531>
    creator = 'ncoghlan'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 31344
    keywords = []
    message_count = 6.0
    messages = ['301273', '301362', '301366', '301374', '301565', '301655']
    nosy_count = 6.0
    nosy_names = ['gregory.p.smith', 'ncoghlan', 'nedbat', 'njs', 'serhiy.storchaka', 'steve.dower']
    pr_nums = ['3417']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue31344'
    versions = ['Python 3.7']

    @ncoghlan
    Copy link
    Contributor Author

    ncoghlan commented Sep 4, 2017

    In order to test bpo-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.

    @ncoghlan ncoghlan added 3.7 (EOL) end of life type-feature A feature request or enhancement labels Sep 4, 2017
    @serhiy-storchaka
    Copy link
    Member

    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.

    @njsmith
    Copy link
    Contributor

    njsmith commented Sep 5, 2017

    Adding Ned to CC in case he wants to comment on the utility of per-opcode tracing from the perspective of coverage.py.

    @ncoghlan
    Copy link
    Contributor Author

    ncoghlan commented Sep 5, 2017

    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)

    @ncoghlan ncoghlan self-assigned this Sep 7, 2017
    @ncoghlan
    Copy link
    Contributor Author

    ncoghlan commented Sep 7, 2017

    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).

    @ncoghlan
    Copy link
    Contributor Author

    ncoghlan commented Sep 8, 2017

    New changeset 5a85167 by Nick Coghlan in branch 'master':
    bpo-31344: Per-frame control of trace events (GH-3417)
    5a85167

    @ncoghlan ncoghlan closed this as completed Sep 8, 2017
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants