@@ -118,7 +118,7 @@ The :mod:`bdb` module also defines two classes:
118118
119119      Count of the number of times a :class: `Breakpoint ` has been hit.
120120
121- .. class :: Bdb(skip=None) 
121+ .. class :: Bdb(skip=None, backend='settrace' ) 
122122
123123   The :class: `Bdb ` class acts as a generic Python debugger base class.
124124
@@ -132,9 +132,22 @@ The :mod:`bdb` module also defines two classes:
132132   frame is considered to originate in a certain module is determined
133133   by the ``__name__ `` in the frame globals.
134134
135+    The *backend * argument specifies the backend to use for :class: `Bdb `. It
136+    can be either ``'settrace' `` or ``'monitoring' ``. ``'settrace' `` uses
137+    :func: `sys.settrace ` which has the best backward compatibility. The
138+    ``'monitoring' `` backend uses the new :mod: `sys.monitoring ` that was
139+    introduced in Python 3.12, which can be much more efficient because it
140+    can disable unused events. We are trying to keep the exact interfaces
141+    for both backends, but there are some differences. The debugger developers
142+    are encouraged to use the ``'monitoring' `` backend to achieve better
143+    performance.
144+ 
135145   .. versionchanged :: 3.1 
136146      Added the *skip * parameter.
137147
148+    .. versionchanged :: 3.14 
149+       Added the *backend * parameter.
150+ 
138151   The following methods of :class: `Bdb ` normally don't need to be overridden.
139152
140153   .. method :: canonic(filename) 
@@ -146,6 +159,20 @@ The :mod:`bdb` module also defines two classes:
146159      <os.path.abspath> `. A *filename * with angle brackets, such as ``"<stdin>" ``
147160      generated in interactive mode, is returned unchanged.
148161
162+    .. method :: start_trace(self) 
163+ 
164+       Start tracing. For ``'settrace' `` backend, this method is equivalent to
165+       ``sys.settrace(self.trace_dispatch) ``
166+ 
167+       .. versionadded :: 3.14 
168+ 
169+    .. method :: stop_trace(self) 
170+ 
171+       Stop tracing. For ``'settrace' `` backend, this method is equivalent to
172+       ``sys.settrace(None) ``
173+ 
174+       .. versionadded :: 3.14 
175+ 
149176   .. method :: reset() 
150177
151178      Set the :attr: `!botframe `, :attr: `!stopframe `, :attr: `!returnframe ` and
@@ -364,6 +391,28 @@ The :mod:`bdb` module also defines two classes:
364391      Return all breakpoints that are set.
365392
366393
394+    Derived classes and clients can call the following methods to disable and
395+    restart events to achieve better performance. These methods only work
396+    when using the ``'monitoring' `` backend.
397+ 
398+    .. method :: disable_current_event() 
399+ 
400+       Disable the current event until the next time :func: `restart_events ` is
401+       called. This is helpful when the debugger is not interested in the current
402+       line.
403+ 
404+       .. versionadded :: 3.14 
405+ 
406+    .. method :: restart_events() 
407+ 
408+       Restart all the disabled events. This function is automatically called in
409+       ``dispatch_* `` methods after ``user_* `` methods are called. If the
410+       ``dispatch_* `` methods are not overridden, the disabled events will be
411+       restarted after each user interaction.
412+ 
413+       .. versionadded :: 3.14 
414+ 
415+ 
367416   Derived classes and clients can call the following methods to get a data
368417   structure representing a stack trace.
369418
0 commit comments