mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-98894: Restore function entry/exit DTrace probes
The function__entry and function__return probes stopped working in Python 3.11 when the interpreter was restructured around the new bytecode system. This change restores these probes by adding DTRACE_FUNCTION_ENTRY() at the start_frame label in bytecodes.c and DTRACE_FUNCTION_RETURN() in the RETURN_VALUE and YIELD_VALUE instructions. The helper functions are defined in ceval.c and extract the filename, function name, and line number from the frame before firing the probe. This builds on the approach from https://github.com/python/cpython/pull/125019 but avoids modifying the JIT template since the JIT does not currently support DTrace. The macros are conditionally compiled with WITH_DTRACE and are no-ops otherwise. The tests have been updated to use modern opcode names (CALL, CALL_KW, CALL_FUNCTION_EX) and a new bpftrace backend was added for Linux CI alongside the existing SystemTap tests. Line probe tests were removed since that probe was never restored after 3.11.
This commit is contained in:
parent
ef51a7c8f3
commit
b1e8453dda
12 changed files with 237 additions and 57 deletions
5
Python/generated_cases.c.h
generated
5
Python/generated_cases.c.h
generated
|
|
@ -7093,6 +7093,7 @@
|
|||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
assert(STACK_LEVEL() == 0);
|
||||
DTRACE_FUNCTION_RETURN();
|
||||
_Py_LeaveRecursiveCallPy(tstate);
|
||||
_PyInterpreterFrame *dying = frame;
|
||||
frame = tstate->current_frame = dying->previous;
|
||||
|
|
@ -7150,6 +7151,7 @@
|
|||
stack_pointer += -1;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
DTRACE_FUNCTION_RETURN();
|
||||
tstate->exc_info = gen->gi_exc_state.previous_item;
|
||||
gen->gi_exc_state.previous_item = NULL;
|
||||
_Py_LeaveRecursiveCallPy(tstate);
|
||||
|
|
@ -10056,6 +10058,7 @@
|
|||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
assert(STACK_LEVEL() == 0);
|
||||
DTRACE_FUNCTION_RETURN();
|
||||
_Py_LeaveRecursiveCallPy(tstate);
|
||||
_PyInterpreterFrame *dying = frame;
|
||||
frame = tstate->current_frame = dying->previous;
|
||||
|
|
@ -11795,6 +11798,7 @@
|
|||
stack_pointer += -1;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
DTRACE_FUNCTION_RETURN();
|
||||
tstate->exc_info = gen->gi_exc_state.previous_item;
|
||||
gen->gi_exc_state.previous_item = NULL;
|
||||
_Py_LeaveRecursiveCallPy(tstate);
|
||||
|
|
@ -11970,6 +11974,7 @@ JUMP_TO_LABEL(error);
|
|||
if (too_deep) {
|
||||
JUMP_TO_LABEL(exit_unwind);
|
||||
}
|
||||
DTRACE_FUNCTION_ENTRY();
|
||||
next_instr = frame->instr_ptr;
|
||||
#ifdef Py_DEBUG
|
||||
int lltrace = maybe_lltrace_resume_frame(frame, GLOBALS());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue