Add tons of features. Should be ready for release 0.91.
This commit is contained in:
parent
6a75cfa2b8
commit
07ab41072e
@ -1,2 +1,3 @@
|
||||
include debug_me.py
|
||||
include ez_setup.py
|
||||
include try-the-debugger.sh
|
||||
|
19
debug_me.py
19
debug_me.py
@ -1,5 +1,22 @@
|
||||
def simple_func(x):
|
||||
x += 1
|
||||
|
||||
s = range(20)
|
||||
z = None
|
||||
w = ()
|
||||
|
||||
y = dict((i, i**2) for i in s)
|
||||
|
||||
k = set(range(5, 99))
|
||||
|
||||
try:
|
||||
x.invalid
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
#import sys
|
||||
#sys.exit(1)
|
||||
|
||||
return 2*x
|
||||
|
||||
def fermat(n):
|
||||
@ -7,7 +24,7 @@ def fermat(n):
|
||||
Warning! Untested with n > 2.
|
||||
"""
|
||||
from itertools import count
|
||||
for x in count(1):
|
||||
for x in range(20):
|
||||
for y in range(1, x+1):
|
||||
for z in range(1, x**n+y**n + 1):
|
||||
#from pudb import set_trace; set_trace()
|
||||
|
105
pudb/__init__.py
Normal file
105
pudb/__init__.py
Normal file
@ -0,0 +1,105 @@
|
||||
VERSION = "0.91"
|
||||
|
||||
|
||||
|
||||
|
||||
CURRENT_DEBUGGER = [None]
|
||||
def set_trace():
|
||||
if CURRENT_DEBUGGER[0] is None:
|
||||
from pudb.debugger import Debugger
|
||||
dbg = Debugger()
|
||||
CURRENT_DEBUGGER[0] = dbg
|
||||
|
||||
import sys
|
||||
dbg.set_trace(sys._getframe().f_back)
|
||||
|
||||
|
||||
|
||||
|
||||
def post_mortem(t):
|
||||
p = Debugger()
|
||||
p.reset()
|
||||
while t.tb_next is not None:
|
||||
t = t.tb_next
|
||||
p.interaction(t.tb_frame, t)
|
||||
|
||||
|
||||
|
||||
|
||||
def pm():
|
||||
import sys
|
||||
post_mortem(sys.last_traceback)
|
||||
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
import sys
|
||||
if not sys.argv[1:]:
|
||||
print "usage: %s scriptfile [-s] [arg] ..." % sys.argv[0]
|
||||
sys.exit(2)
|
||||
|
||||
mainpyfile = sys.argv[1]
|
||||
from os.path import exists, dirname
|
||||
if not exists(mainpyfile):
|
||||
print 'Error:', mainpyfile, 'does not exist'
|
||||
sys.exit(1)
|
||||
|
||||
# Hide "pudb.py" from argument list
|
||||
del sys.argv[0]
|
||||
|
||||
steal_output = sys.argv[0] == "-s"
|
||||
if steal_output:
|
||||
del sys.argv[0]
|
||||
|
||||
# Replace pdb's dir with script's dir in front of module search path.
|
||||
sys.path[0] = dirname(mainpyfile)
|
||||
|
||||
# Note on saving/restoring sys.argv: it's a good idea when sys.argv was
|
||||
# modified by the script being debugged. It's a bad idea when it was
|
||||
# changed by the user from the command line. The best approach would be to
|
||||
# have a "restart" command which would allow explicit specification of
|
||||
# command line arguments.
|
||||
|
||||
from os import getpid
|
||||
|
||||
start_pid = getpid()
|
||||
|
||||
from pudb.debugger import Debugger
|
||||
dbg = Debugger(steal_output=steal_output)
|
||||
|
||||
while True:
|
||||
status_msg = ""
|
||||
try:
|
||||
dbg._runscript(mainpyfile)
|
||||
except SystemExit, se:
|
||||
status_msg = "The debuggee exited normally with status code was %d.\n\n" % se.code
|
||||
except:
|
||||
dbg.post_mortem = True
|
||||
dbg.interaction(None, sys.exc_info())
|
||||
|
||||
if getpid() == start_pid:
|
||||
import urwid
|
||||
result = dbg.ui.call_with_ui(dbg.ui.dialog,
|
||||
urwid.ListBox([urwid.Text(
|
||||
"Your PuDB session has ended.\n\n%s"
|
||||
"Would you like to quit PuDB or restart your program?"
|
||||
% status_msg)]),
|
||||
[
|
||||
("Restart", "restart"),
|
||||
("Quit", "quit"),
|
||||
],
|
||||
focus_buttons=True,
|
||||
title="Finished")
|
||||
|
||||
if result == "quit":
|
||||
return
|
||||
else:
|
||||
return
|
||||
|
||||
dbg.restart()
|
||||
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
main()
|
685
pudb.py → pudb/debugger.py
Executable file → Normal file
685
pudb.py → pudb/debugger.py
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
5
setup.py
5
setup.py
@ -5,9 +5,10 @@ from ez_setup import use_setuptools
|
||||
use_setuptools()
|
||||
|
||||
from setuptools import setup
|
||||
from pudb import VERSION
|
||||
|
||||
setup(name='pudb',
|
||||
version='0.90.6',
|
||||
version=VERSION,
|
||||
description='Python Urwid debugger',
|
||||
long_description="""
|
||||
PuDB is a visual debugger for Python. It runs in the same terminal
|
||||
@ -84,5 +85,5 @@ setup(name='pudb',
|
||||
"Topic :: Terminals",
|
||||
"Topic :: Utilities",
|
||||
],
|
||||
py_modules=["pudb"])
|
||||
packages=["pudb"])
|
||||
|
||||
|
3
try-the-debugger.sh
Executable file
3
try-the-debugger.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#! /bin/sh
|
||||
|
||||
python -m pudb debug_me.py
|
Loading…
x
Reference in New Issue
Block a user