简体   繁体   English

如何调试eclipse后端代码?

[英]How to debug eclipse backend code?

我正在工作的eclipse JUNO由我工作的公司自定义。当我单击特定菜单时,它没有按应有的方式工作。因此,我想查看负责该代码或可能是哪个代码单击该插件会被调用,该怎么办?

You have two options: 您有两种选择:

  1. Run your customized eclipse from your development environment in debug mode 在调试模式下从开发环境运行定制的Eclipse
  2. Attach to running customized eclipse using Eclipse remote debugger 使用Eclipse远程调试器附加到运行自定义的Eclipse

Both options require to have configured development environment in Eclipse, I prefer to use option (2) because it doesn't require to have everything compiled and you always can add missing sources into development environment being in debugging session. 这两个选项都需要在Eclipse中配置开发环境,我更喜欢使用选项(2),因为它不需要编译所有内容,并且您总是可以在调试会话中将缺少的源添加到开发环境中。

(1) You need to have all sources imported in dev eclipse and compiled without errors. (1)您需要将所有源代码都导入dev eclipse并进行编译,而不会出现错误。 Then you just create Eclipse Application launch configuration and run it in debug mode. 然后,您只需创建Eclipse Application启动配置并在调试模式下运行它即可。

(2) Yo need to start your customized eclipse with remote debugger enabled. (2)您需要在启用远程调试器的情况下启动您的自定义蚀。 Add in your custom eclipse eclipse.ini file following lines in -vmargs part 在-vmargs部分中的以下行中添加自定义eclipse eclipse.ini文件

-Xdebug
-Xrunjdwp:transport=dt_socket,address=8001,server=y,suspend=y

So you would have something like this 所以你会有这样的事情

-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.100.v20110505
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-XX:MaxPermSize=512m
-Xms1024m
-Xmx2048m
-Xdebug
-Xrunjdwp:transport=dt_socket,address=8001,server=y,suspend=y

Now you can start custom eclipse. 现在您可以开始自定义蚀了。 You won't see anything because it would be in debug mode and wait until remote debugger is attached. 您将看不到任何东西,因为它将处于调试模式,请等待附加远程调试器。 Console output should contain message 控制台输出应包含消息

...
Listening for transport dt_socket at address: 8001

In your development eclipse import source code you want to debug. 在您的开发eclipse导入源代码中,您要调试。 Make sure you use source code the custom eclipse was built from or line numbers won't match in debug. 确保您使用的是自定义Eclipse的源代码,否则行号在调试中将不匹配。 There is no need to have source compiled without errors. 无需正确编译源代码。

Go in Project->Debug Configurations ... and create new Remote Java Application config. 进入Project-> Debug Configurations ...并创建新的Remote Java Application配置。

Give it name you want and configure port as 8001 (see options in eclipse.ini above). 给它起所需的名称,并将端口配置为8001(请参阅上面的eclipse.ini中的选项)。

Go to Source tab and add all projects with sources you need during debug. 转到“源”选项卡,并添加所有项目以及调试期间所需的源。

Run it, ignore warning about compilation errors and you should see eclipse splash form your custom eclipse started before. 运行它,忽略关于编译错误的警告,您应该从之前开始的自定义Eclipse中看到Eclipse Splash。 After that you can use debugger as usual. 之后,您可以照常使用调试器。

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

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