Eclipse调试器中的Step Into和Step Over有什么区别? [英] What is the difference between Step Into and Step Over in the Eclipse debugger?

查看:808
本文介绍了Eclipse调试器中的Step Into和Step Over有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想调试Java程序的整个流程。 eclipse中的 F5 (步入)和 F6 (逐步)之间有什么区别?

解决方案

f(x); 行中,使用当前指令指针(下一步将执行的行)考虑以下代码c $ c> g(),由 g(2) main()

  public class testprog {
static void f(int x){
System.out.println(num is+(x + 0)); //< - 进入
}

static void g(int x){
- > f(x); //< -----------------------------------当前位置
f(1); //< ----------------------------------- step over
}

public static void main(String args []){
g(2);
g(3); //< -----------------------------------步出
}
}

如果您要在这一步进入,那么你将转到 f()中的 println()行,进入函数调用。



如果您要在 之间,您将转到 f(1); g()中,跳过函数调用。



调试器的另一个有用功能是步骤退出或步骤返回。在这种情况下,步骤返回将基本上运行您通过当前的功能,直到你回到一个级别。换句话说,它将逐步通过 f(x) f(1),然后退回到呼叫功能最终在 g(3); main()



Eclipse(至少欧罗巴,这是我当时唯一的一个)使用 F5 步入 F6 for step over and F7 for step return


I want to debug the whole flow of a Java program. What is the difference between F5 (step into) and F6 (step over) in eclipse?

解决方案

Consider the following code with your current instruction pointer (the line that will be executed next) at the f(x); line in g(), having been called by the g(2) line in main():

public class testprog {
    static void f (int x) {
        System.out.println ("num is " + (x+0)); // <- step into
    }

    static void g (int x) {
->      f(x); // <----------------------------------- current location
        f(1); // <----------------------------------- step over
    }

    public static void main (String args[]) {
        g(2);
        g(3); // <----------------------------------- step out of
    }
}

If you were to step into at that point, you will move to the println() line in f(), stepping into the function call.

If you were to step over at that point, you will move to the f(1); line in g(), stepping over the function call.

Another useful feature of debuggers is the step out of or step return. In that case, a step return will basically run you through the current function until you go back up one level. In other words, it will step through f(x) and f(1), then back out to the calling function to end up at g(3); in main().

Eclipse (at least Europa, which is the only one I have handy at the moment) uses F5 for step into, F6 for step over and F7 for step return.

这篇关于Eclipse调试器中的Step Into和Step Over有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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