-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
gh-98894: Restore function entry/exit DTrace probes #142397
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Restore ``function__entry`` and ``function__return`` DTrace/SystemTap probes | ||
| that were broken since Python 3.11. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1452,6 +1452,38 @@ stop_tracing_and_jit(PyThreadState *tstate, _PyInterpreterFrame *frame) | |
| #define DONT_SLP_VECTORIZE | ||
| #endif | ||
|
|
||
| #ifdef WITH_DTRACE | ||
| static void | ||
| dtrace_function_entry(_PyInterpreterFrame *frame) | ||
| { | ||
| const char *filename; | ||
| const char *funcname; | ||
| int lineno; | ||
|
|
||
| PyCodeObject *code = _PyFrame_GetCode(frame); | ||
| filename = PyUnicode_AsUTF8(code->co_filename); | ||
| funcname = PyUnicode_AsUTF8(code->co_name); | ||
| lineno = PyUnstable_InterpreterFrame_GetLine(frame); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is expensive. In Ultimately, I'd like to redesign the location table to use a series of frames. That way finding the location info could be done with a binary search followed by a short linear scan. |
||
|
|
||
| PyDTrace_FUNCTION_ENTRY(filename, funcname, lineno); | ||
| } | ||
|
|
||
| static void | ||
| dtrace_function_return(_PyInterpreterFrame *frame) | ||
| { | ||
| const char *filename; | ||
| const char *funcname; | ||
| int lineno; | ||
|
|
||
| PyCodeObject *code = _PyFrame_GetCode(frame); | ||
| filename = PyUnicode_AsUTF8(code->co_filename); | ||
| funcname = PyUnicode_AsUTF8(code->co_name); | ||
| lineno = PyUnstable_InterpreterFrame_GetLine(frame); | ||
|
|
||
| PyDTrace_FUNCTION_RETURN(filename, funcname, lineno); | ||
| } | ||
| #endif | ||
|
|
||
| typedef struct { | ||
| _PyInterpreterFrame frame; | ||
| _PyStackRef stack[1]; | ||
|
|
@@ -1531,6 +1563,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int | |
| if (_Py_EnterRecursivePy(tstate)) { | ||
| goto early_exit; | ||
| } | ||
| DTRACE_FUNCTION_ENTRY(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This duplicates the probe point in |
||
| #ifdef Py_GIL_DISABLED | ||
| /* Load thread-local bytecode */ | ||
| if (frame->tlbc_index != ((_PyThreadStateImpl *)tstate)->tlbc_index) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've covered
returnandyield, but you'll need a probe point for unwinding as well.