简体   繁体   English

Eclipse (Helios) 调试器 - 在调试模式和运行模式下获得不同的结果

[英]Eclipse (Helios) debugger - getting different Results in Debug mode and Run mode

I am debugging RCP( multi-threaded GUI application) using Eclipse Helios.我正在使用 Eclipse Helios 调试 RCP(多线程 GUI 应用程序)。

When I am executing the same method, I get a null pointer exception in run mode, but in当我执行相同的方法时,我在运行模式下得到一个空指针异常,但在

debug mode, I don't get any exception.调试模式,我没有得到任何例外。 I think it works fine in Debug mode.我认为它在调试模式下工作正常。

Null pointer exception doesn't come in debug mode , but in run mode only..空指针异常不会在调试模式下出现,但仅在运行模式下..

Please help me out.请帮帮我。 Could it be a multi-threading issue.会不会是多线程问题。

Different behavior in run and debug mode is not unusual.运行和调试模式下的不同行为并不少见。 Once I spent a day to find that a toString() had side effects.有一次我花了一天时间发现 toString() 有副作用。 The debugger calls this method when displaying variables.调试器在显示变量时调用此方法。 Another reason for differences is concurrency.造成差异的另一个原因是并发性。 The execution order in the debugger may be different from run mode.调试器中的执行顺序可能与运行模式不同。

You can add a breakpoint to the line that NPE happened in run mode.您可以在运行模式下发生 NPE 的行添加断点。 And you need set the property of breakpoint to pause the entire vm.并且你需要设置断点的属性来暂停整个虚拟机。

Then debugging your program, the entire vm will be suspended when a thread tries to execute that line.然后调试你的程序,当一个线程试图执行该行时,整个 vm 将被挂起。 You can let other threads which don't try to execute that line to resume, the second thread will be suspended on that line as well.您可以让其他不尝试执行该行的线程恢复,第二个线程也将在该行上挂起。 You can analysis the flaw of your code.您可以分析代码的缺陷。

Please check whether you have used for each to traverse a collection.请检查您是否使用过 for each 来遍历集合。 The traversal order of the collection may be inconsistent between run and debug, which may lead to different results.集合的遍历顺序可能在 run 和 debug 之间不一致,可能会导致不同的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM