Skip to content
Prev Previous commit
Next Next commit
Merge branch 'main' into py-interpreter-frame-api
  • Loading branch information
markshannon committed May 4, 2023
commit 53ce02c9fa6f6210a963e2b116fdcac17aff33b9
71 changes: 5 additions & 66 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,10 +782,12 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
#endif
/* Tell C compilers not to hold the opcode variable in the loop.
next_instr points the current instruction without TARGET(). */
opcode = _Py_OPCODE(*next_instr);
fprintf(stderr, "XXX lineno: %d, opcode: %d\n",
opcode = next_instr->op.code;
_PyErr_Format(tstate, PyExc_SystemError,
PyUnstable_InterpreterFrame_GetLine(frame), opcode);
_PyErr_SetString(tstate, PyExc_SystemError, "unknown opcode");
frame->f_code->co_filename,
PyUnstable_InterpreterFrame_GetLine(frame),
opcode);
goto error;

} /* End instructions */
Expand Down Expand Up @@ -2650,69 +2652,6 @@ PyUnstable_Eval_RequestCodeExtraIndex(freefunc free)
return new_index;
}

static void
dtrace_function_entry(_PyInterpreterFrame *frame)
{
const char *filename;
const char *funcname;
int lineno;

PyCodeObject *code = frame->f_code;
filename = PyUnicode_AsUTF8(code->co_filename);
funcname = PyUnicode_AsUTF8(code->co_name);
lineno = PyUnstable_InterpreterFrame_GetLine(frame);

PyDTrace_FUNCTION_ENTRY(filename, funcname, lineno);
}

static void
dtrace_function_return(_PyInterpreterFrame *frame)
{
const char *filename;
const char *funcname;
int lineno;

PyCodeObject *code = frame->f_code;
filename = PyUnicode_AsUTF8(code->co_filename);
funcname = PyUnicode_AsUTF8(code->co_name);
lineno = PyUnstable_InterpreterFrame_GetLine(frame);

PyDTrace_FUNCTION_RETURN(filename, funcname, lineno);
}

/* DTrace equivalent of maybe_call_line_trace. */
static void
maybe_dtrace_line(_PyInterpreterFrame *frame,
PyTraceInfo *trace_info,
int instr_prev)
{
const char *co_filename, *co_name;

/* If the last instruction executed isn't in the current
instruction window, reset the window.
*/
initialize_trace_info(trace_info, frame);
int lastline = _PyCode_CheckLineNumber(instr_prev*sizeof(_Py_CODEUNIT), &trace_info->bounds);
int addr = _PyInterpreterFrame_LASTI(frame) * sizeof(_Py_CODEUNIT);
int line = _PyCode_CheckLineNumber(addr, &trace_info->bounds);
if (line != -1) {
/* Trace backward edges or first instruction of a new line */
if (_PyInterpreterFrame_LASTI(frame) < instr_prev ||
(line != lastline && addr == trace_info->bounds.ar_start))
{
co_filename = PyUnicode_AsUTF8(frame->f_code->co_filename);
if (!co_filename) {
co_filename = "?";
}
co_name = PyUnicode_AsUTF8(frame->f_code->co_name);
if (!co_name) {
co_name = "?";
}
PyDTrace_LINE(co_filename, co_name, line);
}
}
}

/* Implement Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() as functions
for the limited API. */

Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.