我最近刚刚安装了Ubuntu 11.10,安装了最新版本的Eclipse CDT。我正在尝试使用由CMake生成的makefile和Eclipse项目文件来调试现有的C ++项目。在尝试调试时(使用调试配置中给出的所有正确设置),启动失败并显示错误:
An internal error occurred during: "Launching mops-app".
java.lang.NullPointerException
尝试调试最小的Hello World项目时不会发生这种情况。可以使用最新版本的Eclipse CDT在Ubuntu 11.04上成功调试该项目。我机器上的java版本是:
java version "1.6.0_23"
OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre10-0ubuntu5)
OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)
尝试启动调试配置的Eclipse输出是:
!ENTRY org.eclipse.core.jobs 4 2 2011-10-31 11:50:24.211
!MESSAGE An internal error occurred during: "Launching mops-app".
!STACK 0
java.lang.NullPointerException
at org.eclipse.cdt.debug.internal.core.model.CDebugTarget.getSourceLookupPath(CDebugTarget.java:1837)
at org.eclipse.cdt.debug.internal.core.model.CDebugTarget.getSourceLookupPath(CDebugTarget.java:1848)
at org.eclipse.cdt.debug.internal.core.model.CDebugTarget.getSourceLookupPath(CDebugTarget.java:1848)
at org.eclipse.cdt.debug.internal.core.model.CDebugTarget.setSourceLookupPath(CDebugTarget.java:1815)
at org.eclipse.cdt.debug.internal.core.model.CDebugTarget.initializeSourceLookupPath(CDebugTarget.java:383)
at org.eclipse.cdt.debug.internal.core.model.CDebugTarget.initialize(CDebugTarget.java:282)
at org.eclipse.cdt.debug.internal.core.model.CDebugTarget.<init>(CDebugTarget.java:275)
at org.eclipse.cdt.debug.core.CDIDebugModel$1.run(CDIDebugModel.java:100)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2326)
at org.eclipse.cdt.debug.core.CDIDebugModel.newDebugTarget(CDIDebugModel.java:105)
at org.eclipse.cdt.launch.internal.LocalCDILaunchDelegate.launchLocalDebugSession(LocalCDILaunchDelegate.java:162)
at org.eclipse.cdt.launch.internal.LocalCDILaunchDelegate.launchDebugger(LocalCDILaunchDelegate.java:112)
at org.eclipse.cdt.launch.internal.LocalCDILaunchDelegate.launch(LocalCDILaunchDelegate.java:72)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:854)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:703)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:928)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1132)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
答案 0 :(得分:2)
该问题与升级CMake版本有关。 CMake 2.8.5在Eclipse .cproject
和.project
文件中生成了“子项目”条目。出于某种原因,CMake默认告诉Eclipse忽略Subproject路径,因此在试图调试代码时会混淆Eclipse的索引器。
通过注释<linkedResources>
文件的.project
条目可以轻松解决问题,例如
<!--link>
<name>[Subprojects]/MOPS</name>
<type>2</type>
<location>/home/user/mops-c-Git/src/mopsc</location>
</link-->
并注释掉<pathentry>
文件的子项目部分.cproject
条目,例如
<!--pathentry kind="src" path="MOPS"/>
<pathentry excluding="MOPS/|**/CMakeFiles/" kind="out" path=""/-->
答案 1 :(得分:1)
确保选择要在“运行/运行”或“运行/调试”菜单中运行的可执行文件。
答案 2 :(得分:1)
我遇到了类似的问题(Ubuntu 14.04,SBT 13.1.0) - 启动Debugger导致java.lang.NullPointerException
。通过使用eclipse-nios2 -consoleLog
启动Eclipse来检查日志,我有类似的条目:
java.lang.NullPointerException
at org.eclipse.cdt.debug.internal.core.model.CDebugTarget.getSourceLookupPath(CDebugTarget.java:1843)
at org.eclipse.cdt.debug.internal.core.model.CDebugTarget.getSourceLookupPath(CDebugTarget.java:1864)
at org.eclipse.cdt.debug.internal.core.model.CDebugTarget.getSourceLookupPath(CDebugTarget.java:1864)
at org.eclipse.cdt.debug.internal.core.model.CDebugTarget.setSourceLookupPath(CDebugTarget.java:1817)
at org.eclipse.cdt.debug.internal.core.model.CDebugTarget.initializeSourceLookupPath(CDebugTarget.java:385)
at org.eclipse.cdt.debug.internal.core.model.CDebugTarget.initialize(CDebugTarget.java:286)
at org.eclipse.cdt.debug.internal.core.model.CDebugTarget.<init>(CDebugTarget.java:279)
我相信原因是一样的;我找到了另一个修复程序,并希望分享它的完整性。
我在项目中链接了资源,日志让我怀疑它们是原因。我已将资源与Import->General->File system->[... Create links in workspace...]
相关联。
我删除了这些链接,而是通过Project Properties->C/C++ General->Paths and Symbols->[tab] Source Location->Link folder...
链接到了来源。
这使调试器运行正常而不抱怨。