@@ -1829,6 +1829,81 @@ cpdef stop_monitoring(all_threads=False):
18291829 thread_info.trace = False
18301830
18311831
1832+ # fmt: off
1833+ # IFDEF CYTHON -- DONT EDIT THIS FILE (it is automatically generated)
1834+ cpdef bint suspend_current_thread_tracing():
1835+ cdef ThreadInfo thread_info
1836+ # ELSE
1837+ # def suspend_current_thread_tracing():
1838+ # ENDIF
1839+ # fmt: on
1840+ """
1841+ Suspends tracing for the current thread.
1842+
1843+ Returns the previous tracing state (True if tracing was enabled, False otherwise).
1844+ This is useful for temporarily disabling tracing to prevent recursive debugging.
1845+
1846+ Use resume_current_thread_tracing() or set_current_thread_tracing_state() to restore.
1847+ """
1848+ try :
1849+ thread_info = _thread_local_info.thread_info
1850+ except :
1851+ thread_info = _get_thread_info(False , 1 )
1852+ if thread_info is None :
1853+ return False
1854+ previous_state = thread_info.trace
1855+ thread_info.trace = False
1856+ return previous_state
1857+
1858+
1859+ # fmt: off
1860+ # IFDEF CYTHON -- DONT EDIT THIS FILE (it is automatically generated)
1861+ cpdef resume_current_thread_tracing():
1862+ cdef ThreadInfo thread_info
1863+ # ELSE
1864+ # def resume_current_thread_tracing():
1865+ # ENDIF
1866+ # fmt: on
1867+ """
1868+ Resumes tracing for the current thread.
1869+
1870+ This unconditionally enables tracing. For conditional restoration,
1871+ use set_current_thread_tracing_state().
1872+ """
1873+ try :
1874+ thread_info = _thread_local_info.thread_info
1875+ except :
1876+ thread_info = _get_thread_info(False , 1 )
1877+ if thread_info is None :
1878+ return
1879+ thread_info.trace = True
1880+
1881+
1882+ # fmt: off
1883+ # IFDEF CYTHON -- DONT EDIT THIS FILE (it is automatically generated)
1884+ cpdef set_current_thread_tracing_state(bint trace):
1885+ cdef ThreadInfo thread_info
1886+ # ELSE
1887+ # def set_current_thread_tracing_state(trace):
1888+ # ENDIF
1889+ # fmt: on
1890+ """
1891+ Sets the tracing state for the current thread.
1892+
1893+ :param trace: True to enable tracing, False to disable.
1894+
1895+ This is typically used to restore a previously saved state from
1896+ suspend_current_thread_tracing().
1897+ """
1898+ try :
1899+ thread_info = _thread_local_info.thread_info
1900+ except :
1901+ thread_info = _get_thread_info(False , 1 )
1902+ if thread_info is None :
1903+ return
1904+ thread_info.trace = trace
1905+
1906+
18321907def update_monitor_events (suspend_requested: Optional[bool]=None ) -> None:
18331908 """
18341909 This should be called when breakpoints change.
0 commit comments