├── Doc ├── html │ ├── .cvsignore │ ├── icons │ │ ├── next.gif │ │ ├── next.png │ │ ├── up.gif │ │ ├── up.png │ │ ├── blank.gif │ │ ├── blank.png │ │ ├── index.gif │ │ ├── index.png │ │ ├── pyfav.gif │ │ ├── pyfav.png │ │ ├── contents.gif │ │ ├── contents.png │ │ ├── modules.gif │ │ ├── modules.png │ │ ├── previous.gif │ │ └── previous.png │ ├── index.html │ └── stdabout.dat ├── commontex │ ├── .cvsignore │ ├── boilerplate.tex │ └── copyright.tex ├── tools │ ├── .gitignore │ ├── .cvsignore │ ├── patchlevel.h │ ├── mkinfo │ ├── getversioninfo │ ├── node2label.pl │ └── indfix.py ├── .gitignore ├── lib │ ├── mymodule.py │ ├── hardtodebug.py │ ├── Makefile │ ├── lib-ds.tex │ └── lib.tex ├── info │ ├── .cvsignore │ ├── .gitignore │ └── Makefile ├── paper-letter │ ├── .gitignore │ └── .cvsignore ├── .cvsignore ├── texinputs │ ├── python.ist │ └── pypaper.sty ├── perl │ ├── manual.perl │ └── SynopsisTable.pm └── Makefile.deps ├── htdocs ├── .gitignore ├── debian.png ├── netbsd.png ├── source-code.gif ├── links2linux.de.png ├── download.html └── jc.css ├── test ├── data │ ├── savefile.right │ ├── .cvsignore │ ├── .gitignore │ ├── pydbrc.right │ ├── withbug-2.6.right │ ├── contbug.right │ ├── checkline.py │ ├── withbug.right │ ├── contbug-2.5.right │ ├── step.right │ ├── filebug.right │ ├── file.right │ ├── file-2.5.right │ ├── logging.right │ ├── setshow-no-rl.right │ ├── setshow.right │ ├── fntrace.right │ ├── skip.right │ ├── noscript.right │ ├── sighandler.right │ ├── save.right │ ├── pm.right │ ├── brkpt3.right │ ├── history.right │ ├── brkpt3t.right │ ├── brkpt3-2.5t.right │ ├── Makefile.am │ ├── run.right │ ├── help.right │ ├── run2.right │ ├── brkpt2-2.3.right │ ├── brkpt2.right │ ├── dbgcall.right │ ├── brkpt1-2.7.right │ ├── brkpt1.right │ ├── tracetest-2.4-final.right │ ├── dbgcall-2.5.right │ ├── tracetest-2.5.right │ ├── tracetest.right │ ├── brkpt1t-2.7.right │ ├── brkpt1t.right │ ├── trace.right │ ├── trace-2.4-final.right │ └── trace-2.5.right ├── .pydbrc.in ├── comm1.cmd ├── comm2.cmd ├── unit │ ├── .cvsignore │ ├── .gitignore │ ├── Makefile.am │ ├── pydbcmd.py.in │ ├── fns.py.in │ ├── bytecode.py.in │ ├── checkline.py.in │ ├── listsize.py.in │ └── sighandler.py.in ├── pydbrc.cmd ├── contbug.cmd ├── withbug.cmd ├── filebug.py ├── file.cmd.in ├── thread │ ├── thread-switch.cmd │ ├── test.py │ ├── t2.py │ ├── tlock.py │ ├── q.py │ ├── prof2.py │ └── thread1.py ├── step.cmd ├── logging.cmd ├── skip.cmd ├── file.right.in ├── filebug.cmd ├── pm.cmd ├── file-2.5.right.in ├── noscript.cmd ├── withbug.py ├── sighandler.cmd ├── history.cmd ├── setshow.cmd ├── save.cmd ├── .cvsignore ├── .gitignore ├── run.cmd ├── exceptbug.py.in ├── hanoi.py ├── sigtestexample.py ├── brkpt3.cmd.in ├── except.py.in ├── brkpt3.right.in ├── test-import.py.in ├── run2.cmd ├── dbgcall.py ├── gcd.py ├── brkpt3t.right.in ├── settrace.py.in ├── brkpt2.cmd ├── brkpt1.cmd ├── test-fifo-connect.py.in ├── test-complete.py.in ├── test-disassem.py.in ├── test-save.py.in ├── test-contbug.py.in ├── test-skip.py.in ├── test-step.py.in ├── test-linetrace.py.in ├── test-dbgcall.py.in ├── Makefile.am ├── test-file.py.in ├── test-help.py.in ├── test-pm.py.in ├── test-setshow.py.in ├── test-sighandle.py.in ├── cmdparse.cmd ├── test-with.py.in └── test-fns.py.in ├── cvs2cl_usermap ├── cvs2cl_header ├── pydb ├── .cvsignore ├── .gitignore ├── __init__.py.in ├── Makefile ├── server.py └── bytecode.py ├── .cvsignore ├── .gitignore ├── site-packages-path.py ├── autogen.sh ├── THANKS ├── AUTHORS ├── TODO └── README /Doc/html/.cvsignore: -------------------------------------------------------------------------------- 1 | lib 2 | -------------------------------------------------------------------------------- /htdocs/.gitignore: -------------------------------------------------------------------------------- 1 | /*~ 2 | -------------------------------------------------------------------------------- /test/data/savefile.right: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Doc/commontex/.cvsignore: -------------------------------------------------------------------------------- 1 | patchlevel.tex 2 | -------------------------------------------------------------------------------- /Doc/tools/.gitignore: -------------------------------------------------------------------------------- 1 | /*.pyc 2 | /*~ 3 | -------------------------------------------------------------------------------- /Doc/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /pydb.1 3 | /*~ 4 | -------------------------------------------------------------------------------- /test/.pydbrc.in: -------------------------------------------------------------------------------- 1 | alias myc tbreak %1 ;; continue 2 | -------------------------------------------------------------------------------- /test/comm1.cmd: -------------------------------------------------------------------------------- 1 | commands 2 | print "test" 3 | end 4 | -------------------------------------------------------------------------------- /test/data/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | Makefile.in 3 | -------------------------------------------------------------------------------- /Doc/lib/mymodule.py: -------------------------------------------------------------------------------- 1 | def test(): 2 | print spam 3 | -------------------------------------------------------------------------------- /Doc/tools/.cvsignore: -------------------------------------------------------------------------------- 1 | patchlevel.h 2 | *.pyc 3 | 4 | 5 | -------------------------------------------------------------------------------- /test/data/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | /Makefile 3 | /Makefile.in 4 | -------------------------------------------------------------------------------- /Doc/info/.cvsignore: -------------------------------------------------------------------------------- 1 | python-lib.info 2 | python-lib.texi 3 | -------------------------------------------------------------------------------- /cvs2cl_usermap: -------------------------------------------------------------------------------- 1 | rockyb:Rocky Bernstein 2 | 3 | -------------------------------------------------------------------------------- /Doc/paper-letter/.gitignore: -------------------------------------------------------------------------------- 1 | /lib.dvi 2 | /lib.pdf 3 | /lib.ps 4 | -------------------------------------------------------------------------------- /test/comm2.cmd: -------------------------------------------------------------------------------- 1 | commands 2 2 | print "breakpoint 2 test" 3 | end 4 | -------------------------------------------------------------------------------- /Doc/info/.gitignore: -------------------------------------------------------------------------------- 1 | /python-lib.info 2 | /python-lib.texi 3 | /*~ 4 | -------------------------------------------------------------------------------- /cvs2cl_header: -------------------------------------------------------------------------------- 1 | ## 2 | ## autogenerated ChangeLog -- don't edit 3 | ## 4 | 5 | -------------------------------------------------------------------------------- /pydb/.cvsignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | __init__.py 3 | pydb.py 4 | gdb.py 5 | 6 | 7 | -------------------------------------------------------------------------------- /pydb/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | /*.pyc 3 | /*~ 4 | /__init__.py 5 | /gdb.py 6 | /pydb.py 7 | -------------------------------------------------------------------------------- /htdocs/debian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/pydb/HEAD/htdocs/debian.png -------------------------------------------------------------------------------- /htdocs/netbsd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/pydb/HEAD/htdocs/netbsd.png -------------------------------------------------------------------------------- /Doc/html/icons/next.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/pydb/HEAD/Doc/html/icons/next.gif -------------------------------------------------------------------------------- /Doc/html/icons/next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/pydb/HEAD/Doc/html/icons/next.png -------------------------------------------------------------------------------- /Doc/html/icons/up.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/pydb/HEAD/Doc/html/icons/up.gif -------------------------------------------------------------------------------- /Doc/html/icons/up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/pydb/HEAD/Doc/html/icons/up.png -------------------------------------------------------------------------------- /htdocs/source-code.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/pydb/HEAD/htdocs/source-code.gif -------------------------------------------------------------------------------- /Doc/html/icons/blank.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/pydb/HEAD/Doc/html/icons/blank.gif -------------------------------------------------------------------------------- /Doc/html/icons/blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/pydb/HEAD/Doc/html/icons/blank.png -------------------------------------------------------------------------------- /Doc/html/icons/index.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/pydb/HEAD/Doc/html/icons/index.gif -------------------------------------------------------------------------------- /Doc/html/icons/index.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/pydb/HEAD/Doc/html/icons/index.png -------------------------------------------------------------------------------- /Doc/html/icons/pyfav.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/pydb/HEAD/Doc/html/icons/pyfav.gif -------------------------------------------------------------------------------- /Doc/html/icons/pyfav.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/pydb/HEAD/Doc/html/icons/pyfav.png -------------------------------------------------------------------------------- /htdocs/links2linux.de.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/pydb/HEAD/htdocs/links2linux.de.png -------------------------------------------------------------------------------- /Doc/html/icons/contents.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/pydb/HEAD/Doc/html/icons/contents.gif -------------------------------------------------------------------------------- /Doc/html/icons/contents.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/pydb/HEAD/Doc/html/icons/contents.png -------------------------------------------------------------------------------- /Doc/html/icons/modules.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/pydb/HEAD/Doc/html/icons/modules.gif -------------------------------------------------------------------------------- /Doc/html/icons/modules.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/pydb/HEAD/Doc/html/icons/modules.png -------------------------------------------------------------------------------- /Doc/html/icons/previous.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/pydb/HEAD/Doc/html/icons/previous.gif -------------------------------------------------------------------------------- /Doc/html/icons/previous.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Trepan-Debuggers/pydb/HEAD/Doc/html/icons/previous.png -------------------------------------------------------------------------------- /Doc/paper-letter/.cvsignore: -------------------------------------------------------------------------------- 1 | lib.dvi 2 | lib.how 3 | lib.ind 4 | lib.l2h 5 | lib.pdf 6 | lib.ps 7 | modlib.ind 8 | -------------------------------------------------------------------------------- /test/data/pydbrc.right: -------------------------------------------------------------------------------- 1 | +# Test to see if ./.pydbrc gets loaded. 2 | +alias 3 | myc = tbreak %1 ;; continue 4 | +quit 5 | -------------------------------------------------------------------------------- /test/unit/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | Makefile.in 3 | bytecode.py 4 | checkline.py 5 | fns.py 6 | listsize.py 7 | sighandler.py 8 | -------------------------------------------------------------------------------- /test/data/withbug-2.6.right: -------------------------------------------------------------------------------- 1 | +continue 17 2 | Breakpoint 1 set in file withbug.py, line 17. 3 | Deleted breakpoint 1 4 | +info local 5 | f = 1 6 | +quit 7 | -------------------------------------------------------------------------------- /Doc/.cvsignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *.aux 3 | *.dvi 4 | *.idx 5 | *.ind 6 | *.l2h 7 | *.log 8 | *.toc 9 | html-*.tar 10 | html-*.tgz 11 | info 12 | pydb.1 13 | 14 | -------------------------------------------------------------------------------- /test/pydbrc.cmd: -------------------------------------------------------------------------------- 1 | # $Id: pydbrc.cmd,v 1.1 2007/02/20 18:23:39 rockyb Exp $ 2 | set trace-commands on 3 | # Test to see if ./.pydbrc gets loaded. 4 | alias 5 | quit 6 | 7 | -------------------------------------------------------------------------------- /test/unit/.gitignore: -------------------------------------------------------------------------------- 1 | /*.pyc 2 | /*~ 3 | /Makefile 4 | /Makefile.in 5 | /bytecode.py 6 | /checkline.py 7 | /fns.py 8 | /listsize.py 9 | /pydbcmd.py 10 | /sighandler.py 11 | -------------------------------------------------------------------------------- /test/contbug.cmd: -------------------------------------------------------------------------------- 1 | # $Id: contbug.cmd,v 1.1 2007/02/17 10:53:01 rockyb Exp $ 2 | set basename on 3 | set trace-commands on 4 | # Test to see if continue *line* works when invoked initially 5 | c 12 6 | quit 7 | -------------------------------------------------------------------------------- /Doc/lib/hardtodebug.py: -------------------------------------------------------------------------------- 1 | import pydb 2 | # some code here 3 | def test(): 4 | # Force a call to the debugger in running code here 5 | pydb.set_trace() 6 | # ... 7 | # ... 8 | test() 9 | x=5 10 | -------------------------------------------------------------------------------- /test/data/contbug.right: -------------------------------------------------------------------------------- 1 | (hanoi.py:2): 2 | 2 """Towers of Hanoi""" 3 | + c 12 4 | Breakpoint 1 set in file hanoi.py, line 12. 5 | Deleted breakpoint 1 6 | (hanoi.py:12): 7 | 12 if __name__=='__main__': 8 | + quit 9 | -------------------------------------------------------------------------------- /.cvsignore: -------------------------------------------------------------------------------- 1 | ChangeLog 2 | Makefile 3 | Makefile.in 4 | PKG-INFO 5 | aclocal.m4 6 | autom4te.cache 7 | build 8 | config.log 9 | config.status 10 | configure 11 | pydb*.tar.gz 12 | semantic.cache 13 | setup.py 14 | -------------------------------------------------------------------------------- /test/data/checkline.py: -------------------------------------------------------------------------------- 1 | def foo(): 2 | """Exception to raise to quit debugging. 3 | 4 | FIXME: we allow stopping here but we shouldn't 5 | """ 6 | return 7 | 8 | # Should not allow stopping here 9 | print "hi" 10 | -------------------------------------------------------------------------------- /test/data/withbug.right: -------------------------------------------------------------------------------- 1 | +continue 17 2 | Breakpoint 1 set in file withbug.py, line 17. 3 | Deleted breakpoint 1 4 | +info local 5 | _[1] = 2 | 2 """Towers of Hanoi""" 3 | + c 12 4 | Breakpoint 1 set in file hanoi.py, line 12. 5 | Deleted breakpoint 1 6 | (hanoi.py:12): 7 | 12 if __name__=='__main__': 8 | + quit 9 | -------------------------------------------------------------------------------- /test/filebug.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import os 3 | # Make sure __file__ is defined 4 | # http://groups.google.com/group/comp.lang.python/browse_frm/thread/cf2a718a50f9bb52/fb754e84298513db 5 | print "__file__: %s" % os.path.basename(__file__) 6 | 7 | -------------------------------------------------------------------------------- /test/file.cmd.in: -------------------------------------------------------------------------------- 1 | # 2 | # Test of the 'file' command 3 | # $Id: file.cmd.in,v 1.1 2007/02/13 11:42:54 rockyb Exp $ 4 | # 5 | set trace-commands on 6 | cd @srcdir@ 7 | file hanoi.py 8 | info line 9 | where 2 10 | step 1+1 11 | where 2 12 | quit 13 | -------------------------------------------------------------------------------- /Doc/commontex/boilerplate.tex: -------------------------------------------------------------------------------- 1 | \author{Revised by Rocky Bernstein\\ 2 | } 3 | \authoraddress{ 4 | Email: \email{bashdb-pydb@lists.sourceforge.net} 5 | } 6 | 7 | \date{\today} % XXX update before final release! 8 | \input{patchlevel} % include Python version information 9 | -------------------------------------------------------------------------------- /test/thread/thread-switch.cmd: -------------------------------------------------------------------------------- 1 | set basename on 2 | info thread 3 | break 39 4 | info thread terse 5 | continue 6 | frame 0 7 | frame FakeThreadName 8 | frame MainThread 9 | frame . 10 | where 11 | # thread Thread-1 12 | # info thread terse 13 | kill unconditionally 14 | -------------------------------------------------------------------------------- /test/unit/Makefile.am: -------------------------------------------------------------------------------- 1 | TESTS = bytecode.py checkline.py listsize.py 2 | 3 | abs_srcdir=@abs_srcdir@ 4 | abs_builddir=@abs_builddir@ 5 | 6 | TESTS_ENVIRONMENT = \ 7 | srcdir="$(abs_srcdir)" \ 8 | builddir="$(abs_builddir)" 9 | 10 | EXTRA_DIST = $(TESTS) 11 | 12 | -------------------------------------------------------------------------------- /test/data/step.right: -------------------------------------------------------------------------------- 1 | +set deftrace off 2 | +set listsize 1 3 | +step 4 | +list 5 | 11 -> import sys 6 | +set deftrace on 7 | +step 8 | +list 9 | 13 -> def check_args(): 10 | +set deftrace off 11 | +step 12 | +list 13 | 37 -> if __name__=='__main__': 14 | +quit 15 | -------------------------------------------------------------------------------- /test/data/filebug.right: -------------------------------------------------------------------------------- 1 | +############################################# 2 | +## Test to see that __file__ is set. 3 | +## Just run the program and it does the work. 4 | +############################################# 5 | +continue 6 | The program finished and will be restarted 7 | +quit 8 | -------------------------------------------------------------------------------- /Doc/texinputs/python.ist: -------------------------------------------------------------------------------- 1 | line_max 100 2 | headings_flag 1 3 | heading_prefix " \\bigletter " 4 | 5 | preamble "\\begin{theindex} 6 | \\def\\bigletter#1{{\\Large\\sffamily#1}\\nopagebreak\\vspace{1mm}} 7 | 8 | " 9 | 10 | symhead_positive "{Symbols}" 11 | numhead_positive "{Numbers}" 12 | -------------------------------------------------------------------------------- /test/step.cmd: -------------------------------------------------------------------------------- 1 | # 2 | # Test of the 'step' and deftrace command 3 | # $Id: step.cmd,v 1.1 2008/05/17 10:08:33 rockyb Exp $ 4 | # 5 | set basename on 6 | set trace-commands on 7 | set deftrace off 8 | set listsize 1 9 | step 10 | list 11 | set deftrace on 12 | step 13 | list 14 | set deftrace off 15 | step 16 | list 17 | quit 18 | -------------------------------------------------------------------------------- /test/data/file.right: -------------------------------------------------------------------------------- 1 | +cd . 2 | +file hanoi.py 3 | +info line 4 | Line 2 of "hanoi.py" at instruction 0 5 | +where 2 6 | -> 0 in file 'hanoi.py' at line 2 7 | ## 1 in exec cmd in globals, locals at line 1 8 | +step 1+1 9 | +where 2 10 | -> 0 in file 'hanoi.py' at line 12 11 | ## 1 in exec cmd in globals, locals at line 1 12 | +quit 13 | -------------------------------------------------------------------------------- /test/logging.cmd: -------------------------------------------------------------------------------- 1 | set logging file logging.out 2 | set logging on 3 | set logging redirect on 4 | show logging 5 | show logging redirect 6 | show logging file 7 | show logging overwrite 8 | set logging fdfsdasdfs 9 | set logging file /.bogus/bogusbogus/bogus/bogus/bogus 10 | set logging redirect oon 11 | set logging off 12 | quit 13 | -------------------------------------------------------------------------------- /test/skip.cmd: -------------------------------------------------------------------------------- 1 | # 2 | # Test of the 'step' and deftrace command 3 | # $Id: skip.cmd,v 1.1 2009/02/09 09:28:39 rockyb Exp $ 4 | # 5 | set basename on 6 | set trace-commands on 7 | set deftrace off 8 | set linetrace on 9 | set listsize 1 10 | skip 11 | list 12 | p sys 13 | skip foo 14 | skip 2 15 | c 38 16 | skip 17 | list 18 | quit 19 | -------------------------------------------------------------------------------- /test/file.right.in: -------------------------------------------------------------------------------- 1 | +cd @srcdir@ 2 | +file hanoi.py 3 | +info line 4 | Line 2 of "hanoi.py" at instruction 0 5 | +where 2 6 | -> 0 in file 'hanoi.py' at line 2 7 | ## 1 in exec cmd in globals, locals at line 1 8 | +step 1+1 9 | +where 2 10 | -> 0 in file 'hanoi.py' at line 12 11 | ## 1 in exec cmd in globals, locals at line 1 12 | +quit 13 | -------------------------------------------------------------------------------- /Doc/lib/Makefile: -------------------------------------------------------------------------------- 1 | #============================================================= 2 | # $Id: Makefile,v 1.1 2006/01/28 10:50:36 rockyb Exp $ 3 | #============================================================= 4 | # Whatever it is you want to do, it should be handled by the 5 | # by the main (parent) Makefile. So reissue make from there. 6 | all %: 7 | $(MAKE) -C .. $@ 8 | -------------------------------------------------------------------------------- /test/filebug.cmd: -------------------------------------------------------------------------------- 1 | # Test to see __file__ is set 2 | # $Id: filebug.cmd,v 1.2 2007/01/25 10:19:15 rockyb Exp $ 3 | set basename on 4 | set trace-commands on 5 | ############################################# 6 | ## Test to see that __file__ is set. 7 | ## Just run the program and it does the work. 8 | ############################################# 9 | continue 10 | quit 11 | -------------------------------------------------------------------------------- /test/data/file-2.5.right: -------------------------------------------------------------------------------- 1 | +cd . 2 | +file hanoi.py 3 | +info line 4 | Line 2 of "hanoi.py" at instruction 0 5 | +where 2 6 | -> 0 execfile() file 'hanoi.py' at line 2 7 | ## 1 exec() file '' at line 1 8 | +step 1+1 9 | +where 2 10 | -> 0 execfile() file 'hanoi.py' at line 12 11 | ## 1 exec() file '' at line 1 12 | +quit 13 | -------------------------------------------------------------------------------- /test/pm.cmd: -------------------------------------------------------------------------------- 1 | # Test of restart and linetracing 2 | # $Id: pm.cmd,v 1.5 2008/12/08 11:26:27 rockyb Exp $ 3 | # 4 | set trace-commands on 5 | set interactive off 6 | set basename on 7 | show args 8 | info args 9 | list 10 | # Completion might not be available if no readline 11 | # complete s 12 | # complete help s 13 | where 14 | step 15 | next 16 | finish 17 | return 18 | quit 19 | 20 | 21 | -------------------------------------------------------------------------------- /test/file-2.5.right.in: -------------------------------------------------------------------------------- 1 | +cd @srcdir@ 2 | +file hanoi.py 3 | +info line 4 | Line 2 of "hanoi.py" at instruction 0 5 | +where 2 6 | -> 0 () called from file 'hanoi.py' at line 2 7 | ## 1 () called from file '' at line 1 8 | +step 1+1 9 | +where 2 10 | -> 0 () called from file 'hanoi.py' at line 12 11 | ## 1 () called from file '' at line 1 12 | +quit 13 | -------------------------------------------------------------------------------- /test/noscript.cmd: -------------------------------------------------------------------------------- 1 | where 2 | break 3 | break ctest.c:5 4 | cd . 5 | clear 6 | debug foo 7 | disassemble 8 | down 9 | info a 10 | info args 11 | info br 12 | info break 13 | info di 14 | info display 15 | info gl 16 | info globals 17 | info li 18 | info line 19 | info lo 20 | info locals 21 | info prog 22 | info program 23 | info so 24 | info source 25 | jump 26 | list 27 | run 28 | up 29 | quit 30 | -------------------------------------------------------------------------------- /test/withbug.py: -------------------------------------------------------------------------------- 1 | from __future__ import with_statement 2 | 3 | class FakeClass: 4 | 5 | def __init__(self): 6 | x = 1 7 | return 8 | 9 | def __enter__(self): 10 | return 1 11 | 12 | def __exit__(self, type, value, traceback): 13 | return 2 14 | 15 | def test(): 16 | with FakeClass() as f: 17 | print f 18 | return 19 | return 20 | 21 | test() 22 | 23 | -------------------------------------------------------------------------------- /test/sighandler.cmd: -------------------------------------------------------------------------------- 1 | info signal hup 2 | info handle SIGHUP 3 | handle SIGINT 4 | handle SIGINT stop pass noprint 5 | info handle SIGINT 6 | handle SIGINT print 7 | info handle SIGINT 8 | handle SIGINT nopass noprint nostop 9 | info signal SIGINT 10 | # try changing fatal signal handlers (which are unchangable) 11 | handle SIGKILL stop 12 | info handle KILL 13 | handle SIGSTOP print 14 | info signal sigstop 15 | info signal INT 16 | quit 17 | -------------------------------------------------------------------------------- /pydb/__init__.py.in: -------------------------------------------------------------------------------- 1 | """Python Debugger with a gdb-like command interface.""" 2 | # -*- coding: UTF-8 -*- 3 | app_name = 'Python Extended Debugger' 4 | version = '@PACKAGE_VERSION@' 5 | URL = 'http://bashdb.sourceforge.net/pydb/' 6 | HELP_URL = URL + 'pydb/index.html' 7 | 8 | import sys 9 | assert sys.version_info>= map(int, '@MIN_VERSION@'.split('.')), \ 10 | _("Python %s or newer required") % '@MIN_VERSION@' 11 | from pydb import * 12 | 13 | -------------------------------------------------------------------------------- /test/data/logging.right: -------------------------------------------------------------------------------- 1 | Future logs will be written to logging.out. 2 | Logs will be appended to the log file. 3 | Output will be sent only to the log file. 4 | The logging output mode is on. 5 | The current logfile is "logging.out". 6 | Whether logging overwrites or appends to the log file is off. 7 | *** Undefined set logging command "fdfsdasdfs". 8 | *** Error in opening /.bogus/bogusbogus/bogus/bogus/bogus 9 | *** Expecting 'on', 1, 'off', or 0. Got: oon. 10 | -------------------------------------------------------------------------------- /Doc/commontex/copyright.tex: -------------------------------------------------------------------------------- 1 | Copyright \copyright{} 2001-2004 Python Software Foundation. 2 | All rights reserved. 3 | 4 | Copyright \copyright{} 2000 BeOpen.com. 5 | All rights reserved. 6 | 7 | Copyright \copyright{} 1995-2000 Corporation for National Research Initiatives. 8 | All rights reserved. 9 | 10 | Copyright \copyright{} 1991-1995 Stichting Mathematisch Centrum. 11 | All rights reserved. 12 | 13 | See the end of this document for complete license and permissions 14 | information. 15 | -------------------------------------------------------------------------------- /pydb/Makefile: -------------------------------------------------------------------------------- 1 | #============================================================= 2 | # $Id: Makefile,v 1.2 2006/02/27 01:02:47 rockyb Exp $ 3 | #============================================================= 4 | # Whatever it is you want to do, it should be handled by the 5 | # by the main (parent) Makefile. So reissue make from there. 6 | .PHONY: all 7 | 8 | all: pydb.py 9 | $(MAKE) -C .. $@ 10 | 11 | pydb.py: pydb.py.in 12 | $(MAKE) -C .. pydb/$@ 13 | 14 | %: 15 | $(MAKE) -C .. $@ 16 | 17 | -------------------------------------------------------------------------------- /site-packages-path.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | #$Id: site-packages-path.py,v 1.1 2006/01/11 04:10:32 rockyb Exp $ 3 | """Find where site-path is located. 4 | We print the first location and exit with code 0. 5 | If we don't find the path, exit with code 1. 6 | """ 7 | import sys, os.path 8 | for dir in sys.path: 9 | short_dir=os.path.basename(dir) 10 | if short_dir == 'site-packages': 11 | print dir 12 | sys.exit(0) 13 | #Not found 14 | sys.exit(1) 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /test/data/setshow-no-rl.right: -------------------------------------------------------------------------------- 1 | basename is on. 2 | Annotation level is 0. 3 | Annotation level is 1. 4 | Argument list to give program being debugged when it is started is 5 | ""abc"". 6 | Flushing output is "on". 7 | Flushing output is "off". 8 | Function tracing is on. 9 | Function tracing is off. 10 | Number of source lines pydb will list by default is 10. 11 | Number of lines to show in listing is 60. 12 | *** History is not available (no readline?). 13 | deftrace is off. 14 | deftrace is on. 15 | -------------------------------------------------------------------------------- /test/history.cmd: -------------------------------------------------------------------------------- 1 | # Test of history mechanism 2 | # $Id: history.cmd,v 1.4 2007/01/25 10:19:15 rockyb Exp $ 3 | # 4 | set basename on 5 | set trace-commands on 6 | set history size 5 7 | set history filename 8 | set history filename history.hst 9 | show history 10 | ######################################### 11 | # Test save on and off. 12 | # Test also using short abbreviated name 13 | ######################################### 14 | set his save off 15 | set hi save on 16 | list 17 | show hi 18 | quit 19 | 20 | 21 | -------------------------------------------------------------------------------- /test/data/setshow.right: -------------------------------------------------------------------------------- 1 | basename is on. 2 | Annotation level is 0. 3 | Annotation level is 1. 4 | Argument list to give program being debugged when it is started is 5 | ""abc"". 6 | Flushing output is "on". 7 | Flushing output is "off". 8 | Function tracing is on. 9 | Function tracing is off. 10 | Number of source lines pydb will list by default is 10. 11 | Number of lines to show in listing is 60. 12 | Saving of the history record on exit is off 13 | The size of the command history is 100 14 | deftrace is off. 15 | deftrace is on. 16 | -------------------------------------------------------------------------------- /Doc/perl/manual.perl: -------------------------------------------------------------------------------- 1 | # -*- perl -*- 2 | # 3 | # This implements the Python manual class. All it really needs to do it 4 | # load the "python" style. The style code is not moved into the class code 5 | # at this time, since we expect additional document class to be developed 6 | # for the Python documentation in the future. Appropriate relocations will 7 | # be made at that time. 8 | 9 | package main; 10 | 11 | do_require_package("report"); 12 | do_require_package("alltt"); 13 | do_require_package("python"); 14 | 15 | 1; # sheesh.... 16 | -------------------------------------------------------------------------------- /test/data/fntrace.right: -------------------------------------------------------------------------------- 1 | --Call level 0 check_args() 2 | (gcd.py:13): check_args 3 | + 13 def check_args(): 4 | --Return from level 0 () 5 | --Call level 0 gcd(a=4, b=6) 6 | (gcd.py:24): gcd 7 | + 24 def gcd(a,b): 8 | ----Call level 1 gcd(a=2, b=4) 9 | (gcd.py:24): gcd 10 | + 24 def gcd(a,b): 11 | ------Call level 2 gcd(a=2, b=2) 12 | (gcd.py:24): gcd 13 | + 24 def gcd(a,b): 14 | ------Return from level 2 => 2 () 15 | ----Return from level 1 => 2 () 16 | --Return from level 0 => 2 () 17 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #$Id: autogen.sh,v 1.4 2008/11/16 17:10:05 rockyb Exp $ 3 | # Run this to generate all the initial makefiles, etc. 4 | 5 | srcdir=$(dirname $0) 6 | 7 | aclocal 8 | automake --add-missing --gnu 9 | autoconf 10 | 11 | conf_flags="--enable-maintainer-mode" # --enable-compile-warnings #--enable-iso-c 12 | 13 | if test x$NOCONFIGURE = x; then 14 | echo Running $srcdir/configure $conf_flags "$@" ... 15 | $srcdir/configure $conf_flags "$@" \ 16 | && echo Now type \`make\' to compile $PKG_NAME 17 | else 18 | echo Skipping configure process. 19 | fi 20 | -------------------------------------------------------------------------------- /test/data/skip.right: -------------------------------------------------------------------------------- 1 | +set deftrace off 2 | +set linetrace on 3 | +set listsize 1 4 | +skip 5 | (gcd.py:11): 6 | 11 import sys 7 | +list 8 | 11 -> import sys 9 | +p sys 10 | 11 | +skip foo 12 | *** skip command: Expecting a positive integer, got: foo 13 | +skip 2 14 | (gcd.py:24): 15 | 24 def gcd(a,b): 16 | +c 38 17 | Breakpoint 1 set in file gcd.py, line 38. 18 | +skip 19 | (gcd.py:38): 20 | 38 check_args() 21 | +list 22 | 38 B-> check_args() 23 | +quit 24 | (gcd.py:38): 25 | + 38 check_args() 26 | -------------------------------------------------------------------------------- /test/setshow.cmd: -------------------------------------------------------------------------------- 1 | # Test of set/show commands 2 | # $Id 3 | # 4 | set basename on 5 | show basename 6 | set annotate 0 7 | show annotate 8 | set annotate 1 9 | show annotate 10 | set args "abc" 11 | show args 12 | set flush on 13 | show flush 14 | set flush off 15 | show flush 16 | set fntrace on 17 | show fntrace 18 | set fntrace off 19 | show fntrace 20 | set listsize 10 21 | show listsize 22 | set width 60 23 | show width 24 | show history save 25 | set history size 100 26 | show history size 27 | set deftrace off 28 | show deftrace 29 | set deftrace on 30 | show deftrace 31 | quit 32 | -------------------------------------------------------------------------------- /test/save.cmd: -------------------------------------------------------------------------------- 1 | # $Id: save.cmd,v 1.3 2008/07/03 09:23:07 rockyb Exp $ 2 | # Test of running "save" command 3 | # 4 | set basename on 5 | set autoeval on 6 | set trace-commands on 7 | save foo bar 8 | save foo bar baz 9 | save break ./savefile.txt 10 | p len(open('./savefile.txt').readlines()) 11 | source ./savefile.txt 12 | break 17 13 | save break ./savefile.txt 14 | source ./savefile.txt 15 | p open('./savefile.txt').readlines() 16 | save settings ./savefile.txt 17 | source -v ./savefile.txt 18 | p len(open('./savefile.txt').readlines()) 19 | save all ./savefile.txt 20 | source ./savefile.txt 21 | quit 22 | 23 | -------------------------------------------------------------------------------- /test/thread/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Run a bunch of threading programs with line tracing 3 | to make sure we don't hang tracing them.""" 4 | import os 5 | #prof2.py should work but takes a long time to run. 6 | #tests=['t2.py', 'thread1.py', 'q.py', 'prof2.py'] 7 | tests=['t2.py', 'thread1.py', 'q.py'] 8 | print "=" * 60 9 | cmd='../../pydb/pydb.py --threading --command=thread-switch.cmd q.py' 10 | os.system(cmd) 11 | for test in tests: 12 | print "=" * 60 13 | print test 14 | print "=" * 60 15 | cmd='python ../../pydb/pydb.py --threading --trace %s' % test 16 | os.system(cmd) 17 | -------------------------------------------------------------------------------- /Doc/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | Python Library Reference Manual redirect 8 | 9 | 10 |
11 | If your browser doesn't automatically redirect to 12 | its new location, click 13 | 14 | here (http://docs.python.org/lib/lib.html). 15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /test/thread/t2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """ This is a script that is being used to debug whilst trying to get 3 | the thread debugging features working. 4 | """ 5 | 6 | import threading 7 | 8 | def foo(): 9 | for n in range(2): 10 | print n 11 | print "I am thread %s loop count %d" % \ 12 | (threading.currentThread().getName(), n) 13 | 14 | class MyThread(threading.Thread): 15 | def run(self): 16 | foo() 17 | 18 | def func(): 19 | for i in range(2): 20 | t = MyThread() 21 | t.start() 22 | t.join() 23 | 24 | if __name__ == '__main__': 25 | func() 26 | 27 | -------------------------------------------------------------------------------- /Doc/texinputs/pypaper.sty: -------------------------------------------------------------------------------- 1 | % 2 | % Change this to say a4paper instead of letterpaper if you want A4. These 3 | % are the latex defaults. 4 | % 5 | \newcommand{\py@paper}{letterpaper} 6 | \newcommand{\py@ptsize}{10pt} 7 | 8 | % These set up the fonts for the documents. 9 | % 10 | % The "times" package makes the default font the PostScript Times 11 | % font, which makes for smaller PostScript and a font that more people 12 | % like. 13 | % 14 | % The "avant" package causes the AvantGarde font to be used for 15 | % sans-serif text, instead of the uglier Helvetica set up by the "times" 16 | % package. 17 | % 18 | \RequirePackage{times}\typeout{Using Times instead of Computer Modern.} 19 | -------------------------------------------------------------------------------- /test/.cvsignore: -------------------------------------------------------------------------------- 1 | *.err 2 | *.out 3 | *.pyc 4 | *.pyo 5 | .pydbrc 6 | Makefile 7 | Makefile.in 8 | brkpt3.cmd 9 | brkpt3.right 10 | brkpt3t.right 11 | except.py 12 | file-2.5.right 13 | file.cmd 14 | file.right 15 | history.hst 16 | settrace.py 17 | test-complete.py 18 | test-connect.py 19 | test-contbug.py 20 | test-dbgcall.py 21 | test-disassem.py 22 | test-fifo-connect.py 23 | test-file.py 24 | test-fns.py 25 | test-help.py 26 | test-import.py 27 | test-linetrace.py 28 | test-pm.py 29 | test-run.py 30 | test-save.py 31 | test-setshow.py 32 | test-sig.py 33 | test-sighandle.py 34 | test-skip.py 35 | test-step.py 36 | test-tcp-connect.py 37 | test-trace.py 38 | test-with.py 39 | test.py 40 | trace.py 41 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | /*.out 2 | /*.pyc 3 | /*~ 4 | /Makefile 5 | /Makefile.in 6 | /brkpt3.cmd 7 | /brkpt3.right 8 | /brkpt3t.right 9 | /except.py 10 | /exceptbug.py 11 | /file-2.5.right 12 | /file.cmd 13 | /file.right 14 | /settrace.py 15 | /test-complete.py 16 | /test-connect.py 17 | /test-contbug.py 18 | /test-dbgcall.py 19 | /test-disassem.py 20 | /test-fifo-connect.py 21 | /test-file.py 22 | /test-fns.py 23 | /test-help.py 24 | /test-import.py 25 | /test-linetrace.py 26 | /test-pm.py 27 | /test-run.py 28 | /test-save.py 29 | /test-setshow.py 30 | /test-sig.py 31 | /test-sighandle.py 32 | /test-skip.py 33 | /test-step.py 34 | /test-tcp-connect.py 35 | /test-trace.py 36 | /test-with.py 37 | /test.py 38 | -------------------------------------------------------------------------------- /test/run.cmd: -------------------------------------------------------------------------------- 1 | # Test of restart and linetracing 2 | # $Id: run.cmd,v 1.6 2007/01/25 10:19:15 rockyb Exp $ 3 | # 4 | set basename on 5 | set trace-commands on 6 | info program 7 | continue 8 | ###################################### 9 | ### Now restart with a breakpoint 10 | ###################################### 11 | break hanoi 12 | show args 13 | run 14 | continue 15 | info args 16 | info program 17 | where 2 18 | ###################################### 19 | ### We should be at that breakpoint 20 | ### delete it and run again 21 | ### this time changing a parameter 22 | ###################################### 23 | info break 24 | delete 1 25 | run 1 26 | continue 27 | show args 28 | info args 29 | #### 30 | quit 31 | 32 | 33 | -------------------------------------------------------------------------------- /test/unit/pydbcmd.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | 'Unit test for pydb.pydbcmd' 3 | import os, sys, unittest 4 | 5 | top_srcdir = "@top_srcdir@" 6 | if top_srcdir[-1] != os.path.sep: 7 | top_srcdir += os.path.sep 8 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 9 | 10 | from pydbcmd import Cmd 11 | 12 | class TestCmd(Cmd): 13 | def do_a(self): return 14 | def do_b(self): return 15 | def do_a(self): return 16 | pass 17 | 18 | class TestPydbCmd(unittest.TestCase): 19 | 20 | def test_get_cmd(self): 21 | test_cmd = TestCmd() 22 | self.assertEqual(['a', 'b', 'h', 'help'], test_cmd.get_cmds()) 23 | return 24 | pass 25 | 26 | if __name__ == '__main__': 27 | unittest.main() 28 | -------------------------------------------------------------------------------- /test/exceptbug.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | from __future__ import with_statement 3 | import os, sys 4 | 5 | import threading 6 | 7 | top_builddir = "@top_builddir@" 8 | if top_builddir[-1] != os.path.sep: 9 | top_builddir += os.path.sep 10 | sys.path.insert(0, os.path.join(top_builddir, 'pydb')) 11 | top_srcdir = "@top_srcdir@" 12 | if top_srcdir[-1] != os.path.sep: 13 | top_srcdir += os.path.sep 14 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 15 | 16 | def f(): 17 | l = threading.Lock() 18 | with l: 19 | print "hello" 20 | raise Exception("error") 21 | print "world" 22 | 23 | try: 24 | f() 25 | except: 26 | import pydb 27 | # pydb.pm() 28 | pydb.pm(['set basename on','set interactive off', 'where','quit']) 29 | -------------------------------------------------------------------------------- /THANKS: -------------------------------------------------------------------------------- 1 | This debugger is an extension of the Python debugger pdb which 2 | did much of the heavy lifting. 3 | 4 | The manual also was taken from the Python debugger. But it also draws 5 | on my bashdb debugger reference and both of these at time use some of 6 | the organization and phrases from the GNU Debugger Manual (gdb). 7 | 8 | Stuart Frankel, Ph. Mad. did some amazing proof reading and editing of 9 | the manual. (I may have mucked it up some since then though.) 10 | 11 | Also thanks to: 12 | 13 | Stephen Emslie - Python Patch 1641544 14 | Matt Fleming - Gdb-style signal handling and NetBSD packaging 15 | Oleksandr Moskalenko - Debian packaging 16 | Alberto Griggio - Annotate patch #1781965 17 | 18 | $Id: THANKS,v 1.3 2007/10/30 11:37:42 rockyb Exp $ 19 | 20 | -------------------------------------------------------------------------------- /test/thread/tlock.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys, pydb 3 | import time 4 | import thread 5 | 6 | def myfunction(string,sleeptime,lock,*args): 7 | while 1: 8 | #entering critical section 9 | pydb.set_trace(add_threaddbg=True) 10 | lock.acquire() 11 | print string," Now Sleeping after Lock acquired for ",sleeptime 12 | time.sleep(sleeptime) 13 | print string," Now releasing lock and then sleeping again" 14 | lock.release() 15 | #exiting critical section 16 | time.sleep(sleeptime) # why? 17 | 18 | if __name__=="__main__": 19 | lock=thread.allocate_lock() 20 | thread.start_new_thread(myfunction,("Thread No:1",1,lock)) 21 | thread.start_new_thread(myfunction,("Thread No:2",1,lock)) 22 | 23 | while 1:pass 24 | 25 | -------------------------------------------------------------------------------- /test/data/noscript.right: -------------------------------------------------------------------------------- 1 | No stack. 2 | No stack. 3 | No stack. 4 | No frame selected. 5 | No frame selected. 6 | No stack. 7 | No stack. 8 | No stack. 9 | No breakpoints. 10 | No breakpoints. 11 | There are no auto-display expressions now. 12 | There are no auto-display expressions now. 13 | No frame selected. 14 | No frame selected. 15 | No line number information available. 16 | No line number information available. 17 | No frame selected. 18 | No frame selected. 19 | The program being debugged is not being run. 20 | The program being debugged is not being run. 21 | No current source file. 22 | No current source file. 23 | *** The program being debugged is not being run. 24 | No Python program loaded. 25 | *** No Python program registered. 26 | *** Perhaps you want to use the 'file' command? 27 | No stack. 28 | -------------------------------------------------------------------------------- /test/hanoi.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | """Towers of Hanoi""" 3 | import sys 4 | 5 | def hanoi(n,a,b,c): 6 | if n-1 > 0: 7 | hanoi(n-1, a, c, b) 8 | print "Move disk %s to %s" % (a, b) 9 | if n-1 > 0: 10 | hanoi(n-1, c, b, a) 11 | 12 | if __name__=='__main__': 13 | i_args=len(sys.argv) 14 | if i_args != 1 and i_args != 2: 15 | print "*** Need number of disks or no parameter" 16 | sys.exit(1) 17 | 18 | n=3 19 | 20 | if i_args > 1: 21 | try: 22 | n = int(sys.argv[1]) 23 | except ValueError, msg: 24 | print "** Expecting an integer, got: %s" % repr(sys.argv[1]) 25 | sys.exit(2) 26 | 27 | if n < 1 or n > 100: 28 | print "*** number of disks should be between 1 and 100" 29 | sys.exit(2) 30 | 31 | hanoi(n, "a", "b", "c") 32 | -------------------------------------------------------------------------------- /test/sigtestexample.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # $Id: sigtestexample.py,v 1.5 2006/10/08 19:56:27 rockyb Exp $ 3 | """Something to use to test signal handling. Basically we just need 4 | a program that installs a signal handler. 5 | """ 6 | import sys, os 7 | def signal_handler(num, f): 8 | f = open('log', 'w+') 9 | f.write('signal received\n') 10 | f.close() 11 | sys.exit(0) 12 | 13 | import signal 14 | signal.signal(signal.SIGUSR1, signal_handler) 15 | 16 | if len(sys.argv) > 1 and sys.argv[1] == 'signal': 17 | os.kill(os.getpid(), signal.SIGUSR1) 18 | # We need a statement after the above kill so we can see if the 19 | # debugger stop works. 20 | pass 21 | else: 22 | print "Pid %d" % os.getpid() 23 | reply = raw_input("Waiting in a read for signal USR1. " + 24 | "Type any key to terminate now.") 25 | 26 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | The Python community or whoever wrote pdb.py is largely responsible 2 | for this. 3 | 4 | Richard Wolff worked on the pydb.py that is in ddd. He 5 | also contributed a little to pdb.py. In email he relates: 6 | 7 | .. there was no attempt to make the two systems congruent. I 8 | haven't done any work on either for quite some time. I'm retired 9 | now and it's more than just unlikely that I'll ever do anything more 10 | on either. Which means that as far as ddd and pydb have anything to 11 | do with me, you're more than welcome to do whatever you like. 12 | 13 | This effort merges in changes that were in the ddd pydb.py but not in 14 | pdb.py. In particular, display expressions. 15 | 16 | The command interface is from GDB, and so much of the error messages 17 | and some parts of the documentation too. 18 | 19 | Coordination for putting this together is by Rocky Bernstein. 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /test/data/sighandler.right: -------------------------------------------------------------------------------- 1 | Signal Stop Print Stack Pass Description 2 | SIGHUP Yes Yes No No Hangup 3 | Signal Stop Print Stack Pass Description 4 | SIGHUP Yes Yes No No Hangup 5 | Signal Stop Print Stack Pass Description 6 | SIGINT Yes Yes No No Interrupt 7 | Signal Stop Print Stack Pass Description 8 | SIGINT No No Yes No Interrupt 9 | Signal Stop Print Stack Pass Description 10 | SIGINT No Yes Yes No Interrupt 11 | Signal Stop Print Stack Pass Description 12 | SIGINT No No No No Interrupt 13 | Signal Stop Print Stack Pass Description 14 | SIGKILL No No No Yes Killed 15 | Signal Stop Print Stack Pass Description 16 | SIGSTOP No No No Yes Stopped (signal) 17 | Signal Stop Print Stack Pass Description 18 | SIGINT No No No No Interrupt 19 | -------------------------------------------------------------------------------- /test/data/save.right: -------------------------------------------------------------------------------- 1 | +save foo bar 2 | *** Action has to be 'all', 'break' or 'settings; got 'foo'. 3 | +save foo bar baz 4 | *** Expecting 0-2 arguments, got 3. 5 | +save break ./savefile.txt 6 | Breakpoints saved to file ./savefile.txt 7 | +p len(open('./savefile.txt').readlines()) 8 | 1 9 | +source ./savefile.txt 10 | +break 17 11 | Breakpoint 1 set in file gcd.py, line 17. 12 | +save break ./savefile.txt 13 | Breakpoints saved to file ./savefile.txt 14 | +source ./savefile.txt 15 | +p open('./savefile.txt').readlines() 16 | ['break gcd.py:17\n'] 17 | +save settings ./savefile.txt 18 | Settings saved to file ./savefile.txt 19 | +source -v ./savefile.txt 20 | +p len(open('./savefile.txt').readlines()) 21 | +p len(open('./savefile.txt').readlines()) 22 | 12 23 | +save all ./savefile.txt 24 | +save all ./savefile.txt 25 | Settings and breakpoints saved to file ./savefile.txt 26 | +source ./savefile.txt 27 | +source ./savefile.txt 28 | +quit 29 | -------------------------------------------------------------------------------- /test/brkpt3.cmd.in: -------------------------------------------------------------------------------- 1 | # 2 | # Test of breakpoint handling 3 | # $Id: brkpt3.cmd.in,v 1.1 2007/02/13 11:42:54 rockyb Exp $ 4 | # 5 | set basename on 6 | set trace-commands on 7 | ############################################################### 8 | ### Test bad command parameters 9 | ############################################################### 10 | # Non integer argument 11 | commands a 12 | # No such breakpoint number 13 | commands 5 14 | ############################################################### 15 | ### Test valid command. Note that in order to do this 16 | ### here we need to use the "source" command so that 17 | ### input doesn't get confused. 18 | ### FIXME: somehow output isn't coming out. 19 | ### but at least we're testing part 20 | ### parsing to the "end" 21 | ############################################################### 22 | break 28 23 | cd @srcdir@ 24 | source comm1.cmd 25 | continue 26 | break 31 27 | source comm2.cmd 28 | cd @builddir@ 29 | continue 30 | quit 31 | -------------------------------------------------------------------------------- /test/data/pm.right: -------------------------------------------------------------------------------- 1 | +set interactive off 2 | +set basename on 3 | +show args 4 | Argument list to give program being debugged when it is started is 5 | "". 6 | +info args 7 | +list 8 | 29 pydir = os.path.join(top_builddir, "pydb") 9 | 30 pydb_short = "pydb.py" 10 | 31 pydb_path = os.path.join(pydir, pydb_short) 11 | 32 12 | 33 def raise_error(): 13 | 34 -> raise FloatingPointError 14 | 35 15 | 36 class PdbTests(unittest.TestCase): 16 | 37 17 | 38 ## Don't use assertTrue to be compatible with older version of 18 | +# Completion might not be available if no readline 19 | +# complete s 20 | +# complete help s 21 | +where 22 | +step 23 | *** The program being debugged is not being run. 24 | +next 25 | *** The program being debugged is not being run. 26 | +finish 27 | *** The program being debugged is not being run. 28 | +return 29 | *** The program being debugged is not being run. 30 | +quit 31 | (test-pm.py:34): raise_error 32 | 34 raise FloatingPointError 33 | -------------------------------------------------------------------------------- /test/except.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | # $Id: except.py.in,v 1.4 2007/01/25 19:04:45 rockyb Exp $ 3 | """Test to see if handles an exception when an error is raised.""" 4 | import os, sys 5 | 6 | top_builddir = "@top_builddir@" 7 | if top_builddir[-1] != os.path.sep: 8 | top_builddir += os.path.sep 9 | sys.path.insert(0, os.path.join(top_builddir, 'pydb')) 10 | top_srcdir = "@top_srcdir@" 11 | if top_srcdir[-1] != os.path.sep: 12 | top_srcdir += os.path.sep 13 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 14 | 15 | print __doc__ 16 | 17 | import pydb 18 | pydb.debugger() # we go into the debugger 19 | print "Returning from the debugger" 20 | # Set a variable so we can show the state is 21 | # somewhere after the above set_trace() 22 | z='After set_trace' 23 | try: 24 | # The below statement should not enter the debugger 25 | x=2/0 26 | except: 27 | pass 28 | # We should enter the debugger on the next statement. 29 | y=1/0 # Bullwinkle: This time, for sure! 30 | pass 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /test/data/brkpt3.right: -------------------------------------------------------------------------------- 1 | +############################################################### 2 | +### Test bad command parameters 3 | +############################################################### 4 | +# Non integer argument 5 | +commands a 6 | *** 'commands' command: Expecting a positive integer, got: a 7 | +# No such breakpoint number 8 | +commands 5 9 | *** No breakpoint numbered 5. 10 | +############################################################### 11 | +### Test valid command. Note that in order to do this 12 | +### here we need to use the "source" command so that 13 | +### input doesn't get confused. 14 | +### FIXME: somehow output isn't coming out. 15 | +### but at least we're testing part 16 | +### parsing to the "end" 17 | +############################################################### 18 | +break 28 19 | Breakpoint 1 set in file gcd.py, line 28. 20 | +cd . 21 | +source comm1.cmd 22 | +continue 23 | +break 31 24 | Breakpoint 2 set in file gcd.py, line 31. 25 | +source comm2.cmd 26 | +cd . 27 | +continue 28 | +quit 29 | -------------------------------------------------------------------------------- /test/brkpt3.right.in: -------------------------------------------------------------------------------- 1 | +############################################################### 2 | +### Test bad command parameters 3 | +############################################################### 4 | +# Non integer argument 5 | +commands a 6 | *** 'commands' command: Expecting a positive integer, got: a 7 | +# No such breakpoint number 8 | +commands 5 9 | *** No breakpoint numbered 5. 10 | +############################################################### 11 | +### Test valid command. Note that in order to do this 12 | +### here we need to use the "source" command so that 13 | +### input doesn't get confused. 14 | +### FIXME: somehow output isn't coming out. 15 | +### but at least we're testing part 16 | +### parsing to the "end" 17 | +############################################################### 18 | +break 28 19 | Breakpoint 1 set in file gcd.py, line 28. 20 | +cd @srcdir@ 21 | +source comm1.cmd 22 | +continue 23 | +break 31 24 | Breakpoint 2 set in file gcd.py, line 31. 25 | +source comm2.cmd 26 | +cd @builddir@ 27 | +continue 28 | +quit 29 | -------------------------------------------------------------------------------- /test/data/history.right: -------------------------------------------------------------------------------- 1 | +set history size 5 2 | +set history filename 3 | *** Argument required (filename to set it to). 4 | +set history filename history.hst 5 | +show history 6 | filename: The filename in which to record the command history is 7 | "history.hst". 8 | save: Saving of the history record on exit is off 9 | size: The size of the command history is 5 10 | +######################################### 11 | +# Test save on and off. 12 | +# Test also using short abbreviated name 13 | +######################################### 14 | +set his save off 15 | +set hi save on 16 | +list 17 | 1 #!/usr/bin/python 18 | 2 -> """Towers of Hanoi""" 19 | 3 import sys 20 | 4 21 | 5 def hanoi(n,a,b,c): 22 | 6 if n-1 > 0: 23 | 7 hanoi(n-1, a, c, b) 24 | 8 print "Move disk %s to %s" % (a, b) 25 | 9 if n-1 > 0: 26 | 10 hanoi(n-1, c, b, a) 27 | +show hi 28 | filename: The filename in which to record the command history is 29 | "history.hst". 30 | save: Saving of the history record on exit is on 31 | size: The size of the command history is 5 32 | +quit 33 | -------------------------------------------------------------------------------- /test/test-import.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | # $Id: test-import.py.in,v 1.2 2008/12/10 13:31:26 rockyb Exp $ -*- Python -*- 3 | "Unit test of 'import pydb'" 4 | import os, sys, unittest 5 | 6 | top_builddir = "@top_builddir@" 7 | if top_builddir[-1] != os.path.sep: 8 | top_builddir += os.path.sep 9 | top_srcdir = "@top_srcdir@" 10 | if top_srcdir[-1] != os.path.sep: 11 | top_srcdir += os.path.sep 12 | 13 | builddir = "@builddir@" 14 | if builddir[-1] != os.path.sep: 15 | builddir += os.path.sep 16 | 17 | srcdir = "@srcdir@" 18 | if srcdir[-1] != os.path.sep: 19 | srcdir += os.path.sep 20 | 21 | class PdbTests(unittest.TestCase): 22 | 23 | def test_import(self): 24 | """Test that 'import pydb' works""" 25 | cmd = ("@PYTHON@ -c 'import os, sys; " + 26 | "sys.path.insert(0, \"%s\"); " + 27 | "sys.path.insert(0, \"%s\"); " + 28 | "import pydb'" ) % (top_builddir, top_srcdir) 29 | rc = os.system(cmd) >> 8 30 | self.assertEqual(0, rc, "python import pydb") 31 | return 32 | 33 | if __name__ == "__main__": 34 | unittest.main() 35 | -------------------------------------------------------------------------------- /test/run2.cmd: -------------------------------------------------------------------------------- 1 | # Test of restart and linetracing 2 | # $Id: run2.cmd,v 1.3 2007/01/25 10:19:15 rockyb Exp $ 3 | # 4 | set basename on 5 | set trace-commands on 6 | info program 7 | continue 8 | info program 9 | ###################################### 10 | ### Program munges sys.argv 11 | ### see if we can rerun it okay 12 | ###################################### 13 | set interactive on 14 | run 3 5 15 | ###################################### 16 | ### Break of a fn name and 17 | ### Try a return where there is none 18 | ### either because not in subroutine 19 | ### or no "return" statement 20 | ###################################### 21 | set interactive off 22 | break check_args 23 | return 24 | continue 25 | return 26 | ###################################### 27 | ### rerun wrong number of parameters 28 | ### that causes and exception 29 | ### and use "info program" to check 30 | ### termination 31 | ###################################### 32 | set interactive on 33 | info program 34 | run 5 10 35 | continue 36 | break gcd 37 | continue 38 | info program 39 | set linetrace on 40 | set interactive off 41 | return 42 | where 43 | quit 44 | -------------------------------------------------------------------------------- /test/dbgcall.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | """Towers of Hanoi - testing calling debugger with continue and cmds""" 3 | import sys 4 | 5 | sys.path.insert(0, '..') 6 | import pydb 7 | 8 | pydb.debugger(dbg_cmds=['set basename on', 'set linetrace on', 'step 20']) 9 | 10 | def hanoi(n,a,b,c): 11 | if n-1 > 0: 12 | hanoi(n-1, a, c, b) 13 | print "Move disk %s to %s" % (a, b) 14 | if n-1 > 0: 15 | hanoi(n-1, c, b, a) 16 | 17 | if __name__=='__main__': 18 | i_args=len(sys.argv) 19 | if i_args != 1 and i_args != 2: 20 | print "*** Need number of disks or no parameter" 21 | sys.exit(1) 22 | 23 | n=3 24 | sys.settrace(None) 25 | if i_args > 1: 26 | try: 27 | n = int(sys.argv[1]) 28 | except ValueError, msg: 29 | print "** Expecting an integer, got: %s" % repr(sys.argv[1]) 30 | sys.exit(2) 31 | 32 | pydb.debugger(status='continue', 33 | dbg_cmds=['p "continued"', 'step 2', 'c']) 34 | if n < 1 or n > 100: 35 | print "*** number of disks should be between 1 and 100" 36 | sys.exit(2) 37 | 38 | hanoi(n, "a", "b", "c") 39 | -------------------------------------------------------------------------------- /test/data/brkpt3t.right: -------------------------------------------------------------------------------- 1 | --Call level -1 2 | +############################################################### 3 | +### Test bad command parameters 4 | +############################################################### 5 | +# Non integer argument 6 | +commands a 7 | *** 'commands' command: Expecting a positive integer, got: a 8 | +# No such breakpoint number 9 | +commands 5 10 | *** No breakpoint numbered 5. 11 | +############################################################### 12 | +### Test valid command. Note that in order to do this 13 | +### here we need to use the "source" command so that 14 | +### input doesn't get confused. 15 | +### FIXME: somehow output isn't coming out. 16 | +### but at least we're testing part 17 | +### parsing to the "end" 18 | +############################################################### 19 | +break 28 20 | Breakpoint 1 set in file gcd.py, line 28. 21 | +cd . 22 | +source comm1.cmd 23 | +continue 24 | +break 31 25 | Breakpoint 2 set in file gcd.py, line 31. 26 | +source comm2.cmd 27 | +cd . 28 | +continue 29 | +quit 30 | Requesting exit from MainThread (id -1209792848) 31 | The program exited via sys.exit(). Exit status: 32 | -------------------------------------------------------------------------------- /test/data/brkpt3-2.5t.right: -------------------------------------------------------------------------------- 1 | --Call level -1 2 | +############################################################### 3 | +### Test bad command parameters 4 | +############################################################### 5 | +# Non integer argument 6 | +commands a 7 | *** 'commands' command: Expecting a positive integer, got: a 8 | +# No such breakpoint number 9 | +commands 5 10 | *** No breakpoint numbered 5. 11 | +############################################################### 12 | +### Test valid command. Note that in order to do this 13 | +### here we need to use the "source" command so that 14 | +### input doesn't get confused. 15 | +### FIXME: somehow output isn't coming out. 16 | +### but at least we're testing part 17 | +### parsing to the "end" 18 | +############################################################### 19 | +break 28 20 | Breakpoint 1 set in file gcd.py, line 28. 21 | +cd . 22 | +source comm1.cmd 23 | +continue 24 | +break 31 25 | Breakpoint 2 set in file gcd.py, line 31. 26 | +source comm2.cmd 27 | +cd . 28 | +continue 29 | +quit 30 | Requesting exit from MainThread (id -1210472784) 31 | The program exited via sys.exit(). Exit status: 32 | -------------------------------------------------------------------------------- /test/gcd.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | """Greatest Common Divisor 3 | 4 | Some characterstics of this program used for testing check_args() does 5 | not have a 'return' statement. 6 | 7 | check_args() raises an uncaught exception when given the wrong number 8 | of parameters. 9 | 10 | """ 11 | import sys 12 | 13 | def check_args(): 14 | if len(sys.argv) != 3: 15 | # Rather than use sys.exit let's just raise an error 16 | raise Exception, "Need to give two numbers" 17 | for i in range(2): 18 | try: 19 | sys.argv[i+1] = int(sys.argv[i+1]) 20 | except ValueError: 21 | print "** Expecting an integer, got: %s" % repr(sys.argv[i]) 22 | sys.exit(2) 23 | 24 | def gcd(a,b): 25 | """ GCD. We assume positive numbers""" 26 | 27 | # Make: a <= b 28 | if a > b: 29 | (a, b) = (b, a) 30 | 31 | if a <= 0: 32 | return None 33 | if a == 1 or b-a == 0: 34 | return a 35 | return gcd(b-a, a) 36 | 37 | if __name__=='__main__': 38 | check_args() 39 | 40 | (a, b) = sys.argv[1:3] 41 | print "The GCD of %d and %d is %d" % (a, b, gcd(a, b)) 42 | 43 | -------------------------------------------------------------------------------- /test/brkpt3t.right.in: -------------------------------------------------------------------------------- 1 | --Call level -1 2 | +############################################################### 3 | +### Test bad command parameters 4 | +############################################################### 5 | +# Non integer argument 6 | +commands a 7 | *** 'commands' command: Expecting a positive integer, got: a 8 | +# No such breakpoint number 9 | +commands 5 10 | *** No breakpoint numbered 5. 11 | +############################################################### 12 | +### Test valid command. Note that in order to do this 13 | +### here we need to use the "source" command so that 14 | +### input doesn't get confused. 15 | +### FIXME: somehow output isn't coming out. 16 | +### but at least we're testing part 17 | +### parsing to the "end" 18 | +############################################################### 19 | +break 28 20 | Breakpoint 1 set in file gcd.py, line 28. 21 | +cd @srcdir@ 22 | +source comm1.cmd 23 | +continue 24 | +break 31 25 | Breakpoint 2 set in file gcd.py, line 31. 26 | +source comm2.cmd 27 | +cd @builddir@ 28 | +continue 29 | +quit 30 | Requesting exit from MainThread (id -1209792848) 31 | The program exited via sys.exit(). Exit status: 32 | -------------------------------------------------------------------------------- /test/unit/fns.py.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 'Unit test for pydb.fns' 3 | import os, sys, unittest 4 | 5 | top_builddir = "../.." 6 | if top_builddir[-1] != os.path.sep: 7 | top_builddir += os.path.sep 8 | sys.path.insert(0, os.path.join(top_builddir, 'pydb')) 9 | top_srcdir = "../.." 10 | if top_srcdir[-1] != os.path.sep: 11 | top_srcdir += os.path.sep 12 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 13 | 14 | from fns import printf, print_argspec 15 | 16 | class TestFns(unittest.TestCase): 17 | 18 | def test_fns_printf(self): 19 | self.assertEqual('037', printf(31, "/o")) 20 | self.assertEqual('00011111', printf(31, "/t")) 21 | self.assertEqual('!', printf(33, "/c")) 22 | self.assertEqual('0x21', printf(33, "/x")) 23 | return 24 | 25 | def test_fns_argspec(self): 26 | self.assertEqual('test_fns_argspec(self)', 27 | print_argspec(self.test_fns_argspec, 28 | 'test_fns_argspec')) 29 | self.assertFalse(print_argspec(None, 'invalid_fn')) 30 | return 31 | pass 32 | 33 | if __name__ == '__main__': 34 | unittest.main() 35 | -------------------------------------------------------------------------------- /test/thread/q.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | 4 | import thread 5 | import time 6 | from threading import * 7 | import Queue 8 | 9 | class Producer(Thread): 10 | 11 | def __init__(self,itemq): 12 | Thread.__init__(self) 13 | self.itemq=itemq 14 | 15 | def run(self): 16 | 17 | itemq=self.itemq 18 | i=0 19 | for j in range(10): 20 | 21 | print currentThread(),"Produced One Item:",i 22 | itemq.put(i,1) 23 | i+=1 24 | time.sleep(1) 25 | 26 | 27 | class Consumer(Thread): 28 | 29 | def __init__(self,itemq): 30 | Thread.__init__(self) 31 | self.itemq=itemq 32 | 33 | def run(self): 34 | itemq=self.itemq 35 | 36 | for j in range(4): 37 | time.sleep(2) 38 | it=itemq.get(1) 39 | print currentThread(),"Consumed One Item:",it 40 | 41 | if __name__=="__main__": 42 | 43 | q=Queue.Queue(10) 44 | 45 | pro=Producer(q) 46 | cons1=Consumer(q) 47 | cons2=Consumer(q) 48 | 49 | pro.start() 50 | cons1.start() 51 | cons2.start() 52 | pro.join() 53 | cons1.join() 54 | cons2.join() 55 | -------------------------------------------------------------------------------- /test/unit/bytecode.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | 'Unit test for pydb.bytecode' 3 | import inspect, os, sys, unittest 4 | 5 | top_srcdir = "@top_srcdir@" 6 | if top_srcdir[-1] != os.path.sep: 7 | top_srcdir += os.path.sep 8 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 9 | 10 | from bytecode import op_at_frame, stmt_contains_make_function, is_def_stmt 11 | 12 | class TestByteCode(unittest.TestCase): 13 | 14 | def test_contains_make_function(self): 15 | def sqr(x): 16 | return x * x 17 | frame = inspect.currentframe() 18 | co = frame.f_code 19 | lineno = frame.f_lineno 20 | self.assertTrue(stmt_contains_make_function(co, lineno-4)) 21 | self.assertFalse(stmt_contains_make_function(co, lineno)) 22 | return 23 | 24 | def test_op_at_frame(self): 25 | frame = inspect.currentframe() 26 | self.assertEqual('CALL_FUNCTION', op_at_frame(frame)) 27 | return 28 | 29 | def test_is_def_frame(self): 30 | # Not a "def" statement because frame is wrong spot 31 | frame = inspect.currentframe() 32 | self.assertFalse(is_def_stmt('foo(): pass', frame)) 33 | return 34 | 35 | if __name__ == '__main__': 36 | unittest.main() 37 | -------------------------------------------------------------------------------- /Doc/info/Makefile: -------------------------------------------------------------------------------- 1 | # Generate the Python "info" documentation. 2 | 3 | TOPDIR=.. 4 | TOOLSDIR=$(TOPDIR)/tools 5 | HTMLDIR=$(TOPDIR)/html 6 | 7 | # The emacs binary used to build the info docs. GNU Emacs 21 is required. 8 | EMACS=emacs 9 | 10 | MKINFO=$(TOOLSDIR)/mkinfo 11 | SCRIPTS=$(TOOLSDIR)/checkargs.pm $(TOOLSDIR)/mkinfo $(TOOLSDIR)/py2texi.el 12 | 13 | # set VERSION to code the VERSION number into the info file name 14 | # allowing installation of more than one set of python info docs 15 | # into the same directory 16 | VERSION= 17 | 18 | all: check-emacs-version \ 19 | lib 20 | # doc inst 21 | 22 | lib: python$(VERSION)-lib.info 23 | 24 | whatsnew: $(WHATSNEW) 25 | $(WHATSNEW): python$(VERSION)-$(WHATSNEW).info 26 | 27 | check-emacs-version: 28 | @v="`$(EMACS) --version 2>&1 | egrep '^(GNU |X)Emacs [12]*'`"; \ 29 | if `echo "$$v" | egrep '^GNU Emacs 2[1-3]' >/dev/null 2>&1`; then \ 30 | echo "Using $(EMACS) to build the info docs"; \ 31 | else \ 32 | echo "GNU Emacs 21 or greater is required to build the info docs"; \ 33 | echo "Found $$v"; \ 34 | false; \ 35 | fi 36 | 37 | python$(VERSION)-lib.info: ../lib/lib.tex $(SCRIPTS) 38 | EMACS=$(EMACS) $(MKINFO) $< $*.texi $@ 39 | 40 | clean: 41 | rm -f *.texi~ *.texi 42 | 43 | clobber: clean 44 | rm -f *.texi python*-*.info python*-*.info-[0-9]* 45 | -------------------------------------------------------------------------------- /test/data/Makefile.am: -------------------------------------------------------------------------------- 1 | check_DATA = \ 2 | brkpt1.right \ 3 | brkpt1t.right \ 4 | brkpt2-2.3.right \ 5 | brkpt2.right \ 6 | brkpt3t.right \ 7 | brkpt3-2.5t.right \ 8 | brkpt3.right \ 9 | checkline.py \ 10 | cmdparse.right \ 11 | contbug-2.5.right \ 12 | contbug.right \ 13 | dbgcall.right \ 14 | dbgcall-2.5.right \ 15 | file.right \ 16 | file-2.5.right \ 17 | filebug.right \ 18 | fntrace.right \ 19 | help.right \ 20 | history.right \ 21 | logging.right \ 22 | noscript.right \ 23 | pm.right \ 24 | pydbrc.right \ 25 | run.right \ 26 | run2.right \ 27 | save.right \ 28 | setshow.right \ 29 | setshow-no-rl.right \ 30 | sighandler.right \ 31 | skip.right \ 32 | step.right \ 33 | trace-2.4-final.right \ 34 | trace-2.5.right \ 35 | trace.right \ 36 | tracetest-2.4-final.right \ 37 | tracetest-2.5.right \ 38 | tracetest.right \ 39 | withbug.right \ 40 | withbug-2.6.right 41 | 42 | EXTRA_DIST = $(check_DATA) 43 | -------------------------------------------------------------------------------- /test/settrace.py.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | """Towers of Hanoi""" 3 | import sys, os 4 | 5 | top_builddir = "@top_builddir@" 6 | if top_builddir[-1] != os.path.sep: 7 | top_builddir += os.path.sep 8 | sys.path.insert(0, os.path.join(top_builddir, 'pydb')) 9 | top_srcdir = "@top_srcdir@" 10 | if top_srcdir[-1] != os.path.sep: 11 | top_srcdir += os.path.sep 12 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 13 | 14 | def hanoi(n,a,b,c): 15 | if n-1 > 0: 16 | hanoi(n-1, a, c, b) 17 | print "Move disk %s to %s" % (a, b) 18 | if n-1 > 0: 19 | hanoi(n-1, c, b, a) 20 | 21 | i_args=len(sys.argv) 22 | if i_args > 3: 23 | print "usage %s [disks [cmdfile]]" % sys.argv[0] 24 | sys.exit(1) 25 | 26 | n=3 27 | if i_args > 1: 28 | try: 29 | n = int(sys.argv[1]) 30 | except ValueError, msg: 31 | print "** Expecting an integer, got: %s" % repr(sys.argv[1]) 32 | sys.exit(2) 33 | 34 | if n < 1 or n > 100: 35 | print "*** number of disks should be between 1 and 100" 36 | sys.exit(2) 37 | 38 | dbg_cmds=['set basename on', 39 | 'where', 40 | 'list', 41 | 'step', 42 | 'step', 43 | 'where', 44 | 'info locals', 45 | 'set linetrace on', 46 | 'continue'] 47 | 48 | import pydb 49 | pydb.debugger(dbg_cmds) 50 | 51 | hanoi(n, "a", "b", "c") 52 | -------------------------------------------------------------------------------- /Doc/Makefile.deps: -------------------------------------------------------------------------------- 1 | # -*- Makefile -*- 2 | # LaTeX source dependencies. 3 | 4 | COMMONSTYLES= $(PYTHON_DOC)/texinputs/python.sty \ 5 | $(PYTHON_DOC)/texinputs/pypaper.sty 6 | 7 | INDEXSTYLES=$(PYTHON_DOC)/texinputs/python.ist 8 | 9 | COMMONTEX=$(PTYHON_DOC)/commontex/copyright.tex \ 10 | $(PTYHON_DOC)/commontex/license.tex \ 11 | $(PTYHON_DOC)/commontex/patchlevel.tex \ 12 | $(PTYHON_DOC)/commontex/boilerplate.tex 13 | 14 | MANSTYLES= $(PYTHON_DOC)/texinputs/fncychap.sty \ 15 | $(PYTHON_DOC)/texinputs/manual.cls \ 16 | $(COMMONSTYLES) 17 | 18 | HOWTOSTYLES= 19 | APIFILES= 20 | 21 | # These files are generated from those listed above, and are used to 22 | # generate the typeset versions of the manuals. The list is defined 23 | # here to make it easier to ensure parallelism. 24 | ANNOAPIFILES= $(MANSTYLES) $(INDEXSTYLES) $(COMMONTEX) \ 25 | $(PTYHON_DOC)/commontex/reportingbugs.tex 26 | 27 | DOCFILES= $(HOWTOSTYLES) \ 28 | $(PTYHON_DOC)/commontex/boilerplate.tex \ 29 | $(PYTHON_DOC)/texinputs/ltxmarkup.sty \ 30 | doc/doc.tex 31 | 32 | EXTFILES= 33 | 34 | TUTFILES= 35 | 36 | # LaTeX source files for the Python Reference Manual 37 | REFFILES= 38 | 39 | # LaTeX source files for the Python Library Reference 40 | LIBFILES= lib/libpydb.tex 41 | 42 | 43 | # LaTeX source files for Macintosh Library Modules. 44 | MACFILES= 45 | 46 | INSTFILES = 47 | 48 | DISTFILES = 49 | -------------------------------------------------------------------------------- /test/data/run.right: -------------------------------------------------------------------------------- 1 | +info program 2 | Program stopped. 3 | It stopped after stepping, next'ing or initial start. 4 | +continue 5 | The program finished and will be restarted 6 | +###################################### 7 | +### Now restart with a breakpoint 8 | +###################################### 9 | +break hanoi 10 | Breakpoint 1 set in file hanoi.py, line 5. 11 | +show args 12 | Argument list to give program being debugged when it is started is 13 | "". 14 | +run 15 | Restarting hanoi.py with arguments: 16 | 17 | +continue 18 | +info args 19 | n= 3 20 | a= a 21 | b= b 22 | c= c 23 | +info program 24 | Program stopped. 25 | It stopped at breakpoint 1. 26 | +where 2 27 | -> 0 hanoi(n=3, a='a', b='b', c='c') called from file 'hanoi.py' at line 6 28 | ## 1 in file 'hanoi.py' at line 31 29 | +###################################### 30 | +### We should be at that breakpoint 31 | +### delete it and run again 32 | +### this time changing a parameter 33 | +###################################### 34 | +info break 35 | Num Type Disp Enb Where 36 | 1 breakpoint keep y at hanoi.py:5 37 | breakpoint already hit 2 times 38 | +delete 1 39 | Deleted breakpoint 1 40 | +run 1 41 | Restarting hanoi.py with arguments: 42 | 1 43 | +continue 44 | The program finished and will be restarted 45 | +show args 46 | Argument list to give program being debugged when it is started is 47 | "1". 48 | +info args 49 | +#### 50 | +quit 51 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | Note invalid combinations "stop pass", "noprint stack" is buggy. 2 | break line thread-name buggy 3 | investigate quit exception passing through in ipython. 4 | Add to ddd recent features, e.g. assembly, threads, display expressions 5 | 6 | Write Bdb documentation. 7 | 8 | Remote debugging 9 | add for threading: 10 | step [count] Thread-name 11 | next [count] Thread-name 12 | 13 | Mock objects for thread id's/names. Then more tests on thread code. 14 | 15 | reinstate "thread" command? 16 | 17 | Add watchpoints. (Mentioned in pdbimprovements) 18 | 19 | The main pydb.py file size has been reduced but it is still bit 20 | large. If we can break out into more files that might be nice. 21 | 22 | Some more regression tests should to be written. They've been 23 | invaluable so far and maintain quality. Especially for the large 24 | changes. 25 | 26 | Redo post_mortem, pm, set_step to funnel through parse_options rather 27 | than taking the optional cmdfile and opts parameters. 28 | 29 | gdb return command relies on the existence of a return statement in 30 | the code. 31 | 32 | Add online debugger concept help and in LaTeX? 33 | 34 | Add in patches of various Bdb's such as the one in Eric. 35 | 36 | Better history completion. Better history completion interaction inside 37 | ipython and with or without Emacs. 38 | 39 | Eric or Idle integration. 40 | 41 | Use inspect module get_stack rather than bdb's? 42 | 43 | $Id: TODO,v 1.21 2007/01/13 12:14:29 rockyb Exp $ 44 | -------------------------------------------------------------------------------- /Doc/tools/patchlevel.h: -------------------------------------------------------------------------------- 1 | 2 | /* Newfangled version identification scheme. 3 | 4 | This scheme was added in Python 1.5.2b2; before that time, only PATCHLEVEL 5 | was available. To test for presence of the scheme, test for 6 | defined(PY_MAJOR_VERSION). 7 | 8 | When the major or minor version changes, the VERSION variable in 9 | configure.in must also be changed. 10 | 11 | There is also (independent) API version information in modsupport.h. 12 | */ 13 | 14 | /* Values for PY_RELEASE_LEVEL */ 15 | #define PY_RELEASE_LEVEL_ALPHA 0xA 16 | #define PY_RELEASE_LEVEL_BETA 0xB 17 | #define PY_RELEASE_LEVEL_GAMMA 0xC /* For release candidates */ 18 | #define PY_RELEASE_LEVEL_FINAL 0xF /* Serial should be 0 here */ 19 | /* Higher for patch releases */ 20 | 21 | /* Version parsed out into numeric values */ 22 | #define PY_MAJOR_VERSION 2 23 | #define PY_MINOR_VERSION 5 24 | #define PY_MICRO_VERSION 0 25 | #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA 26 | #define PY_RELEASE_SERIAL 0 27 | 28 | /* Version as a string */ 29 | #define PY_VERSION "pydb" 30 | 31 | /* Subversion Revision number of this file (not of the repository) */ 32 | #define PY_PATCHLEVEL_REVISION "$Revision: 1.3 $" 33 | 34 | /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. 35 | Use this for numeric comparisons, e.g. #if PY_VERSION_HEX >= ... */ 36 | #define PY_VERSION_HEX ((PY_MAJOR_VERSION << 24) | \ 37 | (PY_MINOR_VERSION << 16) | \ 38 | (PY_MICRO_VERSION << 8) | \ 39 | (PY_RELEASE_LEVEL << 4) | \ 40 | (PY_RELEASE_SERIAL << 0)) 41 | -------------------------------------------------------------------------------- /test/data/help.right: -------------------------------------------------------------------------------- 1 | usage: pydb.py [debugger-options] [python-script [script-options...]] 2 | 3 | Runs the extended python debugger 4 | 5 | options: 6 | --version show program's version number and exit 7 | -h, --help show this help message and exit 8 | -X, --trace Show lines before executing them. This option also 9 | sets --batch 10 | -F, --fntrace Show functions before executing them. This option also 11 | sets --batch 12 | --batch Don't run interactive commands shell on stops. 13 | --basename Filenames strip off basename, (e.g. for regression 14 | tests) 15 | -x FILE, --command=FILE 16 | Execute commands from FILE. 17 | --cd=DIR Change current directory to DIR. 18 | --error=FILE Write debugger's error output (stderr) to FILE 19 | -e EXECUTE, --exec=EXECUTE 20 | list of debugger commands to execute. Separate the 21 | commands with ;; 22 | -n, --nx Don't execute commands found in any initialization 23 | files 24 | -o FILE, --output=FILE 25 | Write debugger's output (stdout) to FILE 26 | --sigcheck Set to watch for signal handler changes 27 | -t TARGET, --target=TARGET 28 | Specify a target to connect to. Arguments should be of 29 | form, 'protocol address'. 30 | -T, --threading Start off with threading debug support 31 | --annotate=ANNOTATE Use annotations (to work inside emacs) 32 | -------------------------------------------------------------------------------- /Doc/lib/lib-ds.tex: -------------------------------------------------------------------------------- 1 | \documentclass{manual} 2 | 3 | % NOTE: this file controls which chapters/sections of the library 4 | % manual are actually printed. It is easy to customize your manual 5 | % by commenting out sections that you're not interested in. 6 | 7 | \title{Python Library Reference for the Extended Python Debugger} 8 | 9 | \input{boilerplate} 10 | 11 | \makeindex % tell \index to actually write the 12 | % .idx file 13 | \makemodindex % ... and the module index as well. 14 | 15 | 16 | \begin{document} 17 | 18 | \maketitle 19 | 20 | \ifhtml 21 | \chapter*{Front Matter\label{front}} 22 | \fi 23 | 24 | \input{copyright} 25 | 26 | \begin{abstract} 27 | 28 | \noindent 29 | Python is an extensible, interpreted, object-oriented programming 30 | language. It supports a wide range of applications, from simple text 31 | processing scripts to interactive Web browsers. 32 | 33 | We describe here only the Extended Python Debugger. The rest of the The 34 | \ulink{\module{Python Reference Manual}} 35 | {http://docs.python.org/lib/lib.html} should be consulted for other 36 | standard Python modules including the original \ulink{\module{Python 37 | Debugger}}{http://docs.python.org/lib/module-pdb.html} (\tt{pdb.py}). 38 | 39 | \end{abstract} 40 | 41 | \tableofcontents 42 | 43 | % Chapter title: 44 | 45 | % ============= 46 | % DEVELOPMENT TOOLS 47 | % ============= 48 | % % Software development support 49 | 50 | \renewcommand{\baselinestretch}{3.0}\normalsize 51 | \input{libpydb} % The Python Debugger 52 | 53 | 54 | \end{document} 55 | -------------------------------------------------------------------------------- /Doc/lib/lib.tex: -------------------------------------------------------------------------------- 1 | \documentclass{manual} 2 | 3 | % NOTE: this file controls which chapters/sections of the library 4 | % manual are actually printed. It is easy to customize your manual 5 | % by commenting out sections that you're not interested in. 6 | 7 | \title{Python Library Reference for the Extended Python Debugger} 8 | 9 | \input{boilerplate} 10 | 11 | \makeindex % tell \index to actually write the 12 | % .idx file 13 | \makemodindex % ... and the module index as well. 14 | 15 | 16 | \begin{document} 17 | 18 | \maketitle 19 | 20 | \ifhtml 21 | \chapter*{Front Matter\label{front}} 22 | \fi 23 | 24 | \input{copyright} 25 | 26 | \begin{abstract} 27 | 28 | \noindent 29 | Python is an extensible, interpreted, object-oriented programming 30 | language. It supports a wide range of applications, from simple text 31 | processing scripts to interactive Web browsers. 32 | 33 | We describe here only the Extended Python Debugger. The rest of the The 34 | \ulink{\module{Python Reference Manual}} 35 | {http://docs.python.org/lib/lib.html} should be consulted for other 36 | standard Python modules including the original \ulink{\module{Python 37 | Debugger}}{http://docs.python.org/lib/module-pdb.html} (\tt{pdb.py}). 38 | 39 | \end{abstract} 40 | 41 | \tableofcontents 42 | 43 | % Chapter title: 44 | 45 | % ============= 46 | % DEVELOPMENT TOOLS 47 | % ============= 48 | % % Software development support 49 | 50 | \input{libpydb} % The Python Debugger 51 | 52 | %begin{latexonly} 53 | \renewcommand{\indexname}{Index} 54 | %end{latexonly} 55 | \input{lib.ind} % Index 56 | 57 | \end{document} 58 | -------------------------------------------------------------------------------- /test/thread/prof2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | #Let us profile code which uses threads 4 | import thread 5 | import time 6 | from threading import Thread 7 | 8 | class MyThread(Thread): 9 | 10 | def __init__(self,bignum): 11 | 12 | Thread.__init__(self) 13 | self.bignum=bignum 14 | 15 | def run(self): 16 | 17 | for l in range(5): 18 | for k in range(self.bignum): 19 | res=0 20 | for i in range(self.bignum): 21 | res+=1 22 | 23 | 24 | def myadd_nothread(bignum): 25 | 26 | for l in range(5): 27 | for k in range(bignum): 28 | res=0 29 | for i in range(bignum): 30 | res+=1 31 | 32 | for l in range(5): 33 | for k in range(bignum): 34 | res=0 35 | for i in range(bignum): 36 | res+=1 37 | 38 | def thread_test(bignum): 39 | #We create 2 Thread objects for the 2 threads. 40 | thr1=MyThread(bignum) 41 | thr2=MyThread(bignum) 42 | 43 | thr1.start() 44 | thr2.start() 45 | 46 | thr1.join() 47 | thr2.join() 48 | 49 | 50 | def test(): 51 | 52 | bignum=20 53 | 54 | #Let us test the threading part 55 | 56 | import sys 57 | sys.setcheckinterval(1000) 58 | 59 | 60 | starttime=time.time() 61 | thread_test(bignum) 62 | stoptime=time.time() 63 | 64 | print "Running 2 threads took %.3f seconds" % (stoptime-starttime) 65 | 66 | #Now run without Threads. 67 | starttime=time.time() 68 | myadd_nothread(bignum) 69 | stoptime=time.time() 70 | 71 | print "Running Without Threads took %.3f seconds" % (stoptime-starttime) 72 | 73 | 74 | if __name__=="__main__": 75 | 76 | test() 77 | -------------------------------------------------------------------------------- /test/brkpt2.cmd: -------------------------------------------------------------------------------- 1 | # 2 | # Test of breakpoint handling 3 | # $Id: brkpt2.cmd,v 1.10 2008/11/24 21:24:28 rockyb Exp $ 4 | # 5 | set basename on 6 | set trace-commands on 7 | ############################################################### 8 | ### Clear nonexist break; 9 | ############################################################### 10 | clear 11 | ############################################################### 12 | ### Multiple breakpoints on a line and clearing all 13 | ############################################################### 14 | break 28 15 | break gcd.py:28 16 | info break 17 | clear 28 18 | ############################################################### 19 | ### Clear by current line number 20 | ############################################################### 21 | break 28 22 | continue 23 | clear 24 | info break 25 | ############################################################### 26 | ### Test Delete: invalid/valid number. 27 | ############################################################### 28 | delete 1 29 | break 11 30 | info break 31 | delete 4 32 | tbreak 31 33 | continue 34 | info break 35 | ############################################################### 36 | ### Test Continue with a line number 37 | ############################################################### 38 | c 35 39 | info break 40 | where 2 41 | ############################################################### 42 | ### Test frame command 43 | ############################################################### 44 | frame 45 | frame abs(-1*2) 46 | frame -3 47 | frame -2 48 | frame 0 49 | ############################################################### 50 | ### Test ignore 51 | ############################################################### 52 | ignore 0 1 53 | ignore 4 -1 54 | ## FIXME: need a real ignore test, not just invalid cases 55 | quit 56 | -------------------------------------------------------------------------------- /test/unit/checkline.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | # -*- Python -*- 3 | # $Id: checkline.py.in,v 1.2 2008/12/21 10:54:23 rockyb Exp $ 4 | "Unit test for checkline" 5 | import inspect, os, sys, unittest 6 | 7 | top_builddir = "@top_builddir@" 8 | if top_builddir[-1] != os.path.sep: 9 | top_builddir += os.path.sep 10 | sys.path.insert(0, os.path.join(top_builddir, 'pydb')) 11 | top_srcdir = "@top_srcdir@" 12 | if top_srcdir[-1] != os.path.sep: 13 | top_srcdir += os.path.sep 14 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 15 | 16 | import fns 17 | 18 | class CheckLine(unittest.TestCase): 19 | def errmsg(self, msg): 20 | self.errors.append(msg) 21 | return 22 | 23 | def test_basic(self): 24 | global top_srcdir 25 | self.curframe = inspect.currentframe() 26 | check_script = os.path.join(top_srcdir, 'test', 'data', 27 | 'checkline.py') 28 | for t in ( ( 1, True), 29 | ( 2, False), 30 | ( 3, False), # FIXME add 4 31 | ( 5, False), 32 | ( 6, True), 33 | ( 7, False), 34 | ( 8, False), 35 | ( 9, True), 36 | (10, False), 37 | ): 38 | self.errors=[] 39 | result = fns.checkline(self, check_script, t[0]) 40 | if t[1]: 41 | self.assertEqual(t[0], result, "Should have worked") 42 | self.assertEqual(0, len(self.errors), "With no errors") 43 | else: 44 | self.assertNotEqual(t[0], result, "Should not have worked") 45 | self.assertEqual(1, len(self.errors), "and given an error") 46 | return 47 | 48 | if __name__ == '__main__': 49 | unittest.main() 50 | -------------------------------------------------------------------------------- /pydb/server.py: -------------------------------------------------------------------------------- 1 | """$Id: server.py,v 1.2 2008/05/29 02:53:01 rockyb Exp $ 2 | Debugger Server code 3 | """ 4 | from gdb import Gdb 5 | import sys 6 | import connection 7 | 8 | old_handler = None 9 | server_addr = None 10 | 11 | def setup_server(sig=None, protocol=None, addr=None): 12 | """Gather the parameters to set up a debugging server. 13 | This routine should be imported and called near the top of the 14 | program file. 15 | 16 | When signal "sig" is received, which by default is SIGUSR1, 17 | invoke_server() is called and passed the parameters used to setup 18 | this server. 19 | 20 | Protocol "protocol" is used for communication. 21 | 22 | If "addr" is specified clients can connect to this server 23 | at that address. 24 | """ 25 | import signal 26 | if not sig: 27 | sig = signal.SIGUSR1 28 | 29 | global old_handler 30 | old_handler = signal.signal(sig, invoke_server) 31 | 32 | if protocol != None: 33 | proto = protocol 34 | else: 35 | proto = 'connection.ConnectionFIFO' 36 | 37 | global server_addr 38 | if addr != None: 39 | server_addr = proto + " " + addr 40 | else: 41 | tmp = gettmpdir() + os.path.pathsep + str(os.getpid()) + "pydb" 42 | server_addr = proto + " " + tmp 43 | 44 | def invoke_server(signum, frame): 45 | """This function sets up a signal handler, which when it 46 | traps a signal, starts a debugging server suitable for other 47 | debugging clients to connect to. 48 | """ 49 | p = Gdb() 50 | p._sys_argv = list(sys.argv) 51 | 52 | from remote import RemoteWrapperServer 53 | p = RemoteWrapperServer(p) 54 | p.do_pydbserver(server_addr) 55 | 56 | p.set_trace(frame) 57 | 58 | import signal 59 | signal.signal(signum, old_handler) 60 | -------------------------------------------------------------------------------- /Doc/tools/mkinfo: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # -*- Ksh -*- 3 | 4 | # Script to drive the HTML-info conversion process. 5 | # Pass in upto three parameters: 6 | # - the name of the main tex file 7 | # - the name of the output file in texi format (optional) 8 | # - the name of the output file in info format (optional) 9 | # 10 | # Written by Fred L. Drake, Jr. 11 | 12 | EMACS=${EMACS:-emacs} 13 | MAKEINFO=${MAKEINFO:-makeinfo} 14 | 15 | 16 | # Normalize file name since something called by html2texi.pl seems to 17 | # screw up with relative path names. 18 | FILENAME="$1" 19 | DOCDIR=`dirname "$FILENAME"` 20 | DOCFILE=`basename "$FILENAME"` 21 | DOCNAME=`basename "$FILENAME" .tex` 22 | if [ $# -gt 1 ]; then 23 | TEXINAME="$2" 24 | else 25 | TEXINAME="python-$DOCNAME.texi" 26 | fi 27 | if [ $# -gt 2 ]; then 28 | INFONAME="$3" 29 | else 30 | INFONAME="python-$DOCNAME.info" 31 | fi 32 | 33 | # Now build the real directory names, and locate our support stuff: 34 | WORKDIR=`pwd` 35 | cd `dirname $0` 36 | TOOLSDIR=`pwd` 37 | cd $DOCDIR 38 | DOCDIR=`pwd` 39 | cd $WORKDIR 40 | 41 | COMMONDIR="`dirname $DOCDIR`/commontex" 42 | 43 | 44 | run() { 45 | # show what we're doing, like make does: 46 | echo "$*" 47 | "$@" || exit $? 48 | } 49 | 50 | 51 | # generate the Texinfo file: 52 | 53 | run $EMACS -batch -q --no-site-file -l $TOOLSDIR/py2texi.el \ 54 | --eval "(setq py2texi-dirs '(\"$DOCDIR\" \"$COMMONDIR\" \"../texinputs\"))" \ 55 | --eval "(setq py2texi-texi-file-name \"$TEXINAME\")" \ 56 | --eval "(setq py2texi-info-file-name \"$INFONAME\")" \ 57 | --eval "(py2texi \"$DOCDIR/$DOCFILE\")" \ 58 | -f kill-emacs 59 | echo Done 60 | 61 | 62 | # generate the .info files: 63 | 64 | run $MAKEINFO --footnote-style end --fill-column 72 \ 65 | --paragraph-indent 0 --output=$INFONAME $TEXINAME 66 | -------------------------------------------------------------------------------- /Doc/tools/getversioninfo: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | import os 4 | import re 5 | import sys 6 | 7 | try: 8 | __file__ 9 | except NameError: 10 | __file__ = sys.argv[0] 11 | 12 | tools = os.path.dirname(os.path.abspath(__file__)) 13 | Doc = os.path.dirname(tools) 14 | src = os.path.dirname(Doc) 15 | patchlevel_h = os.path.join(Doc, "tools", "patchlevel.h") 16 | 17 | # This won't pick out all #defines, but it will pick up the ones we 18 | # care about. 19 | rx = re.compile(r"\s*#define\s+([a-zA-Z][a-zA-Z_0-9]*)\s+([a-zA-Z_0-9]+)") 20 | 21 | d = {} 22 | f = open(patchlevel_h) 23 | for line in f: 24 | m = rx.match(line) 25 | if m is not None: 26 | name, value = m.group(1, 2) 27 | d[name] = value 28 | f.close() 29 | 30 | release = "%s.%s" % (d["PY_MAJOR_VERSION"], d["PY_MINOR_VERSION"]) 31 | micro = int(d["PY_MICRO_VERSION"]) 32 | shortversion = release 33 | if micro != 0: 34 | release += "." + str(micro) 35 | level = d["PY_RELEASE_LEVEL"] 36 | 37 | releaseinfo = "pydb" 38 | 39 | def write_file(name, text): 40 | """Write text to a file if the file doesn't exist or if text 41 | differs from any existing content.""" 42 | if os.path.exists(name): 43 | f = open(name, "r") 44 | s = f.read() 45 | f.close() 46 | if s == text: 47 | return 48 | f = open(name, "w") 49 | f.write(text) 50 | f.close() 51 | 52 | patchlevel_tex = os.path.join(Doc, "commontex", "patchlevel.tex") 53 | 54 | write_file(patchlevel_tex, 55 | "%% This file is generated by ../tools/getversioninfo;\n" 56 | "%% do not edit manually.\n" 57 | "\n" 58 | "\\release{%s}\n" 59 | "\\setreleaseinfo{%s}\n" 60 | "\\setshortversion{%s}\n" 61 | % (release, releaseinfo, shortversion)) 62 | 63 | print release + releaseinfo 64 | -------------------------------------------------------------------------------- /test/data/run2.right: -------------------------------------------------------------------------------- 1 | +info program 2 | Program stopped. 3 | It stopped after stepping, next'ing or initial start. 4 | +continue 5 | *** Uncaught exception. Entering post mortem debugging 6 | *** Running 'c' or 'step' will restart the program 7 | +info program 8 | The program being debugged is not being run. 9 | +###################################### 10 | +### Program munges sys.argv 11 | +### see if we can rerun it okay 12 | +###################################### 13 | +set interactive on 14 | +run 3 5 15 | Restarting gcd.py with arguments: 16 | 3 5 17 | +###################################### 18 | +### Break of a fn name and 19 | +### Try a return where there is none 20 | +### either because not in subroutine 21 | +### or no "return" statement 22 | +###################################### 23 | +set interactive off 24 | +break check_args 25 | Breakpoint 1 set in file gcd.py, line 13. 26 | +return 27 | *** I don't see that we are in a subroutine. 28 | +continue 29 | +return 30 | Sorry; a return statement was not found. 31 | +###################################### 32 | +### rerun wrong number of parameters 33 | +### that causes and exception 34 | +### and use "info program" to check 35 | +### termination 36 | +###################################### 37 | +set interactive on 38 | +info program 39 | Program stopped. 40 | It stopped at breakpoint 1. 41 | +run 5 10 42 | Restarting gcd.py with arguments: 43 | 5 10 44 | +continue 45 | +break gcd 46 | Breakpoint 2 set in file gcd.py, line 24. 47 | +continue 48 | +info program 49 | Program stopped. 50 | It stopped at breakpoint 2. 51 | +set linetrace on 52 | +set interactive off 53 | +return 54 | (gcd.py:32): gcd 55 | +where 56 | -> 0 gcd(a=5, b=10) called from file 'gcd.py' at line 32 57 | ## 1 in file 'gcd.py' at line 41 58 | ## 2 in exec cmd in globals, locals at line 1 59 | ## 3 run(self=<__main__.Pdb instance a...) called from file 'bdb.py' at line 366 60 | +quit 61 | -------------------------------------------------------------------------------- /test/brkpt1.cmd: -------------------------------------------------------------------------------- 1 | # 2 | # Test of breakpoint handling 3 | # $Id: brkpt1.cmd,v 1.7 2007/01/26 13:14:35 rockyb Exp $ 4 | # 5 | set base on 6 | set trace-commands on 7 | ############################################################### 8 | # Test the breakpoint by line number 9 | ############################################################### 10 | info break 11 | break 30 12 | info break 13 | ############################################################### 14 | ### Test enable/disable... 15 | ############################################################### 16 | enable 17 | enable 1 18 | info break 19 | enable foo 20 | disable 1 21 | disable 22 | info break 23 | ################################################################ 24 | ### Try setting breakpoints outside of the file range... 25 | ############################################################### 26 | break 0 27 | break 1 28 | break 99 29 | # 30 | # list breakpoints 31 | L 32 | ############################################################### 33 | ### *** Test using file:line format on break... 34 | ############################################################### 35 | break hanoi.py:22 36 | break ./hanoi.py:22 37 | break ./hanoi.py:0 38 | break ./dbg-test1.sh:1955 39 | info break 40 | #### Try deleting breakpoints... 41 | delete 10 42 | delete 1 43 | clear 22 44 | info break 45 | break 22 46 | ############################################################### 47 | ### *** Test breakpoints with conditions... 48 | ############################################################### 49 | condition 1 x==0 50 | ### FIXME: there is no condition 2! 51 | ### condition 2 y > 25 52 | condition 2+2 y > 25 53 | info break 54 | ### FIXME: there still is no condition 2 55 | ### condition 2 56 | condition 4 57 | info break 58 | condition x==1 59 | condition bad 60 | condition 30 y==1 61 | condition 0 y==1 62 | ############################################################### 63 | ### *** Test breakpoints by function name 64 | ############################################################### 65 | break hanoi 66 | clear hanoi 67 | q 68 | -------------------------------------------------------------------------------- /test/unit/listsize.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | "Unit test for Extended Python debugger listsize " 3 | import unittest, sys, os 4 | 5 | top_srcdir = "@top_srcdir@" 6 | if top_srcdir[-1] != os.path.sep: 7 | top_srcdir += os.path.sep 8 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 9 | 10 | import pydb 11 | 12 | class PdbTest(pydb.Pdb): 13 | def __init__(self): 14 | pydb.Pdb.__init__(self) 15 | self.errLines = [] 16 | self.msgLines = [] 17 | self.msg_last_nocr = False 18 | 19 | def errmsg(self, msg): 20 | self.errLines.append(msg) 21 | 22 | def msg(self, msg): 23 | if self.msg_last_nocr: 24 | self.msgLines[-1] += msg 25 | else: 26 | self.msgLines.append(msg) 27 | self.msg_last_nocr = False 28 | 29 | def msg_nocr(self, msg): 30 | if self.msg_last_nocr: 31 | self.msgLines[-1] += msg 32 | else: 33 | self.msgLines.append(msg) 34 | self.msg_last_nocr = True 35 | 36 | class PdbListsize(unittest.TestCase): 37 | def test_listsize(self): 38 | """Test getting list command""" 39 | pydb = PdbTest() 40 | pydb.noninteractive = True 41 | 42 | # Run show listsize 43 | pydb.msgLines=[]; pydb.errLines=[]; 44 | pydb.do_show("listsize") 45 | self.assertTrue(len(pydb.errLines)==0 and len(pydb.msgLines)!=0, 46 | "'show listsize' command") 47 | 48 | # An invalid listsize command 49 | pydb.msgLines=[]; pydb.errLines=[]; 50 | pydb.do_set("listsize foo") 51 | self.assertTrue(len(pydb.errLines)!=0 and len(pydb.msgLines)==0, 52 | "Noninteger arg in 'set listsize'") 53 | 54 | pydb.msgLines=[]; pydb.errLines=[]; 55 | pydb.do_set("listsize 20") 56 | self.assertEqual(pydb.listsize, 20) 57 | self.assertTrue(len(pydb.errLines)==0, 58 | "No error in 'set listsize'") 59 | pydb.msgLines=[]; pydb.errLines=[]; 60 | 61 | if __name__ == "__main__": 62 | unittest.main() 63 | -------------------------------------------------------------------------------- /Doc/html/stdabout.dat: -------------------------------------------------------------------------------- 1 | <-- -*- HTML -*-> 2 |

This document was generated using the 4 | LaTeX2HTML translator. 5 |

6 | 7 |

9 | LaTeX2HTML is Copyright © 10 | 1993, 1994, 1995, 1996, 1997, Nikos 12 | Drakos, Computer Based Learning Unit, University of 13 | Leeds, and Copyright © 1997, 1998, Ross 15 | Moore, Mathematics Department, Macquarie University, 16 | Sydney. 17 |

18 | 19 |

The application of 21 | LaTeX2HTML to the Python 22 | documentation has been heavily tailored by Fred L. Drake, 23 | Jr. Original navigation icons were contributed by Christopher 24 | Petrilli. 25 |

26 | 27 |
28 | 29 |

Comments and Questions

30 | 31 |

General comments and questions regarding this document should 32 | be sent by email to bashdb-pydb@lists.sourceforge.net. 34 | 35 |

If you find specific errors or have patches, requests, please 36 | report this (using the appropriate tab "Patches" or "Bugs" on Python 38 | Extended Debugger Bug Tracker at SourceForge. 40 |

41 | 42 |

43 | If you are able to provide suggested text, either to replace 44 | existing incorrect or unclear material, or additional text to 45 | supplement what's already available, we'd appreciate the 46 | contribution. There's no need to worry about text markup; our 47 | documentation team will gladly take care of that. 48 |

49 | 50 |

For any of these channels, please be sure not to send HTML email. 51 | Thanks. 52 |

53 | -------------------------------------------------------------------------------- /htdocs/download.html: -------------------------------------------------------------------------------- 1 | 2 | pydb - Extended Python Debugger - Download Links 3 | 4 | 5 | 7 | 8 |

9 |


10 | pydb - Extended Python Debugger - Download Information 11 |

12 |
13 | 14 |

Although we don't provide pre-compiled binary packages (just source 15 | code), others do; and we are most grateful for that. 16 | 17 |

18 | 19 | 20 | 21 | 24 | 25 | 26 | 27 | 28 | 29 | 32 | 33 | 34 | 35 | 36 | 37 | 40 | 41 | 42 | 43 | 44 | 45 | 48 | 49 | 50 | 51 | 52 |
source-codeSource code ready for uncompress, untar, and configure, and compile
NetBSD packageNetBSD package.
Debian packageDebian package.
SuSE Packman RMMSuSE Packman RPM.
53 |
54 | 55 | For the other operating systems supported, I know of no precompiled 56 | binaries. You will have to get the source code and build it. 57 | 58 |


59 | 60 |

61 | $Id: download.html,v 1.4 2006/10/06 09:17:24 rockyb Exp $ 62 | 63 | -------------------------------------------------------------------------------- /htdocs/jc.css: -------------------------------------------------------------------------------- 1 | /* Style settings courtesy of John Chidiac. */ 2 | body 3 | { 4 | margin: 0; 5 | color: #676767; 6 | background: white; 7 | font-family: Arial, Helvetica, sans-serif; 8 | background-color: #e2e2e2; 9 | } 10 | 11 | a:link 12 | { 13 | color: #1F00FF; 14 | } 15 | 16 | a:visited 17 | { 18 | color: #9900DD; 19 | } 20 | 21 | #container 22 | { 23 | width: 65em; 24 | padding: 4em; 25 | margin: 0 auto; 26 | background-color: #fff; 27 | } 28 | 29 | #other_projects 30 | { 31 | float: right; 32 | padding: 1em; 33 | background-color: #e2edbe; 34 | width: 14em; 35 | border-left: 2em solid #fff; 36 | } 37 | 38 | h1 39 | { 40 | padding: 48px; 41 | margin: -48px -48px 0 -48px; 42 | background-color: #c2d87e; 43 | } 44 | 45 | h1, h2, h3 46 | { 47 | color: #000; 48 | } 49 | 50 | h2 51 | { 52 | margin: 32px 0 .6em 0; 53 | padding-bottom: .2em; 54 | border-bottom: 1px solid #ddd; 55 | } 56 | 57 | ul 58 | { 59 | list-style: none; 60 | margin: 0; 61 | padding: 0; 62 | } 63 | 64 | ul a 65 | { 66 | font-size: 1.2em; 67 | width: 30em; 68 | } 69 | 70 | li 71 | { 72 | font-size: .9em; 73 | margin-bottom: 6px; 74 | } 75 | 76 | #other_projects p 77 | { 78 | margin-top: 0; 79 | } 80 | 81 | .thumb 82 | { 83 | margin-right: 10px; 84 | text-align: center; 85 | float: left; 86 | width: 150px; 87 | overflow: hidden; 88 | height: 170px; 89 | } 90 | 91 | .thumb a 92 | { 93 | text-decoration: none; 94 | } 95 | 96 | tt 97 | { 98 | font-size: 1.2em; 99 | font-weight: bold; 100 | } 101 | 102 | dt 103 | { 104 | font-weight: bold; 105 | margin-top: 1.2em; 106 | } 107 | 108 | dd 109 | { 110 | margin-top: -18px; 111 | margin-left: 9em; 112 | } 113 | 114 | h4 115 | { 116 | margin-top: -45px; 117 | margin-bottom: 64px; 118 | color: #fff; 119 | } 120 | 121 | p 122 | { 123 | line-height: 1.3; 124 | } 125 | 126 | .credit 127 | { 128 | border-top: 1px solid #e2e2e2; 129 | padding-top: 1em; 130 | margin-top: 3em; 131 | font-style: italic; 132 | font-size: .89em; 133 | } 134 | -------------------------------------------------------------------------------- /test/test-fifo-connect.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | # $Id: test-fifo-connect.py.in,v 1.1 2007/11/01 09:20:31 rockyb Exp $ -*- Python -*- 3 | 4 | # This unit test doesn't use any of the debugger code. It is meant solely 5 | # to test the connection classes. 6 | 7 | import os, sys, thread, time, unittest 8 | 9 | top_builddir = "@top_builddir@" 10 | if top_builddir[-1] != os.path.sep: 11 | top_builddir += os.path.sep 12 | sys.path.insert(0, os.path.join(top_builddir, 'pydb')) 13 | top_srcdir = "@top_srcdir@" 14 | if top_srcdir[-1] != os.path.sep: 15 | top_srcdir += os.path.sep 16 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 17 | 18 | import connection 19 | 20 | class TestFIFOConnections(unittest.TestCase): 21 | 22 | def test_client_server(self): 23 | """Test that the we can read and write between a FIFO client and 24 | server""" 25 | fname='fifotest' 26 | server = connection.ConnectionFIFO(is_server=True) 27 | client = connection.ConnectionFIFO(is_server=False) 28 | thread.start_new_thread(server.connect, (fname,)) 29 | for i in range(10): 30 | if not hasattr(server, 'outp') or server.outp is None: 31 | time.sleep(0.05) 32 | client.connect(fname) 33 | line = 'this is a test\n' 34 | client.write(line) 35 | 36 | for i in range(10): 37 | if not os.path.exists('fifotest.out'): 38 | time.sleep(0.05) 39 | else: 40 | break 41 | 42 | self.assertEqual(True, os.path.exists('fifotest.out')) 43 | for i in range(10): 44 | if not hasattr(server, 'inp') or server.inp is None: 45 | time.sleep(0.05) 46 | l2 = server.readline() 47 | self.assertEqual(l2, line, "client to server") 48 | line = 'Another test\n' 49 | server.write(line) 50 | l2 = client.readline() 51 | self.assertEqual(l2, line, "server to client") 52 | client.disconnect() 53 | server.disconnect() 54 | # And again just to see what will happen 55 | server.disconnect() 56 | 57 | if __name__ == '__main__': 58 | unittest.main() 59 | -------------------------------------------------------------------------------- /Doc/tools/node2label.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env perl 2 | 3 | # On Cygwin, we actually have to generate a temporary file when doing 4 | # the inplace edit, or we'll get permission errors. Not sure who's 5 | # bug this is, except that it isn't ours. To deal with this, we 6 | # generate backups during the edit phase and remove them at the end. 7 | # 8 | use English; 9 | $INPLACE_EDIT = '.bak'; 10 | 11 | # read the labels, then reverse the mappings 12 | require "labels.pl"; 13 | 14 | %nodes = (); 15 | my $key; 16 | # sort so that we get a consistent assignment for nodes with multiple labels 17 | foreach $label (sort keys %external_labels) { 18 | # 19 | # If the label can't be used as a filename on non-Unix platforms, 20 | # skip it. Such labels may be used internally within the documentation, 21 | # but will never be used for filename generation. 22 | # 23 | if ($label =~ /^([-.a-zA-Z0-9]+)$/) { 24 | $key = $external_labels{$label}; 25 | $key =~ s|^/||; 26 | $nodes{$key} = $label; 27 | } 28 | } 29 | 30 | # This adds the "internal" labels added for indexing. These labels will not 31 | # be used for file names. 32 | require "intlabels.pl"; 33 | foreach $label (keys %internal_labels) { 34 | $key = $internal_labels{$label}; 35 | $key =~ s|^/||; 36 | if (defined($nodes{$key})) { 37 | $nodes{$label} = $nodes{$key}; 38 | } 39 | } 40 | 41 | # collect labels that have been used 42 | %newnames = (); 43 | 44 | while (<>) { 45 | # don't want to do one s/// per line per node 46 | # so look for lines with hrefs, then do s/// on nodes present 47 | if (/(HREF|href)=[\"\']node\d+\.html[\#\"\']/) { 48 | @parts = split(/(HREF|href)\=[\"\']/); 49 | shift @parts; 50 | for $node (@parts) { 51 | $node =~ s/[\#\"\'].*$//g; 52 | chomp($node); 53 | if (defined($nodes{$node})) { 54 | $label = $nodes{$node}; 55 | if (s/(HREF|href)=([\"\'])$node([\#\"\'])/href=$2$label.html$3/g) { 56 | s/(HREF|href)=([\"\'])$label.html/href=$2$label.html/g; 57 | $newnames{$node} = "$label.html"; 58 | } 59 | } 60 | } 61 | } 62 | print; 63 | } 64 | 65 | foreach $oldname (keys %newnames) { 66 | rename($oldname, $newnames{$oldname}); 67 | } 68 | 69 | foreach $filename (glob('*.bak')) { 70 | unlink($filename); 71 | } 72 | -------------------------------------------------------------------------------- /test/test-complete.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | # $Id: test-complete.py.in,v 1.4 2009/02/09 09:28:39 rockyb Exp $ -*- Python -*- 3 | 4 | import os, sys, unittest 5 | 6 | try: 7 | import readline 8 | except ImportError: 9 | print "Completion test skipped - no readline" 10 | sys.exit(0) 11 | 12 | top_builddir = "@top_builddir@" 13 | if top_builddir[-1] != os.path.sep: 14 | top_builddir += os.path.sep 15 | sys.path.insert(0, os.path.join(top_builddir, 'pydb')) 16 | top_srcdir = "@top_srcdir@" 17 | if top_srcdir[-1] != os.path.sep: 18 | top_srcdir += os.path.sep 19 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 20 | 21 | from complete import list_completions, all_completions 22 | 23 | class TestComplete(unittest.TestCase): 24 | 25 | def test_list_completions(self): 26 | c=[]; seen={} 27 | l=["a", "an", "another", "also", "boy"] 28 | self.assertEqual(list_completions(l, "a", seen, c), 29 | ['a', 'an', 'another', 'also']) 30 | self.assertEqual(list_completions(l, "b", seen, c), 31 | ['a', 'an', 'another', 'also', 'boy']) 32 | c=[]; seen={} 33 | self.assertEqual(list_completions(l, "a", seen, c, "foo "), 34 | ['foo a', 'foo an', 'foo another', 'foo also']) 35 | c=[]; seen={} 36 | self.assertEqual(list_completions(l, "an", seen, c), ['an', 'another']) 37 | c=[]; seen={} 38 | self.assertEqual(list_completions(l, "b", seen, c), ['boy']) 39 | c=[]; seen={} 40 | self.assertEqual(list_completions(l, "be", seen, c), []) 41 | return 42 | 43 | def test_all_completions(self): 44 | import pydb 45 | dbg = pydb.Pdb() 46 | dbg.curframe = None 47 | self.assertEqual( all_completions(dbg, "s"), 48 | ['s', 'save', 'set', 'shell', 'show', 'signal', 'skip', 49 | 'source', 'step']) 50 | self.assertEqual( all_completions(dbg, "set l"), 51 | ['set linetrace', 'set listsize', 'set logging']) 52 | self.assertEqual( all_completions(dbg, "set l", False), 53 | ['linetrace', 'listsize', 'logging']) 54 | return 55 | 56 | if __name__ == '__main__': 57 | unittest.main() 58 | -------------------------------------------------------------------------------- /test/unit/sighandler.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | 'Unit test for pydb.sighandler' 3 | import inspect, os, signal, sys, unittest 4 | 5 | top_builddir = "@top_builddir@" 6 | if top_builddir[-1] != os.path.sep: 7 | top_builddir += os.path.sep 8 | sys.path.insert(0, os.path.join(top_builddir, 'pydb')) 9 | top_srcdir = "@top_srcdir@" 10 | if top_srcdir[-1] != os.path.sep: 11 | top_srcdir += os.path.sep 12 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 13 | 14 | from sighandler import canonic_signame, lookup_signame, lookup_signum, YN 15 | 16 | class TestSigHandler(unittest.TestCase): 17 | 18 | def test_YN(self): 19 | for expect, b in (('Yes', True), ('No', False)): 20 | self.assertEqual(expect, YN(b)) 21 | pass 22 | return 23 | 24 | def test_canonic_signame(self): 25 | for expect, name_num in (('SIGTERM', '15'), 26 | ('SIGTERM', '-15'), 27 | ('SIGTERM', 'term'), 28 | ('SIGTERM', 'sigterm'), 29 | ('SIGTERM', 'TERM'), 30 | (None, '300'), 31 | (False, 'bogus')): 32 | self.assertEqual(expect, canonic_signame(name_num), 33 | 'name_num: %s' % name_num) 34 | pass 35 | pass 36 | 37 | def test_lookup_signame(self): 38 | for expect, num in (('SIGTERM', 15), ('SIGTERM', -15), 39 | (None, 300)): 40 | self.assertEqual(expect, lookup_signame(num)) 41 | pass 42 | return 43 | 44 | def test_lookup_signum(self): 45 | for expect, name in ((15, 'SIGTERM'), (15, 'TERM'), 46 | (15, 'term'), (None, 'nothere')): 47 | self.assertEqual(expect, lookup_signum(name)) 48 | pass 49 | return 50 | 51 | def test_lookup_signame_signum(self): 52 | for signum in range(signal.NSIG): 53 | signame = lookup_signame(signum) 54 | if signame is not None: 55 | self.assertEqual(signum, lookup_signum(signame)) 56 | # Try without the SIG prefix 57 | self.assertEqual(signum, lookup_signum(signame[3:])) 58 | pass 59 | pass 60 | return 61 | 62 | pass 63 | 64 | if __name__ == '__main__': 65 | unittest.main() 66 | -------------------------------------------------------------------------------- /test/test-disassem.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | # -*- Python -*- 3 | # $Id: test-disassem.py.in,v 1.2 2009/03/31 19:52:59 rockyb Exp $ 4 | "Unit test for Extended Python debugger's signal handling commands " 5 | import inspect, os, time, sys, unittest 6 | 7 | top_builddir = "@top_builddir@" 8 | if top_builddir[-1] != os.path.sep: 9 | top_builddir += os.path.sep 10 | sys.path.insert(0, os.path.join(top_builddir, 'pydb')) 11 | top_srcdir = "@top_srcdir@" 12 | if top_srcdir[-1] != os.path.sep: 13 | top_srcdir += os.path.sep 14 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 15 | 16 | import pydb 17 | 18 | class PdbTest(pydb.Pdb): 19 | def __init__(self): 20 | pydb.Pdb.__init__(self) 21 | self.errLines = [] 22 | self.msgLines = [] 23 | self.msg_last_nocr = False 24 | self.stack = self.curframe = self.botframe = None 25 | return 26 | 27 | def errmsg(self, msg): 28 | self.errLines.append(msg) 29 | return 30 | 31 | def msg(self, msg): 32 | if self.msg_last_nocr: 33 | self.msgLines[-1] += msg 34 | else: 35 | self.msgLines.append(msg) 36 | self.msg_last_nocr = False 37 | return 38 | 39 | def msg_nocr(self, msg): 40 | if self.msg_last_nocr: 41 | self.msgLines[-1] += msg 42 | else: 43 | self.msgLines.append(msg) 44 | self.msg_last_nocr = True 45 | return 46 | 47 | def msgReset(self): 48 | self.msgLines = [] 49 | return 50 | 51 | class PdbTests(unittest.TestCase): 52 | 53 | def test_disassemble(self): 54 | """Unit test dissassemble command""" 55 | import atexit 56 | deb = PdbTest() 57 | deb.curframe = inspect.currentframe() 58 | # deb.do_disassemble('atexit.register') 59 | # all_lines = len(deb.msgLines) 60 | # self.assertEqual(True, all_lines > 0) 61 | # deb.msgReset() 62 | deb.do_disassemble('+') 63 | all_lines = len(deb.msgLines) 64 | self.assertEqual(True, all_lines > 0) 65 | deb.msgReset() 66 | deb.do_disassemble('10') 67 | all_lines = len(deb.msgLines) 68 | self.assertEqual(True, all_lines > 0) 69 | deb.msgReset() 70 | deb.do_disassemble('1 100') 71 | all_lines = len(deb.msgLines) 72 | self.assertEqual(True, all_lines > 0) 73 | deb.msgReset() 74 | return 75 | 76 | if __name__ == "__main__": 77 | unittest.main() 78 | 79 | -------------------------------------------------------------------------------- /test/test-save.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | # $Id: test-save.py.in,v 1.3 2008/12/10 13:31:26 rockyb Exp $ -*- Python -*- 3 | """Unit test of the save command.""" 4 | import difflib, os, time, sys, unittest 5 | 6 | top_builddir = "@top_builddir@" 7 | if top_builddir[-1] != os.path.sep: 8 | top_builddir += os.path.sep 9 | sys.path.insert(0, os.path.join(top_builddir, 'pydb')) 10 | top_srcdir = "@top_srcdir@" 11 | if top_srcdir[-1] != os.path.sep: 12 | top_srcdir += os.path.sep 13 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 14 | 15 | builddir = "@builddir@" 16 | if builddir[-1] != os.path.sep: 17 | builddir += os.path.sep 18 | 19 | srcdir = "@srcdir@" 20 | if srcdir[-1] != os.path.sep: 21 | srcdir += os.path.sep 22 | 23 | pydir = os.path.join(top_builddir, "pydb") 24 | pydb_short = "pydb.py" 25 | pydb_path = os.path.join(pydir, pydb_short) 26 | 27 | def run_debugger(testname, pydb_opts='', args=''): 28 | global srcdir, builddir, pydir 29 | 30 | rightfile = os.path.join(srcdir, 'data', "%s.right" % testname) 31 | 32 | os.environ['PYTHONPATH']=os.pathsep.join(sys.path) 33 | cmdfile = os.path.join(srcdir, "%s.cmd" % testname) 34 | outfile = "%s.out" % testname 35 | outfile_opt = '--output=%s ' % outfile 36 | 37 | # print "builddir: %s, cmdfile: %s, outfile: %s, rightfile: %s" % \ 38 | # (builddir, cmdfile, outfile, rightfile) 39 | 40 | if os.path.exists(outfile): os.unlink(outfile) 41 | 42 | cmd = "%s --command %s %s %s %s %s.py" % \ 43 | (pydb_path, cmdfile, outfile_opt, pydb_opts, args, 44 | '%sgcd' % srcdir) 45 | 46 | os.system(cmd) 47 | fromfile = rightfile 48 | fromdate = time.ctime(os.stat(fromfile).st_mtime) 49 | fromlines = open(fromfile, 'U').readlines() 50 | tofile = outfile 51 | todate = time.ctime(os.stat(tofile).st_mtime) 52 | tolines = open(tofile, 'U').readlines() 53 | diff = list(difflib.unified_diff(fromlines, tolines, fromfile, 54 | tofile, fromdate, todate)) 55 | if len(diff) == 0: 56 | os.unlink(outfile) 57 | for line in diff: 58 | print line, 59 | return len(diff) == 0 60 | 61 | class PdbTests(unittest.TestCase): 62 | 63 | def test_save(self): 64 | """Test running bug running "save" command""" 65 | result=run_debugger(testname='save', pydb_opts='--basename') 66 | self.assertEqual(True, result, "pydb 'save' command comparision") 67 | return 68 | 69 | if __name__ == "__main__": 70 | unittest.main() 71 | -------------------------------------------------------------------------------- /test/test-contbug.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | # -*- Python -*- 3 | # $Id: test-contbug.py.in,v 1.3 2008/12/08 00:40:57 rockyb Exp $ 4 | "Unit test for Extended Python debugger's runl and runv commands " 5 | import difflib, os, sys, unittest, signal, time 6 | 7 | top_builddir = "@top_builddir@" 8 | if top_builddir[-1] != os.path.sep: 9 | top_builddir += os.path.sep 10 | sys.path.insert(0, os.path.join(top_builddir, 'pydb')) 11 | top_srcdir = "@top_srcdir@" 12 | if top_srcdir[-1] != os.path.sep: 13 | top_srcdir += os.path.sep 14 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 15 | 16 | import pydb 17 | 18 | builddir = "@builddir@" 19 | if builddir[-1] != os.path.sep: 20 | builddir += os.path.sep 21 | 22 | srcdir = "@srcdir@" 23 | if srcdir[-1] != os.path.sep: 24 | srcdir += os.path.sep 25 | 26 | pydir = os.path.join(top_builddir, "pydb") 27 | pydb_short = "pydb.py" 28 | pydb_path = os.path.join(pydir, pydb_short) 29 | 30 | def diff_files(outfile, rightfile): 31 | fromfile = rightfile 32 | fromdate = time.ctime(os.stat(fromfile).st_mtime) 33 | fromlines = open(fromfile, 'U').readlines() 34 | tofile = outfile 35 | todate = time.ctime(os.stat(tofile).st_mtime) 36 | tolines = open(tofile, 'U').readlines() 37 | 38 | diff = list(difflib.unified_diff(fromlines, tolines, fromfile, 39 | tofile, fromdate, todate)) 40 | if len(diff) == 0: 41 | os.unlink(outfile) 42 | for line in diff: 43 | print line, 44 | return len(diff) == 0 45 | 46 | class RunTests(unittest.TestCase): 47 | 48 | def test_continue_bug(self): 49 | """Test --exec and a bug whith 'c lineno' when given initially.""" 50 | python_script = '%shanoi.py' % srcdir 51 | 52 | if sys.hexversion >= 0x02050000: 53 | rightfile = os.path.join(srcdir, 'data', 54 | "contbug-2.5.right") 55 | else: 56 | rightfile = os.path.join(srcdir, 'data', 57 | "contbug.right") 58 | 59 | outfile = 'contbug.out' 60 | if os.path.exists(outfile): os.unlink(outfile) 61 | args = ('--basename', '--nx', '--output', outfile, 62 | '--exec', 63 | "set linetrace off;; set trace-commands on;; c 12;; quit", 64 | python_script) 65 | pydb.runv(args) 66 | result = diff_files(outfile, rightfile) 67 | self.assertEqual(True, result, "continue bug (via runv)") 68 | 69 | if __name__ == '__main__': 70 | unittest.main() 71 | -------------------------------------------------------------------------------- /test/test-skip.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | # $Id: test-skip.py.in,v 1.1 2009/02/09 09:28:39 rockyb Exp $ -*- Python -*- 3 | "Unit test of the file command for Extended Python debugger " 4 | import difflib, os, time, sys, unittest 5 | 6 | top_builddir = "@top_builddir@" 7 | if top_builddir[-1] != os.path.sep: 8 | top_builddir += os.path.sep 9 | sys.path.insert(0, os.path.join(top_builddir, 'pydb')) 10 | top_srcdir = "@top_srcdir@" 11 | if top_srcdir[-1] != os.path.sep: 12 | top_srcdir += os.path.sep 13 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 14 | 15 | builddir = "@builddir@" 16 | if builddir[-1] != os.path.sep: 17 | builddir += os.path.sep 18 | 19 | srcdir = "@srcdir@" 20 | if srcdir[-1] != os.path.sep: 21 | srcdir += os.path.sep 22 | 23 | pydir = os.path.join(top_builddir, "pydb") 24 | pydb_short = "pydb.py" 25 | pydb_path = os.path.join(pydir, pydb_short) 26 | 27 | def run_debugger(testname, pythonfile, pydb_opts='', args='', 28 | outfile=None): 29 | global srcdir, builddir, pydir 30 | 31 | rightfile = os.path.join(srcdir, 'data', "%s.right" % testname) 32 | 33 | os.environ['PYTHONPATH']=os.pathsep.join(sys.path) 34 | cmdfile = os.path.join(srcdir, "%s.cmd" % testname) 35 | outfile = "%s.out" % testname 36 | outfile_opt = '--output=%s ' % outfile 37 | 38 | # print "builddir: %s, cmdfile: %s, outfile: %s, rightfile: %s" % \ 39 | # (builddir, cmdfile, outfile, rightfile) 40 | 41 | if os.path.exists(outfile): os.unlink(outfile) 42 | 43 | cmd = "%s --command %s %s %s %s %s" % \ 44 | (pydb_path, cmdfile, outfile_opt, pydb_opts, pythonfile, args) 45 | 46 | os.system(cmd) 47 | fromfile = rightfile 48 | fromdate = time.ctime(os.stat(fromfile).st_mtime) 49 | fromlines = open(fromfile, 'U').readlines() 50 | tofile = outfile 51 | todate = time.ctime(os.stat(tofile).st_mtime) 52 | tolines = open(tofile, 'U').readlines() 53 | diff = list(difflib.unified_diff(fromlines, tolines, fromfile, 54 | tofile, fromdate, todate)) 55 | if len(diff) == 0: 56 | os.unlink(outfile) 57 | for line in diff: 58 | print line, 59 | return len(diff) == 0 60 | 61 | class PdbTests(unittest.TestCase): 62 | 63 | def test_trace(self): 64 | """Test stepping""" 65 | result=run_debugger(testname='skip', pydb_opts='--basename', 66 | pythonfile='%sgcd.py' % srcdir) 67 | self.assertEqual(True, result, "pydb 'skip' command comparision") 68 | return 69 | 70 | if __name__ == "__main__": 71 | unittest.main() 72 | -------------------------------------------------------------------------------- /test/test-step.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | # $Id: test-step.py.in,v 1.3 2008/12/10 13:31:26 rockyb Exp $ -*- Python -*- 3 | "Unit test of the file command for Extended Python debugger " 4 | import difflib, os, time, sys, unittest 5 | 6 | top_builddir = "@top_builddir@" 7 | if top_builddir[-1] != os.path.sep: 8 | top_builddir += os.path.sep 9 | sys.path.insert(0, os.path.join(top_builddir, 'pydb')) 10 | top_srcdir = "@top_srcdir@" 11 | if top_srcdir[-1] != os.path.sep: 12 | top_srcdir += os.path.sep 13 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 14 | 15 | builddir = "@builddir@" 16 | if builddir[-1] != os.path.sep: 17 | builddir += os.path.sep 18 | 19 | srcdir = "@srcdir@" 20 | if srcdir[-1] != os.path.sep: 21 | srcdir += os.path.sep 22 | 23 | pydir = os.path.join(top_builddir, "pydb") 24 | pydb_short = "pydb.py" 25 | pydb_path = os.path.join(pydir, pydb_short) 26 | 27 | def run_debugger(testname, pythonfile, pydb_opts='', args='', 28 | outfile=None): 29 | global srcdir, builddir, pydir 30 | 31 | rightfile = os.path.join(srcdir, 'data', "%s.right" % testname) 32 | 33 | os.environ['PYTHONPATH']=os.pathsep.join(sys.path) 34 | cmdfile = os.path.join(srcdir, "%s.cmd" % testname) 35 | outfile = "%s.out" % testname 36 | outfile_opt = '--output=%s ' % outfile 37 | 38 | # print "builddir: %s, cmdfile: %s, outfile: %s, rightfile: %s" % \ 39 | # (builddir, cmdfile, outfile, rightfile) 40 | 41 | if os.path.exists(outfile): os.unlink(outfile) 42 | 43 | cmd = "%s --command %s %s %s %s %s" % \ 44 | (pydb_path, cmdfile, outfile_opt, pydb_opts, pythonfile, args) 45 | 46 | os.system(cmd) 47 | fromfile = rightfile 48 | fromdate = time.ctime(os.stat(fromfile).st_mtime) 49 | fromlines = open(fromfile, 'U').readlines() 50 | tofile = outfile 51 | todate = time.ctime(os.stat(tofile).st_mtime) 52 | tolines = open(tofile, 'U').readlines() 53 | diff = list(difflib.unified_diff(fromlines, tolines, fromfile, 54 | tofile, fromdate, todate)) 55 | if len(diff) == 0: 56 | os.unlink(outfile) 57 | for line in diff: 58 | print line, 59 | return len(diff) == 0 60 | 61 | class PdbTests(unittest.TestCase): 62 | 63 | def test_trace(self): 64 | """Test stepping""" 65 | result=run_debugger(testname='step', pydb_opts='--basename', 66 | pythonfile='%sgcd.py' % srcdir) 67 | self.assertEqual(True, result, "pydb 'step' command comparision") 68 | return 69 | 70 | if __name__ == "__main__": 71 | unittest.main() 72 | -------------------------------------------------------------------------------- /test/test-linetrace.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | # -*- Python -*- 3 | # $Id: test-linetrace.py.in,v 1.5 2008/12/08 00:40:57 rockyb Exp $ 4 | "Unit test for Extended Python debugger's set linetrace " 5 | import difflib, os, sys, time, unittest 6 | 7 | top_builddir = "@top_builddir@" 8 | if top_builddir[-1] != os.path.sep: 9 | top_builddir += os.path.sep 10 | sys.path.insert(0, os.path.join(top_builddir, 'pydb')) 11 | top_srcdir = "@top_srcdir@" 12 | if top_srcdir[-1] != os.path.sep: 13 | top_srcdir += os.path.sep 14 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 15 | 16 | def run_python(testname, pythonfile, args='', outfile=None): 17 | srcdir = os.path.join(top_srcdir, 'test') 18 | pythonfile = os.path.join(".", pythonfile) 19 | outfile_opt = '' 20 | if outfile is None: 21 | outfile = "%s.out" % testname 22 | 23 | if sys.hexversion >= 0x02050000: 24 | rightfile = os.path.join(srcdir, 'data', 25 | "%s-2.5.right" % testname) 26 | elif sys.version_info[0:2] == (2, 4) and sys.version_info[3] == 'final': 27 | rightfile = os.path.join(srcdir, 'data', 28 | "%s-2.4-final.right" % testname) 29 | else: 30 | rightfile = os.path.join(srcdir, 'data', 31 | "%s.right" % testname) 32 | 33 | if os.path.exists(outfile): os.unlink(outfile) 34 | 35 | cmd = "(@PYTHON@ %s %s) >%s 2>&1" % (pythonfile, args, outfile) 36 | os.system(cmd) 37 | 38 | # Do diff on output 39 | fromfile = rightfile 40 | fromdate = time.ctime(os.stat(fromfile).st_mtime) 41 | fromlines = open(fromfile, 'U').readlines()[1:-1] 42 | tofile = outfile 43 | todate = time.ctime(os.stat(tofile).st_mtime) 44 | tolines = open(tofile, 'U').readlines()[1:-1] 45 | 46 | # 3rd line has a path in it. Pick out just the non-path tail of that 47 | fromlines[2] = fromlines[2][-24:] 48 | tolines[2] = tolines[2][-24:] 49 | diff = list(difflib.unified_diff(fromlines, tolines, 50 | fromfile, tofile, fromdate, todate)) 51 | if len(diff) == 0: 52 | os.unlink(outfile) 53 | for line in diff: 54 | print line, 55 | return len(diff) == 0 56 | 57 | class PdbTests(unittest.TestCase): 58 | 59 | def test_settrace(self): 60 | """Test that 'tracing and set_trace (debugger) work""" 61 | global builddir 62 | result = run_python("tracetest", "settrace.py") 63 | self.assertEqual(True, result, "hanoi trace output comparision") 64 | return 65 | 66 | if __name__ == "__main__": 67 | unittest.main() 68 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | This is an expanded version of the Python debugger, pdb.py 2 | 3 | Largely we're trying to follow gdb's command set unless there's good 4 | reason. So new or modified command names generally refer to the 5 | function they have in gdb. 6 | 7 | Changes from pdb.py: 8 | 9 | - non-interactive POSIX-shell like line tracing. 10 | 11 | - Restart program saving settings (gdb's "run") or a pure "exec" 12 | restart (reloads the entire debugger) 13 | 14 | - Add "display" expressions 15 | 16 | - Some gdb "set"/"show" commands: 17 | args, listsize, version (no set here), and some new ones 18 | basename, cmdtrace, interactive, linetrace, 19 | 20 | - Some gdb "info" commands: 21 | args break, display, globals, line, locals, program, and source 22 | 23 | - Other gdb commands: cd, display, disassemble, frame, pwd, return 24 | (immediate return, not finish), run, shell, source, undisplay 25 | 26 | - debugger is installed in binary directory; i.e. one runs "pydb script..." 27 | rather than "python pdb script..." 28 | 29 | - debugger accepts debugger options; e.g. redirecting output or setting 30 | line tracing 31 | 32 | - Add Perl's "examine" to show info about a symbol. For functions, 33 | methods, classes and modules the documentation string if any is printed. 34 | For functions, we also show the argument list. More work is needed here 35 | to recurse fields of an arbitrary object and show that. 36 | 37 | - add gdb's "frame" command and stack order. Cleaner display of 38 | call stack; for example "exec" calls are marked as such. 39 | 40 | - gdb-like help with subcomamnd-specific help available on 41 | info, set, or show subcommands; e.g. "help info line" works 42 | 43 | - More extensive and complete documentation. See 44 | http://bashdb.sourceforge.net/pydb/pydb/lib/index.html 45 | 46 | - up/down can take a number of frames to move. 47 | 48 | - Stepping skips over "def" statements. 49 | 50 | - Comes with regression tests. Can also be subclassed to capture 51 | debugger output. 52 | 53 | - Works with GUI frontend ddd. (For now a testing version of ddd is 54 | required. See 55 | http://sourceforge.net/project/showfiles.php?group_id=61395&package_id=65341 56 | version 3.3.12-test3 or greater. 57 | 58 | - Miscellaneous pdb bugs fixed. (See ChangeLog for details) 59 | 60 | Coexistence: 61 | For now, we try not to conflict with pdb.py. After all, Python 62 | developers made provision of multiple debuggers so we'll make use of 63 | that! 64 | 65 | So whereever there was a pdb, use pydb. The class name is still 66 | Pdb. So the debugger initialization script is .pydbrc for this 67 | debugger rather than .pdbrc for the one that comes with Python. 68 | 69 | $Id: README,v 1.6 2006/02/21 21:12:57 rockyb Exp $ -------------------------------------------------------------------------------- /test/test-dbgcall.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | # $Id: test-dbgcall.py.in,v 1.3 2008/12/26 02:40:45 rockyb Exp $ -*- Python -*- 3 | "Unit test for Extended Python debugger's debugger() call" 4 | import difflib, os, sys, time, unittest 5 | from subprocess import * 6 | 7 | top_builddir = "@top_builddir@" 8 | if top_builddir[-1] != os.path.sep: 9 | top_builddir += os.path.sep 10 | sys.path.insert(0, os.path.join(top_builddir, 'pydb')) 11 | top_srcdir = "@top_srcdir@" 12 | if top_srcdir[-1] != os.path.sep: 13 | top_srcdir += os.path.sep 14 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 15 | 16 | import pydb 17 | 18 | srcdir = "@srcdir@" 19 | if srcdir[-1] != os.path.sep: 20 | srcdir += os.path.sep 21 | 22 | class DbgCallTests(unittest.TestCase): 23 | 24 | def run_python(self, testname, pythonfile): 25 | global srcdir, builddir, pydir 26 | 27 | if sys.hexversion >= 0x02050000: 28 | rightfile = os.path.join(srcdir, 'data', 29 | "%s-2.5.right" % testname) 30 | else: 31 | rightfile = os.path.join(srcdir, 'data', 32 | "%s.right" % testname) 33 | pass 34 | 35 | outfile = 'dbgcall.out' 36 | cmd = '%s %s >%s' % ('@PYTHON@', pythonfile, outfile) 37 | os.system(cmd) 38 | # p = Popen(['@PYTHON@', pythonfile], stdout=PIPE) 39 | # output = p.communicate()[0] 40 | # if p.returncode != 0: 41 | # print output 42 | # print p.returncode 43 | # self.assertTrue(False, 'Could not run %s' % pythonfile) 44 | # return 45 | 46 | fromfile = rightfile 47 | fromdate = time.ctime(os.stat(fromfile).st_mtime) 48 | fromlines = open(fromfile, 'U').readlines() 49 | tofile = outfile 50 | todate = time.ctime(os.stat(tofile).st_mtime) 51 | tolines = open(tofile, 'U').readlines() 52 | diff = list(difflib.unified_diff(fromlines[1:], tolines[1:], fromfile, 53 | tofile, fromdate, todate)) 54 | if len(diff) == 0: 55 | os.unlink(outfile) 56 | else: 57 | for line in diff: 58 | print line, 59 | self.assertEqual(len(diff), 0) 60 | return 61 | 62 | ## Don't use assertTrue to be compatible with older version of 63 | ## unittest 64 | 65 | def test_debugger_call(self): 66 | """Test debugger with 'dbg_cmds', and 'continue'""" 67 | global srcdir 68 | testname = 'dbgcall' 69 | pythonfile = '%s%s.py' % (srcdir, testname,) 70 | self.run_python(testname, pythonfile) 71 | return 72 | 73 | if __name__ == "__main__": 74 | unittest.main() 75 | -------------------------------------------------------------------------------- /test/Makefile.am: -------------------------------------------------------------------------------- 1 | #$Id: Makefile.am,v 1.55 2009/04/10 23:42:02 rockyb Exp $ 2 | # Copyright (C) 2006, 2007, 2008 Rocky Bernstein 3 | # 4 | # This program is free software; you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation; either version 2 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program; if not, write to the Free Software 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 17 | # 02110-1301 USA. 18 | 19 | # SUBDIRS = data unit thread 20 | SUBDIRS = data unit 21 | 22 | check_DATA = \ 23 | .pydbrc \ 24 | brkpt1.cmd \ 25 | brkpt2.cmd \ 26 | cmdparse.cmd \ 27 | comm1.cmd \ 28 | comm2.cmd \ 29 | dbgcall.py \ 30 | except.py \ 31 | filebug.cmd \ 32 | filebug.py \ 33 | gcd.py \ 34 | hanoi.py \ 35 | history.cmd \ 36 | logging.cmd \ 37 | noscript.cmd \ 38 | pm.cmd \ 39 | pydbrc.cmd \ 40 | run.cmd \ 41 | run2.cmd \ 42 | save.cmd \ 43 | setshow.cmd \ 44 | settrace.py \ 45 | sighandler.cmd \ 46 | skip.cmd \ 47 | step.cmd \ 48 | sigtestexample.py \ 49 | withbug.cmd \ 50 | withbug.py 51 | 52 | TESTS = test.py \ 53 | test-complete.py \ 54 | test-contbug.py \ 55 | test-connect.py \ 56 | test-dbgcall.py \ 57 | test-disassem.py \ 58 | test-file.py \ 59 | test-fifo-connect.py \ 60 | test-fns.py \ 61 | test-help.py \ 62 | test-import.py \ 63 | test-linetrace.py \ 64 | test-pm.py \ 65 | test-run.py \ 66 | test-setshow.py \ 67 | test-sig.py \ 68 | test-sighandle.py \ 69 | test-save.py \ 70 | test-skip.py \ 71 | test-step.py \ 72 | test-trace.py \ 73 | test-tcp-connect.py \ 74 | test-trace.py \ 75 | test-with.py 76 | 77 | EXTRA_DIST = \ 78 | $(check_DATA) \ 79 | $(patsubst %.py,%.py.in, $(TESTS)) \ 80 | brkpt3.cmd.in \ 81 | .pydbrc.in \ 82 | file.right.in file-2.5.right.in file.cmd.in \ 83 | settrace.py.in 84 | 85 | test: check 86 | 87 | clean-generic: 88 | -rm $(top_builddir)/test/*.pyc \ 89 | $(top_builddir)/test/history.hst \ 90 | $(top_builddir)/test/savefile.txt 91 | -------------------------------------------------------------------------------- /Doc/tools/indfix.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | """Combine similar index entries into an entry and subentries. 4 | 5 | For example: 6 | 7 | \item {foobar} (in module flotz), 23 8 | \item {foobar} (in module whackit), 4323 9 | 10 | becomes 11 | 12 | \item {foobar} 13 | \subitem in module flotz, 23 14 | \subitem in module whackit, 4323 15 | 16 | Note that an item which matches the format of a collapsable item but which 17 | isn't part of a group of similar items is not modified. 18 | """ 19 | __version__ = '$Revision: 1.1 $' 20 | 21 | import re 22 | import StringIO 23 | import sys 24 | 25 | 26 | def cmp_entries(e1, e2): 27 | return cmp(e1[1].lower(), e2[1].lower()) or cmp(e1, e2) 28 | 29 | 30 | def dump_entries(write, entries): 31 | if len(entries) == 1: 32 | write(" \\item %s (%s)%s\n" % entries[0]) 33 | return 34 | write(" \item %s\n" % entries[0][0]) 35 | # now sort these in a case insensitive manner: 36 | if len(entries) > 0: 37 | entries.sort(cmp_entries) 38 | for xxx, subitem, pages in entries: 39 | write(" \subitem %s%s\n" % (subitem, pages)) 40 | 41 | 42 | breakable_re = re.compile( 43 | r" \\item (.*) [(](.*)[)]((?:(?:, \d+)|(?:, \\[a-z]*\{\d+\}))+)") 44 | 45 | 46 | def process(ifn, ofn=None): 47 | if ifn == "-": 48 | ifp = sys.stdin 49 | else: 50 | ifp = open(ifn) 51 | if ofn is None: 52 | ofn = ifn 53 | ofp = StringIO.StringIO() 54 | entries = [] 55 | match = breakable_re.match 56 | write = ofp.write 57 | while 1: 58 | line = ifp.readline() 59 | if not line: 60 | break 61 | m = match(line) 62 | if m: 63 | entry = m.group(1, 2, 3) 64 | if entries and entries[-1][0] != entry[0]: 65 | dump_entries(write, entries) 66 | entries = [] 67 | entries.append(entry) 68 | elif entries: 69 | dump_entries(write, entries) 70 | entries = [] 71 | write(line) 72 | else: 73 | write(line) 74 | del write 75 | del match 76 | ifp.close() 77 | data = ofp.getvalue() 78 | ofp.close() 79 | if ofn == "-": 80 | ofp = sys.stdout 81 | else: 82 | ofp = open(ofn, "w") 83 | ofp.write(data) 84 | ofp.close() 85 | 86 | 87 | def main(): 88 | import getopt 89 | outfile = None 90 | opts, args = getopt.getopt(sys.argv[1:], "o:") 91 | for opt, val in opts: 92 | if opt in ("-o", "--output"): 93 | outfile = val 94 | filename = args[0] 95 | outfile = outfile or filename 96 | process(filename, outfile) 97 | 98 | 99 | if __name__ == "__main__": 100 | main() 101 | -------------------------------------------------------------------------------- /test/data/brkpt2-2.3.right: -------------------------------------------------------------------------------- 1 | +############################################################### 2 | +### Clear nonexist break; 3 | +############################################################### 4 | +clear 5 | *** No breakpoint at gcd.py:10. 6 | +############################################################### 7 | +### Multiple breakpoints on a line and clearing all 8 | +############################################################### 9 | +break 28 10 | Breakpoint 1 set in file gcd.py, line 28. 11 | +break gcd.py:28 12 | Breakpoint 2 set in file gcd.py, line 28. 13 | +info break 14 | Num Type Disp Enb Where 15 | 1 breakpoint keep y at gcd.py:28 16 | 2 breakpoint keep y at gcd.py:28 17 | +clear 28 18 | Deleted breakpoints 1 2 19 | +############################################################### 20 | +### Clear by current line number 21 | +############################################################### 22 | +break 28 23 | Breakpoint 3 set in file gcd.py, line 28. 24 | +continue 25 | +clear 26 | Deleted breakpoint 3 27 | +info break 28 | No breakpoints. 29 | +############################################################### 30 | +### Test Delete: invalid/valid number. 31 | +############################################################### 32 | +delete 1 33 | *** Breakpoint (1) already deleted 34 | +break 11 35 | Breakpoint 4 set in file gcd.py, line 11. 36 | +info break 37 | Num Type Disp Enb Where 38 | 4 breakpoint keep y at gcd.py:11 39 | +delete 4 40 | Deleted breakpoint 4 41 | +tbreak 31 42 | Breakpoint 5 set in file gcd.py, line 31. 43 | +continue 44 | Deleted breakpoint 5 45 | +info break 46 | No breakpoints. 47 | +############################################################### 48 | +### Test Continue with a line number 49 | +############################################################### 50 | +c 35 51 | Breakpoint 6 set in file gcd.py, line 35. 52 | Deleted breakpoint 6 53 | +info break 54 | No breakpoints. 55 | +where 2 56 | -> 0 gcd(a=3, b=5) called from file 'gcd.py' at line 35 57 | ## 1 in file 'gcd.py' at line 41 58 | +############################################################### 59 | +### Test frame command 60 | +############################################################### 61 | +frame 62 | (gcd.py:35): gcd 63 | 35 return gcd(b-a, a) 64 | +frame abs(-1*2) 65 | (:1): 66 | +frame -3 67 | (gcd.py:41): 68 | 41 print "The GCD of %d and %d is %d" % (a, b, gcd(a, b)) 69 | +frame -2 70 | (:1): 71 | +frame 0 72 | (gcd.py:35): gcd 73 | 35 return gcd(b-a, a) 74 | +############################################################### 75 | +### Test ignore 76 | +############################################################### 77 | +ignore 0 1 78 | *** Expecting integer value to be at least 1, got: 0. 79 | +ignore 4 -1 80 | +## FIXME: need a real ignore test, not just invalid cases 81 | +quit 82 | -------------------------------------------------------------------------------- /test/test-file.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | # $Id: test-file.py.in,v 1.4 2008/12/10 13:31:26 rockyb Exp $ -*- Python -*- 3 | "Unit test of the file command for Extended Python debugger " 4 | import difflib, os, time, sys, unittest 5 | 6 | top_builddir = "@top_builddir@" 7 | if top_builddir[-1] != os.path.sep: 8 | top_builddir += os.path.sep 9 | sys.path.insert(0, os.path.join(top_builddir, 'pydb')) 10 | top_srcdir = "@top_srcdir@" 11 | if top_srcdir[-1] != os.path.sep: 12 | top_srcdir += os.path.sep 13 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 14 | 15 | builddir = "@builddir@" 16 | if builddir[-1] != os.path.sep: 17 | builddir += os.path.sep 18 | 19 | srcdir = "@srcdir@" 20 | if srcdir[-1] != os.path.sep: 21 | srcdir += os.path.sep 22 | 23 | pydir = os.path.join(top_builddir, "pydb") 24 | pydb_short = "pydb.py" 25 | pydb_path = os.path.join(pydir, pydb_short) 26 | 27 | def run_debugger(testname, pydb_opts='', args=''): 28 | global srcdir, builddir, pydir 29 | 30 | if sys.hexversion >= 0x02050000: 31 | rightfile = os.path.join(srcdir, 'data', 32 | "%s-2.5.right" % testname) 33 | else: 34 | rightfile = os.path.join(srcdir, 'data', 35 | "%s.right" % testname) 36 | 37 | os.environ['PYTHONPATH']=os.pathsep.join(sys.path) 38 | cmdfile = os.path.join(builddir, "%s.cmd" % testname) 39 | outfile = "%s.out" % testname 40 | outfile_opt = '--output=%s ' % outfile 41 | 42 | # print "builddir: %s, cmdfile: %s, outfile: %s, rightfile: %s" % \ 43 | # (builddir, cmdfile, outfile, rightfile) 44 | 45 | if os.path.exists(outfile): os.unlink(outfile) 46 | 47 | cmd = "%s --command %s %s %s %s" % \ 48 | (pydb_path, cmdfile, outfile_opt, pydb_opts, args) 49 | 50 | os.system(cmd) 51 | fromfile = rightfile 52 | fromdate = time.ctime(os.stat(fromfile).st_mtime) 53 | fromlines = open(fromfile, 'U').readlines()[0:-2] 54 | del fromlines[0] 55 | tofile = outfile 56 | todate = time.ctime(os.stat(tofile).st_mtime) 57 | tolines = open(tofile, 'U').readlines()[0:-2] 58 | del tolines[0] 59 | diff = list(difflib.unified_diff(fromlines, tolines, fromfile, 60 | tofile, fromdate, todate)) 61 | if len(diff) == 0: 62 | os.unlink(outfile) 63 | for line in diff: 64 | print line, 65 | return len(diff) == 0 66 | 67 | class PdbTests(unittest.TestCase): 68 | 69 | def test_trace(self): 70 | """Test running program via the 'file' command""" 71 | result=run_debugger(testname='file', pydb_opts='--basename') 72 | self.assertEqual(True, result, "pydb 'file' command comparision") 73 | return 74 | 75 | if __name__ == "__main__": 76 | unittest.main() 77 | -------------------------------------------------------------------------------- /test/data/brkpt2.right: -------------------------------------------------------------------------------- 1 | +############################################################### 2 | +### Clear nonexist break; 3 | +############################################################### 4 | +clear 5 | *** No breakpoint at gcd.py:10. 6 | +############################################################### 7 | +### Multiple breakpoints on a line and clearing all 8 | +############################################################### 9 | +break 28 10 | Breakpoint 1 set in file gcd.py, line 28. 11 | +break gcd.py:28 12 | Breakpoint 2 set in file gcd.py, line 28. 13 | +info break 14 | Num Type Disp Enb Where 15 | 1 breakpoint keep y at gcd.py:28 16 | 2 breakpoint keep y at gcd.py:28 17 | +clear 28 18 | Deleted breakpoints 1 2 19 | +############################################################### 20 | +### Clear by current line number 21 | +############################################################### 22 | +break 28 23 | Breakpoint 3 set in file gcd.py, line 28. 24 | +continue 25 | +clear 26 | Deleted breakpoint 3 27 | +info break 28 | No breakpoints. 29 | +############################################################### 30 | +### Test Delete: invalid/valid number. 31 | +############################################################### 32 | +delete 1 33 | *** Breakpoint (1) already deleted 34 | +break 11 35 | Breakpoint 4 set in file gcd.py, line 11. 36 | +info break 37 | Num Type Disp Enb Where 38 | 4 breakpoint keep y at gcd.py:11 39 | +delete 4 40 | Deleted breakpoint 4 41 | +tbreak 31 42 | Breakpoint 5 set in file gcd.py, line 31. 43 | +continue 44 | Deleted breakpoint 5 45 | +info break 46 | No breakpoints. 47 | +############################################################### 48 | +### Test Continue with a line number 49 | +############################################################### 50 | +c 35 51 | Breakpoint 6 set in file gcd.py, line 35. 52 | Deleted breakpoint 6 53 | +info break 54 | No breakpoints. 55 | +where 2 56 | -> 0 gcd(a=3, b=5) called from file 'gcd.py' at line 35 57 | ## 1 execfile() file 'gcd.py' at line 41 58 | +############################################################### 59 | +### Test frame command 60 | +############################################################### 61 | +frame 62 | (gcd.py:35): gcd 63 | 35 return gcd(b-a, a) 64 | +frame abs(-1*2) 65 | (:1): 66 | +frame -3 67 | (gcd.py:41): 68 | 41 print "The GCD of %d and %d is %d" % (a, b, gcd(a, b)) 69 | +frame -2 70 | (:1): 71 | +frame 0 72 | (gcd.py:35): gcd 73 | 35 return gcd(b-a, a) 74 | +############################################################### 75 | +### Test ignore 76 | +############################################################### 77 | +ignore 0 1 78 | *** Expecting integer value to be at least 1, got: 0. 79 | +ignore 4 -1 80 | +## FIXME: need a real ignore test, not just invalid cases 81 | +quit 82 | -------------------------------------------------------------------------------- /Doc/perl/SynopsisTable.pm: -------------------------------------------------------------------------------- 1 | package SynopsisTable; 2 | 3 | sub new{ 4 | return bless {names=>'', info=>{}, file=>''}; 5 | } 6 | 7 | sub declare{ 8 | my($self,$name,$key,$type) = @_; 9 | if ($self->{names}) { 10 | $self->{names} .= ",$name"; 11 | } 12 | else { 13 | $self->{names} .= "$name"; 14 | } 15 | $self->{info}{$name} = "$key,$type,"; 16 | } 17 | 18 | # The 'file' attribute is used to store the filename of the node in which 19 | # the table will be presented; this assumes that each table will be presented 20 | # only once, which works for the current use of this object. 21 | 22 | sub set_file{ 23 | my($self, $filename) = @_; 24 | $self->{file} = "$filename"; 25 | } 26 | 27 | sub get_file{ 28 | my $self = shift; 29 | return $self->{file}; 30 | } 31 | 32 | sub set_synopsis{ 33 | my($self,$name,$synopsis) = @_; 34 | my($key,$type,$unused) = split ',', $self->{info}{$name}, 3; 35 | $self->{info}{$name} = "$key,$type,$synopsis"; 36 | } 37 | 38 | sub get{ 39 | my($self,$name) = @_; 40 | return split /,/, $self->{info}{$name}, 3; 41 | } 42 | 43 | sub show{ 44 | my $self = shift; 45 | my $name; 46 | print "names: ", $self->{names}, "\n\n"; 47 | foreach $name (split /,/, $self->{names}) { 48 | my($key,$type,$synopsis) = $self->get($name); 49 | print "$name($key) is $type: $synopsis\n"; 50 | } 51 | } 52 | 53 | sub tohtml{ 54 | my $self = shift; 55 | my $oddrow = 1; 56 | my $data = "\n"; 57 | my $name; 58 | foreach $name (split /,/, $self->{names}) { 59 | my($key,$type,$synopsis) = $self->get($name); 60 | my $link = ""; 61 | $synopsis =~ s//%/g; 62 | $synopsis =~ s//\&/g; 63 | $data .= (' \n " : '>') 65 | . "\n" 66 | . " \n" 67 | . " \n"); 68 | $oddrow = !$oddrow; 69 | } 70 | $data .= "
$link$name$synopsis
\n"; 71 | $data; 72 | } 73 | 74 | 75 | package testSynopsisTable; 76 | 77 | sub test{ 78 | # this little test is mostly to debug the stuff above, since this is 79 | # my first Perl "object". 80 | my $st = SynopsisTable->new(); 81 | $st->declare("sample", "sample", "standard"); 82 | $st->set_synopsis("sample", "This is a little synopsis...."); 83 | $st->declare("copy_reg", "copyreg", "standard"); 84 | $st->set_synopsis("copy_reg", "pickle support stuff"); 85 | $st->show(); 86 | 87 | print "\n\n"; 88 | 89 | my $st2 = SynopsisTable->new(); 90 | $st2->declare("st2module", "st2module", "built-in"); 91 | $st2->set_synopsis("st2module", "silly little synopsis"); 92 | $st2->show(); 93 | } 94 | 95 | 1; # This must be the last line -- Perl is bogus! 96 | -------------------------------------------------------------------------------- /test/test-help.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | # $Id: test-help.py.in,v 1.3 2008/12/08 00:40:57 rockyb Exp $ 3 | "Unit test of getting help options " 4 | import difflib, os, time, sys, unittest 5 | 6 | top_builddir = "@top_builddir@" 7 | if top_builddir[-1] != os.path.sep: 8 | top_builddir += os.path.sep 9 | sys.path.insert(0, os.path.join(top_builddir, 'pydb')) 10 | top_srcdir = "@top_srcdir@" 11 | if top_srcdir[-1] != os.path.sep: 12 | top_srcdir += os.path.sep 13 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 14 | 15 | builddir = "@builddir@" 16 | if builddir[-1] != os.path.sep: 17 | builddir += os.path.sep 18 | 19 | srcdir = "@srcdir@" 20 | if srcdir[-1] != os.path.sep: 21 | srcdir += os.path.sep 22 | 23 | pydir = os.path.join(top_builddir, "pydb") 24 | pydb_short = "pydb.py" 25 | pydb_path = os.path.join(pydir, pydb_short) 26 | 27 | def run_debugger(testname, pythonfile, pydb_opts='', args='', 28 | outfile=None, need_25=True): 29 | global srcdir, builddir, pydir 30 | 31 | if sys.hexversion >= 0x02050000 and need_25: 32 | rightfile = os.path.join(srcdir, 'data', 33 | "%s-2.5.right" % testname) 34 | else: 35 | rightfile = os.path.join(srcdir, 'data', 36 | "%s.right" % testname) 37 | 38 | outfile_opt = '' 39 | if outfile is None: 40 | outfile = os.path.join(builddir, "%s.out" % testname) 41 | 42 | if os.path.exists(outfile): os.unlink(outfile) 43 | 44 | os.environ['PYTHONPATH']=os.pathsep.join(sys.path) 45 | os.environ['COLUMNS']='80' 46 | cmd = "%s %s %s %s >%s" % \ 47 | (pydb_path, pydb_opts, pythonfile, args, outfile) 48 | 49 | os.system(cmd) 50 | fromfile = rightfile 51 | fromdate = time.ctime(os.stat(fromfile).st_mtime) 52 | fromlines = open(fromfile, 'U').readlines()[0:-2] 53 | tofile = outfile 54 | todate = time.ctime(os.stat(tofile).st_mtime) 55 | tolines = open(tofile, 'U').readlines()[0:-2] 56 | # Curse you getopts! I'm so ashamed. 57 | tolines[0] = fromlines[0].lower() # Usage -> usage 58 | tolines[4] = fromlines[4].lower() # Options -> options 59 | diff = list(difflib.unified_diff(fromlines, tolines, fromfile, 60 | tofile, fromdate, todate)) 61 | if len(diff) == 0: 62 | os.unlink(outfile) 63 | for line in diff: 64 | print line, 65 | return len(diff) == 0 66 | 67 | class PdbTests(unittest.TestCase): 68 | 69 | def test_help(self): 70 | """Test getting help: --help and -h options""" 71 | for trace_opt in ['--help', '-h']: 72 | result=run_debugger(testname='help', 73 | pydb_opts='%s --help' % trace_opt, 74 | pythonfile='', need_25 = False) 75 | self.assertEqual(True, result, 76 | "help listing output comparision" ) 77 | 78 | 79 | if __name__ == "__main__": 80 | unittest.main() 81 | -------------------------------------------------------------------------------- /test/test-pm.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | # $Id: test-pm.py.in,v 1.2 2008/11/17 19:06:39 rockyb Exp $ -*- Python -*- 3 | "Unit test for Extended Python debugger's Post-Mortem (pm) commands " 4 | import difflib, os, time, sys, unittest 5 | 6 | top_builddir = "@top_builddir@" 7 | if top_builddir[-1] != os.path.sep: 8 | top_builddir += os.path.sep 9 | sys.path.insert(0, os.path.join(top_builddir, 'pydb')) 10 | top_srcdir = "@top_srcdir@" 11 | if top_srcdir[-1] != os.path.sep: 12 | top_srcdir += os.path.sep 13 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 14 | 15 | import pydb 16 | 17 | builddir = "@builddir@" 18 | if builddir[-1] != os.path.sep: 19 | builddir += os.path.sep 20 | 21 | top_builddir = "@top_builddir@" 22 | if top_builddir[-1] != os.path.sep: 23 | top_builddir += os.path.sep 24 | 25 | srcdir = "@srcdir@" 26 | if srcdir[-1] != os.path.sep: 27 | srcdir += os.path.sep 28 | 29 | pydir = os.path.join(top_builddir, "pydb") 30 | pydb_short = "pydb.py" 31 | pydb_path = os.path.join(pydir, pydb_short) 32 | 33 | def raise_error(): 34 | raise FloatingPointError 35 | 36 | class PdbTests(unittest.TestCase): 37 | 38 | ## Don't use assertTrue to be compatible with older version of 39 | ## unittest 40 | 41 | def test_postmortem2(self): 42 | """Test post-mortem processing without a traceback""" 43 | pydb.post_mortem() 44 | self.assertEqual(True, True, "post-mortem test with no traceback") 45 | 46 | def test_postmortem(self): 47 | """Test post-mortem processing""" 48 | try: 49 | raise_error() 50 | except FloatingPointError: 51 | t = sys.exc_info()[2] 52 | outfile = 'pm.out' 53 | rightfile = os.path.join(srcdir, 'data', 'pm.right') 54 | errfile = 'pm.err' 55 | old_stdout = sys.stdout 56 | old_stderr = sys.stderr 57 | sys.stdout = open(outfile, 'w') 58 | sys.stderr = open(errfile, 'w') 59 | pydb.post_mortem(t=t, dbg_cmds=None, 60 | cmdfile=os.path.join(srcdir, 'pm.cmd')) 61 | sys.stdout.close() 62 | sys.stderr.close() 63 | sys.stdout = old_stdout 64 | sys.stderr = old_stderr 65 | fromfile = rightfile 66 | fromdate = time.ctime(os.stat(fromfile).st_mtime) 67 | fromlines = open(fromfile, 'U').readlines() 68 | tofile = outfile 69 | todate = time.ctime(os.stat(tofile).st_mtime) 70 | tolines = open(tofile, 'U').readlines() 71 | 72 | diff = list(difflib.unified_diff(fromlines, tolines, fromfile, 73 | tofile, fromdate, todate)) 74 | 75 | if len(diff) == 0: 76 | os.unlink(outfile) 77 | os.unlink(errfile) 78 | for line in diff: 79 | print line, 80 | self.assertEqual(0, len(diff), "post-mortem test") 81 | return 82 | 83 | 84 | if __name__ == "__main__": 85 | unittest.main() 86 | -------------------------------------------------------------------------------- /pydb/bytecode.py: -------------------------------------------------------------------------------- 1 | from opcode import * 2 | import dis 3 | import re 4 | 5 | def op_at_code_loc(code, loc): 6 | try: 7 | op = ord(code[loc]) 8 | except IndexError: 9 | return 'got IndexError' 10 | return opname[op] 11 | 12 | def op_at_frame(frame, loc=None): 13 | code = frame.f_code.co_code 14 | if loc is None: loc = frame.f_lasti 15 | return op_at_code_loc(code, loc) 16 | 17 | def next_opcode(code, offset): 18 | '''Return the next opcode and offset as a tuple. Tuple (-100, 19 | -1000) is returned when reaching the end.''' 20 | n = len(code) 21 | while offset < n: 22 | c = code[offset] 23 | op = ord(c) 24 | offset += 1 25 | if op >= HAVE_ARGUMENT: 26 | offset += 2 27 | pass 28 | yield op, offset 29 | pass 30 | yield -100, -1000 31 | pass 32 | 33 | def next_linestart(co, offset, count=1): 34 | linestarts = dict(dis.findlinestarts(co)) 35 | code = co.co_code 36 | n = len(code) 37 | contains_cond_jump = False 38 | for op, offset in next_opcode(code, offset): 39 | if offset in linestarts: 40 | count -= 1 41 | if 0 == count: 42 | return linestarts[offset] 43 | pass 44 | pass 45 | return -1000 46 | 47 | # FIXME: break out into a code iterator. 48 | def stmt_contains_make_function(co, lineno): 49 | linestarts = dict(dis.findlinestarts(co)) 50 | code = co.co_code 51 | found_start = False 52 | for offset, start_line in linestarts.items(): 53 | if start_line == lineno: 54 | found_start = True 55 | break 56 | pass 57 | if not found_start: 58 | return False 59 | for op, offset in next_opcode(code, offset): 60 | if -1000 == offset or linestarts.get(offset): return False 61 | opcode = opname[op] 62 | # print opcode 63 | if 'MAKE_FUNCTION' == opcode: 64 | return True 65 | pass 66 | return False 67 | 68 | # A pattern for a def header seems to be used a couple of times. 69 | _re_def_str = r'^\s*def\s' 70 | _re_def = re.compile(_re_def_str) 71 | def is_def_stmt(line, frame): 72 | """Return True if we are looking at a def statement""" 73 | # Should really also check that operand is a code object 74 | return _re_def.match(line) and op_at_frame(frame)=='LOAD_CONST' \ 75 | and stmt_contains_make_function(frame.f_code, frame.f_lineno) 76 | 77 | # Demo stuff above 78 | if __name__=='__main__': 79 | import inspect 80 | def sqr(x): 81 | return x * x 82 | frame = inspect.currentframe() 83 | co = frame.f_code 84 | lineno = frame.f_lineno 85 | print 'contains MAKE_FUNCTION', stmt_contains_make_function(co, lineno-4) 86 | print 'contains MAKE_FUNCTION', stmt_contains_make_function(co, lineno) 87 | 88 | print "op at frame: ", op_at_frame(frame) 89 | print "op at frame, position 2", op_at_frame(frame, 2) 90 | print "def statement: x=5?: ", is_def_stmt('x=5', frame) 91 | # Not a "def" statement because frame is wrong spot 92 | print is_def_stmt('def foo():', frame) 93 | 94 | pass 95 | -------------------------------------------------------------------------------- /test/test-setshow.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | # $Id: test-setshow.py.in,v 1.5 2008/12/10 13:31:26 rockyb Exp $ -*- Python -*- 3 | "Unit test of the file command for Extended Python debugger " 4 | import difflib, os, time, sys, unittest 5 | 6 | top_builddir = "@top_builddir@" 7 | if top_builddir[-1] != os.path.sep: 8 | top_builddir += os.path.sep 9 | sys.path.insert(0, os.path.join(top_builddir, 'pydb')) 10 | top_srcdir = "@top_srcdir@" 11 | if top_srcdir[-1] != os.path.sep: 12 | top_srcdir += os.path.sep 13 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 14 | 15 | builddir = "@builddir@" 16 | if builddir[-1] != os.path.sep: 17 | builddir += os.path.sep 18 | 19 | srcdir = "@srcdir@" 20 | if srcdir[-1] != os.path.sep: 21 | srcdir += os.path.sep 22 | 23 | pydir = os.path.join(top_builddir, "pydb") 24 | pydb_short = "pydb.py" 25 | pydb_path = os.path.join(pydir, pydb_short) 26 | 27 | def run_debugger(testname, pythonfile, pydb_opts='', args='', 28 | rightfile=None): 29 | global srcdir, builddir, pydir 30 | 31 | if rightfile is None: 32 | rightfile = os.path.join(srcdir, 'data', 33 | "%s.right" % testname) 34 | 35 | os.environ['PYTHONPATH']=os.pathsep.join(sys.path) 36 | cmdfile = os.path.join(srcdir, "%s.cmd" % testname) 37 | outfile = "%s.out" % testname 38 | outfile_opt = '--output=%s ' % outfile 39 | 40 | # print "builddir: %s, cmdfile: %s, outfile: %s, rightfile: %s" % \ 41 | # (builddir, cmdfile, outfile, rightfile) 42 | 43 | if os.path.exists(outfile): os.unlink(outfile) 44 | 45 | cmd = "%s --command %s %s %s %s %s" % \ 46 | (pydb_path, cmdfile, outfile_opt, pydb_opts, args, pythonfile) 47 | 48 | os.system(cmd) 49 | fromfile = rightfile 50 | fromdate = time.ctime(os.stat(fromfile).st_mtime) 51 | # fromlines = open(fromfile, 'U').readlines()[0:-1] 52 | fromlines = open(fromfile, 'U').readlines() 53 | tofile = outfile 54 | todate = time.ctime(os.stat(tofile).st_mtime) 55 | # tolines = open(tofile, 'U').readlines()[0:-1] 56 | tolines = open(tofile, 'U').readlines() 57 | diff = list(difflib.unified_diff(fromlines, tolines, fromfile, 58 | tofile, fromdate, todate)) 59 | if len(diff) == 0: 60 | os.unlink(outfile) 61 | for line in diff: 62 | print line, 63 | return len(diff) == 0 64 | 65 | class PdbTests(unittest.TestCase): 66 | 67 | def test_setshow(self): 68 | """Test running program via the 'file' command""" 69 | 70 | try: 71 | import readline 72 | rightfile = os.path.join(srcdir, 'data', 73 | "setshow.right") 74 | except ImportError: 75 | rightfile = os.path.join(srcdir, 'data', 76 | "setshow-no-rl.right") 77 | 78 | result=run_debugger(testname='setshow', pythonfile='', 79 | pydb_opts='--basename', rightfile=rightfile) 80 | self.assertEqual(True, result, "pydb 'set/show' command comparision") 81 | return 82 | 83 | if __name__ == "__main__": 84 | unittest.main() 85 | -------------------------------------------------------------------------------- /test/test-sighandle.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | # -*- Python -*- 3 | # $Id: test-sighandle.py.in,v 1.2 2009/03/06 08:51:46 rockyb Exp $ 4 | "Unit test for Extended Python debugger's signal handling commands " 5 | import os, time, sys, unittest, signal 6 | 7 | top_builddir = "@top_builddir@" 8 | if top_builddir[-1] != os.path.sep: 9 | top_builddir += os.path.sep 10 | sys.path.insert(0, os.path.join(top_builddir, 'pydb')) 11 | top_srcdir = "@top_srcdir@" 12 | if top_srcdir[-1] != os.path.sep: 13 | top_srcdir += os.path.sep 14 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 15 | 16 | import pydb, sighandler 17 | 18 | builddir = "@builddir@" 19 | if builddir[-1] != os.path.sep: 20 | builddir += os.path.sep 21 | 22 | top_builddir = "@top_builddir@" 23 | if top_builddir[-1] != os.path.sep: 24 | top_builddir += os.path.sep 25 | 26 | srcdir = "@srcdir@" 27 | if srcdir[-1] != os.path.sep: 28 | srcdir += os.path.sep 29 | 30 | pydir = os.path.join(top_builddir, "pydb") 31 | pydb_short = "pydb.py" 32 | pydb_path = os.path.join(pydir, pydb_short) 33 | outfile = 'sighandler.out' 34 | program = 'sigtestexample.py' 35 | 36 | class PdbTest(pydb.Pdb): 37 | def __init__(self): 38 | pydb.Pdb.__init__(self) 39 | self.errLines = [] 40 | self.msgLines = [] 41 | self.msg_last_nocr = False 42 | self.stack = self.curframe = self.botframe = None 43 | 44 | def resetmsg(self): 45 | self.msgLines=[] 46 | 47 | def errmsg(self, msg): 48 | self.errLines.append(msg) 49 | 50 | def msg(self, msg): 51 | if self.msg_last_nocr: 52 | self.msgLines[-1] += msg 53 | else: 54 | self.msgLines.append(msg) 55 | self.msg_last_nocr = False 56 | 57 | def msg_nocr(self, msg): 58 | if self.msg_last_nocr: 59 | self.msgLines[-1] += msg 60 | else: 61 | self.msgLines.append(msg) 62 | self.msg_last_nocr = True 63 | 64 | class SigTests(unittest.TestCase): 65 | 66 | def test_settings(self): 67 | """Test setting signals""" 68 | p = PdbTest() 69 | h = sighandler.SignalManager(p) 70 | # Set to known value 71 | h.action('SIGUSR1 print pass') 72 | h.info_signal(['USR1']) 73 | correct = ["Signal Stop Print Stack Pass Description", 74 | "SIGUSR1 No Yes Yes No User-defined signal 1"] 75 | self.assertEqual(p.msgLines, correct) 76 | p.resetmsg() 77 | # noprint implies no stop 78 | h.action('SIGUSR1 noprint stack pass') 79 | h.info_signal(['USR1']) 80 | correct = ["Signal Stop Print Stack Pass Description", 81 | "SIGUSR1 No No Yes Yes User-defined signal 1"] 82 | self.assertEqual(p.msgLines, correct) 83 | # stop keyword implies print and nopass 84 | p.resetmsg() 85 | h.action('SIGUSR1 stop') 86 | h.info_signal(['USR1']) 87 | correct = ["Signal Stop Print Stack Pass Description", 88 | "SIGUSR1 Yes Yes No Yes User-defined signal 1"] 89 | self.assertEqual(p.msgLines, correct) 90 | 91 | if __name__ == '__main__': 92 | unittest.main() 93 | -------------------------------------------------------------------------------- /test/cmdparse.cmd: -------------------------------------------------------------------------------- 1 | # $Id: cmdparse.cmd,v 1.21 2009/03/18 10:15:23 rockyb Exp $ 2 | # This tests the functioning of some debugger command a 3 | # parsing and set/show processing 4 | set basename on 5 | set trace-commands on 6 | ### ******************************* 7 | ### *** Set/show commands *** 8 | ### ******************************* 9 | ######################################## 10 | ### test args and baseneme... 11 | ######################################## 12 | set args this is a test 13 | show args 14 | show basename 15 | set basename foo 16 | show base 17 | set basename off 18 | show basename 19 | set basename 0 20 | show basename 21 | set basename 1 22 | show basename 23 | ######################################## 24 | ### test listsize tests... 25 | ######################################## 26 | show listsize 27 | set listsize 10+10 28 | show listsi 29 | set listsize abc 30 | set listsize -20 31 | set listsize 20 forever 32 | ######################################## 33 | ### test linetrace... 34 | ######################################## 35 | set linetrace delay 36 | set linetrace delay 2 37 | show linetrace delay 38 | set linetrace delay 0.5 39 | show linetrace delay 40 | set linetrace delay foo 41 | show linetrace delay 42 | set linetrace on 43 | show linetrace 44 | set linetrace off 45 | show linetrace 46 | show maxargsize 47 | ######################################## 48 | ### bad enable disable 49 | ######################################## 50 | enable 10 51 | disable 10 52 | enable foo 53 | disable foo 54 | ######################################## 55 | ### test list 56 | ######################################## 57 | list 58 | list 59 | list - 60 | list 10 15 61 | list 10 3 62 | list hanoi.py:12 63 | list hanoi 64 | list hanoi 10 65 | list gcd.py:24 66 | list . 67 | # first and last file names are different 68 | list gcd.py:24 hanoi.py:10 69 | # File doesn't have 50 lines 70 | list 50 71 | set listsi 6 72 | list 5 73 | # Invalid list command - need lineno or fn name 74 | list hanoi.py 75 | ######################################## 76 | ### test prompt, misc... 77 | ######################################## 78 | show prompt 79 | show foo 80 | cd 81 | ######################################## 82 | ### test numeric argument syntax 83 | ######################################## 84 | up fdsafdsa 85 | u='foo' 86 | down 1 b c 87 | frame foo 88 | step -1 89 | next -1 90 | ######################################## 91 | ### test info 92 | ######################################## 93 | info line 94 | info source 95 | ######################################## 96 | ### help/info stuff 97 | ######################################## 98 | help nogood 99 | help restart 100 | help run 101 | help set 102 | help set linesize 103 | help set listsize 104 | help show 105 | help show listsize 106 | help info 107 | ####################################### 108 | # The below "help info" lines should 109 | # have '.' append to the end whereas 110 | # in the above listing they were 111 | # omitted. 112 | ####################################### 113 | help info program 114 | help info source 115 | ####################################### 116 | # The below "help show" commands have 117 | # more than one line of output also 118 | # ommited in a simple "show" 119 | ####################################### 120 | help show args 121 | help show commands 122 | quit 123 | -------------------------------------------------------------------------------- /test/data/dbgcall.right: -------------------------------------------------------------------------------- 1 | (/tmp/pydb-1.25/test/dbgcall.py:17): 2 | 17 if __name__=='__main__': 3 | (dbgcall.py:18): 4 | + 18 i_args=len(sys.argv) 5 | (dbgcall.py:19): 6 | + 19 if i_args != 1 and i_args != 2: 7 | (dbgcall.py:23): 8 | + 23 n=3 9 | (dbgcall.py:24): 10 | + 24 sys.settrace(None) 11 | (dbgcall.py:34): 12 | + 34 if n < 1 or n > 100: 13 | (dbgcall.py:38): 14 | + 38 hanoi(n, "a", "b", "c") 15 | --Call level -5 16 | (dbgcall.py:10): hanoi 17 | + 10 def hanoi(n,a,b,c): 18 | (dbgcall.py:11): hanoi 19 | + 11 if n-1 > 0: 20 | (dbgcall.py:12): hanoi 21 | + 12 hanoi(n-1, a, c, b) 22 | --Call level -4 23 | (dbgcall.py:10): hanoi 24 | + 10 def hanoi(n,a,b,c): 25 | (dbgcall.py:11): hanoi 26 | + 11 if n-1 > 0: 27 | (dbgcall.py:12): hanoi 28 | + 12 hanoi(n-1, a, c, b) 29 | --Call level -3 30 | (dbgcall.py:10): hanoi 31 | + 10 def hanoi(n,a,b,c): 32 | (dbgcall.py:11): hanoi 33 | + 11 if n-1 > 0: 34 | (dbgcall.py:13): hanoi 35 | + 13 print "Move disk %s to %s" % (a, b) 36 | Move disk a to b 37 | (dbgcall.py:14): hanoi 38 | + 14 if n-1 > 0: 39 | (dbgcall.py:14): hanoi 40 | + 14 if n-1 > 0: 41 | (dbgcall.py:13): hanoi 42 | + 13 print "Move disk %s to %s" % (a, b) 43 | Move disk a to c 44 | (dbgcall.py:14): hanoi 45 | + 14 if n-1 > 0: 46 | (dbgcall.py:15): hanoi 47 | + 15 hanoi(n-1, c, b, a) 48 | --Call level -3 49 | (dbgcall.py:10): hanoi 50 | + 10 def hanoi(n,a,b,c): 51 | (dbgcall.py:11): hanoi 52 | + 11 if n-1 > 0: 53 | (dbgcall.py:13): hanoi 54 | + 13 print "Move disk %s to %s" % (a, b) 55 | Move disk b to c 56 | (dbgcall.py:14): hanoi 57 | + 14 if n-1 > 0: 58 | (dbgcall.py:14): hanoi 59 | + 14 if n-1 > 0: 60 | (dbgcall.py:15): hanoi 61 | + 15 hanoi(n-1, c, b, a) 62 | (dbgcall.py:13): hanoi 63 | + 13 print "Move disk %s to %s" % (a, b) 64 | 'continued' 65 | Move disk a to b 66 | (dbgcall.py:14): hanoi 67 | + 14 if n-1 > 0: 68 | (dbgcall.py:15): hanoi 69 | + 15 hanoi(n-1, c, b, a) 70 | --Call level -4 71 | (dbgcall.py:10): hanoi 72 | + 10 def hanoi(n,a,b,c): 73 | (dbgcall.py:11): hanoi 74 | + 11 if n-1 > 0: 75 | (dbgcall.py:12): hanoi 76 | + 12 hanoi(n-1, a, c, b) 77 | --Call level -3 78 | (dbgcall.py:10): hanoi 79 | + 10 def hanoi(n,a,b,c): 80 | (dbgcall.py:11): hanoi 81 | + 11 if n-1 > 0: 82 | (dbgcall.py:13): hanoi 83 | + 13 print "Move disk %s to %s" % (a, b) 84 | Move disk c to a 85 | (dbgcall.py:14): hanoi 86 | + 14 if n-1 > 0: 87 | (dbgcall.py:14): hanoi 88 | + 14 if n-1 > 0: 89 | (dbgcall.py:13): hanoi 90 | + 13 print "Move disk %s to %s" % (a, b) 91 | Move disk c to b 92 | (dbgcall.py:14): hanoi 93 | + 14 if n-1 > 0: 94 | (dbgcall.py:15): hanoi 95 | + 15 hanoi(n-1, c, b, a) 96 | --Call level -3 97 | (dbgcall.py:10): hanoi 98 | + 10 def hanoi(n,a,b,c): 99 | (dbgcall.py:11): hanoi 100 | + 11 if n-1 > 0: 101 | (dbgcall.py:13): hanoi 102 | + 13 print "Move disk %s to %s" % (a, b) 103 | Move disk a to b 104 | (dbgcall.py:14): hanoi 105 | + 14 if n-1 > 0: 106 | (dbgcall.py:14): hanoi 107 | + 14 if n-1 > 0: 108 | (dbgcall.py:15): hanoi 109 | + 15 hanoi(n-1, c, b, a) 110 | (dbgcall.py:15): hanoi 111 | + 15 hanoi(n-1, c, b, a) 112 | (dbgcall.py:38): 113 | + 38 hanoi(n, "a", "b", "c") 114 | -------------------------------------------------------------------------------- /test/data/brkpt1-2.7.right: -------------------------------------------------------------------------------- 1 | +############################################################### 2 | +# Test the breakpoint by line number 3 | +############################################################### 4 | +info break 5 | No breakpoints. 6 | +break 30 7 | *** Blank, doc string, or comment 8 | +info break 9 | No breakpoints. 10 | +############################################################### 11 | +### Test enable/disable... 12 | +############################################################### 13 | +enable 14 | *** No breakpoint number given 15 | +enable 1 16 | *** No breakpoint numbered 1. 17 | +info break 18 | No breakpoints. 19 | +enable foo 20 | *** Breakpoint index 'foo' is not a number 21 | +disable 1 22 | No breakpoint numbered 1. 23 | +disable 24 | *** No breakpoint number given. 25 | +info break 26 | No breakpoints. 27 | +################################################################ 28 | +### Try setting breakpoints outside of the file range... 29 | +############################################################### 30 | +break 0 31 | *** End of file 32 | +break 1 33 | *** Blank, doc string, or comment 34 | +break 99 35 | *** End of file 36 | +# 37 | +# list breakpoints 38 | +L 39 | No breakpoints. 40 | +############################################################### 41 | +### *** Test using file:line format on break... 42 | +############################################################### 43 | +break hanoi.py:22 44 | Breakpoint 1 set in file hanoi.py, line 22. 45 | +break ./hanoi.py:22 46 | Breakpoint 2 set in file hanoi.py, line 22. 47 | +break ./hanoi.py:0 48 | *** End of file 49 | +break ./dbg-test1.sh:1955 50 | *** './dbg-test1.sh' not found using sys.path 51 | +info break 52 | Num Type Disp Enb Where 53 | 1 breakpoint keep y at hanoi.py:22 54 | 2 breakpoint keep y at hanoi.py:22 55 | +#### Try deleting breakpoints... 56 | +delete 10 57 | *** No breakpoint numbered 10. 58 | +delete 1 59 | Deleted breakpoint 1 60 | +clear 22 61 | Deleted breakpoint 2 62 | +info break 63 | No breakpoints. 64 | +break 22 65 | Breakpoint 3 set in file hanoi.py, line 22. 66 | +############################################################### 67 | +### *** Test breakpoints with conditions... 68 | +############################################################### 69 | +condition 1 x==0 70 | +### FIXME: there is no condition 2! 71 | +### condition 2 y > 25 72 | +condition 2+2 y > 25 73 | *** No breakpoint numbered 4. 74 | +info break 75 | Num Type Disp Enb Where 76 | 3 breakpoint keep y at hanoi.py:22 77 | +### FIXME: there still is no condition 2 78 | +### condition 2 79 | +condition 4 80 | *** No breakpoint numbered 4. 81 | +info break 82 | Num Type Disp Enb Where 83 | 3 breakpoint keep y at hanoi.py:22 84 | +condition x==1 85 | *** condition command: Expecting a positive integer, got: x==1 86 | +condition bad 87 | *** condition command: Expecting a positive integer, got: bad 88 | +condition 30 y==1 89 | *** No breakpoint numbered 30. 90 | +condition 0 y==1 91 | *** condition command: Expecting a positive integer at least 1, got: 0. 92 | +############################################################### 93 | +### *** Test breakpoints by function name 94 | +############################################################### 95 | +break hanoi 96 | Breakpoint 4 set in file hanoi.py, line 5. 97 | +clear hanoi 98 | Deleted breakpoint 4 99 | +q 100 | -------------------------------------------------------------------------------- /test/data/brkpt1.right: -------------------------------------------------------------------------------- 1 | +############################################################### 2 | +# Test the breakpoint by line number 3 | +############################################################### 4 | +info break 5 | No breakpoints. 6 | +break 30 7 | *** Blank, doc string, or comment 8 | +info break 9 | No breakpoints. 10 | +############################################################### 11 | +### Test enable/disable... 12 | +############################################################### 13 | +enable 14 | *** No breakpoint number given 15 | +enable 1 16 | *** No breakpoint numbered 1. 17 | +info break 18 | No breakpoints. 19 | +enable foo 20 | *** Breakpoint index 'foo' is not a number 21 | +disable 1 22 | No breakpoint numbered 1. 23 | +disable 24 | *** No breakpoint number given. 25 | +info break 26 | No breakpoints. 27 | +################################################################ 28 | +### Try setting breakpoints outside of the file range... 29 | +############################################################### 30 | +break 0 31 | *** End of file 32 | +break 1 33 | *** Blank, doc string, or comment 34 | +break 99 35 | *** End of file 36 | +# 37 | +# list breakpoints 38 | +L 39 | No breakpoints. 40 | +############################################################### 41 | +### *** Test using file:line format on break... 42 | +############################################################### 43 | +break hanoi.py:22 44 | Breakpoint 1 set in file hanoi.py, line 22. 45 | +break ./hanoi.py:22 46 | Breakpoint 2 set in file hanoi.py, line 22. 47 | +break ./hanoi.py:0 48 | *** End of file 49 | +break ./dbg-test1.sh:1955 50 | *** './dbg-test1.sh' not found using sys.path 51 | +info break 52 | Num Type Disp Enb Where 53 | 1 breakpoint keep y at hanoi.py:22 54 | 2 breakpoint keep y at hanoi.py:22 55 | +#### Try deleting breakpoints... 56 | +delete 10 57 | *** No breakpoint numbered 10. 58 | +delete 1 59 | Deleted breakpoint 1 60 | +clear 22 61 | *** No breakpoint at hanoi.py:22. 62 | +info break 63 | No breakpoints. 64 | +break 22 65 | Breakpoint 3 set in file hanoi.py, line 22. 66 | +############################################################### 67 | +### *** Test breakpoints with conditions... 68 | +############################################################### 69 | +condition 1 x==0 70 | +### FIXME: there is no condition 2! 71 | +### condition 2 y > 25 72 | +condition 2+2 y > 25 73 | *** No breakpoint numbered 4. 74 | +info break 75 | Num Type Disp Enb Where 76 | 3 breakpoint keep y at hanoi.py:22 77 | +### FIXME: there still is no condition 2 78 | +### condition 2 79 | +condition 4 80 | *** No breakpoint numbered 4. 81 | +info break 82 | Num Type Disp Enb Where 83 | 3 breakpoint keep y at hanoi.py:22 84 | +condition x==1 85 | *** condition command: Expecting a positive integer, got: x==1 86 | +condition bad 87 | *** condition command: Expecting a positive integer, got: bad 88 | +condition 30 y==1 89 | *** No breakpoint numbered 30. 90 | +condition 0 y==1 91 | *** condition command: Expecting a positive integer at least 1, got: 0. 92 | +############################################################### 93 | +### *** Test breakpoints by function name 94 | +############################################################### 95 | +break hanoi 96 | Breakpoint 4 set in file hanoi.py, line 5. 97 | +clear hanoi 98 | Deleted breakpoint 4 99 | +q 100 | -------------------------------------------------------------------------------- /test/test-with.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | # $Id: test-with.py.in,v 1.7 2008/12/10 13:31:26 rockyb Exp $ -*- Python -*- 3 | """Unit test of the bug in using 'info local' when inside a "with" command.""" 4 | import difflib, os, time, sys, unittest 5 | 6 | top_builddir = "@top_builddir@" 7 | if top_builddir[-1] != os.path.sep: 8 | top_builddir += os.path.sep 9 | sys.path.insert(0, os.path.join(top_builddir, 'pydb')) 10 | top_srcdir = "@top_srcdir@" 11 | if top_srcdir[-1] != os.path.sep: 12 | top_srcdir += os.path.sep 13 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 14 | 15 | builddir = "@builddir@" 16 | if builddir[-1] != os.path.sep: 17 | builddir += os.path.sep 18 | 19 | srcdir = "@srcdir@" 20 | if srcdir[-1] != os.path.sep: 21 | srcdir += os.path.sep 22 | 23 | pydir = os.path.join(top_builddir, "pydb") 24 | pydb_short = "pydb.py" 25 | pydb_path = os.path.join(pydir, pydb_short) 26 | 27 | def run_debugger(testname, pythonfile, pydb_opts='', args='', rightfile=None, 28 | need_26=False): 29 | global srcdir, builddir, pydir 30 | 31 | if rightfile is None: 32 | rightfile = os.path.join(builddir, 'data', "%s.right" % testname) 33 | 34 | os.environ['PYTHONPATH']=os.pathsep.join(sys.path) 35 | cmdfile = os.path.join(srcdir, "%s.cmd" % testname) 36 | outfile = "%s.out" % testname 37 | outfile_opt = '--output=%s ' % outfile 38 | 39 | # print "builddir: %s, cmdfile: %s, outfile: %s, rightfile: %s" % \ 40 | # (builddir, cmdfile, outfile, rightfile) 41 | 42 | if os.path.exists(outfile): os.unlink(outfile) 43 | 44 | cmd = "%s --command %s %s %s %s %s" % \ 45 | (pydb_path, cmdfile, outfile_opt, pydb_opts, args, pythonfile) 46 | 47 | os.system(cmd) 48 | fromfile = rightfile 49 | fromdate = time.ctime(os.stat(fromfile).st_mtime) 50 | fromlines = open(fromfile, 'U').readlines()[0:-1] 51 | tofile = outfile 52 | todate = time.ctime(os.stat(tofile).st_mtime) 53 | tolines = open(tofile, 'U').readlines()[0:-1] 54 | if not need_26: 55 | tolines[4]= tolines[4][0:74] + "\n" 56 | diff = list(difflib.unified_diff(fromlines, tolines, fromfile, 57 | tofile, fromdate, todate)) 58 | if len(diff) == 0: 59 | os.unlink(outfile) 60 | for line in diff: 61 | print line, 62 | return len(diff) == 0 63 | 64 | class PdbTests(unittest.TestCase): 65 | 66 | def test_with(self): 67 | """Test running bug running "info local" inside a "with" command""" 68 | if sys.hexversion >= 0x02050000: 69 | if sys.hexversion >= 0x02060000: 70 | need_26 = True 71 | rightfile = os.path.join(srcdir, 'data', 72 | "withbug-2.6.right") 73 | else: 74 | need_26 = False 75 | rightfile = os.path.join(srcdir, 'data', 76 | "withbug.right") 77 | result=run_debugger(testname='withbug', 78 | pythonfile='%swithbug.py' % srcdir, 79 | pydb_opts='--basename', 80 | rightfile=rightfile, need_26=need_26) 81 | self.assertEqual(True, result, "pydb 'withbug' command comparision") 82 | self.assertTrue(True, 'With test skipped - not 2.5') 83 | return 84 | 85 | if __name__ == "__main__": 86 | unittest.main() 87 | -------------------------------------------------------------------------------- /test/data/tracetest-2.4-final.right: -------------------------------------------------------------------------------- 1 | (/tmp/pydb-1.23cvs/test/settrace.py:51): 2 | 51 hanoi(n, "a", "b", "c") 3 | -> 0 in file 'settrace.py' at line 51 4 | 46 'continue'] 5 | 47 6 | 48 import pydb 7 | 49 pydb.debugger(dbg_cmds) 8 | 50 9 | 51 -> hanoi(n, "a", "b", "c") 10 | [EOF] 11 | --Call level -5 12 | (settrace.py:14): hanoi 13 | 14 def hanoi(n,a,b,c): 14 | (settrace.py:15): hanoi 15 | 15 if n-1 > 0: 16 | -> 0 hanoi(n=3, a='a', b='b', c='c') called from file 'settrace.py' at line 15 17 | ## 1 in file 'settrace.py' at line 51 18 | a = 'a' 19 | c = 'c' 20 | b = 'b' 21 | n = 3 22 | (settrace.py:16): hanoi 23 | + 16 hanoi(n-1, a, c, b) 24 | --Call level -4 25 | (settrace.py:14): hanoi 26 | + 14 def hanoi(n,a,b,c): 27 | (settrace.py:15): hanoi 28 | + 15 if n-1 > 0: 29 | (settrace.py:16): hanoi 30 | + 16 hanoi(n-1, a, c, b) 31 | --Call level -3 32 | (settrace.py:14): hanoi 33 | + 14 def hanoi(n,a,b,c): 34 | (settrace.py:15): hanoi 35 | + 15 if n-1 > 0: 36 | (settrace.py:17): hanoi 37 | + 17 print "Move disk %s to %s" % (a, b) 38 | Move disk a to b 39 | (settrace.py:18): hanoi 40 | + 18 if n-1 > 0: 41 | (settrace.py:18): hanoi 42 | + 18 if n-1 > 0: 43 | (settrace.py:17): hanoi 44 | + 17 print "Move disk %s to %s" % (a, b) 45 | Move disk a to c 46 | (settrace.py:18): hanoi 47 | + 18 if n-1 > 0: 48 | (settrace.py:19): hanoi 49 | + 19 hanoi(n-1, c, b, a) 50 | --Call level -3 51 | (settrace.py:14): hanoi 52 | + 14 def hanoi(n,a,b,c): 53 | (settrace.py:15): hanoi 54 | + 15 if n-1 > 0: 55 | (settrace.py:17): hanoi 56 | + 17 print "Move disk %s to %s" % (a, b) 57 | Move disk b to c 58 | (settrace.py:18): hanoi 59 | + 18 if n-1 > 0: 60 | (settrace.py:18): hanoi 61 | + 18 if n-1 > 0: 62 | (settrace.py:19): hanoi 63 | + 19 hanoi(n-1, c, b, a) 64 | (settrace.py:17): hanoi 65 | + 17 print "Move disk %s to %s" % (a, b) 66 | Move disk a to b 67 | (settrace.py:18): hanoi 68 | + 18 if n-1 > 0: 69 | (settrace.py:19): hanoi 70 | + 19 hanoi(n-1, c, b, a) 71 | --Call level -4 72 | (settrace.py:14): hanoi 73 | + 14 def hanoi(n,a,b,c): 74 | (settrace.py:15): hanoi 75 | + 15 if n-1 > 0: 76 | (settrace.py:16): hanoi 77 | + 16 hanoi(n-1, a, c, b) 78 | --Call level -3 79 | (settrace.py:14): hanoi 80 | + 14 def hanoi(n,a,b,c): 81 | (settrace.py:15): hanoi 82 | + 15 if n-1 > 0: 83 | (settrace.py:17): hanoi 84 | + 17 print "Move disk %s to %s" % (a, b) 85 | Move disk c to a 86 | (settrace.py:18): hanoi 87 | + 18 if n-1 > 0: 88 | (settrace.py:18): hanoi 89 | + 18 if n-1 > 0: 90 | (settrace.py:17): hanoi 91 | + 17 print "Move disk %s to %s" % (a, b) 92 | Move disk c to b 93 | (settrace.py:18): hanoi 94 | + 18 if n-1 > 0: 95 | (settrace.py:19): hanoi 96 | + 19 hanoi(n-1, c, b, a) 97 | --Call level -3 98 | (settrace.py:14): hanoi 99 | + 14 def hanoi(n,a,b,c): 100 | (settrace.py:15): hanoi 101 | + 15 if n-1 > 0: 102 | (settrace.py:17): hanoi 103 | + 17 print "Move disk %s to %s" % (a, b) 104 | Move disk a to b 105 | (settrace.py:18): hanoi 106 | + 18 if n-1 > 0: 107 | (settrace.py:18): hanoi 108 | + 18 if n-1 > 0: 109 | (settrace.py:19): hanoi 110 | + 19 hanoi(n-1, c, b, a) 111 | (settrace.py:19): hanoi 112 | + 19 hanoi(n-1, c, b, a) 113 | (settrace.py:51): 114 | + 51 hanoi(n, "a", "b", "c") 115 | -------------------------------------------------------------------------------- /test/data/dbgcall-2.5.right: -------------------------------------------------------------------------------- 1 | (/src/external-vcs/pydb/test/dbgcall.py:17): 2 | 17 if __name__=='__main__': 3 | (dbgcall.py:18): 4 | + 18 i_args=len(sys.argv) 5 | (dbgcall.py:19): 6 | + 19 if i_args != 1 and i_args != 2: 7 | (dbgcall.py:23): 8 | + 23 n=3 9 | (dbgcall.py:24): 10 | + 24 sys.settrace(None) 11 | (dbgcall.py:34): 12 | + 34 if n < 1 or n > 100: 13 | (dbgcall.py:38): 14 | + 38 hanoi(n, "a", "b", "c") 15 | --Call level -5 16 | (dbgcall.py:10): hanoi 17 | + 10 def hanoi(n,a,b,c): 18 | (dbgcall.py:11): hanoi 19 | + 11 if n-1 > 0: 20 | (dbgcall.py:12): hanoi 21 | + 12 hanoi(n-1, a, c, b) 22 | --Call level -4 23 | (dbgcall.py:10): hanoi 24 | + 10 def hanoi(n,a,b,c): 25 | (dbgcall.py:11): hanoi 26 | + 11 if n-1 > 0: 27 | (dbgcall.py:12): hanoi 28 | + 12 hanoi(n-1, a, c, b) 29 | --Call level -3 30 | (dbgcall.py:10): hanoi 31 | + 10 def hanoi(n,a,b,c): 32 | (dbgcall.py:11): hanoi 33 | + 11 if n-1 > 0: 34 | (dbgcall.py:13): hanoi 35 | + 13 print "Move disk %s to %s" % (a, b) 36 | Move disk a to b 37 | (dbgcall.py:14): hanoi 38 | + 14 if n-1 > 0: 39 | (dbgcall.py:14): hanoi 40 | + 14 if n-1 > 0: 41 | (dbgcall.py:13): hanoi 42 | + 13 print "Move disk %s to %s" % (a, b) 43 | Move disk a to c 44 | (dbgcall.py:14): hanoi 45 | + 14 if n-1 > 0: 46 | (dbgcall.py:15): hanoi 47 | + 15 hanoi(n-1, c, b, a) 48 | --Call level -3 49 | (dbgcall.py:10): hanoi 50 | + 10 def hanoi(n,a,b,c): 51 | (dbgcall.py:11): hanoi 52 | + 11 if n-1 > 0: 53 | (dbgcall.py:13): hanoi 54 | + 13 print "Move disk %s to %s" % (a, b) 55 | Move disk b to c 56 | (dbgcall.py:14): hanoi 57 | + 14 if n-1 > 0: 58 | (dbgcall.py:14): hanoi 59 | + 14 if n-1 > 0: 60 | (dbgcall.py:15): hanoi 61 | + 15 hanoi(n-1, c, b, a) 62 | (dbgcall.py:13): hanoi 63 | + 13 print "Move disk %s to %s" % (a, b) 64 | 'continued' 65 | Move disk a to b 66 | (dbgcall.py:14): hanoi 67 | + 14 if n-1 > 0: 68 | (dbgcall.py:15): hanoi 69 | + 15 hanoi(n-1, c, b, a) 70 | --Call level -4 71 | (dbgcall.py:10): hanoi 72 | + 10 def hanoi(n,a,b,c): 73 | (dbgcall.py:11): hanoi 74 | + 11 if n-1 > 0: 75 | (dbgcall.py:12): hanoi 76 | + 12 hanoi(n-1, a, c, b) 77 | --Call level -3 78 | (dbgcall.py:10): hanoi 79 | + 10 def hanoi(n,a,b,c): 80 | (dbgcall.py:11): hanoi 81 | + 11 if n-1 > 0: 82 | (dbgcall.py:13): hanoi 83 | + 13 print "Move disk %s to %s" % (a, b) 84 | Move disk c to a 85 | (dbgcall.py:14): hanoi 86 | + 14 if n-1 > 0: 87 | (dbgcall.py:14): hanoi 88 | + 14 if n-1 > 0: 89 | (dbgcall.py:13): hanoi 90 | + 13 print "Move disk %s to %s" % (a, b) 91 | Move disk c to b 92 | (dbgcall.py:14): hanoi 93 | + 14 if n-1 > 0: 94 | (dbgcall.py:15): hanoi 95 | + 15 hanoi(n-1, c, b, a) 96 | --Call level -3 97 | (dbgcall.py:10): hanoi 98 | + 10 def hanoi(n,a,b,c): 99 | (dbgcall.py:11): hanoi 100 | + 11 if n-1 > 0: 101 | (dbgcall.py:13): hanoi 102 | + 13 print "Move disk %s to %s" % (a, b) 103 | Move disk a to b 104 | (dbgcall.py:14): hanoi 105 | + 14 if n-1 > 0: 106 | (dbgcall.py:14): hanoi 107 | + 14 if n-1 > 0: 108 | (dbgcall.py:15): hanoi 109 | + 15 hanoi(n-1, c, b, a) 110 | (dbgcall.py:15): hanoi 111 | + 15 hanoi(n-1, c, b, a) 112 | (dbgcall.py:38): 113 | + 38 hanoi(n, "a", "b", "c") 114 | -------------------------------------------------------------------------------- /test/data/tracetest-2.5.right: -------------------------------------------------------------------------------- 1 | (/src/external-cvs/pydb/test/settrace.py:51): 2 | 51 hanoi(n, "a", "b", "c") 3 | -> 0 file 'settrace.py' at line 51 4 | 46 'continue'] 5 | 47 6 | 48 import pydb 7 | 49 pydb.debugger(dbg_cmds) 8 | 50 9 | 51 -> hanoi(n, "a", "b", "c") 10 | [EOF] 11 | --Call level -5 12 | (settrace.py:14): hanoi 13 | 14 def hanoi(n,a,b,c): 14 | (settrace.py:15): hanoi 15 | 15 if n-1 > 0: 16 | -> 0 hanoi(n=3, a='a', b='b', c='c') called from file 'settrace.py' at line 15 17 | ## 1 file 'settrace.py' at line 51 18 | a = 'a' 19 | c = 'c' 20 | b = 'b' 21 | n = 3 22 | (settrace.py:16): hanoi 23 | + 16 hanoi(n-1, a, c, b) 24 | --Call level -4 25 | (settrace.py:14): hanoi 26 | + 14 def hanoi(n,a,b,c): 27 | (settrace.py:15): hanoi 28 | + 15 if n-1 > 0: 29 | (settrace.py:16): hanoi 30 | + 16 hanoi(n-1, a, c, b) 31 | --Call level -3 32 | (settrace.py:14): hanoi 33 | + 14 def hanoi(n,a,b,c): 34 | (settrace.py:15): hanoi 35 | + 15 if n-1 > 0: 36 | (settrace.py:17): hanoi 37 | + 17 print "Move disk %s to %s" % (a, b) 38 | Move disk a to b 39 | (settrace.py:18): hanoi 40 | + 18 if n-1 > 0: 41 | (settrace.py:18): hanoi 42 | + 18 if n-1 > 0: 43 | (settrace.py:17): hanoi 44 | + 17 print "Move disk %s to %s" % (a, b) 45 | Move disk a to c 46 | (settrace.py:18): hanoi 47 | + 18 if n-1 > 0: 48 | (settrace.py:19): hanoi 49 | + 19 hanoi(n-1, c, b, a) 50 | --Call level -3 51 | (settrace.py:14): hanoi 52 | + 14 def hanoi(n,a,b,c): 53 | (settrace.py:15): hanoi 54 | + 15 if n-1 > 0: 55 | (settrace.py:17): hanoi 56 | + 17 print "Move disk %s to %s" % (a, b) 57 | Move disk b to c 58 | (settrace.py:18): hanoi 59 | + 18 if n-1 > 0: 60 | (settrace.py:18): hanoi 61 | + 18 if n-1 > 0: 62 | (settrace.py:19): hanoi 63 | + 19 hanoi(n-1, c, b, a) 64 | (settrace.py:17): hanoi 65 | + 17 print "Move disk %s to %s" % (a, b) 66 | Move disk a to b 67 | (settrace.py:18): hanoi 68 | + 18 if n-1 > 0: 69 | (settrace.py:19): hanoi 70 | + 19 hanoi(n-1, c, b, a) 71 | --Call level -4 72 | (settrace.py:14): hanoi 73 | + 14 def hanoi(n,a,b,c): 74 | (settrace.py:15): hanoi 75 | + 15 if n-1 > 0: 76 | (settrace.py:16): hanoi 77 | + 16 hanoi(n-1, a, c, b) 78 | --Call level -3 79 | (settrace.py:14): hanoi 80 | + 14 def hanoi(n,a,b,c): 81 | (settrace.py:15): hanoi 82 | + 15 if n-1 > 0: 83 | (settrace.py:17): hanoi 84 | + 17 print "Move disk %s to %s" % (a, b) 85 | Move disk c to a 86 | (settrace.py:18): hanoi 87 | + 18 if n-1 > 0: 88 | (settrace.py:18): hanoi 89 | + 18 if n-1 > 0: 90 | (settrace.py:17): hanoi 91 | + 17 print "Move disk %s to %s" % (a, b) 92 | Move disk c to b 93 | (settrace.py:18): hanoi 94 | + 18 if n-1 > 0: 95 | (settrace.py:19): hanoi 96 | + 19 hanoi(n-1, c, b, a) 97 | --Call level -3 98 | (settrace.py:14): hanoi 99 | + 14 def hanoi(n,a,b,c): 100 | (settrace.py:15): hanoi 101 | + 15 if n-1 > 0: 102 | (settrace.py:17): hanoi 103 | + 17 print "Move disk %s to %s" % (a, b) 104 | Move disk a to b 105 | (settrace.py:18): hanoi 106 | + 18 if n-1 > 0: 107 | (settrace.py:18): hanoi 108 | + 18 if n-1 > 0: 109 | (settrace.py:19): hanoi 110 | + 19 hanoi(n-1, c, b, a) 111 | (settrace.py:19): hanoi 112 | + 19 hanoi(n-1, c, b, a) 113 | (settrace.py:51): 114 | + 51 hanoi(n, "a", "b", "c") 115 | -------------------------------------------------------------------------------- /test/data/tracetest.right: -------------------------------------------------------------------------------- 1 | --Return-- 2 | --Call-- 3 | (/export/home/src/build/pydb-1.20/test/settrace.py:14): hanoi 4 | -> 0 hanoi(n=3, a='a', b='b', c='c') called from file 'settrace.py' at line 14 5 | ## 1 in file 'settrace.py' at line 51 6 | 9 top_srcdir = ".." 7 | 10 if top_srcdir[-1] != os.path.sep: 8 | 11 top_srcdir += os.path.sep 9 | 12 sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 10 | 13 11 | 14 -> def hanoi(n,a,b,c): 12 | 15 if n-1 > 0: 13 | 16 hanoi(n-1, a, c, b) 14 | 17 print "Move disk %s to %s" % (a, b) 15 | 18 if n-1 > 0: 16 | (settrace.py:15): hanoi 17 | (settrace.py:16): hanoi 18 | -> 0 hanoi(n=3, a='a', b='b', c='c') called from file 'settrace.py' at line 16 19 | ## 1 in file 'settrace.py' at line 51 20 | a = 'a' 21 | c = 'c' 22 | b = 'b' 23 | n = 3 24 | --Call-- 25 | (settrace.py:14): hanoi 26 | +def hanoi(n,a,b,c): 27 | (settrace.py:15): hanoi 28 | + if n-1 > 0: 29 | (settrace.py:16): hanoi 30 | + hanoi(n-1, a, c, b) 31 | --Call-- 32 | (settrace.py:14): hanoi 33 | +def hanoi(n,a,b,c): 34 | (settrace.py:15): hanoi 35 | + if n-1 > 0: 36 | (settrace.py:17): hanoi 37 | + print "Move disk %s to %s" % (a, b) 38 | Move disk a to b 39 | (settrace.py:18): hanoi 40 | + if n-1 > 0: 41 | --Return-- 42 | (settrace.py:18): hanoi 43 | + if n-1 > 0: 44 | (settrace.py:17): hanoi 45 | + print "Move disk %s to %s" % (a, b) 46 | Move disk a to c 47 | (settrace.py:18): hanoi 48 | + if n-1 > 0: 49 | (settrace.py:19): hanoi 50 | + hanoi(n-1, c, b, a) 51 | --Call-- 52 | (settrace.py:14): hanoi 53 | +def hanoi(n,a,b,c): 54 | (settrace.py:15): hanoi 55 | + if n-1 > 0: 56 | (settrace.py:17): hanoi 57 | + print "Move disk %s to %s" % (a, b) 58 | Move disk b to c 59 | (settrace.py:18): hanoi 60 | + if n-1 > 0: 61 | --Return-- 62 | (settrace.py:18): hanoi 63 | + if n-1 > 0: 64 | --Return-- 65 | (settrace.py:19): hanoi 66 | + hanoi(n-1, c, b, a) 67 | (settrace.py:17): hanoi 68 | + print "Move disk %s to %s" % (a, b) 69 | Move disk a to b 70 | (settrace.py:18): hanoi 71 | + if n-1 > 0: 72 | (settrace.py:19): hanoi 73 | + hanoi(n-1, c, b, a) 74 | --Call-- 75 | (settrace.py:14): hanoi 76 | +def hanoi(n,a,b,c): 77 | (settrace.py:15): hanoi 78 | + if n-1 > 0: 79 | (settrace.py:16): hanoi 80 | + hanoi(n-1, a, c, b) 81 | --Call-- 82 | (settrace.py:14): hanoi 83 | +def hanoi(n,a,b,c): 84 | (settrace.py:15): hanoi 85 | + if n-1 > 0: 86 | (settrace.py:17): hanoi 87 | + print "Move disk %s to %s" % (a, b) 88 | Move disk c to a 89 | (settrace.py:18): hanoi 90 | + if n-1 > 0: 91 | --Return-- 92 | (settrace.py:18): hanoi 93 | + if n-1 > 0: 94 | (settrace.py:17): hanoi 95 | + print "Move disk %s to %s" % (a, b) 96 | Move disk c to b 97 | (settrace.py:18): hanoi 98 | + if n-1 > 0: 99 | (settrace.py:19): hanoi 100 | + hanoi(n-1, c, b, a) 101 | --Call-- 102 | (settrace.py:14): hanoi 103 | +def hanoi(n,a,b,c): 104 | (settrace.py:15): hanoi 105 | + if n-1 > 0: 106 | (settrace.py:17): hanoi 107 | + print "Move disk %s to %s" % (a, b) 108 | Move disk a to b 109 | (settrace.py:18): hanoi 110 | + if n-1 > 0: 111 | --Return-- 112 | (settrace.py:18): hanoi 113 | + if n-1 > 0: 114 | --Return-- 115 | (settrace.py:19): hanoi 116 | + hanoi(n-1, c, b, a) 117 | --Return-- 118 | (settrace.py:19): hanoi 119 | + hanoi(n-1, c, b, a) 120 | --Return-- 121 | (settrace.py:51): 122 | +hanoi(n, "a", "b", "c") 123 | -------------------------------------------------------------------------------- /test/data/brkpt1t-2.7.right: -------------------------------------------------------------------------------- 1 | --Call level -1 2 | +############################################################### 3 | +# Test the breakpoint by line number 4 | +############################################################### 5 | +info break 6 | No breakpoints. 7 | +break 30 8 | *** Blank, doc string, or comment 9 | +info break 10 | No breakpoints. 11 | +############################################################### 12 | +### Test enable/disable... 13 | +############################################################### 14 | +enable 15 | *** No breakpoint number given 16 | +enable 1 17 | *** No breakpoint numbered 1. 18 | +info break 19 | No breakpoints. 20 | +enable foo 21 | *** Breakpoint index 'foo' is not a number 22 | +disable 1 23 | No breakpoint numbered 1. 24 | +disable 25 | *** No breakpoint number given. 26 | +info break 27 | No breakpoints. 28 | +################################################################ 29 | +### Try setting breakpoints outside of the file range... 30 | +############################################################### 31 | +break 0 32 | *** End of file 33 | +break 1 34 | *** Blank, doc string, or comment 35 | +break 99 36 | *** End of file 37 | +# 38 | +# list breakpoints 39 | +L 40 | No breakpoints. 41 | +############################################################### 42 | +### *** Test using file:line format on break... 43 | +############################################################### 44 | +break hanoi.py:22 45 | Breakpoint 1 set in file hanoi.py, line 22. 46 | +break ./hanoi.py:22 47 | Breakpoint 2 set in file hanoi.py, line 22. 48 | +break ./hanoi.py:0 49 | *** End of file 50 | +break ./dbg-test1.sh:1955 51 | *** './dbg-test1.sh' not found using sys.path 52 | +info break 53 | Num Type Disp Enb Where 54 | 1 breakpoint keep y at hanoi.py:22 55 | 2 breakpoint keep y at hanoi.py:22 56 | +#### Try deleting breakpoints... 57 | +delete 10 58 | *** No breakpoint numbered 10. 59 | +delete 1 60 | Deleted breakpoint 1 61 | +clear 22 62 | Deleted breakpoint 2 63 | +info break 64 | No breakpoints. 65 | +break 22 66 | Breakpoint 3 set in file hanoi.py, line 22. 67 | +############################################################### 68 | +### *** Test breakpoints with conditions... 69 | +############################################################### 70 | +condition 1 x==0 71 | +### FIXME: there is no condition 2! 72 | +### condition 2 y > 25 73 | +condition 2+2 y > 25 74 | *** No breakpoint numbered 4. 75 | +info break 76 | Num Type Disp Enb Where 77 | 3 breakpoint keep y at hanoi.py:22 78 | +### FIXME: there still is no condition 2 79 | +### condition 2 80 | +condition 4 81 | *** No breakpoint numbered 4. 82 | +info break 83 | Num Type Disp Enb Where 84 | 3 breakpoint keep y at hanoi.py:22 85 | +condition x==1 86 | *** condition command: Expecting a positive integer, got: x==1 87 | +condition bad 88 | *** condition command: Expecting a positive integer, got: bad 89 | +condition 30 y==1 90 | *** No breakpoint numbered 30. 91 | +condition 0 y==1 92 | *** condition command: Expecting a positive integer at least 1, got: 0. 93 | +############################################################### 94 | +### *** Test breakpoints by function name 95 | +############################################################### 96 | +break hanoi 97 | Breakpoint 4 set in file hanoi.py, line 5. 98 | +clear hanoi 99 | Deleted breakpoint 4 100 | +q 101 | Requesting exit from MainThread (id -1209805136) 102 | The program exited via sys.exit(). Exit status: 103 | -------------------------------------------------------------------------------- /test/data/brkpt1t.right: -------------------------------------------------------------------------------- 1 | --Call level -1 2 | +############################################################### 3 | +# Test the breakpoint by line number 4 | +############################################################### 5 | +info break 6 | No breakpoints. 7 | +break 30 8 | *** Blank, doc string, or comment 9 | +info break 10 | No breakpoints. 11 | +############################################################### 12 | +### Test enable/disable... 13 | +############################################################### 14 | +enable 15 | *** No breakpoint number given 16 | +enable 1 17 | *** No breakpoint numbered 1. 18 | +info break 19 | No breakpoints. 20 | +enable foo 21 | *** Breakpoint index 'foo' is not a number 22 | +disable 1 23 | No breakpoint numbered 1. 24 | +disable 25 | *** No breakpoint number given. 26 | +info break 27 | No breakpoints. 28 | +################################################################ 29 | +### Try setting breakpoints outside of the file range... 30 | +############################################################### 31 | +break 0 32 | *** End of file 33 | +break 1 34 | *** Blank, doc string, or comment 35 | +break 99 36 | *** End of file 37 | +# 38 | +# list breakpoints 39 | +L 40 | No breakpoints. 41 | +############################################################### 42 | +### *** Test using file:line format on break... 43 | +############################################################### 44 | +break hanoi.py:22 45 | Breakpoint 1 set in file hanoi.py, line 22. 46 | +break ./hanoi.py:22 47 | Breakpoint 2 set in file hanoi.py, line 22. 48 | +break ./hanoi.py:0 49 | *** End of file 50 | +break ./dbg-test1.sh:1955 51 | *** './dbg-test1.sh' not found using sys.path 52 | +info break 53 | Num Type Disp Enb Where 54 | 1 breakpoint keep y at hanoi.py:22 55 | 2 breakpoint keep y at hanoi.py:22 56 | +#### Try deleting breakpoints... 57 | +delete 10 58 | *** No breakpoint numbered 10. 59 | +delete 1 60 | Deleted breakpoint 1 61 | +clear 22 62 | *** No breakpoint at hanoi.py:22. 63 | +info break 64 | No breakpoints. 65 | +break 22 66 | Breakpoint 3 set in file hanoi.py, line 22. 67 | +############################################################### 68 | +### *** Test breakpoints with conditions... 69 | +############################################################### 70 | +condition 1 x==0 71 | +### FIXME: there is no condition 2! 72 | +### condition 2 y > 25 73 | +condition 2+2 y > 25 74 | *** No breakpoint numbered 4. 75 | +info break 76 | Num Type Disp Enb Where 77 | 3 breakpoint keep y at hanoi.py:22 78 | +### FIXME: there still is no condition 2 79 | +### condition 2 80 | +condition 4 81 | *** No breakpoint numbered 4. 82 | +info break 83 | Num Type Disp Enb Where 84 | 3 breakpoint keep y at hanoi.py:22 85 | +condition x==1 86 | *** condition command: Expecting a positive integer, got: x==1 87 | +condition bad 88 | *** condition command: Expecting a positive integer, got: bad 89 | +condition 30 y==1 90 | *** No breakpoint numbered 30. 91 | +condition 0 y==1 92 | *** condition command: Expecting a positive integer at least 1, got: 0. 93 | +############################################################### 94 | +### *** Test breakpoints by function name 95 | +############################################################### 96 | +break hanoi 97 | Breakpoint 4 set in file hanoi.py, line 5. 98 | +clear hanoi 99 | Deleted breakpoint 4 100 | +q 101 | Requesting exit from MainThread (id -1209805136) 102 | The program exited via sys.exit(). Exit status: 103 | -------------------------------------------------------------------------------- /test/data/trace.right: -------------------------------------------------------------------------------- 1 | (hanoi.py:2): 2 | + 2 """Towers of Hanoi""" 3 | (hanoi.py:3): 4 | + 3 import sys 5 | (hanoi.py:5): 6 | + 5 def hanoi(n,a,b,c): 7 | (hanoi.py:12): 8 | + 12 if __name__=='__main__': 9 | (hanoi.py:13): 10 | + 13 i_args=len(sys.argv) 11 | (hanoi.py:14): 12 | + 14 if i_args != 1 and i_args != 2: 13 | (hanoi.py:18): 14 | + 18 n=3 15 | (hanoi.py:20): 16 | + 20 if i_args > 1: 17 | (hanoi.py:27): 18 | + 27 if n < 1 or n > 100: 19 | (hanoi.py:31): 20 | + 31 hanoi(n, "a", "b", "c") 21 | --Call level 0 hanoi(n=3, a='a', b='b', c='c') 22 | (hanoi.py:5): hanoi 23 | + 5 def hanoi(n,a,b,c): 24 | (hanoi.py:6): hanoi 25 | + 6 if n-1 > 0: 26 | (hanoi.py:7): hanoi 27 | + 7 hanoi(n-1, a, c, b) 28 | ----Call level 1 hanoi(n=2, a='a', b='c', c='b') 29 | (hanoi.py:5): hanoi 30 | + 5 def hanoi(n,a,b,c): 31 | (hanoi.py:6): hanoi 32 | + 6 if n-1 > 0: 33 | (hanoi.py:7): hanoi 34 | + 7 hanoi(n-1, a, c, b) 35 | ------Call level 2 hanoi(n=1, a='a', b='b', c='c') 36 | (hanoi.py:5): hanoi 37 | + 5 def hanoi(n,a,b,c): 38 | (hanoi.py:6): hanoi 39 | + 6 if n-1 > 0: 40 | (hanoi.py:8): hanoi 41 | + 8 print "Move disk %s to %s" % (a, b) 42 | (hanoi.py:9): hanoi 43 | + 9 if n-1 > 0: 44 | ------Return from level 2 () 45 | (hanoi.py:9): hanoi 46 | + 9 if n-1 > 0: 47 | (hanoi.py:8): hanoi 48 | + 8 print "Move disk %s to %s" % (a, b) 49 | (hanoi.py:9): hanoi 50 | + 9 if n-1 > 0: 51 | (hanoi.py:10): hanoi 52 | + 10 hanoi(n-1, c, b, a) 53 | ------Call level 2 hanoi(n=1, a='b', b='c', c='a') 54 | (hanoi.py:5): hanoi 55 | + 5 def hanoi(n,a,b,c): 56 | (hanoi.py:6): hanoi 57 | + 6 if n-1 > 0: 58 | (hanoi.py:8): hanoi 59 | + 8 print "Move disk %s to %s" % (a, b) 60 | (hanoi.py:9): hanoi 61 | + 9 if n-1 > 0: 62 | ------Return from level 2 () 63 | (hanoi.py:9): hanoi 64 | + 9 if n-1 > 0: 65 | ----Return from level 1 () 66 | (hanoi.py:10): hanoi 67 | + 10 hanoi(n-1, c, b, a) 68 | (hanoi.py:8): hanoi 69 | + 8 print "Move disk %s to %s" % (a, b) 70 | (hanoi.py:9): hanoi 71 | + 9 if n-1 > 0: 72 | (hanoi.py:10): hanoi 73 | + 10 hanoi(n-1, c, b, a) 74 | ----Call level 1 hanoi(n=2, a='c', b='b', c='a') 75 | (hanoi.py:5): hanoi 76 | + 5 def hanoi(n,a,b,c): 77 | (hanoi.py:6): hanoi 78 | + 6 if n-1 > 0: 79 | (hanoi.py:7): hanoi 80 | + 7 hanoi(n-1, a, c, b) 81 | ------Call level 2 hanoi(n=1, a='c', b='a', c='b') 82 | (hanoi.py:5): hanoi 83 | + 5 def hanoi(n,a,b,c): 84 | (hanoi.py:6): hanoi 85 | + 6 if n-1 > 0: 86 | (hanoi.py:8): hanoi 87 | + 8 print "Move disk %s to %s" % (a, b) 88 | (hanoi.py:9): hanoi 89 | + 9 if n-1 > 0: 90 | ------Return from level 2 () 91 | (hanoi.py:9): hanoi 92 | + 9 if n-1 > 0: 93 | (hanoi.py:8): hanoi 94 | + 8 print "Move disk %s to %s" % (a, b) 95 | (hanoi.py:9): hanoi 96 | + 9 if n-1 > 0: 97 | (hanoi.py:10): hanoi 98 | + 10 hanoi(n-1, c, b, a) 99 | ------Call level 2 hanoi(n=1, a='a', b='b', c='c') 100 | (hanoi.py:5): hanoi 101 | + 5 def hanoi(n,a,b,c): 102 | (hanoi.py:6): hanoi 103 | + 6 if n-1 > 0: 104 | (hanoi.py:8): hanoi 105 | + 8 print "Move disk %s to %s" % (a, b) 106 | (hanoi.py:9): hanoi 107 | + 9 if n-1 > 0: 108 | ------Return from level 2 () 109 | (hanoi.py:9): hanoi 110 | + 9 if n-1 > 0: 111 | ----Return from level 1 () 112 | (hanoi.py:10): hanoi 113 | + 10 hanoi(n-1, c, b, a) 114 | --Return from level 0 () 115 | (hanoi.py:10): hanoi 116 | + 10 hanoi(n-1, c, b, a) 117 | (hanoi.py:31): 118 | + 31 hanoi(n, "a", "b", "c") 119 | (:1): 120 | + -------------------------------------------------------------------------------- /test/data/trace-2.4-final.right: -------------------------------------------------------------------------------- 1 | (hanoi.py:2): 2 | + 2 """Towers of Hanoi""" 3 | (hanoi.py:3): 4 | + 3 import sys 5 | (hanoi.py:5): 6 | + 5 def hanoi(n,a,b,c): 7 | (hanoi.py:12): 8 | + 12 if __name__=='__main__': 9 | (hanoi.py:13): 10 | + 13 i_args=len(sys.argv) 11 | (hanoi.py:14): 12 | + 14 if i_args != 1 and i_args != 2: 13 | (hanoi.py:18): 14 | + 18 n=3 15 | (hanoi.py:20): 16 | + 20 if i_args > 1: 17 | (hanoi.py:27): 18 | + 27 if n < 1 or n > 100: 19 | (hanoi.py:31): 20 | + 31 hanoi(n, "a", "b", "c") 21 | --Call level 0 hanoi(n=3, a='a', b='b', c='c') 22 | (hanoi.py:5): hanoi 23 | + 5 def hanoi(n,a,b,c): 24 | (hanoi.py:6): hanoi 25 | + 6 if n-1 > 0: 26 | (hanoi.py:7): hanoi 27 | + 7 hanoi(n-1, a, c, b) 28 | ----Call level 1 hanoi(n=2, a='a', b='c', c='b') 29 | (hanoi.py:5): hanoi 30 | + 5 def hanoi(n,a,b,c): 31 | (hanoi.py:6): hanoi 32 | + 6 if n-1 > 0: 33 | (hanoi.py:7): hanoi 34 | + 7 hanoi(n-1, a, c, b) 35 | ------Call level 2 hanoi(n=1, a='a', b='b', c='c') 36 | (hanoi.py:5): hanoi 37 | + 5 def hanoi(n,a,b,c): 38 | (hanoi.py:6): hanoi 39 | + 6 if n-1 > 0: 40 | (hanoi.py:8): hanoi 41 | + 8 print "Move disk %s to %s" % (a, b) 42 | (hanoi.py:9): hanoi 43 | + 9 if n-1 > 0: 44 | ------Return from level 2 () 45 | (hanoi.py:9): hanoi 46 | + 9 if n-1 > 0: 47 | (hanoi.py:8): hanoi 48 | + 8 print "Move disk %s to %s" % (a, b) 49 | (hanoi.py:9): hanoi 50 | + 9 if n-1 > 0: 51 | (hanoi.py:10): hanoi 52 | + 10 hanoi(n-1, c, b, a) 53 | ------Call level 2 hanoi(n=1, a='b', b='c', c='a') 54 | (hanoi.py:5): hanoi 55 | + 5 def hanoi(n,a,b,c): 56 | (hanoi.py:6): hanoi 57 | + 6 if n-1 > 0: 58 | (hanoi.py:8): hanoi 59 | + 8 print "Move disk %s to %s" % (a, b) 60 | (hanoi.py:9): hanoi 61 | + 9 if n-1 > 0: 62 | ------Return from level 2 () 63 | (hanoi.py:9): hanoi 64 | + 9 if n-1 > 0: 65 | ----Return from level 1 () 66 | (hanoi.py:10): hanoi 67 | + 10 hanoi(n-1, c, b, a) 68 | (hanoi.py:8): hanoi 69 | + 8 print "Move disk %s to %s" % (a, b) 70 | (hanoi.py:9): hanoi 71 | + 9 if n-1 > 0: 72 | (hanoi.py:10): hanoi 73 | + 10 hanoi(n-1, c, b, a) 74 | ----Call level 1 hanoi(n=2, a='c', b='b', c='a') 75 | (hanoi.py:5): hanoi 76 | + 5 def hanoi(n,a,b,c): 77 | (hanoi.py:6): hanoi 78 | + 6 if n-1 > 0: 79 | (hanoi.py:7): hanoi 80 | + 7 hanoi(n-1, a, c, b) 81 | ------Call level 2 hanoi(n=1, a='c', b='a', c='b') 82 | (hanoi.py:5): hanoi 83 | + 5 def hanoi(n,a,b,c): 84 | (hanoi.py:6): hanoi 85 | + 6 if n-1 > 0: 86 | (hanoi.py:8): hanoi 87 | + 8 print "Move disk %s to %s" % (a, b) 88 | (hanoi.py:9): hanoi 89 | + 9 if n-1 > 0: 90 | ------Return from level 2 () 91 | (hanoi.py:9): hanoi 92 | + 9 if n-1 > 0: 93 | (hanoi.py:8): hanoi 94 | + 8 print "Move disk %s to %s" % (a, b) 95 | (hanoi.py:9): hanoi 96 | + 9 if n-1 > 0: 97 | (hanoi.py:10): hanoi 98 | + 10 hanoi(n-1, c, b, a) 99 | ------Call level 2 hanoi(n=1, a='a', b='b', c='c') 100 | (hanoi.py:5): hanoi 101 | + 5 def hanoi(n,a,b,c): 102 | (hanoi.py:6): hanoi 103 | + 6 if n-1 > 0: 104 | (hanoi.py:8): hanoi 105 | + 8 print "Move disk %s to %s" % (a, b) 106 | (hanoi.py:9): hanoi 107 | + 9 if n-1 > 0: 108 | ------Return from level 2 () 109 | (hanoi.py:9): hanoi 110 | + 9 if n-1 > 0: 111 | ----Return from level 1 () 112 | (hanoi.py:10): hanoi 113 | + 10 hanoi(n-1, c, b, a) 114 | --Return from level 0 () 115 | (hanoi.py:10): hanoi 116 | + 10 hanoi(n-1, c, b, a) 117 | (hanoi.py:31): 118 | + 31 hanoi(n, "a", "b", "c") 119 | (:1): 120 | + -------------------------------------------------------------------------------- /test/data/trace-2.5.right: -------------------------------------------------------------------------------- 1 | (hanoi.py:2): 2 | + 2 """Towers of Hanoi""" 3 | (hanoi.py:3): 4 | + 3 import sys 5 | (hanoi.py:5): 6 | + 5 def hanoi(n,a,b,c): 7 | (hanoi.py:12): 8 | + 12 if __name__=='__main__': 9 | (hanoi.py:13): 10 | + 13 i_args=len(sys.argv) 11 | (hanoi.py:14): 12 | + 14 if i_args != 1 and i_args != 2: 13 | (hanoi.py:18): 14 | + 18 n=3 15 | (hanoi.py:20): 16 | + 20 if i_args > 1: 17 | (hanoi.py:27): 18 | + 27 if n < 1 or n > 100: 19 | (hanoi.py:31): 20 | + 31 hanoi(n, "a", "b", "c") 21 | --Call level 0 hanoi(n=3, a='a', b='b', c='c') 22 | (hanoi.py:5): hanoi 23 | + 5 def hanoi(n,a,b,c): 24 | (hanoi.py:6): hanoi 25 | + 6 if n-1 > 0: 26 | (hanoi.py:7): hanoi 27 | + 7 hanoi(n-1, a, c, b) 28 | ----Call level 1 hanoi(n=2, a='a', b='c', c='b') 29 | (hanoi.py:5): hanoi 30 | + 5 def hanoi(n,a,b,c): 31 | (hanoi.py:6): hanoi 32 | + 6 if n-1 > 0: 33 | (hanoi.py:7): hanoi 34 | + 7 hanoi(n-1, a, c, b) 35 | ------Call level 2 hanoi(n=1, a='a', b='b', c='c') 36 | (hanoi.py:5): hanoi 37 | + 5 def hanoi(n,a,b,c): 38 | (hanoi.py:6): hanoi 39 | + 6 if n-1 > 0: 40 | (hanoi.py:8): hanoi 41 | + 8 print "Move disk %s to %s" % (a, b) 42 | (hanoi.py:9): hanoi 43 | + 9 if n-1 > 0: 44 | ------Return from level 2 () 45 | (hanoi.py:9): hanoi 46 | + 9 if n-1 > 0: 47 | (hanoi.py:8): hanoi 48 | + 8 print "Move disk %s to %s" % (a, b) 49 | (hanoi.py:9): hanoi 50 | + 9 if n-1 > 0: 51 | (hanoi.py:10): hanoi 52 | + 10 hanoi(n-1, c, b, a) 53 | ------Call level 2 hanoi(n=1, a='b', b='c', c='a') 54 | (hanoi.py:5): hanoi 55 | + 5 def hanoi(n,a,b,c): 56 | (hanoi.py:6): hanoi 57 | + 6 if n-1 > 0: 58 | (hanoi.py:8): hanoi 59 | + 8 print "Move disk %s to %s" % (a, b) 60 | (hanoi.py:9): hanoi 61 | + 9 if n-1 > 0: 62 | ------Return from level 2 () 63 | (hanoi.py:9): hanoi 64 | + 9 if n-1 > 0: 65 | ----Return from level 1 () 66 | (hanoi.py:10): hanoi 67 | + 10 hanoi(n-1, c, b, a) 68 | (hanoi.py:8): hanoi 69 | + 8 print "Move disk %s to %s" % (a, b) 70 | (hanoi.py:9): hanoi 71 | + 9 if n-1 > 0: 72 | (hanoi.py:10): hanoi 73 | + 10 hanoi(n-1, c, b, a) 74 | ----Call level 1 hanoi(n=2, a='c', b='b', c='a') 75 | (hanoi.py:5): hanoi 76 | + 5 def hanoi(n,a,b,c): 77 | (hanoi.py:6): hanoi 78 | + 6 if n-1 > 0: 79 | (hanoi.py:7): hanoi 80 | + 7 hanoi(n-1, a, c, b) 81 | ------Call level 2 hanoi(n=1, a='c', b='a', c='b') 82 | (hanoi.py:5): hanoi 83 | + 5 def hanoi(n,a,b,c): 84 | (hanoi.py:6): hanoi 85 | + 6 if n-1 > 0: 86 | (hanoi.py:8): hanoi 87 | + 8 print "Move disk %s to %s" % (a, b) 88 | (hanoi.py:9): hanoi 89 | + 9 if n-1 > 0: 90 | ------Return from level 2 () 91 | (hanoi.py:9): hanoi 92 | + 9 if n-1 > 0: 93 | (hanoi.py:8): hanoi 94 | + 8 print "Move disk %s to %s" % (a, b) 95 | (hanoi.py:9): hanoi 96 | + 9 if n-1 > 0: 97 | (hanoi.py:10): hanoi 98 | + 10 hanoi(n-1, c, b, a) 99 | ------Call level 2 hanoi(n=1, a='a', b='b', c='c') 100 | (hanoi.py:5): hanoi 101 | + 5 def hanoi(n,a,b,c): 102 | (hanoi.py:6): hanoi 103 | + 6 if n-1 > 0: 104 | (hanoi.py:8): hanoi 105 | + 8 print "Move disk %s to %s" % (a, b) 106 | (hanoi.py:9): hanoi 107 | + 9 if n-1 > 0: 108 | ------Return from level 2 () 109 | (hanoi.py:9): hanoi 110 | + 9 if n-1 > 0: 111 | ----Return from level 1 () 112 | (hanoi.py:10): hanoi 113 | + 10 hanoi(n-1, c, b, a) 114 | --Return from level 0 () 115 | (hanoi.py:10): hanoi 116 | + 10 hanoi(n-1, c, b, a) 117 | (hanoi.py:31): 118 | + 31 hanoi(n, "a", "b", "c") 119 | (:1): 120 | + 121 | -------------------------------------------------------------------------------- /test/thread/thread1.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import threading,Queue,time,sys,traceback 3 | 4 | class easy_pool: 5 | def __init__(self,func): 6 | self.Qin = Queue.Queue() 7 | self.Qout = Queue.Queue() 8 | self.Qerr = Queue.Queue() 9 | self.Pool = [] 10 | self.Func=func 11 | def process_queue(self): 12 | flag='ok' 13 | while flag !='stop': 14 | flag,item=self.Qin.get() #will wait here! 15 | if flag=='ok': 16 | try: 17 | self.Qout.put(self.Func(item)) 18 | except: 19 | self.Qerr.put(self.err_msg()) 20 | def start_threads(self,num_threads=5): 21 | for i in range(num_threads): 22 | thread = threading.Thread(target=self.process_queue) 23 | thread.start() 24 | self.Pool.append(thread) 25 | def put(self,data,flag='ok'): 26 | self.Qin.put([flag,data]) 27 | 28 | def get(self): return self.Qout.get() #will wait here! 29 | 30 | def get_errors(self): 31 | try: 32 | while 1: 33 | yield self.Qerr.get_nowait() 34 | except Queue.Empty: 35 | pass 36 | 37 | def get_all(self): 38 | try: 39 | while 1: 40 | yield self.Qout.get_nowait() 41 | except Queue.Empty: 42 | pass 43 | 44 | def stop_threads(self): 45 | for i in range(len(self.Pool)): 46 | self.Qin.put(('stop',None)) 47 | while self.Pool: 48 | time.sleep(0.1) 49 | for index,the_thread in enumerate(self.Pool): 50 | if the_thread.isAlive(): 51 | continue 52 | else: 53 | del self.Pool[index] 54 | break 55 | def run_all(self,asap=None,num_threads=10): 56 | if asap: 57 | self.start_threads(num_threads) 58 | #do nothing until 1st one arrives 59 | #assumes you'll get enough data for the threads not to hang 60 | yield self.get() 61 | 62 | while self.Qin.qsize(): 63 | for i in self.get_all(): 64 | yield i 65 | time.sleep(60) 66 | self.stop_threads() 67 | for i in self.get_all(): 68 | yield i 69 | else: 70 | self.start_threads(num_threads) 71 | self.stop_threads() 72 | for i in self.get_all(): 73 | yield i 74 | def err_msg(self): 75 | trace= sys.exc_info()[2] 76 | try: 77 | exc_value=str(sys.exc_value) 78 | except: 79 | exc_value='' 80 | return str(traceback.format_tb(trace)),str(sys.exc_type),exc_value 81 | def qinfo(self): 82 | return 'in',self.Qin.qsize(),'out',self.Qout.qsize() 83 | 84 | def work1(item): 85 | time.sleep(1) 86 | return 'hi '+item 87 | 88 | t=easy_pool(work1) 89 | for i in ('a','b','c','1'): t.put(i) 90 | for i in t.run_all(): print i 91 | for i in t.get_errors(): print 'error %d' % i 92 | 93 | #This turns on asap and changes the threads to 25 94 | t2=easy_pool(work1) 95 | #add to input queue 96 | for i in ('d','e','f'): t2.put(i) 97 | #start 8 threads 98 | t2.start_threads(8) 99 | #add more to input queue, 7 will make an error 100 | for i in ('aa','bb','cc',7,'dd','ee','ff'): t2.put(i) 101 | 102 | #wait here until a single result arrives 103 | print '1st result', t2.get() 104 | 105 | #get whatever data is available, not waiting 106 | for i in t2.get_all(): print i 107 | for i in t2.get_errors(): print i 108 | 109 | #decide you've done enough work and shutdown the threads 110 | t2.stop_threads() 111 | 112 | #now threads have stopped, get remaining available data 113 | for i in t2.get_all(): print i 114 | for i in t2.get_errors(): print i 115 | -------------------------------------------------------------------------------- /test/test-fns.py.in: -------------------------------------------------------------------------------- 1 | #!@PYTHON@ -t 2 | # $Id: test-fns.py.in,v 1.1 2007/11/01 09:20:31 rockyb Exp $ -*- Python -*- 3 | 4 | # This unit test doesn't use any of the debugger code. It is meant solely 5 | # to test the connection classes. 6 | 7 | import os, sys, thread, time, unittest 8 | 9 | top_builddir = "@top_builddir@" 10 | if top_builddir[-1] != os.path.sep: 11 | top_builddir += os.path.sep 12 | sys.path.insert(0, os.path.join(top_builddir, 'pydb')) 13 | top_srcdir = "@top_srcdir@" 14 | if top_srcdir[-1] != os.path.sep: 15 | top_srcdir += os.path.sep 16 | sys.path.insert(0, os.path.join(top_srcdir, 'pydb')) 17 | 18 | import fns 19 | 20 | class TestFns(unittest.TestCase): 21 | 22 | def test_show_onoff(self): 23 | """Test of fns.show_onoff()""" 24 | self.assertEqual(fns.show_onoff(True), 'on') 25 | self.assertEqual(fns.show_onoff(False), 'off') 26 | 27 | def test_printf(self): 28 | """Test of fns.printf()""" 29 | self.assertEqual( fns.printf(31, "/o"), '037') 30 | self.assertEqual( fns.printf(31, "/t"), '00011111') 31 | self.assertEqual( fns.printf(33, "/c"), '!') 32 | self.assertEqual( fns.printf(33, "/x"), '0x21') 33 | 34 | def test_file_pyc2py(self): 35 | """Test file_pyc2py()""" 36 | self.assertEqual( "gcd.py", fns.file_pyc2py("gcd.pyo"), 37 | "xx.pyo should transform to xx.py") 38 | self.assertEqual( "/tmp/gcd.py", fns.file_pyc2py("/tmp/gcd.pyc"), 39 | "xx.pyc should transform to xx.py") 40 | self.assertEqual( "../gcd.py", fns.file_pyc2py("../gcd.py"), 41 | "Test null transform") 42 | 43 | def test_whence_file(self): 44 | """Test whence_file()""" 45 | fname = os.path.join(os.curdir, "thisfilenotthere") 46 | self.assertEqual( fname, fns.whence_file(fname), 47 | "whence should not change due to sep in name" ) 48 | 49 | os.environ["PATH"] = "" 50 | fname = "gcd.py" 51 | self.assertEqual( fname, fns.whence_file(fname), 52 | "Test of whence_file path expansion - not found " ) 53 | test_dir = os.path.join(top_srcdir, "test") 54 | os.environ["PATH"] = test_dir 55 | fname = "gcd.py" 56 | expand_fname = os.path.join(test_dir, fname) 57 | self.assertEqual( expand_fname, fns.whence_file(fname), 58 | "Test of whence_file path expansion - found" ) 59 | 60 | def test_columnize(self): 61 | self.assertEqual("['one', 'two', 'three']", 62 | fns.columnize_array(["one", "two", "three"])) 63 | self.assertEqual("[oneitem]", fns.columnize_array(["oneitem"])) 64 | self.assertEqual( 65 | """['one', 'two', 'three', '4ne', '5wo', '6hree', '7ne', '8wo', '9hree' 66 | '10e', '11o', '12ree', '13e', '14o', '15ree', '16e', '17o', '18ree' 67 | '19e', '20o', '21ree', '22e', '23o', '24ree', '25e', '26o', '27ree' 68 | '28e', '29o', '30ree', '31e', '32o', '33ree', '34e', '35o', '36ree' 69 | '37e', '38o', '39ree', '40e', '41o', '42ree', '43e', '44o', '45ree' 70 | '46e', '47o', '48ree', 'one'...]""", 71 | fns.columnize_array([ 72 | "one", "two", "three", 73 | "4ne", "5wo", "6hree", 74 | "7ne", "8wo", "9hree", 75 | "10e", "11o", "12ree", 76 | "13e", "14o", "15ree", 77 | "16e", "17o", "18ree", 78 | "19e", "20o", "21ree", 79 | "22e", "23o", "24ree", 80 | "25e", "26o", "27ree", 81 | "28e", "29o", "30ree", 82 | "31e", "32o", "33ree", 83 | "34e", "35o", "36ree", 84 | "37e", "38o", "39ree", 85 | "40e", "41o", "42ree", 86 | "43e", "44o", "45ree", 87 | "46e", "47o", "48ree", 88 | "one", "two", "three"])) 89 | 90 | 91 | if __name__ == '__main__': 92 | unittest.main() 93 | --------------------------------------------------------------------------------