Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/smexe_ro.../usr/lib64/python2....
File: bdb.py
"""Debugger basics"""
[0] Fix | Delete
[1] Fix | Delete
import fnmatch
[2] Fix | Delete
import sys
[3] Fix | Delete
import os
[4] Fix | Delete
import types
[5] Fix | Delete
[6] Fix | Delete
__all__ = ["BdbQuit","Bdb","Breakpoint"]
[7] Fix | Delete
[8] Fix | Delete
class BdbQuit(Exception):
[9] Fix | Delete
"""Exception to give up completely"""
[10] Fix | Delete
[11] Fix | Delete
[12] Fix | Delete
class Bdb:
[13] Fix | Delete
[14] Fix | Delete
"""Generic Python debugger base class.
[15] Fix | Delete
[16] Fix | Delete
This class takes care of details of the trace facility;
[17] Fix | Delete
a derived class should implement user interaction.
[18] Fix | Delete
The standard debugger class (pdb.Pdb) is an example.
[19] Fix | Delete
"""
[20] Fix | Delete
[21] Fix | Delete
def __init__(self, skip=None):
[22] Fix | Delete
self.skip = set(skip) if skip else None
[23] Fix | Delete
self.breaks = {}
[24] Fix | Delete
self.fncache = {}
[25] Fix | Delete
self.frame_returning = None
[26] Fix | Delete
[27] Fix | Delete
def canonic(self, filename):
[28] Fix | Delete
if filename == "<" + filename[1:-1] + ">":
[29] Fix | Delete
return filename
[30] Fix | Delete
canonic = self.fncache.get(filename)
[31] Fix | Delete
if not canonic:
[32] Fix | Delete
canonic = os.path.abspath(filename)
[33] Fix | Delete
canonic = os.path.normcase(canonic)
[34] Fix | Delete
self.fncache[filename] = canonic
[35] Fix | Delete
return canonic
[36] Fix | Delete
[37] Fix | Delete
def reset(self):
[38] Fix | Delete
import linecache
[39] Fix | Delete
linecache.checkcache()
[40] Fix | Delete
self.botframe = None
[41] Fix | Delete
self._set_stopinfo(None, None)
[42] Fix | Delete
[43] Fix | Delete
def trace_dispatch(self, frame, event, arg):
[44] Fix | Delete
if self.quitting:
[45] Fix | Delete
return # None
[46] Fix | Delete
if event == 'line':
[47] Fix | Delete
return self.dispatch_line(frame)
[48] Fix | Delete
if event == 'call':
[49] Fix | Delete
return self.dispatch_call(frame, arg)
[50] Fix | Delete
if event == 'return':
[51] Fix | Delete
return self.dispatch_return(frame, arg)
[52] Fix | Delete
if event == 'exception':
[53] Fix | Delete
return self.dispatch_exception(frame, arg)
[54] Fix | Delete
if event == 'c_call':
[55] Fix | Delete
return self.trace_dispatch
[56] Fix | Delete
if event == 'c_exception':
[57] Fix | Delete
return self.trace_dispatch
[58] Fix | Delete
if event == 'c_return':
[59] Fix | Delete
return self.trace_dispatch
[60] Fix | Delete
print 'bdb.Bdb.dispatch: unknown debugging event:', repr(event)
[61] Fix | Delete
return self.trace_dispatch
[62] Fix | Delete
[63] Fix | Delete
def dispatch_line(self, frame):
[64] Fix | Delete
if self.stop_here(frame) or self.break_here(frame):
[65] Fix | Delete
self.user_line(frame)
[66] Fix | Delete
if self.quitting: raise BdbQuit
[67] Fix | Delete
return self.trace_dispatch
[68] Fix | Delete
[69] Fix | Delete
def dispatch_call(self, frame, arg):
[70] Fix | Delete
# XXX 'arg' is no longer used
[71] Fix | Delete
if self.botframe is None:
[72] Fix | Delete
# First call of dispatch since reset()
[73] Fix | Delete
self.botframe = frame.f_back # (CT) Note that this may also be None!
[74] Fix | Delete
return self.trace_dispatch
[75] Fix | Delete
if not (self.stop_here(frame) or self.break_anywhere(frame)):
[76] Fix | Delete
# No need to trace this function
[77] Fix | Delete
return # None
[78] Fix | Delete
self.user_call(frame, arg)
[79] Fix | Delete
if self.quitting: raise BdbQuit
[80] Fix | Delete
return self.trace_dispatch
[81] Fix | Delete
[82] Fix | Delete
def dispatch_return(self, frame, arg):
[83] Fix | Delete
if self.stop_here(frame) or frame == self.returnframe:
[84] Fix | Delete
try:
[85] Fix | Delete
self.frame_returning = frame
[86] Fix | Delete
self.user_return(frame, arg)
[87] Fix | Delete
finally:
[88] Fix | Delete
self.frame_returning = None
[89] Fix | Delete
if self.quitting: raise BdbQuit
[90] Fix | Delete
return self.trace_dispatch
[91] Fix | Delete
[92] Fix | Delete
def dispatch_exception(self, frame, arg):
[93] Fix | Delete
if self.stop_here(frame):
[94] Fix | Delete
self.user_exception(frame, arg)
[95] Fix | Delete
if self.quitting: raise BdbQuit
[96] Fix | Delete
return self.trace_dispatch
[97] Fix | Delete
[98] Fix | Delete
# Normally derived classes don't override the following
[99] Fix | Delete
# methods, but they may if they want to redefine the
[100] Fix | Delete
# definition of stopping and breakpoints.
[101] Fix | Delete
[102] Fix | Delete
def is_skipped_module(self, module_name):
[103] Fix | Delete
for pattern in self.skip:
[104] Fix | Delete
if fnmatch.fnmatch(module_name, pattern):
[105] Fix | Delete
return True
[106] Fix | Delete
return False
[107] Fix | Delete
[108] Fix | Delete
def stop_here(self, frame):
[109] Fix | Delete
# (CT) stopframe may now also be None, see dispatch_call.
[110] Fix | Delete
# (CT) the former test for None is therefore removed from here.
[111] Fix | Delete
if self.skip and \
[112] Fix | Delete
self.is_skipped_module(frame.f_globals.get('__name__')):
[113] Fix | Delete
return False
[114] Fix | Delete
if frame is self.stopframe:
[115] Fix | Delete
if self.stoplineno == -1:
[116] Fix | Delete
return False
[117] Fix | Delete
return frame.f_lineno >= self.stoplineno
[118] Fix | Delete
while frame is not None and frame is not self.stopframe:
[119] Fix | Delete
if frame is self.botframe:
[120] Fix | Delete
return True
[121] Fix | Delete
frame = frame.f_back
[122] Fix | Delete
return False
[123] Fix | Delete
[124] Fix | Delete
def break_here(self, frame):
[125] Fix | Delete
filename = self.canonic(frame.f_code.co_filename)
[126] Fix | Delete
if not filename in self.breaks:
[127] Fix | Delete
return False
[128] Fix | Delete
lineno = frame.f_lineno
[129] Fix | Delete
if not lineno in self.breaks[filename]:
[130] Fix | Delete
# The line itself has no breakpoint, but maybe the line is the
[131] Fix | Delete
# first line of a function with breakpoint set by function name.
[132] Fix | Delete
lineno = frame.f_code.co_firstlineno
[133] Fix | Delete
if not lineno in self.breaks[filename]:
[134] Fix | Delete
return False
[135] Fix | Delete
[136] Fix | Delete
# flag says ok to delete temp. bp
[137] Fix | Delete
(bp, flag) = effective(filename, lineno, frame)
[138] Fix | Delete
if bp:
[139] Fix | Delete
self.currentbp = bp.number
[140] Fix | Delete
if (flag and bp.temporary):
[141] Fix | Delete
self.do_clear(str(bp.number))
[142] Fix | Delete
return True
[143] Fix | Delete
else:
[144] Fix | Delete
return False
[145] Fix | Delete
[146] Fix | Delete
def do_clear(self, arg):
[147] Fix | Delete
raise NotImplementedError, "subclass of bdb must implement do_clear()"
[148] Fix | Delete
[149] Fix | Delete
def break_anywhere(self, frame):
[150] Fix | Delete
return self.canonic(frame.f_code.co_filename) in self.breaks
[151] Fix | Delete
[152] Fix | Delete
# Derived classes should override the user_* methods
[153] Fix | Delete
# to gain control.
[154] Fix | Delete
[155] Fix | Delete
def user_call(self, frame, argument_list):
[156] Fix | Delete
"""This method is called when there is the remote possibility
[157] Fix | Delete
that we ever need to stop in this function."""
[158] Fix | Delete
pass
[159] Fix | Delete
[160] Fix | Delete
def user_line(self, frame):
[161] Fix | Delete
"""This method is called when we stop or break at this line."""
[162] Fix | Delete
pass
[163] Fix | Delete
[164] Fix | Delete
def user_return(self, frame, return_value):
[165] Fix | Delete
"""This method is called when a return trap is set here."""
[166] Fix | Delete
pass
[167] Fix | Delete
[168] Fix | Delete
def user_exception(self, frame, exc_info):
[169] Fix | Delete
exc_type, exc_value, exc_traceback = exc_info
[170] Fix | Delete
"""This method is called if an exception occurs,
[171] Fix | Delete
but only if we are to stop at or just below this level."""
[172] Fix | Delete
pass
[173] Fix | Delete
[174] Fix | Delete
def _set_stopinfo(self, stopframe, returnframe, stoplineno=0):
[175] Fix | Delete
self.stopframe = stopframe
[176] Fix | Delete
self.returnframe = returnframe
[177] Fix | Delete
self.quitting = 0
[178] Fix | Delete
# stoplineno >= 0 means: stop at line >= the stoplineno
[179] Fix | Delete
# stoplineno -1 means: don't stop at all
[180] Fix | Delete
self.stoplineno = stoplineno
[181] Fix | Delete
[182] Fix | Delete
# Derived classes and clients can call the following methods
[183] Fix | Delete
# to affect the stepping state.
[184] Fix | Delete
[185] Fix | Delete
def set_until(self, frame): #the name "until" is borrowed from gdb
[186] Fix | Delete
"""Stop when the line with the line no greater than the current one is
[187] Fix | Delete
reached or when returning from current frame"""
[188] Fix | Delete
self._set_stopinfo(frame, frame, frame.f_lineno+1)
[189] Fix | Delete
[190] Fix | Delete
def set_step(self):
[191] Fix | Delete
"""Stop after one line of code."""
[192] Fix | Delete
# Issue #13183: pdb skips frames after hitting a breakpoint and running
[193] Fix | Delete
# step commands.
[194] Fix | Delete
# Restore the trace function in the caller (that may not have been set
[195] Fix | Delete
# for performance reasons) when returning from the current frame.
[196] Fix | Delete
if self.frame_returning:
[197] Fix | Delete
caller_frame = self.frame_returning.f_back
[198] Fix | Delete
if caller_frame and not caller_frame.f_trace:
[199] Fix | Delete
caller_frame.f_trace = self.trace_dispatch
[200] Fix | Delete
self._set_stopinfo(None, None)
[201] Fix | Delete
[202] Fix | Delete
def set_next(self, frame):
[203] Fix | Delete
"""Stop on the next line in or below the given frame."""
[204] Fix | Delete
self._set_stopinfo(frame, None)
[205] Fix | Delete
[206] Fix | Delete
def set_return(self, frame):
[207] Fix | Delete
"""Stop when returning from the given frame."""
[208] Fix | Delete
self._set_stopinfo(frame.f_back, frame)
[209] Fix | Delete
[210] Fix | Delete
def set_trace(self, frame=None):
[211] Fix | Delete
"""Start debugging from `frame`.
[212] Fix | Delete
[213] Fix | Delete
If frame is not specified, debugging starts from caller's frame.
[214] Fix | Delete
"""
[215] Fix | Delete
if frame is None:
[216] Fix | Delete
frame = sys._getframe().f_back
[217] Fix | Delete
self.reset()
[218] Fix | Delete
while frame:
[219] Fix | Delete
frame.f_trace = self.trace_dispatch
[220] Fix | Delete
self.botframe = frame
[221] Fix | Delete
frame = frame.f_back
[222] Fix | Delete
self.set_step()
[223] Fix | Delete
sys.settrace(self.trace_dispatch)
[224] Fix | Delete
[225] Fix | Delete
def set_continue(self):
[226] Fix | Delete
# Don't stop except at breakpoints or when finished
[227] Fix | Delete
self._set_stopinfo(self.botframe, None, -1)
[228] Fix | Delete
if not self.breaks:
[229] Fix | Delete
# no breakpoints; run without debugger overhead
[230] Fix | Delete
sys.settrace(None)
[231] Fix | Delete
frame = sys._getframe().f_back
[232] Fix | Delete
while frame and frame is not self.botframe:
[233] Fix | Delete
del frame.f_trace
[234] Fix | Delete
frame = frame.f_back
[235] Fix | Delete
[236] Fix | Delete
def set_quit(self):
[237] Fix | Delete
self.stopframe = self.botframe
[238] Fix | Delete
self.returnframe = None
[239] Fix | Delete
self.quitting = 1
[240] Fix | Delete
sys.settrace(None)
[241] Fix | Delete
[242] Fix | Delete
# Derived classes and clients can call the following methods
[243] Fix | Delete
# to manipulate breakpoints. These methods return an
[244] Fix | Delete
# error message is something went wrong, None if all is well.
[245] Fix | Delete
# Set_break prints out the breakpoint line and file:lineno.
[246] Fix | Delete
# Call self.get_*break*() to see the breakpoints or better
[247] Fix | Delete
# for bp in Breakpoint.bpbynumber: if bp: bp.bpprint().
[248] Fix | Delete
[249] Fix | Delete
def set_break(self, filename, lineno, temporary=0, cond = None,
[250] Fix | Delete
funcname=None):
[251] Fix | Delete
filename = self.canonic(filename)
[252] Fix | Delete
import linecache # Import as late as possible
[253] Fix | Delete
line = linecache.getline(filename, lineno)
[254] Fix | Delete
if not line:
[255] Fix | Delete
return 'Line %s:%d does not exist' % (filename,
[256] Fix | Delete
lineno)
[257] Fix | Delete
if not filename in self.breaks:
[258] Fix | Delete
self.breaks[filename] = []
[259] Fix | Delete
list = self.breaks[filename]
[260] Fix | Delete
if not lineno in list:
[261] Fix | Delete
list.append(lineno)
[262] Fix | Delete
bp = Breakpoint(filename, lineno, temporary, cond, funcname)
[263] Fix | Delete
[264] Fix | Delete
def _prune_breaks(self, filename, lineno):
[265] Fix | Delete
if (filename, lineno) not in Breakpoint.bplist:
[266] Fix | Delete
self.breaks[filename].remove(lineno)
[267] Fix | Delete
if not self.breaks[filename]:
[268] Fix | Delete
del self.breaks[filename]
[269] Fix | Delete
[270] Fix | Delete
def clear_break(self, filename, lineno):
[271] Fix | Delete
filename = self.canonic(filename)
[272] Fix | Delete
if not filename in self.breaks:
[273] Fix | Delete
return 'There are no breakpoints in %s' % filename
[274] Fix | Delete
if lineno not in self.breaks[filename]:
[275] Fix | Delete
return 'There is no breakpoint at %s:%d' % (filename,
[276] Fix | Delete
lineno)
[277] Fix | Delete
# If there's only one bp in the list for that file,line
[278] Fix | Delete
# pair, then remove the breaks entry
[279] Fix | Delete
for bp in Breakpoint.bplist[filename, lineno][:]:
[280] Fix | Delete
bp.deleteMe()
[281] Fix | Delete
self._prune_breaks(filename, lineno)
[282] Fix | Delete
[283] Fix | Delete
def clear_bpbynumber(self, arg):
[284] Fix | Delete
try:
[285] Fix | Delete
number = int(arg)
[286] Fix | Delete
except:
[287] Fix | Delete
return 'Non-numeric breakpoint number (%s)' % arg
[288] Fix | Delete
try:
[289] Fix | Delete
bp = Breakpoint.bpbynumber[number]
[290] Fix | Delete
except IndexError:
[291] Fix | Delete
return 'Breakpoint number (%d) out of range' % number
[292] Fix | Delete
if not bp:
[293] Fix | Delete
return 'Breakpoint (%d) already deleted' % number
[294] Fix | Delete
bp.deleteMe()
[295] Fix | Delete
self._prune_breaks(bp.file, bp.line)
[296] Fix | Delete
[297] Fix | Delete
def clear_all_file_breaks(self, filename):
[298] Fix | Delete
filename = self.canonic(filename)
[299] Fix | Delete
if not filename in self.breaks:
[300] Fix | Delete
return 'There are no breakpoints in %s' % filename
[301] Fix | Delete
for line in self.breaks[filename]:
[302] Fix | Delete
blist = Breakpoint.bplist[filename, line]
[303] Fix | Delete
for bp in blist:
[304] Fix | Delete
bp.deleteMe()
[305] Fix | Delete
del self.breaks[filename]
[306] Fix | Delete
[307] Fix | Delete
def clear_all_breaks(self):
[308] Fix | Delete
if not self.breaks:
[309] Fix | Delete
return 'There are no breakpoints'
[310] Fix | Delete
for bp in Breakpoint.bpbynumber:
[311] Fix | Delete
if bp:
[312] Fix | Delete
bp.deleteMe()
[313] Fix | Delete
self.breaks = {}
[314] Fix | Delete
[315] Fix | Delete
def get_break(self, filename, lineno):
[316] Fix | Delete
filename = self.canonic(filename)
[317] Fix | Delete
return filename in self.breaks and \
[318] Fix | Delete
lineno in self.breaks[filename]
[319] Fix | Delete
[320] Fix | Delete
def get_breaks(self, filename, lineno):
[321] Fix | Delete
filename = self.canonic(filename)
[322] Fix | Delete
return filename in self.breaks and \
[323] Fix | Delete
lineno in self.breaks[filename] and \
[324] Fix | Delete
Breakpoint.bplist[filename, lineno] or []
[325] Fix | Delete
[326] Fix | Delete
def get_file_breaks(self, filename):
[327] Fix | Delete
filename = self.canonic(filename)
[328] Fix | Delete
if filename in self.breaks:
[329] Fix | Delete
return self.breaks[filename]
[330] Fix | Delete
else:
[331] Fix | Delete
return []
[332] Fix | Delete
[333] Fix | Delete
def get_all_breaks(self):
[334] Fix | Delete
return self.breaks
[335] Fix | Delete
[336] Fix | Delete
# Derived classes and clients can call the following method
[337] Fix | Delete
# to get a data structure representing a stack trace.
[338] Fix | Delete
[339] Fix | Delete
def get_stack(self, f, t):
[340] Fix | Delete
stack = []
[341] Fix | Delete
if t and t.tb_frame is f:
[342] Fix | Delete
t = t.tb_next
[343] Fix | Delete
while f is not None:
[344] Fix | Delete
stack.append((f, f.f_lineno))
[345] Fix | Delete
if f is self.botframe:
[346] Fix | Delete
break
[347] Fix | Delete
f = f.f_back
[348] Fix | Delete
stack.reverse()
[349] Fix | Delete
i = max(0, len(stack) - 1)
[350] Fix | Delete
while t is not None:
[351] Fix | Delete
stack.append((t.tb_frame, t.tb_lineno))
[352] Fix | Delete
t = t.tb_next
[353] Fix | Delete
if f is None:
[354] Fix | Delete
i = max(0, len(stack) - 1)
[355] Fix | Delete
return stack, i
[356] Fix | Delete
[357] Fix | Delete
#
[358] Fix | Delete
[359] Fix | Delete
def format_stack_entry(self, frame_lineno, lprefix=': '):
[360] Fix | Delete
import linecache, repr
[361] Fix | Delete
frame, lineno = frame_lineno
[362] Fix | Delete
filename = self.canonic(frame.f_code.co_filename)
[363] Fix | Delete
s = '%s(%r)' % (filename, lineno)
[364] Fix | Delete
if frame.f_code.co_name:
[365] Fix | Delete
s = s + frame.f_code.co_name
[366] Fix | Delete
else:
[367] Fix | Delete
s = s + "<lambda>"
[368] Fix | Delete
if '__args__' in frame.f_locals:
[369] Fix | Delete
args = frame.f_locals['__args__']
[370] Fix | Delete
else:
[371] Fix | Delete
args = None
[372] Fix | Delete
if args:
[373] Fix | Delete
s = s + repr.repr(args)
[374] Fix | Delete
else:
[375] Fix | Delete
s = s + '()'
[376] Fix | Delete
if '__return__' in frame.f_locals:
[377] Fix | Delete
rv = frame.f_locals['__return__']
[378] Fix | Delete
s = s + '->'
[379] Fix | Delete
s = s + repr.repr(rv)
[380] Fix | Delete
line = linecache.getline(filename, lineno, frame.f_globals)
[381] Fix | Delete
if line: s = s + lprefix + line.strip()
[382] Fix | Delete
return s
[383] Fix | Delete
[384] Fix | Delete
# The following two methods can be called by clients to use
[385] Fix | Delete
# a debugger to debug a statement, given as a string.
[386] Fix | Delete
[387] Fix | Delete
def run(self, cmd, globals=None, locals=None):
[388] Fix | Delete
if globals is None:
[389] Fix | Delete
import __main__
[390] Fix | Delete
globals = __main__.__dict__
[391] Fix | Delete
if locals is None:
[392] Fix | Delete
locals = globals
[393] Fix | Delete
self.reset()
[394] Fix | Delete
sys.settrace(self.trace_dispatch)
[395] Fix | Delete
if not isinstance(cmd, types.CodeType):
[396] Fix | Delete
cmd = cmd+'\n'
[397] Fix | Delete
try:
[398] Fix | Delete
exec cmd in globals, locals
[399] Fix | Delete
except BdbQuit:
[400] Fix | Delete
pass
[401] Fix | Delete
finally:
[402] Fix | Delete
self.quitting = 1
[403] Fix | Delete
sys.settrace(None)
[404] Fix | Delete
[405] Fix | Delete
def runeval(self, expr, globals=None, locals=None):
[406] Fix | Delete
if globals is None:
[407] Fix | Delete
import __main__
[408] Fix | Delete
globals = __main__.__dict__
[409] Fix | Delete
if locals is None:
[410] Fix | Delete
locals = globals
[411] Fix | Delete
self.reset()
[412] Fix | Delete
sys.settrace(self.trace_dispatch)
[413] Fix | Delete
if not isinstance(expr, types.CodeType):
[414] Fix | Delete
expr = expr+'\n'
[415] Fix | Delete
try:
[416] Fix | Delete
return eval(expr, globals, locals)
[417] Fix | Delete
except BdbQuit:
[418] Fix | Delete
pass
[419] Fix | Delete
finally:
[420] Fix | Delete
self.quitting = 1
[421] Fix | Delete
sys.settrace(None)
[422] Fix | Delete
[423] Fix | Delete
def runctx(self, cmd, globals, locals):
[424] Fix | Delete
# B/W compatibility
[425] Fix | Delete
self.run(cmd, globals, locals)
[426] Fix | Delete
[427] Fix | Delete
# This method is more useful to debug a single function call.
[428] Fix | Delete
[429] Fix | Delete
def runcall(self, func, *args, **kwds):
[430] Fix | Delete
self.reset()
[431] Fix | Delete
sys.settrace(self.trace_dispatch)
[432] Fix | Delete
res = None
[433] Fix | Delete
try:
[434] Fix | Delete
res = func(*args, **kwds)
[435] Fix | Delete
except BdbQuit:
[436] Fix | Delete
pass
[437] Fix | Delete
finally:
[438] Fix | Delete
self.quitting = 1
[439] Fix | Delete
sys.settrace(None)
[440] Fix | Delete
return res
[441] Fix | Delete
[442] Fix | Delete
[443] Fix | Delete
def set_trace():
[444] Fix | Delete
Bdb().set_trace()
[445] Fix | Delete
[446] Fix | Delete
[447] Fix | Delete
class Breakpoint:
[448] Fix | Delete
[449] Fix | Delete
"""Breakpoint class
[450] Fix | Delete
[451] Fix | Delete
Implements temporary breakpoints, ignore counts, disabling and
[452] Fix | Delete
(re)-enabling, and conditionals.
[453] Fix | Delete
[454] Fix | Delete
Breakpoints are indexed by number through bpbynumber and by
[455] Fix | Delete
the file,line tuple using bplist. The former points to a
[456] Fix | Delete
single instance of class Breakpoint. The latter points to a
[457] Fix | Delete
list of such instances since there may be more than one
[458] Fix | Delete
breakpoint per line.
[459] Fix | Delete
[460] Fix | Delete
"""
[461] Fix | Delete
[462] Fix | Delete
# XXX Keeping state in the class is a mistake -- this means
[463] Fix | Delete
# you cannot have more than one active Bdb instance.
[464] Fix | Delete
[465] Fix | Delete
next = 1 # Next bp to be assigned
[466] Fix | Delete
bplist = {} # indexed by (file, lineno) tuple
[467] Fix | Delete
bpbynumber = [None] # Each entry is None or an instance of Bpt
[468] Fix | Delete
# index 0 is unused, except for marking an
[469] Fix | Delete
# effective break .... see effective()
[470] Fix | Delete
[471] Fix | Delete
def __init__(self, file, line, temporary=0, cond=None, funcname=None):
[472] Fix | Delete
self.funcname = funcname
[473] Fix | Delete
# Needed if funcname is not None.
[474] Fix | Delete
self.func_first_executable_line = None
[475] Fix | Delete
self.file = file # This better be in canonical form!
[476] Fix | Delete
self.line = line
[477] Fix | Delete
self.temporary = temporary
[478] Fix | Delete
self.cond = cond
[479] Fix | Delete
self.enabled = 1
[480] Fix | Delete
self.ignore = 0
[481] Fix | Delete
self.hits = 0
[482] Fix | Delete
self.number = Breakpoint.next
[483] Fix | Delete
Breakpoint.next = Breakpoint.next + 1
[484] Fix | Delete
# Build the two lists
[485] Fix | Delete
self.bpbynumber.append(self)
[486] Fix | Delete
if (file, line) in self.bplist:
[487] Fix | Delete
self.bplist[file, line].append(self)
[488] Fix | Delete
else:
[489] Fix | Delete
self.bplist[file, line] = [self]
[490] Fix | Delete
[491] Fix | Delete
[492] Fix | Delete
def deleteMe(self):
[493] Fix | Delete
index = (self.file, self.line)
[494] Fix | Delete
self.bpbynumber[self.number] = None # No longer in list
[495] Fix | Delete
self.bplist[index].remove(self)
[496] Fix | Delete
if not self.bplist[index]:
[497] Fix | Delete
# No more bp for this f:l combo
[498] Fix | Delete
del self.bplist[index]
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function