@@ -189,6 +189,34 @@ lltrace_resume_frame(_PyInterpreterFrame *frame)
189189 fflush (stdout );
190190 PyErr_SetRaisedException (exc );
191191}
192+
193+ static int
194+ maybe_lltrace_resume_frame (_PyInterpreterFrame * frame , _PyInterpreterFrame * skip_frame , PyObject * globals )
195+ {
196+ if (globals == NULL ) {
197+ return 0 ;
198+ }
199+ if (frame == skip_frame ) {
200+ return 0 ;
201+ }
202+ int r = PyDict_Contains (globals , & _Py_ID (__lltrace__ ));
203+ if (r < 0 ) {
204+ return -1 ;
205+ }
206+ int lltrace = r ;
207+ if (!lltrace ) {
208+ // When tracing executed uops, also trace bytecode
209+ char * uop_debug = Py_GETENV ("PYTHONUOPSDEBUG" );
210+ if (uop_debug != NULL && * uop_debug >= '0' ) {
211+ lltrace = (* uop_debug - '0' ) >= 5 ; // TODO: Parse an int and all that
212+ }
213+ }
214+ if (lltrace ) {
215+ lltrace_resume_frame (frame );
216+ }
217+ return lltrace ;
218+ }
219+
192220#endif
193221
194222static void monitor_raise (PyThreadState * tstate ,
@@ -576,6 +604,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
576604 return _PyEval_EvalFrame (tstate , f -> f_frame , throwflag );
577605}
578606
607+ #define TIER_ONE 1
579608#include "ceval_macros.h"
580609
581610
@@ -714,24 +743,9 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
714743 SET_LOCALS_FROM_FRAME ();
715744
716745#ifdef LLTRACE
717- {
718- if (frame != & entry_frame && GLOBALS ()) {
719- int r = PyDict_Contains (GLOBALS (), & _Py_ID (__lltrace__ ));
720- if (r < 0 ) {
721- goto exit_unwind ;
722- }
723- lltrace = r ;
724- if (!lltrace ) {
725- // When tracing executed uops, also trace bytecode
726- char * uop_debug = Py_GETENV ("PYTHONUOPSDEBUG" );
727- if (uop_debug != NULL && * uop_debug >= '0' ) {
728- lltrace = (* uop_debug - '0' ) >= 5 ; // TODO: Parse an int and all that
729- }
730- }
731- }
732- if (lltrace ) {
733- lltrace_resume_frame (frame );
734- }
746+ lltrace = maybe_lltrace_resume_frame (frame , & entry_frame , GLOBALS ());
747+ if (lltrace < 0 ) {
748+ goto exit_unwind ;
735749 }
736750#endif
737751
@@ -752,7 +766,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
752766#endif
753767 {
754768
755- #define TIER_ONE 1
756769#include "generated_cases.c.h"
757770
758771 /* INSTRUMENTED_LINE has to be here, rather than in bytecodes.c,
0 commit comments