在调试器中单步执行和单步执行有什么区别 [英] What is the difference between Step Into and Step Over in a debugger

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

问题描述

我想调试(Java)程序的整个流程.我看到在程序中有 stepping 的几个选项.走进越过有什么区别?

I want to debug the whole flow of a (Java) program. I see there are several options for stepping through my program. What is the difference between step into and step over?

推荐答案

在当前位置,将以下代码与您当前的指令指针(接下来将执行的行,由-> 指示)一起考虑. g()中的 f(x)行,已由 main()中的 g(2)行调用代码>:

Consider the following code with your current instruction pointer (the line that will be executed next, indicated by ->) 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); //
        f(1); // <----------------------------------- STEP OVER
    }

    public static void main (String args[]) {
        g(2);
        g(3); // <----------------------------------- STEP OUT OF
    }
}

如果此时要进入 ,您将移至 f()中的 println()行,进入函数调用.

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

如果您要跨过 ,您将移至 g()中的 f(1)行,通过函数调用.

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

调试器的另一个有用功能是步骤 或步骤 return.在这种情况下,步骤return基本上将使您遍历当前函数,直到返回为止上一层.换句话说,它将逐步遍历 f(x) f(1),然后返回到调用函数,最终在 g(3) main()中.

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().

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

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