forked from dmanchon/pydump
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pydump
executable file
·35 lines (30 loc) · 1.21 KB
/
pydump
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python
import pdb
import sys
import pydump
import linecache
from optparse import OptionParser
if __name__ == '__main__':
parser = OptionParser(usage="%prog <filename.dump> [options]", description="pydump v%s: post-mortem debugging for Python programs" % pydump.__version__)
parser.add_option("--pdb", action="append_const", const="pdb", dest="debuggers", help="Use builtin pdb or pdb++")
parser.add_option("--pudb", action="append_const", const="pudb", dest="debuggers", help="Use pudb visual debugger")
parser.add_option("--ipdb", action="append_const", const="ipdb", dest="debuggers", help="Use ipdb IPython debugger")
(options, args) = parser.parse_args()
if len(args) < 1:
parser.print_help()
sys.exit(1)
if not options.debuggers:
options.debuggers = ["pdb"]
for debugger in options.debuggers:
try:
dbg = __import__(debugger)
except ImportError as e:
print(str(e))
continue
else:
print("Starting %s..." % debugger)
if debugger == "pudb":
pydump.debug_dump(args[0], dbg.post_mortem)
else:
pydump.debug_dump(args[0])
break