Back to index

python3.2  3.2.2
Classes | Functions | Variables
bdb Namespace Reference

Classes

class  BdbQuit
class  Bdb
class  Breakpoint
class  Tdb

Functions

def set_trace
def checkfuncname
def effective
def foo
def bar
def test

Variables

list __all__ = ["BdbQuit", "Bdb", "Breakpoint"]

Detailed Description

Debugger basics

Function Documentation

def bdb.bar (   a)

Definition at line 628 of file bdb.py.

00628 
00629 def bar(a):
00630     print('bar(', a, ')')
00631     return a/2

Here is the caller graph for this function:

def bdb.checkfuncname (   b,
  frame 
)
Check whether we should break here because of `b.funcname`.

Definition at line 529 of file bdb.py.

00529 
00530 def checkfuncname(b, frame):
00531     """Check whether we should break here because of `b.funcname`."""
00532     if not b.funcname:
00533         # Breakpoint was set via line number.
00534         if b.line != frame.f_lineno:
00535             # Breakpoint was set at a line with a def statement and the function
00536             # defined is called: don't break.
00537             return False
00538         return True
00539 
00540     # Breakpoint set via function name.
00541 
00542     if frame.f_code.co_name != b.funcname:
00543         # It's not a function call, but rather execution of def statement.
00544         return False
00545 
00546     # We are in the right frame.
00547     if not b.func_first_executable_line:
00548         # The function is entered for the 1st time.
00549         b.func_first_executable_line = frame.f_lineno
00550 
00551     if  b.func_first_executable_line != frame.f_lineno:
00552         # But we are not at the first line number: don't break.
00553         return False
00554     return True
00555 
00556 # Determines if there is an effective (active) breakpoint at this
# line of code.  Returns breakpoint number or 0 if none

Here is the caller graph for this function:

def bdb.effective (   file,
  line,
  frame 
)
Determine which breakpoint for this file:line is to be acted upon.

Called only if we know there is a bpt at this
location.  Returns breakpoint that was triggered and a flag
that indicates if it is ok to delete a temporary bp.

Definition at line 557 of file bdb.py.

00557 
00558 def effective(file, line, frame):
00559     """Determine which breakpoint for this file:line is to be acted upon.
00560 
00561     Called only if we know there is a bpt at this
00562     location.  Returns breakpoint that was triggered and a flag
00563     that indicates if it is ok to delete a temporary bp.
00564 
00565     """
00566     possibles = Breakpoint.bplist[file, line]
00567     for b in possibles:
00568         if not b.enabled:
00569             continue
00570         if not checkfuncname(b, frame):
00571             continue
00572         # Count every hit when bp is enabled
00573         b.hits += 1
00574         if not b.cond:
00575             # If unconditional, and ignoring go on to next, else break
00576             if b.ignore > 0:
00577                 b.ignore -= 1
00578                 continue
00579             else:
00580                 # breakpoint and marker that it's ok to delete if temporary
00581                 return (b, True)
00582         else:
00583             # Conditional bp.
00584             # Ignore count applies only to those bpt hits where the
00585             # condition evaluates to true.
00586             try:
00587                 val = eval(b.cond, frame.f_globals, frame.f_locals)
00588                 if val:
00589                     if b.ignore > 0:
00590                         b.ignore -= 1
00591                         # continue
00592                     else:
00593                         return (b, True)
00594                 # else:
00595                 #   continue
00596             except:
00597                 # if eval fails, most conservative thing is to stop on
00598                 # breakpoint regardless of ignore count.  Don't delete
00599                 # temporary, as another hint to user.
00600                 return (b, False)
00601     return (None, None)
00602 
00603 
00604 # -------------------- testing --------------------

Here is the call graph for this function:

Here is the caller graph for this function:

def bdb.foo (   n)

Definition at line 623 of file bdb.py.

00623 
00624 def foo(n):
00625     print('foo(', n, ')')
00626     x = bar(n*10)
00627     print('bar returned', x)

Here is the call graph for this function:

def bdb.set_trace ( )

Definition at line 435 of file bdb.py.

00435 
00436 def set_trace():
00437     Bdb().set_trace()
00438 

def bdb.test ( )

Definition at line 632 of file bdb.py.

00632 
00633 def test():
00634     t = Tdb()
00635     t.run('import bdb; bdb.foo(10)')

Variable Documentation

list bdb.__all__ = ["BdbQuit", "Bdb", "Breakpoint"]

Definition at line 7 of file bdb.py.