eclipse 在 intellij 上调试评估表达式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32585475/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
debug an evaluate expression on intellij
提问by albfan
Using evaluate expression/code fragment:
使用评估表达式/代码片段:
https://www.jetbrains.com/idea/help/evaluating-expressions.html
https://www.jetbrains.com/idea/help/evaluating-expressions.html
Is it possible to debug evaluated expression/code fragment on intellij?.
是否可以在 Intellij 上调试评估的表达式/代码片段?。
On eclipse if you launch a code evaluation on display window and that code has any breakpoint inside, eclipse debugger stops on that breakpoint. If you try again eclipse says it can execute inspections on nested debug session.
在 Eclipse 上,如果您在显示窗口上启动代码评估并且该代码内部有任何断点,则 Eclipse 调试器将在该断点处停止。如果你再试一次 eclipse 说它可以在嵌套调试会话上执行检查。
Intellij seems to launch expression in a different session.
Intellij 似乎在不同的会话中启动表达式。
My workflow on this is to stop on "whatever line" of code and add fragment I want to evaluate for a Q&D debug. Many times this leads to a debug restart.
我的工作流程是停止“任何一行”代码并添加我想要评估的片段以进行 Q&D 调试。很多时候这会导致调试重启。
回答by Andrew Terekhine
Unfortunately it's not possible in Intellij 14 and stated in the official link you provided:
不幸的是,这在 Intellij 14 中是不可能的,并在您提供的官方链接中说明:
If a method invoked within the Expression Evaluationhas a breakpoint inside its body, this breakpoint will be ignored.
如果在表达式求值中调用的方法在其主体内具有断点,则该断点将被忽略。
To eliminate the problem you mentioned with frequent restarting of a debug session I use the following work-around with the drop-frame debug feature:
为了消除您在频繁重新启动调试会话时提到的问题,我使用以下解决方法和丢帧调试功能:
- Step in to a method and before return use the drop-frame functionality to fall back to a previous stack frame. See the drop-frame icon's location on the screenshot below:
- Now it's possible to rerun this method with different parameters without restarting the debug session (parameters can be set using Evaluate Expression dialog).
回答by Karthik P
The feature is not available in IntelliJ IDEA 2019.2
该功能在 IntelliJ IDEA 2019.2 中不可用
The workaround I use is to update the code as follows,
我使用的解决方法是更新代码如下,
Boolean shouldExecute = false;
if(shouldExecute){
//method call
}
During the debug session, I will change shouldExecuteflag to true. This way I can debug the method callwhen needed.
在调试会话期间,我会将shouldExecute标志更改为 true。这样我就可以在需要时调试方法调用。
Of coarse this is just a workaround, I need to remove this flag later.
粗略地说,这只是一种解决方法,稍后我需要删除此标志。