Emacs and pdb after upgrading to Ubuntu Feisty

L

levander

I've been using pdb under emacs on an Ubuntu box to debug python
programs. I just upgraded from Ubuntu Edgy to Feisty and this combo
has stopped working. Python is at 2.5.1 now, and emacs is at 21.41.1.

It used to be I could just "M-x pdb RET pdb <script-name> RET" and be
presented with a prompt where I could debug my script, as well as an
arrow in another source code buffer indicating where I am in the
source code.

Now however, when I do "M-x pdb RET pdb ~/grabbers/npr-grabber.py -s
WESUN", I get this is in a buffer called *gud*:

Current directory is /home/levander/grabbers/

No prompt or anything follows it, just that one line. It doesn't pop
up an arrow in the other buffer either. None of the regular commands
like 'n', 's', or 'l' do anything here. So, I did a 'Ctrl-C' and got:
/home/levander/grabbers/npr-grabber.py(24)<module>()
-> """
(Pdb) > /home/levander/grabbers/npr-grabber.py(30)<module>()
-> import getopt
(Pdb) Traceback (most recent call last):
File "/usr/bin/pdb", line 1213, in main
pdb._runscript(mainpyfile)
File "/usr/bin/pdb", line 1138, in _runscript
self.run(statement, globals=globals_, locals=locals_)
File "bdb.py", line 366, in run
exec cmd in globals, locals
File "<string>", line 1, in <module>
File "/home/levander/grabbers/npr-grabber.py", line 30, in <module>
import getopt
File "/home/levander/grabbers/npr-grabber.py", line 30, in <module>
import getopt
File "bdb.py", line 48, in trace_dispatch
return self.dispatch_line(frame)
File "bdb.py", line 66, in dispatch_line
self.user_line(frame)
File "/usr/bin/pdb", line 144, in user_line
self.interaction(frame, None)
File "/usr/bin/pdb", line 187, in interaction
self.cmdloop()
File "cmd.py", line 130, in cmdloop
line = raw_input(self.prompt)
KeyboardInterrupt
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
/home/levander/grabbers/cmd.py(151)cmdloop()
-> pass
(Pdb)

It's wierd because at the bottom of that call stack, it does look like
it's wating for input, but no input works... And, after I hit Ctrl-C
I do get a prompt as you see at the bottom of that listing just
above. Now I type "quit" and get:

Post mortem debugger finished. The /home/cponder/grabbers/npr-
grabber.py will be restarted

Anybody can tell me who to get pdb working under emacs on Ubuntu
Feisty?
 
A

Alexander Schmolck

levander said:
Anybody can tell me who to get pdb working under emacs on Ubuntu
Feisty?

This is not a direct answer to your question, but I'd recommend you try
ipython (apt-get'able) and ipython.el; (manual install). Just enter ``pdb on``
in the interactive shell to end up in the debugger on errors and the
corresponding file and line is opened in emacs.

BTW, I'd also suggest to upgrade to emacs-snapshot (23 alpha -- but don't be
overly worried -- seems more stable than 21. to me so far), for one thing you
get decent (ttf) fonts:

<http://peadrop.com/blog/category/computers/emacs/>

'as
 
R

R. Bernstein

levander said:
I've been using pdb under emacs on an Ubuntu box to debug python
programs. I just upgraded from Ubuntu Edgy to Feisty and this combo
has stopped working. Python is at 2.5.1 now, and emacs is at 21.41.1.

If I had to take a guess the big change would be in Python 2.5.1 and
the Emacs pdb package has not kept up with that. Edgy was running
Python 2.4.x. The emacs version is about the same. (And I agree with
Alexander Schmolck that emacs 23 alpha is much much nicer).

If you were to report a problem, my guess then would be the Debian
maintainer for the Emacs pdb package. More info below.
It used to be I could just "M-x pdb RET pdb <script-name> RET" and be
presented with a prompt where I could debug my script, as well as an
arrow in another source code buffer indicating where I am in the
source code.

Now however, when I do "M-x pdb RET pdb ~/grabbers/npr-grabber.py -s
WESUN", I get this is in a buffer called *gud*:

Current directory is /home/levander/grabbers/

No prompt or anything follows it, just that one line. It doesn't pop
up an arrow in the other buffer either. None of the regular commands
like 'n', 's', or 'l' do anything here. So, I did a 'Ctrl-C' and got:

-> """
(Pdb) > /home/levander/grabbers/npr-grabber.py(30)<module>()
-> import getopt
(Pdb) Traceback (most recent call last):
File "/usr/bin/pdb", line 1213, in main
pdb._runscript(mainpyfile)
File "/usr/bin/pdb", line 1138, in _runscript
self.run(statement, globals=globals_, locals=locals_)
File "bdb.py", line 366, in run
exec cmd in globals, locals
File "<string>", line 1, in <module>
File "/home/levander/grabbers/npr-grabber.py", line 30, in <module>
import getopt
File "/home/levander/grabbers/npr-grabber.py", line 30, in <module>
import getopt
File "bdb.py", line 48, in trace_dispatch
return self.dispatch_line(frame)
File "bdb.py", line 66, in dispatch_line
self.user_line(frame)
File "/usr/bin/pdb", line 144, in user_line
self.interaction(frame, None)
File "/usr/bin/pdb", line 187, in interaction
self.cmdloop()
File "cmd.py", line 130, in cmdloop
line = raw_input(self.prompt)
KeyboardInterrupt
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
-> pass
(Pdb)

It's wierd because at the bottom of that call stack, it does look like
it's wating for input, but no input works... And, after I hit Ctrl-C
I do get a prompt as you see at the bottom of that listing just
above. Now I type "quit" and get:

Yes, it looks like it is in its input look reading debugger commands.
If you've tried commands that produce output (e.g. "list", "where",
"print") and you are getting nothing then, yes, that's weird. Emacs
however will gobble up and hide what it thinks is location information
from the debugger. So if you were running "step" or "next" or
"continue" I could see how output would be disappearing.

In any event a guess for some of the problem is that the Emacs isn't
parsing the output correctly.

I've noticed subtle changes in reporting the where you are between
Python 2.4 and 2.5 such as giving a module name when that's known. The
emacs regular expressions no doubt haven't been updated for knowing
this and matching the location is and probably needs to be a little
bit fussy.
Post mortem debugger finished. The /home/cponder/grabbers/npr-
grabber.py will be restarted

Anybody can tell me who to get pdb working under emacs on Ubuntu
Feisty?

I haven't tried pdb, but another Alex, Oleksandr Moskale, has a Debian
package for pydb which gets filtered down to Edgy and Feisty, and I've
used that and it works. ;-) And it also works with ipython in the way
that 'as mentioned too.
 
L

levander

Okay, thanks Alexander and Bernstein. I'll lookinto Emacs 23, but I'm
worried about compatibility with modes. Does all the stuff that works
in Emacs 21 work in 23? Like even that ipython.el file, does it work
in Emacs 23? And, I probably will report a bug to either Ubuntu's
Launchpad or to Debian's package maintainer for pdb mode (which
apparently has been integrated into just the gud mode stuff, at least
that's how it looks from looking around on my system). Does Debian
have a web site for reporting bugs like Ubuntu does? Or, do I just
email the package maintainer?

I'm messing around with ipython.el and ipython now. It looks like if
you just want to step through some code that isn't throwing any
execption, you have to modify the source code of your script to tell
ipython to stop on this line and start debugging here? With all the
raving about ipython, I'm sure it's a great product. But, this thing
about having to modify your source code really sounds like it sucks.
I'd be surprised if it were difficult to implement a command line
option for ipython that tells it to open this file and then start
debugging it from the top. And, have the emacs mode operate much like
it does with pdb, where emacs remembers your command line when you
invoked pdb, so you just hit "M-x pdb RET RET RET ..." to open up your
file. But, maybe I just haven't foud it yet?
 
A

Alexander Schmolck

levander said:
Okay, thanks Alexander and Bernstein. I'll lookinto Emacs 23, but I'm
worried about compatibility with modes. Does all the stuff that works
in Emacs 21 work in 23?

I've switched from 21 to 23 a few weeks ago and don't recall any particular
issues (and I'm a fairly hardcore emacs user with pretty complex configuration
and many third-party packages -- my emacs config has 182 matches for
require\|autoload).
Like even that ipython.el file, does it work in Emacs 23?

I think as the author I would have noticed by now if it didn't :)
And, I probably will report a bug to either Ubuntu's Launchpad or to
Debian's package maintainer for pdb mode (which apparently has been
integrated into just the gud mode stuff, at least that's how it looks from
looking around on my system). Does Debian have a web site for reporting bugs
like Ubuntu does? Or, do I just email the package maintainer?

I'm messing around with ipython.el and ipython now. It looks like if
you just want to step through some code that isn't throwing any
execption, you have to modify the source code of your script to tell
ipython to stop on this line and start debugging here?

Nope. Try ``run -d myscript`` (and ``?run`` for more info).

I must admit that this doesn't work properly for me though -- I don't get
stepping through the corresponding source in emacs. ``M-x pdb`` works with pdb
as debugger but not with pydb; maybe the problem is missing pydb support in
the relevant regexps?

I can't devote any time to this at the moment, but I'd be pretty interested in
having this working -- so I'd appreciate a note if someone figures out what's
going on (and if a change to ipython.el is needed I'll make sure it gets in).
With all the raving about ipython, I'm sure it's a great product. But, this
thing about having to modify your source code really sounds like it sucks.
I'd be surprised if it were difficult to implement a command line option for
ipython that tells it to open this file and then start debugging it from the
top.

It's already there -- I'm using 0.7.4 svn (which is the ubuntu feisty
package), so I think it should also work for you.
And, have the emacs mode operate much like it does with pdb, where emacs
remembers your command line when you invoked pdb, so you just hit "M-x pdb
RET RET RET ..." to open up your file. But, maybe I just haven't foud it
yet?

I'd type something like ``run -<Meta>+<P>`` (with M-p bound
to `comint-previous-matching-input-from-input') or M-r, which is even fewer
keystrokes.

'as
 
P

Patricia J. Hawkins

l> Okay, thanks Alexander and Bernstein. I'll lookinto Emacs 23, but
l> I'm worried about compatibility with modes. Does all the stuff
l> that works in Emacs 21 work in 23? Like even that ipython.el file,
l> does it work in Emacs 23?

Well...

Python 2.5.1c1 (release25-maint, Apr 12 2007, 21:00:25)
Type "copyright", "credits" or "license" for more information.

IPython 0.7.2 -- An enhanced Interactive Python.
? -> Introduction to IPython's features.
%magic -> Information about IPython's 'magic' % functions.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

In [1]: 3 + 4
Out[1]: 7

In [2]:

And pdb:

Current directory is /media/extend/skeezix/pjh/CODING/python/
> /media/extend/skeezix/pjh/CODING/python/fibclass.py(3)<module>()
-> class Fib:
(Pdb) n
> /media/extend/skeezix/pjh/CODING/python/fibclass.py(14)<module>()
-> f = Fib()
(Pdb) n
> /media/extend/skeezix/pjh/CODING/python/fibclass.py(15)<module>()
-> print f[10]
(Pdb) n
89
--Return--
> /media/extend/skeezix/pjh/CODING/python/fibclass.py(15)<module>()->None
-> print f[10]
(Pdb) n
--Return--
> <string>(1)<module>()->None
(Pdb) n
The program finished and will be restarted
> /media/extend/skeezix/pjh/CODING/python/fibclass.py(3)<module>()
-> class Fib:
(Pdb)

This is emacs 23.0.0.1, from a weekly Feisty build of
emacs-snapshot-gtk maintained by Alexandre Vassalotti, which also
includes the xft font backend. Which means anti-aliased fonts on
emacs... :)

See:
http://peadrop.com/blog/2007/01/06/pretty-emacs/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top