新的调试技巧
在eclipse中内建了很强的代码调试功能,其中有一个Conditional Breakpoint的功能实际上还可以用来作为另外的用途:
public void someMethod(String argument) {然后我们可以在 someMethod 中加入如下的条件断点:
String a = getSomeValue();
String b = getSomeOtherValue();
// conditional breakpoint on this line
}
System.out.println(argument);
System.out.println(a);
System.out.println(b);
return false;
这样的话,这个断点会让代码每次运行时都打印一些额外的信息,但却不会导致程序的停顿。这可以让我们在不修改代码的情况下,增加一些调试的代码,让其在程序中得以运行。
类似的另外一个功能是在Display窗口中进行evaluation/run/display等操作,也可以执行我们的一些新的代码,比较灵活,但难以自动化的让其执行。
0 Comments:
张贴评论
<< Home