例如,我尝试了一个名为 abc()期望得到 12 ,但在重新检查返回值后,我注意到它是 5 而不是 12 。我怎么可以重新回到我之前的位置,然后一步一步的去看看发生了什么?我知道你可以在视觉工作室做到这一点,但是我在IntelliJ中找不到如何做到这一点。
解决方案您可以放下框架,直到达到要建立的位置。这并不是完全倒退的,但是在很多方面都非常相似。
虽然Tiago在下面提到这一点不会恢复您的应用程序的全局状态 - 如果您正在开发无状态服务,这不是一个巨大的问题,但可能是如果你正在开发swing应用程序(如果有人实际上这样做)。
在调试工具栏上,它看起来像这样:。在 Idea 2016.3 中,图标看起来像这样
完整的文档可以在这里: IntelliJ Debugger Docs ,以及有一个 StackOverflow丢帧问题,几个有用的答案
Is it possible to step backwards through executed code in a debug session?
For example I step over a method called abc() expecting to get 12 but after re-checking the value returned I notice it's 5 instead of 12. How can I step back to where I was before and step into the method to see what is going on? I know you can do this in visual studio but I can't find how to do this in intelliJ.
解决方案You can drop the frames until you reach the point where you want to be. This isn't exactly stepping backwards, but it is quite similar in a lot of respects.
Though as Tiago mentions below this will not revert the global state of your application -- which isn't a huge concern if you're developing stateless services, but could be if you're developing swing applications (if anyone actually does that any more).
On the debugger toolbar it looks like this: . in Idea 2016.3 and up the icon look like this
Full documentation is available here: IntelliJ Debugger Docs, and there is a StackOverflow Drop Frame Question, with a few useful answers
更多推荐
如何在IntelliJ中一步一步?
发布评论