【问题标题】:Eclipse CDT failure to debug in Ubuntu 11.10, throwing java.lang.NullPointerExceptionEclipse CDT 在 Ubuntu 11.10 中调试失败,抛出 java.lang.NullPointerException
【发布时间】:2015-02-19 23:37:43
【问题描述】:

我最近完成了 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)

【问题讨论】:

    标签: eclipse ubuntu


    【解决方案1】:

    该问题与升级 CMake 版本有关。 CMake 2.8.5 在 Eclipse .cproject.project 文件中生成了“子项目”条目。出于某种原因,默认情况下,CMake 告诉 Eclipse 忽略子项目路径,从而在尝试调试代码时混淆 Eclipse 的索引器。

    通过注释掉.project 文件的&lt;linkedResources&gt; 条目可以轻松解决问题,例如

    <!--link>
        <name>[Subprojects]/MOPS</name>
        <type>2</type>
        <location>/home/user/mops-c-Git/src/mopsc</location>
    </link-->
    

    并注释掉 .cproject 文件的子项目部分 &lt;pathentry&gt; 条目,例如

    <!--pathentry kind="src" path="MOPS"/>
    <pathentry excluding="MOPS/|**/CMakeFiles/" kind="out" path=""/-->
    

    【讨论】:

    • 啊哈!这也解决了我的问题,但是我手动创建了一个链接资源,这让调试器感到困惑,删除,工作,现在很棒!
    • @iondiode 是的,这确实是由于链接资源。如果您仍然需要链接资源,我找到了另一个解决方法,请参阅我的回答。
    【解决方案2】:

    确保已在“运行/运行”或“运行/调试”菜单中选择了要运行的可执行文件。

    【讨论】:

    • 检查了这个,不是问题。
    【解决方案3】:

    我遇到了类似的问题(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-&gt;General-&gt;File system-&gt;[... Create links in workspace...] 链接。

    我删除了这些链接,而是通过Project Properties-&gt;C/C++ General-&gt;Paths and Symbols-&gt;[tab] Source Location-&gt;Link folder... 链接到源代码。

    这使得调试器运行良好而没有抱怨。

    【讨论】:

      猜你喜欢
      • 2012-11-16
      • 2012-05-14
      • 2011-06-21
      • 2022-01-25
      • 2015-07-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-31
      相关资源
      最近更新 更多