简体   繁体   English

如何从Intellij IDEA中删除指向旧/丢失源的(虚拟)断点?

[英]How to remove (phantom) breakpoints pointing to old/missing source from Intellij IDEA?

Using Intellij (v14 and now v15) I have put breakpoints to debug no-yet released classes coming from an external dependency (usually a snapshot version) for a web app running in Tomcat 7+. 使用Intellij(v14,现在是v15),我已经设置了断点来调试在Tomcat 7+中运行的Web应用程序的外部依赖(通常是快照版本)发布的尚未发布的类。

when I change that external dependency to a released version, recompile the project and run in debug mode; 当我将外部依赖关系更改为发行版本时,重新编译项目并以调试模式运行; IntelliJ still halts the execution at the old class breakpoint even though the breakpoint no longer exists in the breakpoint list view (from menu: Run > Breakpoints). 即使该断点不再存在于断点列表视图中(从菜单:“运行”>“断点”),IntelliJ仍会在旧类断点处停止执行。

I have tried the following: 我尝试了以下方法:

  • Clean and rebuild all artifacts before launching the app to make sure the deployed apps have the updated dependencies. 在启动应用程序之前,请清理并重建所有工件,以确保已部署的应用程序具有更新的依赖性。
  • Run the "Invalidated Caches / Restart" feature, which clear my beloved file change history but not these breakpoints. 运行“无效的缓存/重新启动”功能,该功能将清除我心爱的文件更改历史记录,但不会清除这些断点。
  • Remove all breakpoints: (which clear the current valid breakpoints but not the phantom breakpoints since they are not in the current list) 删除所有断点:(清除当前有效断点,但不清除幻像断点,因为它们不在当前列表中)

The only thing that has worked for me, is to re-attach the exact old source jar (whenever possible) look for the affected class and remove the breakpoint from there. 对我有用的唯一方法是,重新附加确切的旧源jar(如果可能),寻找受影响的类并从那里删除断点。

Is there any less inconvenient way to clear these phantom breakpoints? 有什么不便的方法可以清除这些幻像断点?

Disclaimer : This is perhaps best suited as a comment but does not fit the limited number of chars. 免责声明 :这也许最适合作为注释,但不适合有限数量的字符。


Nice catch! 好赶上! I never had this problem before but I managed to reproduce it by switching the JDK version. 我以前从未遇到过这个问题,但是我设法通过切换JDK版本来重现它。 I simply opened java.io.File from JDK8 and set a breakpoint on line 276: 我只是从JDK8中打开java.io.File并在第276行设置了一个断点:

public File(String pathname) {
    if (pathname == null) { // <= breakpoint here
        throw new NullPointerException();
    }
    this.path = fs.normalize(pathname);
    this.prefixLength = fs.prefixLength(this.path);
}

Then I switched to JDK6 which has a simple right-curly-bracket ( } ) on that line. 然后,我切换到JDK6,该行在该行上有一个简单的右弯括号( } )。 However, when pressing CTRL + SHIFT + F8 (windows) the breakpoint IS available, but has the description of the old source file: 但是,当按CTRL + SHIFT + F8 (Windows)时,断点是可用的,但是具有旧源文件的描述:

断点

This got me thinking, so I tried to figure out where the breakpoints are stored, and it turns out they're in <project root>/.idea/workspace.xml under the <component name="XDebuggerManager"> section: 这让我开始思考,因此我试图找出断点的存储位置,结果发现断点位于<project root>/.idea/workspace.xml <component name="XDebuggerManager"> <project root>/.idea/workspace.xml<component name="XDebuggerManager">部分下:

<component name="XDebuggerManager">
    <breakpoint-manager>
      <breakpoints>
        ...
        <line-breakpoint enabled="true" type="java-line">
          <url>jar://C:/Program Files/Java/jdk1.8.0_45/src.zip!/java/io/File.java</url>
          <line>275</line>
          <properties />
          <option name="timeStamp" value="4" />
        </line-breakpoint>
      </breakpoints>
      ...

So it looks like it keeps a reference to the initial file. 因此,它似乎保留了对初始文件的引用。 I'm not sure whether the breakpoints would still appear in the list when you're using maven, gradle, etc, case in which it would be easy to reference the path to your old jar from the local repo, but at this point I don't think it matters anyway. 我不确定当您使用Maven,Gradle等时,断点是否仍会出现在列表中,在这种情况下,从本地存储库中引用旧jar的路径很容易,但是在这一点上,我无论如何都没关系。

Quick workaround (maybe?!) : Nonetheless, if you manually remove the phantom breakpoint from the xml and save the file, IJ will automatically pick up the change, and update the setting. 快速的解决方法(也许?!) :尽管如此,如果您从xml中手动删除幻影断点并保存文件,IJ将自动获取更改并更新设置。 At the minimum after doing it, the breakpoint no longer appeared in my list. 至少这样做后,断点不再出现在我的列表中。

A quick search on their tracker revealed this issue affecting v14.1.1 (I'm currently on 14.1.6) which seems to not be fixed yet, so I guess we'll just have to wait until it gets fixed (somehow, because right now I can't think of a simple/decent way). 在他们的跟踪器上快速搜索发现此问题影响了v14.1.1(我目前在14.1.6上),该问题似乎尚未修复,所以我想我们只需要等待它修复即可(某种程度上,因为正确现在我想不出一种简单/体面的方式)。

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

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