From: "Ken Manheimer" <ken.manheimer@gmail.com>
To: "Nick Roberts" <nickrob@snap.net.nz>
Cc: skip montanaro <skip@pobox.com>,
rms@gnu.org, cyd@stupidchicken.com, Barry Warsaw <barry@wooz.org>,
emacs-devel@gnu.org, sdl.web@gmail.com
Subject: Re: python.el fixes for Emacs 22
Date: Wed, 20 Feb 2008 19:20:53 -0500 [thread overview]
Message-ID: <2cd46e7f0802201620o6b6190dcmb53805bbb30aa3ec@mail.gmail.com> (raw)
In-Reply-To: <18363.29854.271108.937443@kahikatea.snap.net.nz>
On Feb 19, 2008 7:30 PM, Nick Roberts <nickrob@snap.net.nz> wrote:
> > in any case, i *do* want to see pdb tracking included in whichever.
> > as the author of the feature, i should be able to authorize its use
> > wherever, and am frustrated with the twisty turns of events that have
> > prevented that.
> >
> > If you wrote the original version, we can install that
> > with papers from you alone. (Just say that you consider
> > it a change to Emacs and your assignment will cover it.)
> [...]
> As Ken is the author of these changes, has an assignment for Emacs and is keen
> to see them installed, to move things along I have installed them.
yay! thanks!
> My understanding is that the advantage of Pdbtrack is that you can start to
> debug on the fly. There's a small example attached below using a file called
> fibo.py (which I probably pinched from somewhere, but I can't remember where).
> However, as I've said before I'm not a Python programmer and Ken can probably
> explain better.
the crucial thing is that, with an interactive language, you're much
more able, and more likely, to trigger debugging whenever you need to
do so. the idea of having to switch to a special debugging
environment (like gdb/gud) is a holdover from dealing with compiled
code, and means you have to restart your program and resurrect the
context where the problem happened. that often is a terrible hassle
and loss of context. (imagine if you had to restart emacs to debug
elisp. pdb tracking is the minimalist equivalent of edebug.)
instead, pdb tracking makes debugger sensitivity available at every moment.
the way you've implemented it, you put the comint hook only in the
python-shell. the thing is, python programs aren't only run from
python-shell. in fact, many python programs and servers are usually
launched as regular commands, from bash shells. in python-mode.el,
pdb tracking is hooked into all comint shells, and i would like to see
that same thing in the python.el version.
the way i most commonly use it, nowadays, is with python-based
servers, like zope, which i launch as bash shell commands in
non-forking "development" mode. the server runs normally until i
arrange for a pdb.set_trace() to be hit, or i have it rigged to go to
pdb for uncaught exceptions. in many cases i can edit code to add the
set_trace() on the fly, in the filesystem or in application-resident
storage. the debugging traces show up in the shell where i launched
the server, and pdb tracking kicks in.
there's a provision, not yet ported to the python.el version, which
handles the case where the traced script doesn't actually live in the
local filesystem. in this case, when pdb tracking is unable to find
the script according to indicated path, it looks for a python-mode
buffer with the same file name as the target, and uses that. this is
a very general approach that works with stored or remote procedures in
any application, not just zope.
there's one further, much smaller tweak to add. more recent versions
of python-mode (than the one you evidently were using) provide for
recursive debugging, where you can delve into an arbitrary statement
in the midst of debugging something else, and return to where you
started. the regular expressions need to be adjusted to account for
that situation
(i have wanted to mention this approach to instrumenting emacs as a
debugging environment for a long time, particularly at times when
rejiggering of gud was being discussed. pdb tracking features are
pretty minimal - it's just maintenance of the arrow overlay in the
target file, as you step through - but the original implementation was
just 150 lines of code, and over half of those were comments. gud
does a lot more - but it's many orders of magnitude larger. i think
this more loosely coupled approach may be a lot more useful and
efficient particularly for interpreted languages.)
> Note that python-shell is similar to run-python and one should probably
> eventually subsume the other.
>
> So, all credit to Ken, complaints to me... no, what the heck, give Ken your
> grief too!
>
> More seriously, this is only on the trunk and I can always revert these changes
> if there are problems.
>
> Enjoy!
>
> Ken,
>
> Have you got write access yet?
yes.
i'm hoping to have time to work on this more, hopefully tomorrow or
friday. i'd like to put in all the features i've described (though i
certainly wouldn't mind someone else beating me to it, if anyone is so
inclined), and check them in to the trunk. let me know if you there
are any objections.
also, i've also been talking with barry and skip, who would also be
interested in seeing the python mode versions converge. i do see that
python-mode.el is actively maintained - it's current with the
pre-release python 3.0, and it looks like a much more complete
language mode than python.el. would there be interest in helping to
get this convergence? is python.el actively maintained, and if so,
would the maintainers be interested in helping consolidate the
versions?
ken
> --
> Nick http://www.inet.net.nz/~nickrob
> ---------------------------------------
>
> # Fibonacci numbers module (fibo.py)
>
> def fib (n): # write Fibonacci series up to n
> a, b = 0, 1
> while b < n:
> print b,
> a, b = b, a+b
>
> def fib2 (n): # return Fibonacci series up to n
> result = []
> a, b = 0, 1
> while b < n:
> result.append (b)
> a, b = b, a+b
> return result
>
> ---------------------------------------
>
> Pdbtrack:
>
> M-x python-shell (note doesn't use run-python)
>
> Python 2.5.1c1 (release25-maint, Apr 12 2007, 21:00:25)
> [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import pdb
> >>> import fibo
> >>> pdb.run ("fibo.fib(1000)")
> > <string>(1)<module>()
> (Pdb) b fibo.py:5
> Breakpoint 1 at /home/nickrob/python/fibo.py:5
> (Pdb) c
> > /home/nickrob/python/fibo.py(5)fib()
> -> while b < n:
> (Pdb)
>
> Source should appear in buffer with overlay arrow.
>
--
ken
http://myriadicity.net
next prev parent reply other threads:[~2008-02-21 0:20 UTC|newest]
Thread overview: 81+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-11 13:34 python.el fixes for Emacs 22 Richard Stallman
2008-02-11 15:15 ` Stefan Monnier
2008-02-11 21:10 ` Richard Stallman
2008-02-12 3:04 ` Stefan Monnier
2008-02-12 17:44 ` Richard Stallman
2008-02-12 21:40 ` Stefan Monnier
2008-02-13 16:32 ` Richard Stallman
2008-02-13 19:19 ` Stefan Monnier
2008-02-14 0:36 ` Chong Yidong
2008-02-14 0:51 ` Miles Bader
2008-02-14 1:56 ` Leo
2008-02-14 18:11 ` Richard Stallman
2008-02-14 23:42 ` Leo
2008-02-15 0:01 ` Nick Roberts
2008-02-15 0:08 ` Leo
2008-02-15 0:17 ` Miles Bader
2008-02-15 2:10 ` Nick Roberts
2008-02-15 17:57 ` Ken Manheimer
2008-02-16 5:53 ` Richard Stallman
2008-02-16 8:18 ` Leo
2008-02-16 8:35 ` Miles Bader
2008-02-16 14:45 ` Stefan Monnier
2008-02-16 14:51 ` Miles Bader
2008-02-17 3:44 ` Stephen J. Turnbull
2008-02-17 13:22 ` Richard Stallman
2008-02-17 13:26 ` Piet van Oostrum
2008-02-15 12:59 ` Richard Stallman
2008-02-15 13:27 ` David Kastrup
2008-02-15 17:43 ` Ken Manheimer
2008-02-15 21:47 ` Nick Roberts
2008-02-15 22:21 ` Ken Manheimer
2008-02-15 23:57 ` Nick Roberts
2008-02-16 0:22 ` Ken Manheimer
2008-02-16 0:39 ` python.el versus python-mode.el [was Re: python.el fixes for Emacs 22] Glenn Morris
2008-02-17 13:22 ` python.el fixes for Emacs 22 Richard Stallman
2008-02-17 13:22 ` Richard Stallman
2008-02-20 0:30 ` Nick Roberts
2008-02-20 2:24 ` pdbtrack [was Re: python.el fixes for Emacs 22] Glenn Morris
2008-02-20 2:34 ` Nick Roberts
2008-02-20 2:56 ` pdbtrack Glenn Morris
2008-02-21 22:40 ` pdbtrack [was Re: python.el fixes for Emacs 22] Ken Manheimer
2008-02-21 23:35 ` pdbtrack Glenn Morris
2008-02-22 18:00 ` pdbtrack Ken Manheimer
2008-02-22 18:35 ` pdbtrack Stefan Monnier
2008-02-23 23:09 ` pdbtrack Ken Manheimer
2008-02-22 20:08 ` pdbtrack Nick Roberts
2008-02-23 23:16 ` pdbtrack Ken Manheimer
2008-02-24 4:49 ` pdbtrack Nick Roberts
2008-02-24 15:40 ` pdbtrack Stefan Monnier
2008-02-24 17:00 ` pdbtrack Ken Manheimer
2008-02-24 20:44 ` pdbtrack Stefan Monnier
2008-02-21 0:20 ` Ken Manheimer [this message]
2008-02-21 4:02 ` python.el fixes for Emacs 22 Stefan Monnier
2008-02-21 5:12 ` Barry Warsaw
2008-02-21 22:28 ` Richard Stallman
2008-02-21 23:00 ` Barry Warsaw
2008-02-21 23:08 ` Ken Manheimer
2008-02-21 23:12 ` Barry Warsaw
2008-02-22 1:49 ` Stefan Monnier
2008-02-22 13:44 ` Barry Warsaw
2008-02-22 15:13 ` skip
2008-02-22 15:30 ` Barry Warsaw
2008-02-22 22:57 ` Richard Stallman
2008-02-22 22:57 ` Richard Stallman
2008-02-22 3:23 ` Stephen J. Turnbull
2008-02-22 13:45 ` Barry Warsaw
2008-02-22 16:28 ` Stefan Monnier
2008-02-22 17:05 ` Barry Warsaw
2008-02-22 17:13 ` Ken Manheimer
2008-02-22 18:27 ` Stefan Monnier
2008-02-22 19:38 ` Barry Warsaw
2008-02-23 19:28 ` Richard Stallman
2008-02-23 20:16 ` skip
2008-02-22 22:57 ` Richard Stallman
2008-02-22 23:33 ` Barry Warsaw
2008-02-23 19:29 ` Richard Stallman
2008-02-23 0:09 ` skip
2008-02-25 13:53 ` Bernhard Herzog
2008-02-21 5:09 ` Barry Warsaw
2008-02-21 5:22 ` Nick Roberts
2008-02-15 16:51 ` Chong Yidong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2cd46e7f0802201620o6b6190dcmb53805bbb30aa3ec@mail.gmail.com \
--to=ken.manheimer@gmail.com \
--cc=barry@wooz.org \
--cc=cyd@stupidchicken.com \
--cc=emacs-devel@gnu.org \
--cc=nickrob@snap.net.nz \
--cc=rms@gnu.org \
--cc=sdl.web@gmail.com \
--cc=skip@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).