Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Tidy up lltrace code a bit
  • Loading branch information
markshannon committed Aug 27, 2023
commit b142c56073fcb9c8be45177f9b9de28b1849ca7b
21 changes: 3 additions & 18 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -780,24 +780,9 @@ dummy_func(
LOAD_IP();

#if LLTRACE && TIER_ONE
{
if (frame != &entry_frame && GLOBALS()) {
int r = PyDict_Contains(GLOBALS(), &_Py_ID(__lltrace__));
if (r < 0) {
goto exit_unwind;
}
lltrace = r;
if (!lltrace) {
// When tracing executed uops, also trace bytecode
char *uop_debug = Py_GETENV("PYTHONUOPSDEBUG");
if (uop_debug != NULL && *uop_debug >= '0') {
lltrace = (*uop_debug - '0') >= 5; // TODO: Parse an int and all that
}
}
}
if (lltrace) {
lltrace_resume_frame(frame);
}
lltrace = maybe_lltrace_resume_frame(frame, &entry_frame, GLOBALS());
if (lltrace < 0) {
goto exit_unwind;
}
#endif
}
Expand Down
49 changes: 31 additions & 18 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,34 @@ lltrace_resume_frame(_PyInterpreterFrame *frame)
fflush(stdout);
PyErr_SetRaisedException(exc);
}

static int
maybe_lltrace_resume_frame(_PyInterpreterFrame *frame, _PyInterpreterFrame *skip_frame, PyObject *globals)
{
if (globals == NULL) {
return 0;
}
if (frame == skip_frame) {
return 0;
}
int r = PyDict_Contains(globals, &_Py_ID(__lltrace__));
if (r < 0) {
return -1;
}
int lltrace = r;
if (!lltrace) {
// When tracing executed uops, also trace bytecode
char *uop_debug = Py_GETENV("PYTHONUOPSDEBUG");
if (uop_debug != NULL && *uop_debug >= '0') {
lltrace = (*uop_debug - '0') >= 5; // TODO: Parse an int and all that
}
}
if (lltrace) {
lltrace_resume_frame(frame);
}
return lltrace;
}

#endif

static void monitor_raise(PyThreadState *tstate,
Expand Down Expand Up @@ -715,24 +743,9 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
SET_LOCALS_FROM_FRAME();

#ifdef LLTRACE
{
if (frame != &entry_frame && GLOBALS()) {
int r = PyDict_Contains(GLOBALS(), &_Py_ID(__lltrace__));
if (r < 0) {
goto exit_unwind;
}
lltrace = r;
if (!lltrace) {
// When tracing executed uops, also trace bytecode
char *uop_debug = Py_GETENV("PYTHONUOPSDEBUG");
if (uop_debug != NULL && *uop_debug >= '0') {
lltrace = (*uop_debug - '0') >= 5; // TODO: Parse an int and all that
}
}
}
if (lltrace) {
lltrace_resume_frame(frame);
}
lltrace = maybe_lltrace_resume_frame(frame, &entry_frame, GLOBALS());
if (lltrace < 0) {
goto exit_unwind;
}
#endif

Expand Down
21 changes: 3 additions & 18 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 6 additions & 36 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.