-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpydump.py
executable file
·35 lines (30 loc) · 1.29 KB
/
pydump.py
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 python3
import pdb
import sys
from pydump 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), file=sys.stderr)
continue
else:
print("Starting %s..." % debugger, file=sys.stderr)
if debugger == "pudb":
pydump.debug_dump(args[0], lambda tb: dbg.post_mortem((None, None, tb)))
else:
pydump.debug_dump(args[0])
break