Eclipse:编辑源代码并继续调试 [英] Eclipse :Edit the source and continue debugging

查看:161
本文介绍了Eclipse:编辑源代码并继续调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Eclipse IDE(Helios版本)
在Eclipse中调试时,是否可以编辑源代码并继续调试?



例如我有这个文件
调试时,我尝试修改a4值在调试时不反映?

  public class Tes {

public static void main(String args []){
int a4 = 15; (int i = 0; i


I am using Eclipse IDE (Helios Version) While debugging in Eclipse , is it possible to edit the source and continue debugging ??

For example i have this file While debugging when i tried to modify the a4 value during debugging its not reflecting ??

public class Tes {

    public static void main(String args[]) {
        int a4 = 15;

        for (int i = 0; i < a4; i++) {
            System.out.println(i);
        }

    }
}

解决方案

Yes it is possible to edit the source and continue debugging in Eclipse! You'll find extensive information here: Debugging with the Eclipse Platform (scroll down to the section Hotswap Bug Fixing: On-the-fly code fixing).

If you are running Java Virtual Machine (JVM) V1.4 or higher, Eclipse supports a feature called Hotswap Bug Fixing (not available in JVM V1.3 or lower). It allows the changing of source code during a debugger session, which is better than exiting the application, changing the code, recompiling, then starting another debugging session. To use this function, simply change the code in the editor and resume debugging.

There are some cases where the feature will not work. E.g. if you make changes to your main method's a4 variable, the JVM will not be able to remove all stack frames running old code from the call stack. The debugger data will be lost.

To see the Hotswap Bug Fixing JVM feature in action, just move the code from your main method in the Test class to some other class. Here's what I mean:

Now you can modify the code on the fly while debugging in the MyObject class. Have fun!

EDIT: Just found a similar question at superuser.com: Debugging in Eclipse, how to run until a breakpoint

这篇关于Eclipse:编辑源代码并继续调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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