@@ -20,20 +20,21 @@ The following exception is defined:
20
20
21
21
The :mod: `bdb ` module also defines two classes:
22
22
23
- .. class :: Breakpoint(self, file, line, temporary=0 , cond=None, funcname=None)
23
+ .. class :: Breakpoint(self, file, line, temporary=False , cond=None, funcname=None)
24
24
25
25
This class implements temporary breakpoints, ignore counts, disabling and
26
26
(re-)enabling, and conditionals.
27
27
28
28
Breakpoints are indexed by number through a list called :attr: `bpbynumber `
29
- and by ``(file, line) `` pairs through :attr: `bplist `. The former points to a
30
- single instance of class :class: `Breakpoint `. The latter points to a list of
31
- such instances since there may be more than one breakpoint per line.
29
+ and by ``(file, line) `` pairs through :attr: `bplist `. The former points to
30
+ a single instance of class :class: `Breakpoint `. The latter points to a list
31
+ of such instances since there may be more than one breakpoint per line.
32
32
33
- When creating a breakpoint, its associated filename should be in canonical
34
- form. If a *funcname * is defined, a breakpoint hit will be counted when the
35
- first line of that function is executed. A conditional breakpoint always
36
- counts a hit.
33
+ When creating a breakpoint, its associated :attr: `file name <file> ` should
34
+ be in canonical form. If a :attr: `funcname ` is defined, a breakpoint
35
+ :attr: `hit <hits> ` will be counted when the first line of that function is
36
+ executed. A :attr: `conditional <cond> ` breakpoint always counts a
37
+ :attr: `hit <hits> `.
37
38
38
39
:class: `Breakpoint ` instances have the following methods:
39
40
@@ -59,12 +60,12 @@ The :mod:`bdb` module also defines two classes:
59
60
Return a string with all the information about the breakpoint, nicely
60
61
formatted:
61
62
62
- * The breakpoint number.
63
- * If it is temporary or not .
64
- * Its file, line position.
65
- * The condition that causes a break .
66
- * If it must be ignored the next N times .
67
- * The breakpoint hit count .
63
+ * Breakpoint number.
64
+ * Temporary status (del or keep) .
65
+ * File/ line position.
66
+ * Break condition.
67
+ * Number of times to ignore .
68
+ * Number of times hit .
68
69
69
70
.. versionadded :: 3.2
70
71
@@ -73,6 +74,49 @@ The :mod:`bdb` module also defines two classes:
73
74
Print the output of :meth: `bpformat ` to the file *out *, or if it is
74
75
``None ``, to standard output.
75
76
77
+ :class: `Breakpoint ` instances have the following attributes:
78
+
79
+ .. attribute :: file
80
+
81
+ File name of the :class: `Breakpoint `.
82
+
83
+ .. attribute :: line
84
+
85
+ Line number of the :class: `Breakpoint ` within :attr: `file `.
86
+
87
+ .. attribute :: temporary
88
+
89
+ True if a :class: `Breakpoint ` at (file, line) is temporary.
90
+
91
+ .. attribute :: cond
92
+
93
+ Condition for evaluating a :class: `Breakpoint ` at (file, line).
94
+
95
+ .. attribute :: funcname
96
+
97
+ Function name that defines whether a :class: `Breakpoint ` is hit upon
98
+ entering the function.
99
+
100
+ .. attribute :: enabled
101
+
102
+ True if :class: `Breakpoint ` is enabled.
103
+
104
+ .. attribute :: bpbynumber
105
+
106
+ Numeric index for a single instance of a :class: `Breakpoint `.
107
+
108
+ .. attribute :: bplist
109
+
110
+ Dictionary of :class: `Breakpoint ` instances indexed by
111
+ (:attr: `file `, :attr: `line `) tuples.
112
+
113
+ .. attribute :: ignore
114
+
115
+ Number of times to ignore a :class: `Breakpoint `.
116
+
117
+ .. attribute :: hits
118
+
119
+ Count of the number of times a :class: `Breakpoint ` has been hit.
76
120
77
121
.. class :: Bdb(skip=None)
78
122
@@ -95,9 +139,12 @@ The :mod:`bdb` module also defines two classes:
95
139
96
140
.. method :: canonic(filename)
97
141
98
- Auxiliary method for getting a filename in a canonical form, that is, as a
99
- case-normalized (on case-insensitive filesystems) absolute path, stripped
100
- of surrounding angle brackets.
142
+ Return canonical form of *filename *.
143
+
144
+ For real file names, the canonical form is an operating-system-dependent,
145
+ :func: `case-normalized <os.path.normcase> ` :func: `absolute path
146
+ <os.path.abspath> `. A *filename * with angle brackets, such as `"<stdin>" `
147
+ generated in interactive mode, is returned unchanged.
101
148
102
149
.. method :: reset()
103
150
@@ -166,45 +213,46 @@ The :mod:`bdb` module also defines two classes:
166
213
Normally derived classes don't override the following methods, but they may
167
214
if they want to redefine the definition of stopping and breakpoints.
168
215
216
+ .. method :: is_skipped_line(module_name)
217
+
218
+ Return True if *module_name * matches any skip pattern.
219
+
169
220
.. method :: stop_here(frame)
170
221
171
- This method checks if the *frame * is somewhere below :attr: `botframe ` in
172
- the call stack. :attr: `botframe ` is the frame in which debugging started.
222
+ Return True if *frame * is below the starting frame in the stack.
173
223
174
224
.. method :: break_here(frame)
175
225
176
- This method checks if there is a breakpoint in the filename and line
177
- belonging to *frame * or, at least, in the current function. If the
178
- breakpoint is a temporary one, this method deletes it.
226
+ Return True if there is an effective breakpoint for this line.
227
+
228
+ Check whether a line or function breakpoint exists and is in effect. Delete temporary
229
+ breakpoints based on information from :func: `effective `.
179
230
180
231
.. method :: break_anywhere(frame)
181
232
182
- This method checks if there is a breakpoint in the filename of the current
183
- frame.
233
+ Return True if any breakpoint exists for *frame *'s filename.
184
234
185
235
Derived classes should override these methods to gain control over debugger
186
236
operation.
187
237
188
238
.. method :: user_call(frame, argument_list)
189
239
190
- This method is called from :meth: `dispatch_call ` when there is the
191
- possibility that a break might be necessary anywhere inside the called
192
- function.
240
+ Called from :meth: `dispatch_call ` if a break might stop inside the
241
+ called function.
193
242
194
243
.. method :: user_line(frame)
195
244
196
- This method is called from :meth: `dispatch_line ` when either
197
- :meth: `stop_here ` or :meth: ` break_here ` yields ``True ``.
245
+ Called from :meth: `dispatch_line ` when either :meth: ` stop_here ` or
246
+ :meth: `break_here ` returns ``True ``.
198
247
199
248
.. method :: user_return(frame, return_value)
200
249
201
- This method is called from :meth: `dispatch_return ` when :meth: `stop_here `
202
- yields ``True ``.
250
+ Called from :meth: `dispatch_return ` when :meth: `stop_here ` returns ``True ``.
203
251
204
252
.. method :: user_exception(frame, exc_info)
205
253
206
- This method is called from :meth: `dispatch_exception ` when
207
- :meth: ` stop_here ` yields ``True ``.
254
+ Called from :meth: `dispatch_exception ` when :meth: ` stop_here `
255
+ returns ``True ``.
208
256
209
257
.. method :: do_clear(arg)
210
258
@@ -228,9 +276,9 @@ The :mod:`bdb` module also defines two classes:
228
276
229
277
Stop when returning from the given frame.
230
278
231
- .. method :: set_until(frame)
279
+ .. method :: set_until(frame, lineno=None )
232
280
233
- Stop when the line with the line no greater than the current one is
281
+ Stop when the line with the * lineno * greater than the current one is
234
282
reached or when returning from current frame.
235
283
236
284
.. method :: set_trace([frame])
@@ -253,16 +301,16 @@ The :mod:`bdb` module also defines two classes:
253
301
breakpoints. These methods return a string containing an error message if
254
302
something went wrong, or ``None `` if all is well.
255
303
256
- .. method :: set_break(filename, lineno, temporary=0 , cond, funcname)
304
+ .. method :: set_break(filename, lineno, temporary=False , cond=None , funcname=None )
257
305
258
306
Set a new breakpoint. If the *lineno * line doesn't exist for the
259
307
*filename * passed as argument, return an error message. The *filename *
260
308
should be in canonical form, as described in the :meth: `canonic ` method.
261
309
262
310
.. method :: clear_break(filename, lineno)
263
311
264
- Delete the breakpoints in *filename * and *lineno *. If none were set, an
265
- error message is returned .
312
+ Delete the breakpoints in *filename * and *lineno *. If none were set,
313
+ return an error message .
266
314
267
315
.. method :: clear_bpbynumber(arg)
268
316
@@ -272,12 +320,13 @@ The :mod:`bdb` module also defines two classes:
272
320
273
321
.. method :: clear_all_file_breaks(filename)
274
322
275
- Delete all breakpoints in *filename *. If none were set, an error message
276
- is returned .
323
+ Delete all breakpoints in *filename *. If none were set, return an error
324
+ message .
277
325
278
326
.. method :: clear_all_breaks()
279
327
280
- Delete all existing breakpoints.
328
+ Delete all existing breakpoints. If none were set, return an error
329
+ message.
281
330
282
331
.. method :: get_bpbynumber(arg)
283
332
@@ -290,7 +339,7 @@ The :mod:`bdb` module also defines two classes:
290
339
291
340
.. method :: get_break(filename, lineno)
292
341
293
- Check if there is a breakpoint for *lineno * of *filename *.
342
+ Return True if there is a breakpoint for *lineno * in *filename *.
294
343
295
344
.. method :: get_breaks(filename, lineno)
296
345
@@ -311,16 +360,18 @@ The :mod:`bdb` module also defines two classes:
311
360
312
361
.. method :: get_stack(f, t)
313
362
314
- Get a list of records for a frame and all higher (calling) and lower
315
- frames, and the size of the higher part.
363
+ Return a list of (frame, lineno) tuples in a stack trace, and a size.
364
+
365
+ The most recently called frame is last in the list. The size is the number
366
+ of frames below the frame where the debugger was invoked.
316
367
317
368
.. method :: format_stack_entry(frame_lineno, lprefix=': ')
318
369
319
- Return a string with information about a stack entry, identified by a
320
- ``(frame, lineno) `` tuple:
370
+ Return a string with information about a stack entry, which is a
371
+ ``(frame, lineno) `` tuple. The return string contains :
321
372
322
- * The canonical form of the filename which contains the frame.
323
- * The function name, or ``"<lambda>" ``.
373
+ * The canonical filename which contains the frame.
374
+ * The function name or ``"<lambda>" ``.
324
375
* The input arguments.
325
376
* The return value.
326
377
* The line of code (if it exists).
@@ -352,20 +403,34 @@ Finally, the module defines the following functions:
352
403
353
404
.. function :: checkfuncname(b, frame)
354
405
355
- Check whether we should break here, depending on the way the breakpoint * b *
356
- was set.
406
+ Return True if we should break here, depending on the way the
407
+ :class: ` Breakpoint ` * b * was set.
357
408
358
- If it was set via line number, it checks if ``b.line `` is the same as the one
359
- in the frame also passed as argument. If the breakpoint was set via function
360
- name, we have to check we are in the right frame (the right function) and if
361
- we are in its first executable line.
409
+ If it was set via line number, it checks if
410
+ :attr: `b.line <bdb.Breakpoint.line> ` is the same as the one in *frame *.
411
+ If the breakpoint was set via
412
+ :attr: `function name <bdb.Breakpoint.funcname> `, we have to check we are in
413
+ the right *frame * (the right function) and if we are on its first executable
414
+ line.
362
415
363
416
.. function :: effective(file, line, frame)
364
417
365
- Determine if there is an effective (active) breakpoint at this line of code.
366
- Return a tuple of the breakpoint and a boolean that indicates if it is ok
367
- to delete a temporary breakpoint. Return ``(None, None) `` if there is no
368
- matching breakpoint.
418
+ Return ``(active breakpoint, delete temporary flag) `` or ``(None, None) `` as the
419
+ breakpoint to act upon.
420
+
421
+ The *active breakpoint * is the first entry in
422
+ :attr: `bplist <bdb.Breakpoint.bplist> ` for the
423
+ (:attr: `file <bdb.Breakpoint.file> `, :attr: `line <bdb.Breakpoint.line> `)
424
+ (which must exist) that is :attr: `enabled <bdb.Breakpoint.enabled> `, for
425
+ which :func: `checkfuncname ` is True, and that has neither a False
426
+ :attr: `condition <bdb.Breakpoint.cond> ` nor positive
427
+ :attr: `ignore <bdb.Breakpoint.ignore> ` count. The *flag *, meaning that a
428
+ temporary breakpoint should be deleted, is False only when the
429
+ :attr: `cond <bdb.Breakpoint.cond> ` cannot be evaluated (in which case,
430
+ :attr: `ignore <bdb.Breakpoint.ignore> ` count is ignored).
431
+
432
+ If no such entry exists, then (None, None) is returned.
433
+
369
434
370
435
.. function :: set_trace()
371
436
0 commit comments