简体   繁体   English

如何退回 Eclipse 调试器?

[英]How to step back in Eclipse debugger?

Is it possible to do reverse execution in Eclipse debugger?是否可以在 Eclipse 调试器中进行反向执行? The current project I'm working on requires a minimum of 5 seconds to read and initialize data from a file before anything can be done.我正在处理的当前项目需要至少 5 秒才能从文件读取和初始化数据,然后才能完成任何操作。 If I overstep in the debugger, I have to terminate the program and restart, and this takes a fair bit of time.如果我在调试器中越级,我必须终止程序并重新启动,这需要相当长的时间。

You can use Eclipse's drop to frame command to re-enter the current method from the top.您可以使用 Eclipse 的drop to frame命令从顶部重新输入当前方法。 But it won't unroll any state changes that have happened, so it may not work depending on the sort of method you're in.但是它不会展开已经发生的任何状态更改,因此它可能无法工作,具体取决于您使用的方法类型。

Another really cool tool that actually does let you step back and forward in time is the Omniscient Debugger .另一个非常酷的工具是Omniscient Debugger It works by instrumenting classes as they're loaded in the classloader, so it can record everything that your code does.它通过在类加载器中加载类时对其进行检测来工作,因此它可以记录您的代码所做的一切。 It can do very cool things, like answer "when, where, and why was this field assigned its current value?".它可以做很酷的事情,比如回答“这个字段在何时、何地以及为什么被分配其当前值?”。 The UI is rather clunky, and it can have a hard time handling large code bases, but for some cases it can really save a lot of time. UI 相当笨重,处理大型代码库可能会很困难,但在某些情况下,它确实可以节省大量时间。

Update : Chronon provides a commercial product that it describes as a "DVR for Java", which appears to do a lot of the same things as the ODB.更新Chronon提供了一个商业产品,它被描述为“Java DVR”,它似乎做很多与 ODB 相同的事情。

Beyond what's been mentioned in earlier answers - ie Eclipse's drop to frame feature in the debug view , which restarts debugging earlier in the stack frame (but does not revert global/static data) and Omniscient debugger , which is a bit raw and not so much evolving - there are a few Eclipse-based tools that could be used to "go back" in (run)time:除了前面的答案中提到的内容之外 - 即 Eclipse 在调试视图中的 drop to frame 功能,它在堆栈帧中更早地重新启动调试(但不恢复全局/静态数据)和Omniscient debugger ,这有点原始而不是那么多不断发展 - 有一些基于 Eclipse 的工具可用于在(运行)时“返回”:

JIVE extends Eclipse Java debugger with the ability to record the program states. JIVE 扩展了 Eclipse Java 调试器,使其能够记录程序状态。 The JIVE perspective provides some useful UML diagrams that are updated while the program is running. JIVE 透视图提供了一些有用的 UML 图,这些图在程序运行时更新。 These diagrams provide an overview of the state of the application (object diagram) and of the stack trace (sequence diagram).这些图提供了应用程序状态(对象图)和堆栈跟踪(序列图)的概览。 You can query the memorized trace and step back and forward in time and see the corresponding diagrams.您可以查询记忆的轨迹并及时退步和查看相应的图表。

Diver only records method calls and does not really record program states like JIVE. Diver 只记录方法调用,并没有像 JIVE 那样真正记录程序状态。 Every method call event is stored for later retrieval and analysis.每个方法调用事件都被存储起来供以后检索和分析。 It extends the Java Run and Debug configurations mainly to specify filters.它扩展了 Java Run 和 Debug 配置,主要用于指定过滤器。 Trace can be paused/resumed/filtered at runtime.跟踪可以在运行时暂停/恢复/过滤。 Once recorded, the Diver perspective can display it in an interactive sequence diagram.记录后,Diver 透视图可以将其显示在交互式序列图中。

JIVE and Diver are open source projects issued from academic research. JIVE 和 Diver 是由学术研究发布的开源项目。 As of November 2012 both projects are active.截至 2012 年 11 月,这两个项目都处于活动状态。

Chronon is a commercial product, but they have free licenses for students and open source projects. Chronon 是一种商业产品,但他们为学生和开源项目提供免费许可证。 From what's being claimed on their website it's probably the most comprehensive recorder since it's able to replay the recorded history, step back and forth, allowing as they say time traveling debugging.从他们网站上声称的内容来看,它可能是最全面的记录器,因为它能够重放记录的历史,来回走动,正如他们所说的那样进行时间旅行调试。 Also Eclipse isn't needed for recording.录制也不需要 Eclipse。

All of these plugin are quite greedy in resources so it's best to have a good spec machine and use their filter feature.所有这些插件在资源上都非常贪婪,所以最好有一个好的规格机器并使用它们的过滤器功能。 A definite requirement to run them successfully is to extend the heap space in eclipse.ini .成功运行它们的一个明确要求是扩展 eclipse.ini 中的堆空间

In my case I've tried to use JIVE and Diver to debug an XML parsing program but always ended up freezing eclipse due to lack of resources.就我而言,我曾尝试使用 JIVE 和 Diver 来调试 XML 解析程序,但由于缺乏资源,最终总是冻结 eclipse。 Diver could be tricky to run on linux 64bit , it works on ubuntu 32bit and possibly other 32bit distros using these tips . Diver 在 64 位 linux 上运行可能很棘手,它可以使用这些技巧在 ubuntu 32 位和可能的其他 32 位发行版上运行。 Diver works on Windows, better yet on a Windows 64bit + 64bit JVM otherwise you will be limited to a maximum heap space of 1.3-1.6Gb on 32bit windows . Diver 在 Windows 上工作,在 Windows 64bit + 64bit JVM 上更好,否则你将被限制在 32bit windows 上最大堆空间为 1.3-1.6Gb JIVE works great on my linux 64bit, and seems to work fine on other platforms. JIVE 在我的 64 位 linux 上运行良好,在其他平台上似乎也运行良好。

Yes , Eclipse CDT has support of historical debugger feature.是的,Eclipse CDT 支持历史调试器功能。

Open Debug Configuration -> Debugger -> Enable Reverse Debugging at startup .打开Debug Configuration -> Debugger -> Enable Reverse Debugging at startup

Than you can press shift+F5 or shift+F6 for step back like F5 or F6 for step forward.比您可以按shift+F5shift+F6后退,如F5F6前进。

I am biased, but Chronon does exactly what you are looking for.我有偏见,但Chronon正是您正在寻找的。

Drop to Frame isnt exactly stepping back, since if the method has changed anything on the heap it wont be reverted. Drop to Frame 并不是完全退步,因为如果该方法更改了堆上的任何内容,它就不会被还原。

I was looking for this feature in eclipse too.我也在 eclipse 中寻找这个功能。 I know the visual studio can do that.我知道视觉工作室可以做到这一点。 Actually you can drag the current line marker and drop anywhere back in code.实际上,您可以拖动当前行标记并将其放回代码中的任何位置。 I'm not pretty sure if the changes to variables can be undone.我不太确定是否可以撤消对变量的更改。 But it is still very useful even so and saves lots of time.但即便如此,它仍然非常有用,并且可以节省大量时间。 I've been waiting for this in eclipse for a very long.我一直在 eclipse 中等待这个很长时间。

The question doesn't specify an Eclipse language, and many of the answers assume Java.该问题没有指定 Eclipse 语言,许多答案都假定为 Java。

If using C++ and GCC with the GDB debugger, Eclipse has Run->Move to Line which does the job and functions like the Visual Studio Set Next Statement .如果将 C++ 和 GCC 与 GDB 调试器一起使用,Eclipse 有Run->Move to Line来完成工作和像 Visual Studio Set Next Statement一样的功能。 In this case, Eclipse is using the capability that is in GDB.在这种情况下,Eclipse 使用的是 GDB 中的功能。

If using Java, I'm not aware of a way to it with Eclipse or Netbeans, although other answers have suggested plugins.如果使用 Java,我不知道使用 Eclipse 或 Netbeans 的方法,尽管其他答案建议使用插件。 Eclipse does have the "drop to frame" command which works for Java in my version (Juno SR1). Eclipse 确实具有适用于我的版本 (Juno SR1) 中的 Java 的“drop to frame”命令。 If I modify and save code within a function in debug mode, the execution line automatically moves to the top of the current function and I can continue from there.如果我在调试模式下修改和保存函数中的代码,执行行会自动移动到当前函数的顶部,我可以从那里继续。 Not the same as specifying the line, but it is something.与指定行不同,但它是一些东西。

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

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