调试时更改java程序的执行 [英] Change execution of java program while debugging
问题描述
在Visual Studio中,在调试时,您可以通过堆栈返回来更改程序的执行流程。我的意思是,在你传递了一些表达式并且调试器突出显示下一行之后,你可以返回并再次执行该表达式。
In Visual Studio, while debugging, you can change execution flow of program by returning up via stack. I mean, after you passed some expression and debugger is highlighting next line, you can return up and execute that expression again.
调试Java程序时这是否可行?
Is this possible while debugging Java programs?
推荐答案
我知道只有一种方法可以引导你达到这种效果。它需要修改源代码,例如:
There is only one way I know that can lead you to that effect. It requires modificatoin of source code, e.g.:
public static void main(String[] args) {
int a = 1;
int b = 1;
int c = 1; //<-- break point here
int d = 1;
}
设置断点,而调试器在该行停止,更改源代码这个主
方法可用于任何其他方法,例如:
set a break point, while debugger stops at that line, change source code of this main
method to any thing else, e.g.:
public static void main(String[] args) {
int a = 1;
int b = 1;
int c = 1; //<-- break point here
int d = 1;
int e = 1; //<-- any modification will do
}
现在,按下一步 你可以选择让调试器重启。
Now, when press "next" you can choose to let debugger restart.
除了这种解决方法之外,我认为你不能在Eclipse中做到这一点。
Other than this work-around, I don't think you can do it in Eclipse.
这篇关于调试时更改java程序的执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!