Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GH-103082: Implementation of PEP 669: Low Impact Monitoring for CPython#103083

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
markshannon merged 127 commits intopython:mainfromfaster-cpython:pep-669
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
127 commits
Select commitHold shift + click to select a range
e85d910
Initial experimental implementation of PEP 669.
markshannonNov 9, 2022
6283ee8
First draft implementing small subset of PEP 669.
markshannonNov 18, 2022
4edb7b7
Support disabling and restarting.
markshannonNov 28, 2022
852c40b
Support multiple tools per event.
markshannonNov 28, 2022
416b314
Tidy up of monitoring internals
markshannonDec 2, 2022
7971979
Fix legacy tracing.
markshannonDec 4, 2022
9896902
Implement support for multiple tools.
markshannonDec 8, 2022
f432a66
Get support for line tracing mostly working. Needs to wait for regist…
markshannonDec 22, 2022
fb29b34
Merge branch 'main' into pep-669-incremental
markshannonJan 13, 2023
15a1ccd
Fix up INSTRUMENTED_OPCODES vector.
markshannonJan 13, 2023
9abb339
Fix instrumented branches to call instrumentation with correct target.
markshannonJan 16, 2023
3ba6a39
Merge main and assorted fixups to handle new instruction.
markshannonJan 17, 2023
aa09895
Add PY_THROW event handling and fix up line table.
markshannonJan 17, 2023
9e5d87d
LINE events working for sys.setrace.
markshannonJan 17, 2023
e52cbe6
Add lots of internal debugging for instrumentation.
markshannonJan 18, 2023
6c8be7e
Add more tests. Get those and some other passing.
markshannonJan 18, 2023
c9e1e21
Fix LINE instrumentation and frame.set_lineno support (mostly)
markshannonJan 19, 2023
e52e8d3
Refining line event generation.
markshannonJan 20, 2023
f434ec7
Get sys.settrace tests passing.
markshannonJan 20, 2023
b680084
Monitor 'internal' StopIteration raises.
markshannonJan 20, 2023
e6e7cf1
Check for NULLs.
markshannonJan 20, 2023
5bbc83e
Fix up a few tests
markshannonJan 20, 2023
7fe9a43
Turn off debugging output by default.
markshannonJan 23, 2023
8b9f996
Remove debugging printfs
markshannonJan 26, 2023
9b02640
Avoid refleak.
markshannonJan 26, 2023
2cadf32
Record last traced line on frame object.
markshannonJan 26, 2023
1f54d77
Get a couple more top-level tests passing.
markshannonJan 30, 2023
43a3f3e
Update magic number
markshannonJan 30, 2023
3d436cf
Remove debug print statement.
markshannonJan 30, 2023
691bcf5
Raise SystemError if frame is missing.
markshannonJan 30, 2023
f07be07
Restore a few tests and better handle EXTENDED_ARG.
markshannonJan 31, 2023
8b8f67e
Make sure instrumentation respects instruction boundaries.
markshannonFeb 1, 2023
d0a2228
Fix handling of errors in jump instruments
markshannonFeb 1, 2023
2a3a85e
Fix memory leaks.
markshannonFeb 1, 2023
c3724ab
Instrument FOR_ITER.
markshannonFeb 1, 2023
d64823c
Fix legacy profiling of calls.
markshannonFeb 2, 2023
284d0b1
Fix up instrumented yield.
markshannonFeb 3, 2023
b9e1f3b
Merge branch 'main' into pep-669-incremental
markshannonFeb 8, 2023
1440473
Fix instrumentation of SEND and tidy up instrumented bytecode numbering.
markshannonFeb 9, 2023
825f42a
Handle line numbers in exception handled event.
markshannonFeb 9, 2023
ce5ddb3
Instrument END_FOR to mimic PEP 380 StopIteration and add more tests.
markshannonFeb 10, 2023
5740c47
Merge branch 'main' into pep-669-incremental
markshannonFeb 13, 2023
da83abe
Add END_SEND for instrumentation.
markshannonFeb 14, 2023
cdb2bda
Correctly set StopIteration in INSTRUMENTED_END_FOR.
markshannonFeb 14, 2023
0148fa3
Set last traced line when jumping in debugger.
markshannonFeb 14, 2023
c5fb4f4
Fix test_dis to account for END_SEND.
markshannonFeb 17, 2023
7fa431b
Add a few more tests.
markshannonFeb 17, 2023
25bbc61
delete commented out code
markshannonFeb 17, 2023
5629a3e
Fix last (known) inconsistency in sys.settrace behaviour
markshannonFeb 17, 2023
477cc53
More clearly differentiate between instrumented events and non-instru…
markshannonFeb 20, 2023
23b5f5e
Add support for sys.monitoring.MISSING
markshannonFeb 21, 2023
dfc18c5
Add support for local (per-code-object) event monitoring.
markshannonFeb 23, 2023
566adbe
Merge branch 'main' into pep-669
markshannonFeb 23, 2023
cfb17ed
Make sure that tracing/profiling thread counts are correct.
markshannonFeb 23, 2023
c535f76
Remove linearray field
markshannonFeb 23, 2023
d579d2e
Rename some fields, shortening names.
markshannonFeb 23, 2023
0982e5e
Remove out of dat comments.
markshannonFeb 23, 2023
0693423
Remove instrumentation for JUMP_IF_[FALS|TRUE]_OR_POP
markshannonMar 22, 2023
d6453e5
Merge branch 'main' into pep-669
markshannonMar 22, 2023
0ee2aee
Minor fixups from merge.
markshannonMar 23, 2023
acdca93
Remove instrumentation for COMPARE_AND_BRANCH.
markshannonMar 23, 2023
f17ef14
Merge branch 'main' into pep-669
markshannonMar 23, 2023
e7f6c37
Group instrumented opcodes.
markshannonMar 23, 2023
e44ebc5
Remove last references to DO_TRACING
markshannonMar 23, 2023
ece51e6
Merge branch 'main' into pep-669
markshannonMar 23, 2023
e88921e
Remove unused function.
markshannonMar 23, 2023
2d9f22c
Streamline de-instrumentation a little.
markshannonMar 23, 2023
b7579ac
Use modern API for saving and restoring exception.
markshannonMar 23, 2023
5a089a6
Refactor instrumentation calls to reduce duplication.
markshannonMar 24, 2023
d5fdec8
Fix refleaks
markshannonMar 24, 2023
c88741d
Remove commented out code.
markshannonMar 24, 2023
b6744ca
Make sure that stacktop == -1 when stack_pointer is cached.
markshannonMar 24, 2023
6c3473a
Minor cleanups.
markshannonMar 24, 2023
899aecd
Remove useless asserts.
markshannonMar 24, 2023
80d2e2e
Make functions static
markshannonMar 24, 2023
94d35d8
Update Windows build files.
markshannonMar 24, 2023
5aa0805
Make _PyLegacyEventHandler_Type immortal
markshannonMar 24, 2023
b39edd3
Make arrays const.
markshannonMar 24, 2023
c9c40cb
Rename _PyFrame_GetStackPointer to _PyFrame_FetchStackPointer and mak…
markshannonMar 24, 2023
6611c72
Fixups from code review
markshannonMar 24, 2023
50d28f1
Improve debugging output and make a few things more robust.
markshannonMar 24, 2023
7165f52
Fix up frame.set_lineno().
markshannonMar 25, 2023
65c548e
Make line instrumentation able to handle multiple inits.
markshannonMar 25, 2023
575f7d1
Add brief comments on instrumentation data structures.
markshannonMar 25, 2023
415741d
Add symbol constant for min instrumented opcode.
markshannonMar 25, 2023
d70a1a4
Code cleanup from review.
markshannonMar 25, 2023
d580de6
A bit more cleanup.
markshannonMar 25, 2023
2076d5f
Add a few more comments.
markshannonMar 25, 2023
7b32d79
Remove unused code.
markshannonMar 25, 2023
662c16c
Fix leak of monitoring blocks.
markshannonMar 25, 2023
d0139e9
Merge branch 'main' into pep-669
markshannonMar 25, 2023
51a93e7
Make function static.
markshannonMar 25, 2023
64bf37f
Use symbolic constants in line computations.
markshannonMar 26, 2023
5faec77
Make data static.
markshannonMar 26, 2023
0be1562
Add extra check.
markshannonMar 26, 2023
b32a075
Make sure that instrumentation of line and instructions at the same t…
markshannonMar 26, 2023
85d6923
Remove incorrect assertion.
markshannonMar 31, 2023
ebcc42f
Turn off instrumentation debugging.
markshannonMar 31, 2023
7cfbc7e
Fix a couple of errors.
markshannonMar 31, 2023
d366364
Add minimal news entry.
markshannonMar 31, 2023
fdb4860
Pacify the global object checker.
markshannonMar 31, 2023
aee722f
Minor fixups.
markshannonApr 3, 2023
bba53b8
Fix refleak when error in RETURN instrumentation.
markshannonApr 3, 2023
718fbc8
Merge branch 'main' into pep-669
markshannonApr 3, 2023
97ec1c5
Fix another refleak in error handling in instrumented instruction.
markshannonApr 3, 2023
edc6709
Remove debug code ready for final review.
markshannonApr 3, 2023
e40a68f
Fix another (and hopefully final) refleak when handling an error in a…
markshannonApr 3, 2023
d9f8192
Comment and rename #defines to better reflect names in PEP.
markshannonApr 4, 2023
2d9a380
Add various IDs as defined in the PEP.
markshannonApr 4, 2023
29f41e7
Remove _PyThreadState_UpdateTracingState.
markshannonApr 4, 2023
38b7f43
Formatting fixes, and check error codes.
markshannonApr 4, 2023
9a40dad
Make sure tool API function names match PEP.
markshannonApr 4, 2023
a551d65
A bit more cleanup.
markshannonApr 4, 2023
4951306
Tidy up imports.
markshannonApr 4, 2023
44a031e
Use clinic return converters.
markshannonApr 4, 2023
c2155b7
Address code review.
markshannonApr 4, 2023
b218428
Address further review comments.
markshannonApr 4, 2023
9c0429e
Use byte offset, to conform to the convention used in other APIs taki…
markshannonApr 5, 2023
c6bf38e
Address code review.
markshannonApr 5, 2023
82fe16c
Merge branch 'main' into pep-669
markshannonApr 5, 2023
43618a9
Keep check-c-globals happy.
markshannonApr 5, 2023
821ae52
Don't crash if locals events aren't set.
markshannonApr 9, 2023
505a08d
Add NO_EVENTS.
markshannonApr 9, 2023
f63da91
Flip order of LINE and INSTRUCTION events.
markshannonApr 9, 2023
c324344
Check tool is in use when setting events.
markshannonApr 9, 2023
168b34a
Reset last traced line number when setting frame.f_trace only if set …
markshannonApr 12, 2023
f07a080
Tidy up test case.
markshannonApr 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Reset last traced line number when setting frame.f_trace only if set …
…to new value.
  • Loading branch information
@markshannon
markshannon committedApr 12, 2023
commit168b34ab6f94ccdcc88f0ab7fc6d2b6e0182b74c
42 changes: 42 additions & 0 deletionsLib/test/test_sys_settrace.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2825,5 +2825,47 @@ def test_events(self):
(6, 'line')])


class TestSetLocalTrace(TraceTestCase):

def test_with_branches(self):
events = []

def tracefunc(frame, event, arg):
if frame.f_code.co_name == "func":
frame.f_trace = tracefunc
line = frame.f_lineno - frame.f_code.co_firstlineno
events.append((line, event))
return tracefunc
def func(arg = 1):
N = 1
if arg >= 2: # step 1
not_reached = 3
else:
reached = 5
if arg >= 3: # step 3
not_reached = 7
else:
reached = 9
the_end = 10

EXPECTED_EVENTS = [
(0, 'call'),
(1, 'line'),
(2, 'line'),
(5, 'line'),
(6, 'line'),
(9, 'line'),
(10, 'line'),
(10, 'return'),
]

sys.settrace(tracefunc)
sys._getframe().f_trace = tracefunc
func()
self.assertEqual(events, EXPECTED_EVENTS)
sys.settrace(None)



if __name__ == "__main__":
unittest.main()
6 changes: 4 additions & 2 deletionsObjects/frameobject.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -852,8 +852,10 @@ frame_settrace(PyFrameObject *f, PyObject* v, void *closure)
if (v == Py_None) {
v = NULL;
}
Py_XSETREF(f->f_trace, Py_XNewRef(v));
f->f_last_traced_line = -1;
if (v != f->f_trace) {
Py_XSETREF(f->f_trace, Py_XNewRef(v));
f->f_last_traced_line = -1;
}
return 0;
}

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp