简体   繁体   English

在代码中使用ipdb和emacs'gud,没有明确的断点

[英]Using ipdb with emacs' gud without explicit breakpoints in code

I'm using python.el If I choose 'debugger' from the menu, and enter 'python -m pdb myfile.py', gud starts, and in a split frame I see the (Pdb) prompt in one, and my python code in the other with a caret on the first line, indicating that it's ready to go. 我正在使用python.el如果我从菜单中选择'debugger'并输入'python -m pdb myfile.py',gud启动,并在拆分框架中我看到(Pdb)提示符在一个,我的python另一个代码在第一行有一个插入符号,表示它已准备就绪。 For example 'n' steps to the next line and the caret moves accordingly. 例如,'n'步骤到下一行,插入符相应地移动。

If instead I enter 'python -m ipdb myfile.py', the frame splits, and one split is labeled gud, but there's no ipdb console evident. 如果我输入'python -m ipdb myfile.py',框架拆分,一个拆分标记为gud,但没有明显的ipdb控制台。 In other words, this way of starting ipdb doesn't seem to work. 换句话说,这种启动ipdb的方式似乎不起作用。 Ipdb works just fine if I manually insert a breakpoint into my python code using ipdb.set_trace(), except that it does not use the gud interface. 如果我使用ipdb.set_trace()手动将断点插入到我的python代码中,Ipdb工作得很好,除了它不使用gud接口。 Is this intentional so that ipdb's stack trace will work nicely? 这是故意的,以便ipdb的堆栈跟踪能很好地工作吗?

If so, that's fine, but is there a way to start ipdb from emacs without manually adding a set_trace() command? 如果是这样,那很好,但有没有办法从emacs启动ipdb而无需手动添加set_trace()命令?

The basic problem here is that gud is looking for a (Pdb) prompt and ipdb doesn't prompt this way. 这里的基本问题是gud正在寻找(Pdb)提示符,并且ipdb不会以这种方式提示。 There are three ways to fix this: fix ipdb to give a (Pdb) prompt, fix gud not to need to look for (Pdb) or (my favorite) use something else either on the gud side or on the ipdb side. 有三种方法可以解决这个问题:修复ipdb以提供(Pdb)提示,修复gud不需要查找(Pdb)或(我最喜欢的)在gud端或ipdb端使用其他东西。

The problem with fixing up gud is that it is rather old and to my mind a bit creaky using global variables and not making use of Emacs Lisp data structures available other than lists and cons cells. 修复gud的问题在于它相当陈旧,在我看来使用全局变量并没有使用除列表和缺点单元之外的Emacs Lisp数据结构有点吱吱作响。 A total rewrite of gud is called realgud , it is currently in MELPA and ELPA. 完全重写gud称为realgud ,它目前在MELPA和ELPA中。 And ipdb is supported. 并且支持ipdb。

The last option is to use something else, so let me suggest the Python trepan debugger which is already integrated into realgud (but not gud since I consider that a dead end). 最后一个选项是使用其他东西,所以让我建议已经集成到realgud中Python trepan调试器 (但是因为我认为这是一个死胡同而不是gud )。 Although the backtraces it gives are not exactly like ipdb's, it does colorize them and the source code. 虽然它提供的回溯与ipdb不完全相同,但它确实为它们和源代码着色。

And recent versions of trepan3k backtraces will even show, on demand, you where in the line you are. 最新版本的trepan3k回溯甚至可以根据需要显示您的位置。 So if you had say two calls of a function, like fib() it would distinguish which of the calls function was the one in progress. 因此,如果你说两个函数调用,比如fib()它会区分哪个调用函数正在进行中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM