@@ -118,7 +118,7 @@ The :mod:`bdb` module also defines two classes:
118
118
119
119
Count of the number of times a :class: `Breakpoint ` has been hit.
120
120
121
- .. class :: Bdb(skip=None)
121
+ .. class :: Bdb(skip=None, backend='settrace' )
122
122
123
123
The :class: `Bdb ` class acts as a generic Python debugger base class.
124
124
@@ -132,9 +132,22 @@ The :mod:`bdb` module also defines two classes:
132
132
frame is considered to originate in a certain module is determined
133
133
by the ``__name__ `` in the frame globals.
134
134
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
+
135
145
.. versionchanged :: 3.1
136
146
Added the *skip * parameter.
137
147
148
+ .. versionchanged :: 3.14
149
+ Added the *backend * parameter.
150
+
138
151
The following methods of :class: `Bdb ` normally don't need to be overridden.
139
152
140
153
.. method :: canonic(filename)
@@ -146,6 +159,20 @@ The :mod:`bdb` module also defines two classes:
146
159
<os.path.abspath> `. A *filename * with angle brackets, such as ``"<stdin>" ``
147
160
generated in interactive mode, is returned unchanged.
148
161
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
+
149
176
.. method :: reset()
150
177
151
178
Set the :attr: `!botframe `, :attr: `!stopframe `, :attr: `!returnframe ` and
@@ -364,6 +391,28 @@ The :mod:`bdb` module also defines two classes:
364
391
Return all breakpoints that are set.
365
392
366
393
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
+
367
416
Derived classes and clients can call the following methods to get a data
368
417
structure representing a stack trace.
369
418
0 commit comments