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