Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 1 | """Debugger basics""" |
Guido van Rossum | babe2bf | 1992-01-22 22:21:31 +0000 | [diff] [blame] | 2 | |
| 3 | import sys |
Barry Warsaw | 148ffbc | 1999-09-09 23:24:33 +0000 | [diff] [blame] | 4 | import os |
Guido van Rossum | 4808dcb | 1996-10-15 14:40:21 +0000 | [diff] [blame] | 5 | import types |
Guido van Rossum | babe2bf | 1992-01-22 22:21:31 +0000 | [diff] [blame] | 6 | |
Skip Montanaro | e99d5ea | 2001-01-20 19:54:20 +0000 | [diff] [blame] | 7 | __all__ = ["BdbQuit","Bdb","Breakpoint"] |
| 8 | |
Neal Norwitz | 93cf79f | 2002-03-31 14:06:41 +0000 | [diff] [blame] | 9 | class BdbQuit(Exception): |
| 10 | """Exception to give up completely""" |
Guido van Rossum | babe2bf | 1992-01-22 22:21:31 +0000 | [diff] [blame] | 11 | |
| 12 | |
Guido van Rossum | 6ea27cc | 1999-01-25 20:51:34 +0000 | [diff] [blame] | 13 | class Bdb: |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 14 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 15 | """Generic Python debugger base class. |
Guido van Rossum | 6ea27cc | 1999-01-25 20:51:34 +0000 | [diff] [blame] | 16 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 17 | This class takes care of details of the trace facility; |
| 18 | a derived class should implement user interaction. |
| 19 | The standard debugger class (pdb.Pdb) is an example. |
| 20 | """ |
Guido van Rossum | 6ea27cc | 1999-01-25 20:51:34 +0000 | [diff] [blame] | 21 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 22 | def __init__(self): |
| 23 | self.breaks = {} |
| 24 | self.fncache = {} |
Barry Warsaw | 148ffbc | 1999-09-09 23:24:33 +0000 | [diff] [blame] | 25 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 26 | def canonic(self, filename): |
Guido van Rossum | 42f5332 | 2001-11-29 02:50:15 +0000 | [diff] [blame] | 27 | if filename == "<" + filename[1:-1] + ">": |
| 28 | return filename |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 29 | canonic = self.fncache.get(filename) |
| 30 | if not canonic: |
| 31 | canonic = os.path.abspath(filename) |
Guido van Rossum | bdba320 | 2002-02-25 23:23:24 +0000 | [diff] [blame] | 32 | canonic = os.path.normcase(canonic) |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 33 | self.fncache[filename] = canonic |
| 34 | return canonic |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 35 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 36 | def reset(self): |
| 37 | import linecache |
| 38 | linecache.checkcache() |
| 39 | self.botframe = None |
| 40 | self.stopframe = None |
| 41 | self.returnframe = None |
| 42 | self.quitting = 0 |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 43 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 44 | def trace_dispatch(self, frame, event, arg): |
| 45 | if self.quitting: |
| 46 | return # None |
| 47 | if event == 'line': |
| 48 | return self.dispatch_line(frame) |
| 49 | if event == 'call': |
| 50 | return self.dispatch_call(frame, arg) |
| 51 | if event == 'return': |
| 52 | return self.dispatch_return(frame, arg) |
| 53 | if event == 'exception': |
| 54 | return self.dispatch_exception(frame, arg) |
Nicholas Bastin | c69ebe8 | 2004-03-24 21:57:10 +0000 | [diff] [blame] | 55 | if event == 'c_call': |
| 56 | return self.trace_dispatch |
| 57 | if event == 'c_exception': |
| 58 | return self.trace_dispatch |
| 59 | if event == 'c_return': |
| 60 | return self.trace_dispatch |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 61 | print('bdb.Bdb.dispatch: unknown debugging event:', repr(event)) |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 62 | return self.trace_dispatch |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 63 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 64 | def dispatch_line(self, frame): |
| 65 | if self.stop_here(frame) or self.break_here(frame): |
| 66 | self.user_line(frame) |
| 67 | if self.quitting: raise BdbQuit |
| 68 | return self.trace_dispatch |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 69 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 70 | def dispatch_call(self, frame, arg): |
| 71 | # XXX 'arg' is no longer used |
| 72 | if self.botframe is None: |
| 73 | # First call of dispatch since reset() |
Christian Tismer | 313a751 | 2002-05-28 08:04:00 +0000 | [diff] [blame] | 74 | self.botframe = frame.f_back # (CT) Note that this may also be None! |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 75 | return self.trace_dispatch |
| 76 | if not (self.stop_here(frame) or self.break_anywhere(frame)): |
| 77 | # No need to trace this function |
| 78 | return # None |
| 79 | self.user_call(frame, arg) |
| 80 | if self.quitting: raise BdbQuit |
| 81 | return self.trace_dispatch |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 82 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 83 | def dispatch_return(self, frame, arg): |
| 84 | if self.stop_here(frame) or frame == self.returnframe: |
| 85 | self.user_return(frame, arg) |
| 86 | if self.quitting: raise BdbQuit |
Just van Rossum | ae1f65f | 2001-06-25 18:01:24 +0000 | [diff] [blame] | 87 | return self.trace_dispatch |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 88 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 89 | def dispatch_exception(self, frame, arg): |
| 90 | if self.stop_here(frame): |
| 91 | self.user_exception(frame, arg) |
| 92 | if self.quitting: raise BdbQuit |
| 93 | return self.trace_dispatch |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 94 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 95 | # Normally derived classes don't override the following |
| 96 | # methods, but they may if they want to redefine the |
| 97 | # definition of stopping and breakpoints. |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 98 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 99 | def stop_here(self, frame): |
Neal Norwitz | 72a2b4d | 2002-05-29 00:54:38 +0000 | [diff] [blame] | 100 | # (CT) stopframe may now also be None, see dispatch_call. |
| 101 | # (CT) the former test for None is therefore removed from here. |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 102 | if frame is self.stopframe: |
Tim Peters | bc0e910 | 2002-04-04 22:55:58 +0000 | [diff] [blame] | 103 | return True |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 104 | while frame is not None and frame is not self.stopframe: |
| 105 | if frame is self.botframe: |
Tim Peters | bc0e910 | 2002-04-04 22:55:58 +0000 | [diff] [blame] | 106 | return True |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 107 | frame = frame.f_back |
Tim Peters | bc0e910 | 2002-04-04 22:55:58 +0000 | [diff] [blame] | 108 | return False |
Guido van Rossum | d93643f | 1998-09-11 22:38:35 +0000 | [diff] [blame] | 109 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 110 | def break_here(self, frame): |
| 111 | filename = self.canonic(frame.f_code.co_filename) |
Raymond Hettinger | 54f0222 | 2002-06-01 14:18:47 +0000 | [diff] [blame] | 112 | if not filename in self.breaks: |
Tim Peters | bc0e910 | 2002-04-04 22:55:58 +0000 | [diff] [blame] | 113 | return False |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 114 | lineno = frame.f_lineno |
| 115 | if not lineno in self.breaks[filename]: |
Johannes Gijsbers | 4a9faa1 | 2004-08-30 13:29:44 +0000 | [diff] [blame] | 116 | # The line itself has no breakpoint, but maybe the line is the |
| 117 | # first line of a function with breakpoint set by function name. |
| 118 | lineno = frame.f_code.co_firstlineno |
| 119 | if not lineno in self.breaks[filename]: |
| 120 | return False |
| 121 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 122 | # flag says ok to delete temp. bp |
| 123 | (bp, flag) = effective(filename, lineno, frame) |
| 124 | if bp: |
| 125 | self.currentbp = bp.number |
| 126 | if (flag and bp.temporary): |
| 127 | self.do_clear(str(bp.number)) |
Tim Peters | bc0e910 | 2002-04-04 22:55:58 +0000 | [diff] [blame] | 128 | return True |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 129 | else: |
Tim Peters | bc0e910 | 2002-04-04 22:55:58 +0000 | [diff] [blame] | 130 | return False |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 131 | |
Guido van Rossum | 9cec8fb | 2001-04-08 15:05:16 +0000 | [diff] [blame] | 132 | def do_clear(self, arg): |
| 133 | raise NotImplementedError, "subclass of bdb must implement do_clear()" |
| 134 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 135 | def break_anywhere(self, frame): |
Guido van Rossum | e2b70bc | 2006-08-18 22:13:04 +0000 | [diff] [blame] | 136 | return self.canonic(frame.f_code.co_filename) in self.breaks |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 137 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 138 | # Derived classes should override the user_* methods |
| 139 | # to gain control. |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 140 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 141 | def user_call(self, frame, argument_list): |
| 142 | """This method is called when there is the remote possibility |
| 143 | that we ever need to stop in this function.""" |
| 144 | pass |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 145 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 146 | def user_line(self, frame): |
| 147 | """This method is called when we stop or break at this line.""" |
| 148 | pass |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 149 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 150 | def user_return(self, frame, return_value): |
| 151 | """This method is called when a return trap is set here.""" |
| 152 | pass |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 153 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 154 | def user_exception(self, frame, (exc_type, exc_value, exc_traceback)): |
| 155 | """This method is called if an exception occurs, |
| 156 | but only if we are to stop at or just below this level.""" |
| 157 | pass |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 158 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 159 | # Derived classes and clients can call the following methods |
| 160 | # to affect the stepping state. |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 161 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 162 | def set_step(self): |
| 163 | """Stop after one line of code.""" |
| 164 | self.stopframe = None |
| 165 | self.returnframe = None |
| 166 | self.quitting = 0 |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 167 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 168 | def set_next(self, frame): |
| 169 | """Stop on the next line in or below the given frame.""" |
| 170 | self.stopframe = frame |
| 171 | self.returnframe = None |
| 172 | self.quitting = 0 |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 173 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 174 | def set_return(self, frame): |
| 175 | """Stop when returning from the given frame.""" |
| 176 | self.stopframe = frame.f_back |
| 177 | self.returnframe = frame |
| 178 | self.quitting = 0 |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 179 | |
Johannes Gijsbers | 84a6c20 | 2004-11-07 11:35:30 +0000 | [diff] [blame] | 180 | def set_trace(self, frame=None): |
| 181 | """Start debugging from `frame`. |
| 182 | |
| 183 | If frame is not specified, debugging starts from caller's frame. |
| 184 | """ |
| 185 | if frame is None: |
| 186 | frame = sys._getframe().f_back |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 187 | self.reset() |
| 188 | while frame: |
| 189 | frame.f_trace = self.trace_dispatch |
| 190 | self.botframe = frame |
| 191 | frame = frame.f_back |
| 192 | self.set_step() |
| 193 | sys.settrace(self.trace_dispatch) |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 194 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 195 | def set_continue(self): |
| 196 | # Don't stop except at breakpoints or when finished |
| 197 | self.stopframe = self.botframe |
| 198 | self.returnframe = None |
| 199 | self.quitting = 0 |
| 200 | if not self.breaks: |
| 201 | # no breakpoints; run without debugger overhead |
| 202 | sys.settrace(None) |
Christian Tismer | 313a751 | 2002-05-28 08:04:00 +0000 | [diff] [blame] | 203 | frame = sys._getframe().f_back |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 204 | while frame and frame is not self.botframe: |
| 205 | del frame.f_trace |
| 206 | frame = frame.f_back |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 207 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 208 | def set_quit(self): |
| 209 | self.stopframe = self.botframe |
| 210 | self.returnframe = None |
| 211 | self.quitting = 1 |
| 212 | sys.settrace(None) |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 213 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 214 | # Derived classes and clients can call the following methods |
| 215 | # to manipulate breakpoints. These methods return an |
| 216 | # error message is something went wrong, None if all is well. |
| 217 | # Set_break prints out the breakpoint line and file:lineno. |
| 218 | # Call self.get_*break*() to see the breakpoints or better |
| 219 | # for bp in Breakpoint.bpbynumber: if bp: bp.bpprint(). |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 220 | |
Johannes Gijsbers | 4a9faa1 | 2004-08-30 13:29:44 +0000 | [diff] [blame] | 221 | def set_break(self, filename, lineno, temporary=0, cond = None, |
| 222 | funcname=None): |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 223 | filename = self.canonic(filename) |
| 224 | import linecache # Import as late as possible |
| 225 | line = linecache.getline(filename, lineno) |
| 226 | if not line: |
| 227 | return 'Line %s:%d does not exist' % (filename, |
| 228 | lineno) |
Raymond Hettinger | 54f0222 | 2002-06-01 14:18:47 +0000 | [diff] [blame] | 229 | if not filename in self.breaks: |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 230 | self.breaks[filename] = [] |
| 231 | list = self.breaks[filename] |
| 232 | if not lineno in list: |
| 233 | list.append(lineno) |
Johannes Gijsbers | 4a9faa1 | 2004-08-30 13:29:44 +0000 | [diff] [blame] | 234 | bp = Breakpoint(filename, lineno, temporary, cond, funcname) |
Guido van Rossum | d93643f | 1998-09-11 22:38:35 +0000 | [diff] [blame] | 235 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 236 | def clear_break(self, filename, lineno): |
| 237 | filename = self.canonic(filename) |
Raymond Hettinger | 54f0222 | 2002-06-01 14:18:47 +0000 | [diff] [blame] | 238 | if not filename in self.breaks: |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 239 | return 'There are no breakpoints in %s' % filename |
| 240 | if lineno not in self.breaks[filename]: |
| 241 | return 'There is no breakpoint at %s:%d' % (filename, |
| 242 | lineno) |
| 243 | # If there's only one bp in the list for that file,line |
| 244 | # pair, then remove the breaks entry |
| 245 | for bp in Breakpoint.bplist[filename, lineno][:]: |
| 246 | bp.deleteMe() |
Guido van Rossum | e2b70bc | 2006-08-18 22:13:04 +0000 | [diff] [blame] | 247 | if (filename, lineno) not in Breakpoint.bplist: |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 248 | self.breaks[filename].remove(lineno) |
| 249 | if not self.breaks[filename]: |
| 250 | del self.breaks[filename] |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 251 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 252 | def clear_bpbynumber(self, arg): |
| 253 | try: |
| 254 | number = int(arg) |
| 255 | except: |
| 256 | return 'Non-numeric breakpoint number (%s)' % arg |
| 257 | try: |
| 258 | bp = Breakpoint.bpbynumber[number] |
| 259 | except IndexError: |
| 260 | return 'Breakpoint number (%d) out of range' % number |
| 261 | if not bp: |
| 262 | return 'Breakpoint (%d) already deleted' % number |
| 263 | self.clear_break(bp.file, bp.line) |
Guido van Rossum | 6ea27cc | 1999-01-25 20:51:34 +0000 | [diff] [blame] | 264 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 265 | def clear_all_file_breaks(self, filename): |
| 266 | filename = self.canonic(filename) |
Raymond Hettinger | 54f0222 | 2002-06-01 14:18:47 +0000 | [diff] [blame] | 267 | if not filename in self.breaks: |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 268 | return 'There are no breakpoints in %s' % filename |
| 269 | for line in self.breaks[filename]: |
| 270 | blist = Breakpoint.bplist[filename, line] |
| 271 | for bp in blist: |
| 272 | bp.deleteMe() |
| 273 | del self.breaks[filename] |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 274 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 275 | def clear_all_breaks(self): |
| 276 | if not self.breaks: |
| 277 | return 'There are no breakpoints' |
| 278 | for bp in Breakpoint.bpbynumber: |
| 279 | if bp: |
| 280 | bp.deleteMe() |
| 281 | self.breaks = {} |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 282 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 283 | def get_break(self, filename, lineno): |
| 284 | filename = self.canonic(filename) |
Raymond Hettinger | 54f0222 | 2002-06-01 14:18:47 +0000 | [diff] [blame] | 285 | return filename in self.breaks and \ |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 286 | lineno in self.breaks[filename] |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 287 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 288 | def get_breaks(self, filename, lineno): |
| 289 | filename = self.canonic(filename) |
Raymond Hettinger | 54f0222 | 2002-06-01 14:18:47 +0000 | [diff] [blame] | 290 | return filename in self.breaks and \ |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 291 | lineno in self.breaks[filename] and \ |
| 292 | Breakpoint.bplist[filename, lineno] or [] |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 293 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 294 | def get_file_breaks(self, filename): |
| 295 | filename = self.canonic(filename) |
Raymond Hettinger | 54f0222 | 2002-06-01 14:18:47 +0000 | [diff] [blame] | 296 | if filename in self.breaks: |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 297 | return self.breaks[filename] |
| 298 | else: |
| 299 | return [] |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 300 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 301 | def get_all_breaks(self): |
| 302 | return self.breaks |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 303 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 304 | # Derived classes and clients can call the following method |
| 305 | # to get a data structure representing a stack trace. |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 306 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 307 | def get_stack(self, f, t): |
| 308 | stack = [] |
| 309 | if t and t.tb_frame is f: |
| 310 | t = t.tb_next |
| 311 | while f is not None: |
| 312 | stack.append((f, f.f_lineno)) |
| 313 | if f is self.botframe: |
| 314 | break |
| 315 | f = f.f_back |
| 316 | stack.reverse() |
| 317 | i = max(0, len(stack) - 1) |
| 318 | while t is not None: |
| 319 | stack.append((t.tb_frame, t.tb_lineno)) |
| 320 | t = t.tb_next |
| 321 | return stack, i |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 322 | |
| 323 | # |
| 324 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 325 | def format_stack_entry(self, frame_lineno, lprefix=': '): |
Eric S. Raymond | b49f4a4 | 2001-02-09 05:07:04 +0000 | [diff] [blame] | 326 | import linecache, repr |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 327 | frame, lineno = frame_lineno |
| 328 | filename = self.canonic(frame.f_code.co_filename) |
Walter Dörwald | 70a6b49 | 2004-02-12 17:35:32 +0000 | [diff] [blame] | 329 | s = '%s(%r)' % (filename, lineno) |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 330 | if frame.f_code.co_name: |
| 331 | s = s + frame.f_code.co_name |
| 332 | else: |
| 333 | s = s + "<lambda>" |
Raymond Hettinger | 54f0222 | 2002-06-01 14:18:47 +0000 | [diff] [blame] | 334 | if '__args__' in frame.f_locals: |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 335 | args = frame.f_locals['__args__'] |
| 336 | else: |
| 337 | args = None |
| 338 | if args: |
| 339 | s = s + repr.repr(args) |
| 340 | else: |
| 341 | s = s + '()' |
Raymond Hettinger | 54f0222 | 2002-06-01 14:18:47 +0000 | [diff] [blame] | 342 | if '__return__' in frame.f_locals: |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 343 | rv = frame.f_locals['__return__'] |
| 344 | s = s + '->' |
| 345 | s = s + repr.repr(rv) |
| 346 | line = linecache.getline(filename, lineno) |
Eric S. Raymond | b49f4a4 | 2001-02-09 05:07:04 +0000 | [diff] [blame] | 347 | if line: s = s + lprefix + line.strip() |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 348 | return s |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 349 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 350 | # The following two methods can be called by clients to use |
| 351 | # a debugger to debug a statement, given as a string. |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 352 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 353 | def run(self, cmd, globals=None, locals=None): |
| 354 | if globals is None: |
| 355 | import __main__ |
| 356 | globals = __main__.__dict__ |
| 357 | if locals is None: |
| 358 | locals = globals |
| 359 | self.reset() |
| 360 | sys.settrace(self.trace_dispatch) |
| 361 | if not isinstance(cmd, types.CodeType): |
| 362 | cmd = cmd+'\n' |
| 363 | try: |
| 364 | try: |
Georg Brandl | 7cae87c | 2006-09-06 06:51:57 +0000 | [diff] [blame] | 365 | exec(cmd, globals, locals) |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 366 | except BdbQuit: |
| 367 | pass |
| 368 | finally: |
| 369 | self.quitting = 1 |
| 370 | sys.settrace(None) |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 371 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 372 | def runeval(self, expr, globals=None, locals=None): |
| 373 | if globals is None: |
| 374 | import __main__ |
| 375 | globals = __main__.__dict__ |
| 376 | if locals is None: |
| 377 | locals = globals |
| 378 | self.reset() |
| 379 | sys.settrace(self.trace_dispatch) |
| 380 | if not isinstance(expr, types.CodeType): |
| 381 | expr = expr+'\n' |
| 382 | try: |
| 383 | try: |
| 384 | return eval(expr, globals, locals) |
| 385 | except BdbQuit: |
| 386 | pass |
| 387 | finally: |
| 388 | self.quitting = 1 |
| 389 | sys.settrace(None) |
Guido van Rossum | 5e38b6f | 1995-02-27 13:13:40 +0000 | [diff] [blame] | 390 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 391 | def runctx(self, cmd, globals, locals): |
| 392 | # B/W compatibility |
| 393 | self.run(cmd, globals, locals) |
Guido van Rossum | 4e16098 | 1992-09-02 20:43:20 +0000 | [diff] [blame] | 394 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 395 | # This method is more useful to debug a single function call. |
Guido van Rossum | 4e16098 | 1992-09-02 20:43:20 +0000 | [diff] [blame] | 396 | |
Raymond Hettinger | 2ef7e6c | 2004-10-24 00:32:24 +0000 | [diff] [blame] | 397 | def runcall(self, func, *args, **kwds): |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 398 | self.reset() |
| 399 | sys.settrace(self.trace_dispatch) |
| 400 | res = None |
| 401 | try: |
| 402 | try: |
Raymond Hettinger | 2ef7e6c | 2004-10-24 00:32:24 +0000 | [diff] [blame] | 403 | res = func(*args, **kwds) |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 404 | except BdbQuit: |
| 405 | pass |
| 406 | finally: |
| 407 | self.quitting = 1 |
| 408 | sys.settrace(None) |
| 409 | return res |
Guido van Rossum | babe2bf | 1992-01-22 22:21:31 +0000 | [diff] [blame] | 410 | |
Guido van Rossum | babe2bf | 1992-01-22 22:21:31 +0000 | [diff] [blame] | 411 | |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 412 | def set_trace(): |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 413 | Bdb().set_trace() |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 414 | |
Guido van Rossum | d93643f | 1998-09-11 22:38:35 +0000 | [diff] [blame] | 415 | |
| 416 | class Breakpoint: |
| 417 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 418 | """Breakpoint class |
Guido van Rossum | d93643f | 1998-09-11 22:38:35 +0000 | [diff] [blame] | 419 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 420 | Implements temporary breakpoints, ignore counts, disabling and |
| 421 | (re)-enabling, and conditionals. |
Guido van Rossum | d93643f | 1998-09-11 22:38:35 +0000 | [diff] [blame] | 422 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 423 | Breakpoints are indexed by number through bpbynumber and by |
| 424 | the file,line tuple using bplist. The former points to a |
| 425 | single instance of class Breakpoint. The latter points to a |
| 426 | list of such instances since there may be more than one |
| 427 | breakpoint per line. |
Guido van Rossum | d93643f | 1998-09-11 22:38:35 +0000 | [diff] [blame] | 428 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 429 | """ |
Guido van Rossum | d93643f | 1998-09-11 22:38:35 +0000 | [diff] [blame] | 430 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 431 | # XXX Keeping state in the class is a mistake -- this means |
| 432 | # you cannot have more than one active Bdb instance. |
Guido van Rossum | d93643f | 1998-09-11 22:38:35 +0000 | [diff] [blame] | 433 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 434 | next = 1 # Next bp to be assigned |
| 435 | bplist = {} # indexed by (file, lineno) tuple |
| 436 | bpbynumber = [None] # Each entry is None or an instance of Bpt |
| 437 | # index 0 is unused, except for marking an |
| 438 | # effective break .... see effective() |
Guido van Rossum | d93643f | 1998-09-11 22:38:35 +0000 | [diff] [blame] | 439 | |
Johannes Gijsbers | 4a9faa1 | 2004-08-30 13:29:44 +0000 | [diff] [blame] | 440 | def __init__(self, file, line, temporary=0, cond=None, funcname=None): |
| 441 | self.funcname = funcname |
| 442 | # Needed if funcname is not None. |
| 443 | self.func_first_executable_line = None |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 444 | self.file = file # This better be in canonical form! |
| 445 | self.line = line |
| 446 | self.temporary = temporary |
| 447 | self.cond = cond |
| 448 | self.enabled = 1 |
| 449 | self.ignore = 0 |
| 450 | self.hits = 0 |
| 451 | self.number = Breakpoint.next |
| 452 | Breakpoint.next = Breakpoint.next + 1 |
| 453 | # Build the two lists |
| 454 | self.bpbynumber.append(self) |
Guido van Rossum | e2b70bc | 2006-08-18 22:13:04 +0000 | [diff] [blame] | 455 | if (file, line) in self.bplist: |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 456 | self.bplist[file, line].append(self) |
| 457 | else: |
| 458 | self.bplist[file, line] = [self] |
Guido van Rossum | d93643f | 1998-09-11 22:38:35 +0000 | [diff] [blame] | 459 | |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 460 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 461 | def deleteMe(self): |
| 462 | index = (self.file, self.line) |
| 463 | self.bpbynumber[self.number] = None # No longer in list |
| 464 | self.bplist[index].remove(self) |
| 465 | if not self.bplist[index]: |
| 466 | # No more bp for this f:l combo |
| 467 | del self.bplist[index] |
Guido van Rossum | d93643f | 1998-09-11 22:38:35 +0000 | [diff] [blame] | 468 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 469 | def enable(self): |
| 470 | self.enabled = 1 |
Guido van Rossum | d93643f | 1998-09-11 22:38:35 +0000 | [diff] [blame] | 471 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 472 | def disable(self): |
| 473 | self.enabled = 0 |
Guido van Rossum | d93643f | 1998-09-11 22:38:35 +0000 | [diff] [blame] | 474 | |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 475 | def bpprint(self, out=None): |
| 476 | if out is None: |
| 477 | out = sys.stdout |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 478 | if self.temporary: |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 479 | disp = 'del ' |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 480 | else: |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 481 | disp = 'keep ' |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 482 | if self.enabled: |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 483 | disp = disp + 'yes ' |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 484 | else: |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 485 | disp = disp + 'no ' |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 486 | print('%-4dbreakpoint %s at %s:%d' % (self.number, disp, |
| 487 | self.file, self.line), file=out) |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 488 | if self.cond: |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 489 | print('\tstop only if %s' % (self.cond,), file=out) |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 490 | if self.ignore: |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 491 | print('\tignore next %d hits' % (self.ignore), file=out) |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 492 | if (self.hits): |
| 493 | if (self.hits > 1): ss = 's' |
| 494 | else: ss = '' |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 495 | print(('\tbreakpoint already hit %d time%s' % |
| 496 | (self.hits, ss)), file=out) |
Guido van Rossum | d93643f | 1998-09-11 22:38:35 +0000 | [diff] [blame] | 497 | |
| 498 | # -----------end of Breakpoint class---------- |
| 499 | |
Johannes Gijsbers | 4a9faa1 | 2004-08-30 13:29:44 +0000 | [diff] [blame] | 500 | def checkfuncname(b, frame): |
| 501 | """Check whether we should break here because of `b.funcname`.""" |
| 502 | if not b.funcname: |
| 503 | # Breakpoint was set via line number. |
| 504 | if b.line != frame.f_lineno: |
| 505 | # Breakpoint was set at a line with a def statement and the function |
| 506 | # defined is called: don't break. |
| 507 | return False |
| 508 | return True |
| 509 | |
| 510 | # Breakpoint set via function name. |
| 511 | |
| 512 | if frame.f_code.co_name != b.funcname: |
| 513 | # It's not a function call, but rather execution of def statement. |
| 514 | return False |
| 515 | |
| 516 | # We are in the right frame. |
| 517 | if not b.func_first_executable_line: |
| 518 | # The function is entered for the 1st time. |
| 519 | b.func_first_executable_line = frame.f_lineno |
| 520 | |
| 521 | if b.func_first_executable_line != frame.f_lineno: |
| 522 | # But we are not at the first line number: don't break. |
| 523 | return False |
| 524 | return True |
| 525 | |
Guido van Rossum | d93643f | 1998-09-11 22:38:35 +0000 | [diff] [blame] | 526 | # Determines if there is an effective (active) breakpoint at this |
| 527 | # line of code. Returns breakpoint number or 0 if none |
| 528 | def effective(file, line, frame): |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 529 | """Determine which breakpoint for this file:line is to be acted upon. |
Guido van Rossum | d93643f | 1998-09-11 22:38:35 +0000 | [diff] [blame] | 530 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 531 | Called only if we know there is a bpt at this |
| 532 | location. Returns breakpoint that was triggered and a flag |
| 533 | that indicates if it is ok to delete a temporary bp. |
Guido van Rossum | d93643f | 1998-09-11 22:38:35 +0000 | [diff] [blame] | 534 | |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 535 | """ |
| 536 | possibles = Breakpoint.bplist[file,line] |
| 537 | for i in range(0, len(possibles)): |
| 538 | b = possibles[i] |
| 539 | if b.enabled == 0: |
| 540 | continue |
Johannes Gijsbers | 4a9faa1 | 2004-08-30 13:29:44 +0000 | [diff] [blame] | 541 | if not checkfuncname(b, frame): |
| 542 | continue |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 543 | # Count every hit when bp is enabled |
| 544 | b.hits = b.hits + 1 |
| 545 | if not b.cond: |
| 546 | # If unconditional, and ignoring, |
| 547 | # go on to next, else break |
| 548 | if b.ignore > 0: |
| 549 | b.ignore = b.ignore -1 |
| 550 | continue |
| 551 | else: |
| 552 | # breakpoint and marker that's ok |
| 553 | # to delete if temporary |
| 554 | return (b,1) |
| 555 | else: |
| 556 | # Conditional bp. |
| 557 | # Ignore count applies only to those bpt hits where the |
| 558 | # condition evaluates to true. |
| 559 | try: |
| 560 | val = eval(b.cond, frame.f_globals, |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 561 | frame.f_locals) |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 562 | if val: |
| 563 | if b.ignore > 0: |
| 564 | b.ignore = b.ignore -1 |
| 565 | # continue |
| 566 | else: |
| 567 | return (b,1) |
| 568 | # else: |
| 569 | # continue |
| 570 | except: |
| 571 | # if eval fails, most conservative |
| 572 | # thing is to stop on breakpoint |
Tim Peters | 11cf605 | 2001-01-14 21:54:20 +0000 | [diff] [blame] | 573 | # regardless of ignore count. |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 574 | # Don't delete temporary, |
| 575 | # as another hint to user. |
| 576 | return (b,0) |
| 577 | return (None, None) |
Guido van Rossum | d93643f | 1998-09-11 22:38:35 +0000 | [diff] [blame] | 578 | |
Guido van Rossum | babe2bf | 1992-01-22 22:21:31 +0000 | [diff] [blame] | 579 | # -------------------- testing -------------------- |
| 580 | |
| 581 | class Tdb(Bdb): |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 582 | def user_call(self, frame, args): |
| 583 | name = frame.f_code.co_name |
| 584 | if not name: name = '???' |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 585 | print('+++ call', name, args) |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 586 | def user_line(self, frame): |
Eric S. Raymond | b49f4a4 | 2001-02-09 05:07:04 +0000 | [diff] [blame] | 587 | import linecache |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 588 | name = frame.f_code.co_name |
| 589 | if not name: name = '???' |
| 590 | fn = self.canonic(frame.f_code.co_filename) |
| 591 | line = linecache.getline(fn, frame.f_lineno) |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 592 | print('+++', fn, frame.f_lineno, name, ':', line.strip()) |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 593 | def user_return(self, frame, retval): |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 594 | print('+++ return', retval) |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 595 | def user_exception(self, frame, exc_stuff): |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 596 | print('+++ exception', exc_stuff) |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 597 | self.set_continue() |
Guido van Rossum | babe2bf | 1992-01-22 22:21:31 +0000 | [diff] [blame] | 598 | |
| 599 | def foo(n): |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 600 | print('foo(', n, ')') |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 601 | x = bar(n*10) |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 602 | print('bar returned', x) |
Guido van Rossum | babe2bf | 1992-01-22 22:21:31 +0000 | [diff] [blame] | 603 | |
| 604 | def bar(a): |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 605 | print('bar(', a, ')') |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 606 | return a/2 |
Guido van Rossum | babe2bf | 1992-01-22 22:21:31 +0000 | [diff] [blame] | 607 | |
| 608 | def test(): |
Guido van Rossum | 4acc25b | 2000-02-02 15:10:15 +0000 | [diff] [blame] | 609 | t = Tdb() |
| 610 | t.run('import bdb; bdb.foo(10)') |
Eric S. Raymond | b49f4a4 | 2001-02-09 05:07:04 +0000 | [diff] [blame] | 611 | |
| 612 | # end |