如何在特定位置创建断点,而断点后不包含任何代码
我正在创建断点来调试我的java应用程序,并且正在使用netbeans 6.8(如果这是相关的)。
基本上我遇到的问题是,当我设置断点并调试时,程序将在执行该行的代码之前中断。例如,如果我有以下内容。
public static void someMethod() {
Object iWantToInspectThis = someOtherMethod();
if(somethingThatIsFalseInThisCase == true)
{
doSomethingElse();
}
}
因此,我想在 iWantToInspectThis 对象上设置一个监视,然后在将其设置为 someOtherMethod() 的返回值后中断,以便我可以看到它设置的内容。
但是,如果我在该行上设置断点,那么我将看不到该行执行的结果,并且稍后无法设置断点(在 if 语句内),因为这样就无法到达该断点。
我能做到这一点的唯一方法是添加一个无用的行,如 System.out.println("this is pointless");在通话之后并在那里休息,这似乎是一种愚蠢的方式。
其他人如何处理这个问题?
I am creating breakpoints to debug my java application , and am using netbeans 6.8 (if this is relevant).
Basically the problem I have is that when I set a breakpoint and debug the program will break before it executes the code at that line. So for example if I have the following.
public static void someMethod() {
Object iWantToInspectThis = someOtherMethod();
if(somethingThatIsFalseInThisCase == true)
{
doSomethingElse();
}
}
So , I want to set a watch on iWantToInspectThis object and then break after it is set to the return value of someOtherMethod() so I can see what it is set to.
But if I set a breakpoint on that line then I will not see the result of this line being executed, and I cannot set the breakpoint later (inside the if statement) because then it will not be reached.
The only way I can manage to do this is to add a useless line like System.out.println("this is pointless"); after the call and break there instead which seems like a stupid way to have to do it.
How does everybody else deal with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在该行上放置一个中断,然后使用步骤进入下一行(如果我没记错的话,F8)以便执行该行,然后您可以通过将鼠标悬停在变量中或使用手表来查看该值。
Put a break on that line, and use step into next line (F8 if i remember correctly) so the line executes, and then you can see the value by hovering the mouse into the variable, or using a watch.