Intellij想法中跳过的行如何调试? [英] How skip line in Intellij idea debug?

查看:563
本文介绍了Intellij想法中跳过的行如何调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有这样的java代码(仅作为例子):

  public void someMethod(){
int a = 3;
int b = 2; //< - 保持调试这里
a = b + 2;
System.out.prinln(a);
}

可以跳过int a = b + 2行的执行; 并去immitiatly到System.out.prinln(a);?



P.S。我使用Intellij Idea 12。

解决方案

调试器不可能不执行部分代码。



然而,可以在变量上执行额外的代码和更改值,因此如果您需要在调试期间排除执行一行,则必须更改代码以准备这种调试。

  public void someMethod(){
int a = 3;
int b = 2;
boolean shouldRun = true;
if(shouldRun){
a = b + 2;
}
System.out.prinln(a);
}

然后您将设置一个断点,改变shouldRun的值而不停止执行。可以这样做。





请注意,


  1. 暂停 isn

  2. 记录评估表达式用于在断点被击中时更改变量


Suppose I have java code like this (only as Example):

public void someMethod(){
    int a = 3;
    int b = 2; // <-- stay debug here
    a = b + 2;
    System.out.prinln(a);
}

It is possible to skip execution of line "int a = b+2;" and go immidiatly to "System.out.prinln(a);"?

P.S. I use Intellij Idea 12.

解决方案

It's not possible with the debugger to not execute parts of the code.

It is however possible to execute extra code and change values on variables so if you need to exclude one row from execution during debug you will have to alter your code to prepare for that kind of debugging.

public void someMethod() {
    int a = 3;
    int b = 2;
    boolean shouldRun = true;
    if (shouldRun) {
        a = b + 2;
    }
    System.out.prinln(a);
}

You would then set a break point that changes the value of shouldRun without stopping execution. It can be done like this.

Note that

  1. Suspend isn't checked
  2. Log evaluated expression is used to alter a variable when the break point is hit

这篇关于Intellij想法中跳过的行如何调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆