断点处的交互式 pyDev 控制台

发布于 2024-08-18 01:09:55 字数 293 浏览 7 评论 0原文

我使用 Aptana Studio 和 Pydev 1.5.3 来调试我的 Django 应用程序。我使用 PyDev 的远程调试器和 manage.py 中的一些代码,并且在大多数情况下,此设置都可以成功运行 - 我可以设置断点、检查变量并单步执行/继续执行我的代码。

然而,我想在断点处执行任意代码——这是从 pdb 切换到 Eclipse 调试后我真正想念的事情。调试视角中有一个交互式控制台可用,但它对我来说不活动。

所以我的问题是——是否可以在 PyDev 中使用远程调试器设置一个交互式控制台,该控制台可以在断点处“注入”代码?

I'm using Aptana Studio with Pydev 1.5.3 to debug my Django applications. I use PyDev's remote debugger and some code in manage.py and for most of the time this setup is working successfully- I can set breakpoints, inspect variables and step/continue through my code.

However, I'd like to execute arbitrary code at the breakpoint- the thing I really miss after switching from pdb to Eclipse debugging. There is an interactive console available in debug perspective but it is inactive for me.

So my question- is it possible to set up an interactive console in PyDev with remote debugger which could "inject" code at breakpoint?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

独行侠 2024-08-25 01:09:55

奇怪的是,我使用 pydev 1.5.6 进行远程调试,我可以使用交互式控制台 - 我输入 cmmand,按 Enter 键,过了一会儿就得到结果;检查您的防火墙没有阻止任何内容(如果您确定,交互式控制台在本地模式下工作)。 pydev 源代码中甚至有设置来设置应将多少标准输出返回给客户端(以字符形式),它应该可以工作

strange, i am using pydev 1.5.6 for remote debugging and I can use the interactive console - i type the cmmand, hit enter, after a while get results back; check your firewall is not blocking anything (if you are sure, the interactive console works in local mode). there is even settings in pydev source code to set how much of stdout should be returned back to client (in chars), it should work

妄断弥空 2024-08-25 01:09:55

经过一番挖掘后,我发现我可以使用表达式视图来访问变量属性并查看类方法的结果,但这仍然不是断点处的完整控制台。

After some digging I discovered that I can use Expressions view to access variables properties and view results of class methods, but that still isn't a complete console at breakpoint though.

柳若烟 2024-08-25 01:09:55

对于 PyDev 1.5.5,它应该是可能的:

  1. 在“变量”视图中,您可以右键单击名称,然后选择“更改值”。
  2. 控制台也可以工作,尽管有点棘手。
    它仅用于检查,并且以一种非常奇怪的方式:您必须在“调试服务器”控制台中输入文本,然后您将在“文件名”控制台中获得输出。
    另请注意,您需要按两次 Enter 键,留空行。

虽然“空行”技巧已被记录,但有关输入和输出的两个不同控制台的问题却没有记录,我认为这可能是一个错误。

With PyDev 1.5.5 it should be possible:

  1. In "Variables" view, you can right-click on a name, then select "change value".
  2. The console is working as well, albeit a bit tricky.
    It is only for inspection and in a very strange way: you have to input the text in the "Debug server" console, and you will get the output in the "filename" console.
    Note also that you need to press enter twice, leaving an empty line.

While the "empty line" trick is documented, the issue about two different console for input and output is not, and I think it may be a bug.

旧伤慢歌 2024-08-25 01:09:55

在我的开发堆栈上,运行 Apache + mod_wsgi,在控制台中输入命令,将其输出路由到站点的错误日志。要解决此问题,您需要设置 stdoutToServer=TruesterrToServer=True 将捕获的所有输出路由到 PyDev 远程调试器:

from pydevsrc import pydevd;pydevd.settrace('192.168.2.8', stdoutToServer=True, stderrToServer=True) #clone and put on python path: https://github.com/tenXer/PyDevSrc

On my development stack running Apache + mod_wsgi entering commands into the console had their output routed to the site's error logs. To resolve this you have set the stdoutToServer=True and sterrToServer=True to route capture all output to the PyDev remote debugger:

from pydevsrc import pydevd;pydevd.settrace('192.168.2.8', stdoutToServer=True, stderrToServer=True) #clone and put on python path: https://github.com/tenXer/PyDevSrc
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文