@@ -5568,57 +5568,47 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
5568
5568
case DO_TRACING :
5569
5569
#endif
5570
5570
{
5571
- if (tstate -> tracing == 0 ) {
5571
+ if (tstate -> tracing == 0 &&
5572
+ INSTR_OFFSET () >= frame -> f_code -> _co_firsttraceable
5573
+ ) {
5572
5574
int instr_prev = _PyInterpreterFrame_LASTI (frame );
5573
5575
frame -> prev_instr = next_instr ;
5574
5576
TRACING_NEXTOPARG ();
5575
- switch (opcode ) {
5576
- case COPY_FREE_VARS :
5577
- case MAKE_CELL :
5578
- case RETURN_GENERATOR :
5579
- /* Frame not fully initialized */
5580
- break ;
5581
- case RESUME :
5582
- if (oparg < 2 ) {
5583
- CHECK_EVAL_BREAKER ();
5584
- }
5585
- /* Call tracing */
5586
- TRACE_FUNCTION_ENTRY ();
5587
- DTRACE_FUNCTION_ENTRY ();
5588
- break ;
5589
- case POP_TOP :
5590
- if (_Py_OPCODE (next_instr [-1 ]) == RETURN_GENERATOR ) {
5591
- /* Frame not fully initialized */
5592
- break ;
5593
- }
5594
- /* fall through */
5595
- default :
5596
- /* line-by-line tracing support */
5597
- if (PyDTrace_LINE_ENABLED ()) {
5598
- maybe_dtrace_line (frame , & tstate -> trace_info , instr_prev );
5599
- }
5600
-
5601
- if (cframe .use_tracing &&
5602
- tstate -> c_tracefunc != NULL && !tstate -> tracing ) {
5603
- int err ;
5604
- /* see maybe_call_line_trace()
5605
- for expository comments */
5606
- _PyFrame_SetStackPointer (frame , stack_pointer );
5607
-
5608
- err = maybe_call_line_trace (tstate -> c_tracefunc ,
5609
- tstate -> c_traceobj ,
5610
- tstate , frame , instr_prev );
5611
- if (err ) {
5612
- /* trace function raised an exception */
5613
- next_instr ++ ;
5614
- goto error ;
5615
- }
5616
- /* Reload possibly changed frame fields */
5617
- next_instr = frame -> prev_instr ;
5577
+ if (opcode == RESUME ) {
5578
+ if (oparg < 2 ) {
5579
+ CHECK_EVAL_BREAKER ();
5580
+ }
5581
+ /* Call tracing */
5582
+ TRACE_FUNCTION_ENTRY ();
5583
+ DTRACE_FUNCTION_ENTRY ();
5584
+ }
5585
+ else {
5586
+ /* line-by-line tracing support */
5587
+ if (PyDTrace_LINE_ENABLED ()) {
5588
+ maybe_dtrace_line (frame , & tstate -> trace_info , instr_prev );
5589
+ }
5618
5590
5619
- stack_pointer = _PyFrame_GetStackPointer (frame );
5620
- frame -> stacktop = -1 ;
5591
+ if (cframe .use_tracing &&
5592
+ tstate -> c_tracefunc != NULL && !tstate -> tracing ) {
5593
+ int err ;
5594
+ /* see maybe_call_line_trace()
5595
+ for expository comments */
5596
+ _PyFrame_SetStackPointer (frame , stack_pointer );
5597
+
5598
+ err = maybe_call_line_trace (tstate -> c_tracefunc ,
5599
+ tstate -> c_traceobj ,
5600
+ tstate , frame , instr_prev );
5601
+ if (err ) {
5602
+ /* trace function raised an exception */
5603
+ next_instr ++ ;
5604
+ goto error ;
5621
5605
}
5606
+ /* Reload possibly changed frame fields */
5607
+ next_instr = frame -> prev_instr ;
5608
+
5609
+ stack_pointer = _PyFrame_GetStackPointer (frame );
5610
+ frame -> stacktop = -1 ;
5611
+ }
5622
5612
}
5623
5613
}
5624
5614
TRACING_NEXTOPARG ();
@@ -6855,13 +6845,8 @@ maybe_call_line_trace(Py_tracefunc func, PyObject *obj,
6855
6845
then call the trace function if we're tracing source lines.
6856
6846
*/
6857
6847
initialize_trace_info (& tstate -> trace_info , frame );
6858
- int entry_point = 0 ;
6859
- _Py_CODEUNIT * code = _PyCode_CODE (frame -> f_code );
6860
- while (_PyOpcode_Deopt [_Py_OPCODE (code [entry_point ])] != RESUME ) {
6861
- entry_point ++ ;
6862
- }
6863
6848
int lastline ;
6864
- if (instr_prev <= entry_point ) {
6849
+ if (instr_prev <= frame -> f_code -> _co_firsttraceable ) {
6865
6850
lastline = -1 ;
6866
6851
}
6867
6852
else {
0 commit comments