From: Guido van Rossum Date: Tue, 8 Sep 1992 11:59:04 +0000 (+0000) Subject: Added post_mortem() and pm() interfaces to pdb and wdb. X-Git-Tag: v0.9.8~142 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3577113d8366d1c75cf2cbdbeb5168fd86d2834c;p=thirdparty%2FPython%2Fcpython.git Added post_mortem() and pm() interfaces to pdb and wdb. Added colorsys.py (color system conversions). SV.py: new version for new svideo.h (Sjoerd). DEVICE.py: added VIDEO event type. --- diff --git a/Lib/irix5/DEVICE.py b/Lib/irix5/DEVICE.py index 2c20485aa42b..7ace8cb0b6c1 100755 --- a/Lib/irix5/DEVICE.py +++ b/Lib/irix5/DEVICE.py @@ -385,6 +385,7 @@ WINQUIT = 542 DEPTHCHANGE = 543 WINSHUT = 546 DRAWOVERLAY = 547 +VIDEO = 548 MENUBUTTON = RIGHTMOUSE WINCLOSE = 537 KEYBDFNAMES = 544 diff --git a/Lib/lib-stdwin/wdb.py b/Lib/lib-stdwin/wdb.py index b3d6b737601d..c499296c8a01 100644 --- a/Lib/lib-stdwin/wdb.py +++ b/Lib/lib-stdwin/wdb.py @@ -2,8 +2,6 @@ # XXX To do: # - don't fall out of bottom frame -# - is the /tmp file hack really needed? -# - also use it for post-mortem debugging import stdwin @@ -273,6 +271,8 @@ class Wdb(bdb.Bdb, basewin.BaseWindow): # Window debugger d.close() +# Simplified interface + def run(statement): x = Wdb().init() try: x.run(statement) @@ -288,6 +288,21 @@ def runcall(*args): try: apply(Pdb().init().runcall, args) finally: x.close() + +# Post-Mortem interface + +def post_mortem(traceback): + p = Pdb().init() + p.reset() + p.interaction(None, traceback) + +def pm(): + import sys + post_mortem(sys.last_traceback) + + +# Main program for testing + TESTCMD = 'import x; x.main()' def test(): diff --git a/Lib/pdb.doc b/Lib/pdb.doc index 0ae4c0e2e8eb..c92b57229d7e 100644 --- a/Lib/pdb.doc +++ b/Lib/pdb.doc @@ -9,6 +9,15 @@ To use the debugger in its simplest form: The debugger's prompt is '(Pdb) '. This will stop in the first function call in . +Alternatively, if a statement terminated with an unhandled exception, +you can use pdb's post-mortem facility to inspect the contents of the +traceback: + + >>> + + >>> import pdb + >>> pdb.pm() + The commands recognized by the debugger are listed in the next section. Most can be abbreviated as indicated; e.g., h(elp) means that 'help' can be typed as 'h' or 'help' (but not as 'he' or 'hel', diff --git a/Lib/pdb.py b/Lib/pdb.py index f564f642b3bf..94dcd797a61e 100755 --- a/Lib/pdb.py +++ b/Lib/pdb.py @@ -248,6 +248,8 @@ class Pdb(bdb.Bdb, cmd.Cmd): print self.format_stack_entry(frame_lineno) +# Simplified interface + def run(statement): Pdb().init().run(statement) @@ -257,6 +259,22 @@ def runctx(statement, globals, locals): def runcall(*args): apply(Pdb().init().runcall, args) + +# Post-Mortem interface + +def post_mortem(t): + p = Pdb().init() + p.reset() + while t.tb_next <> None: t = t.tb_next + p.interaction(t.tb_frame, t) + +def pm(): + import sys + post_mortem(sys.last_traceback) + + +# Main program for testing + TESTCMD = 'import x; x.main()' def test(): diff --git a/Lib/plat-irix5/DEVICE.py b/Lib/plat-irix5/DEVICE.py index 2c20485aa42b..7ace8cb0b6c1 100755 --- a/Lib/plat-irix5/DEVICE.py +++ b/Lib/plat-irix5/DEVICE.py @@ -385,6 +385,7 @@ WINQUIT = 542 DEPTHCHANGE = 543 WINSHUT = 546 DRAWOVERLAY = 547 +VIDEO = 548 MENUBUTTON = RIGHTMOUSE WINCLOSE = 537 KEYBDFNAMES = 544 diff --git a/Lib/stdwin/wdb.py b/Lib/stdwin/wdb.py index b3d6b737601d..c499296c8a01 100755 --- a/Lib/stdwin/wdb.py +++ b/Lib/stdwin/wdb.py @@ -2,8 +2,6 @@ # XXX To do: # - don't fall out of bottom frame -# - is the /tmp file hack really needed? -# - also use it for post-mortem debugging import stdwin @@ -273,6 +271,8 @@ class Wdb(bdb.Bdb, basewin.BaseWindow): # Window debugger d.close() +# Simplified interface + def run(statement): x = Wdb().init() try: x.run(statement) @@ -288,6 +288,21 @@ def runcall(*args): try: apply(Pdb().init().runcall, args) finally: x.close() + +# Post-Mortem interface + +def post_mortem(traceback): + p = Pdb().init() + p.reset() + p.interaction(None, traceback) + +def pm(): + import sys + post_mortem(sys.last_traceback) + + +# Main program for testing + TESTCMD = 'import x; x.main()' def test():