【问题标题】:How to fix breakpoint error when debugging in Eclipse?在 Eclipse 中调试时如何修复断点错误?
【发布时间】:2013-12-19 02:26:21
【问题描述】:

需要调试一个JAR文件“ProA”,所以在项目中导入源代码, 但是在尝试设置断点时,Eclipse 中出现了一个奇怪的错误。 详情如下:

Unable to install breakpoint due to missing line number attributes.
Modify compiler options to generate line number attributes.

我尝试了几种方法来解决,但都失败了。

  1. Window > Preferences: Java > Compiler > Classfile Generation 下,所有选项都必须为 True
  2. 在项目的.settings 文件夹中,查找名为org.eclipse.jdt.core.prefs 的文件。验证或设置org.eclipse.jdt.core.compiler.debug.lineNumber=generate
  3. build.xml 中添加debug=true 标志,就像这样:<javac srcdir="./src/java" destdir="./bin" debug="true">

任何帮助将不胜感激。

【问题讨论】:

  • 您的配置似乎正确。只需尝试清理您的项目的构建。
  • 我已经清理了项目和tomcat,但问题仍然存在。
  • 我看了下面的地址,但没有解决问题,所以再问。 stackoverflow.com/questions/957822/…
  • 我自己解决了这个问题并详细说明了我是如何做到的:stackoverflow.com/a/46553615/1599699这可能是一个重复的 JAR 问题。

标签: java eclipse debugging breakpoints


【解决方案1】:

我也遇到了同样的问题,但是阅读您的帖子帮助我解决了我的问题。我将org.eclipse.jdt.core.prefs 更改如下:

之前:

eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7

之后:

eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7

在 Project> Properties> Java Compiler 中修改这些选项的另一种方法。因此,无需手动修改org.eclipse.jdt.core.prefs 文件。您需要确保选中 Classfile Generation 选项。

【讨论】:

    【解决方案2】:

    在 JAR 中,编译后的字节码中缺少行号属性。添加源代码后,Eclipse 知道行号,但不知道 Java VM,它执行字节码并且看不到源代码。

    如果 Eclipse 告诉 Java VM 在特定行停止,那将毫无用处,因为 Java VM 不知道哪个命令在哪一行,也不知道何时停止。

    唯一的解决方案是重新创建 JAR 或至少是字节码(.class 文件)带有您要设置的类的行信息断点。

    【讨论】:

      【解决方案3】:

      ****窗口->首选项->编译器**** 为了调试,我们需要在类文件中生成行号。 选择“将行号属性添加到生成的类文件(由调试器使用)后,重建项目并运行调试器以查看行号和断点以及执行指针。 enter image description here

      【讨论】:

        猜你喜欢
        • 2022-11-17
        • 2017-08-06
        • 1970-01-01
        • 2016-12-21
        • 2010-12-13
        • 1970-01-01
        • 2011-12-05
        • 2018-02-20
        • 1970-01-01
        相关资源
        最近更新 更多