简体   繁体   English

Eclipse 调试器未遵循源代码

[英]Eclipse Debugger not following the source code

I have encountered a problem with the Eclipse and I am unsure how to fix it.我遇到了 Eclipse 问题,但不确定如何解决。 When I enter the debugger and press the step over button the debugger usually highlights the line of source code that I stepped to.当我进入调试器并按下 step over 按钮时,调试器通常会突出显示我步进到的源代码行。 However, for some reason this is not working for me anymore.但是,由于某种原因,这不再适合我。 I enter the debugger and go to the breakpoint but if I hit the step button the source is not highlighted and if I continue to hit the step button I can see that the Debugger is stepping into other files (looking at the Thread) but my view of my code doesn't change.我进入调试器并转到断点,但是如果我点击 step 按钮,源不会突出显示,如果我继续点击 step 按钮,我可以看到调试器正在进入其他文件(查看线程),但我的观点我的代码没有改变。 The only way I can find what line my Debugger is on is if I control click on the line from Debug tab and click Lookup Source which then highlights the line the Debug Current Construction pointer is on.我可以找到调试器所在行的唯一方法是,如果我控制单击“调试”选项卡中的行,然后单击“查找源”,然后突出显示“调试当前构造”指针所在的行。 If I am debugging I would like to follow this Current Construction pointer line by line.如果我正在调试,我想一行一行地跟踪这个 Current Construction 指针。 I must have accidentally altered this somehow and I am unsure how to change it back.我一定是不小心以某种方式改变了它,我不确定如何将它改回来。

Simply stated the problem is this, usually the Eclipse Debugger highlights your source code as you step through it.简单地说,问题是这样的,通常 Eclipse 调试器会在您逐步执行时突出显示您的源代码。 It is not doing that for me anymore, the debugger is stepping properly but it is not highlighting the line of code that it is on.它不再对我这样做了,调试器正在正确步进,但它没有突出显示它所在的代码行。

This happens when we make Java code change in file, compiler creates a class but running server has a old copy of your class file.当我们在文件中更改 Java 代码时,会发生这种情况,编译器创建一个类,但运行的服务器具有类文件的旧副本。 Go with JRebel to get rid of such kind of issues.与 JRebel 一起摆脱此类问题。

This can also happen if you have more than one project in you work space, and you create a debug configuration that points at the wrong project base directory.如果您的工作空间中有多个项目,并且您创建了指向错误项目基目录的调试配置,也会发生这种情况。

To resolve this:要解决此问题:

  1. Open your debug configuration list (Run -> Debug Configurations)打开您的调试配置列表(运行 -> 调试配置)
  2. Select the proper configuration under your Remote Java Application list在您的远程 Java 应用程序列表下选择正确的配置
  3. Verify that you have the correct project source listed under the Base directory on the Main tab.验证您在 Main 选项卡上的 Base 目录下列出了正确的项目源。

If you have the wrong directory selected (say, one that holds a different project), the debugger will start with no issues, but you will not be able to step through your code.如果您选择了错误的目录(例如,包含不同项目的目录),调试器启动时不会出现问题,但您将无法单步调试代码。

I had the same issue.我遇到过同样的问题。

There was a workaround for that by right-clicking on associated callstack line in Debug view and selecting "Lookup Source".通过右键单击调试视图中的关联调用堆栈行并选择“查找源”,有一种解决方法。 After that the current instruction line is (green) highlighted as usual.之后,当前指令行像往常一样突出显示(绿色)。 But I needed to do this after every debug step.但是我需要在每个调试步骤之后执行此操作。

Rebuild all projects didn't help.重建所有项目没有帮助。

The solution: Restart Eclipse and all works fine.解决方案:重新启动 Eclipse,一切正常。

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

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