summaryrefslogtreecommitdiffstats
path: root/Lib/pdb.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2003-04-09 19:06:21 (GMT)
committerGuido van Rossum <guido@python.org>2003-04-09 19:06:21 (GMT)
commita12fe4e81fa3221458e16225e76ec7b8a05820ee (patch)
tree05f9ba6e5dab68aa1627e340aa1b6f2437c8e302 /Lib/pdb.py
parent12dd7b12c6bce882a7e789173760abab62c80304 (diff)
downloadcpython-a12fe4e81fa3221458e16225e76ec7b8a05820ee.zip
cpython-a12fe4e81fa3221458e16225e76ec7b8a05820ee.tar.gz
cpython-a12fe4e81fa3221458e16225e76ec7b8a05820ee.tar.bz2
- New function sys.call_tracing() allows pdb to debug code
recursively. - pdb has a new command, "debug", which lets you step through arbitrary code from the debugger's (pdb) prompt.
Diffstat (limited to 'Lib/pdb.py')
-rwxr-xr-xLib/pdb.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/Lib/pdb.py b/Lib/pdb.py
index d7215cf..46dff55 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -523,6 +523,33 @@ class Pdb(bdb.Bdb, cmd.Cmd):
print '*** Jump failed:', e
do_j = do_jump
+ def do_debug(self, arg):
+ sys.settrace(None)
+ globals = self.curframe.f_globals
+ locals = self.curframe.f_locals
+ p = Pdb()
+ p.prompt = "(%s) " % self.prompt.strip()
+ print "ENTERING RECURSIVE DEBUGGER"
+ sys.call_tracing(p.run, (arg, globals, locals))
+ print "LEAVING RECURSIVE DEBUGGER"
+ sys.settrace(self.trace_dispatch)
+ self.lastcmd = p.lastcmd
+
+ def dont_debug(self, arg):
+ locals = self.curframe.f_locals
+ globals = self.curframe.f_globals
+ try:
+ r = sys.call_tracing(eval, (arg, globals, locals))
+ print "--- DEBUG RETURNED ---"
+ if r is not None:
+ print repr(r)
+ except:
+ t, v = sys.exc_info()[:2]
+ if type(t) == type(''):
+ exc_type_name = t
+ else: exc_type_name = t.__name__
+ print '***', exc_type_name + ':', v
+
def do_quit(self, arg):
self.set_quit()
return 1
@@ -834,6 +861,12 @@ Continue execution, only stop when a breakpoint is encountered."""
print """j(ump) lineno
Set the next line that will be executed."""
+ def help_debug(self):
+ print """debug code
+Enter a recursive debugger that steps through the code argument
+(which is an arbitrary expression or statement to be executed
+in the current environment)."""
+
def help_list(self):
self.help_l()