调试器中的 Step Into 和 Step Over 有什么区别 [英] What is the difference between Step Into and Step Over in a debugger
问题描述
我想调试一个(Java)程序的整个流程.我看到有几个选项可以单步执行我的程序.step into 和 step over 有什么区别?
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.
如果您要在那个点over,您将移动到 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.
调试器的另一个有用功能是 out of 或 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()
.
这篇关于调试器中的 Step Into 和 Step Over 有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!