调试 Eclipse 插件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13324722/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 19:23:00  来源:igfitidea点击:

Debugging Eclipse plug-ins

eclipsedebuggingeclipse-plugin

提问by Anand

This is my first attempt at creating an Eclipse plug-in. I've created one, along with a feature and update site. I set the target platform as my local Eclipse installation. When I run/debug the plugin from within the development environment everything works fine.

这是我第一次尝试创建 Eclipse 插件。我已经创建了一个,以及一个功能和更新站点。我将目标平台设置为我的本地 Eclipse 安装。当我从开发环境中运行/调试插件时,一切正常。

Now, my colleague installed the plug-in from the update site that I hosted. When he starts using any of the functionality exposed by my plugin he gets runtime exceptions.

现在,我的同事从我托管的更新站点安装了插件。当他开始使用我的插件公开的任何功能时,他会收到运行时异常。

  1. He sees null pointer exceptions which didn't occur when I ran my plug-in project from my development environment.
  2. I have a wizard that's part of my plug-in. When he close it he gets a "Unhandled event loop exception", and the wizard doesn't close. I didn't have this issue when I was running/debugging my plugin in my development environment.
  1. 他看到我从开发环境运行插件项目时没有发生空指针异常。
  2. 我有一个向导,它是我插件的一部分。当他关闭它时,他得到一个“未处理的事件循环异常”,并且向导没有关闭。我在开发环境中运行/调试插件时没有遇到这个问题。

Now I'm confused as to why the same plug-in is behaving differently in the production environment, as against the dev environment and when I was debugging it from my IDE. The target platform in both cases is the same Eclipse version. What could be the reasons?

现在我很困惑为什么同一个插件在生产环境中表现不同,与开发环境相比,当我从我的 IDE 调试它时。两种情况下的目标平台都是相同的 Eclipse 版本。可能是什么原因?

And how do I debug the plug-in in a production environment? Is there a remote debugging capability for debugging the plug-ins on the production environment? Any suggestions would be really useful!

以及如何在生产环境中调试插件?是否有远程调试能力,可以在生产环境调试插件?任何建议都会非常有用!

回答by tkotisis

To remote debug your plug-in, first add debug arguments to your target Eclipse .ini file

要远程调试插件,首先将调试参数添加到目标 Eclipse .ini 文件

-vmargs
-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044

before launching it.

在启动它之前。

Then open another Eclipse instance with a workspace containing your plug-in project. Open Run> Debug Configurations..., select Remote Java Applicationand create a new configuration.

然后使用包含插件项目的工作区打开另一个 Eclipse 实例。打开Run> Debug Configurations...,选择Remote Java Application并创建一个新配置。

As Project, browse and select your plug-in project. Also fill in your connection properties (hostof target Eclipse and port1044).

作为Project,浏览并选择您的插件项目。还要填写您的连接属性(目标 Eclipse主机端口1044)。

Launching the newly created debug configuration allows you to debug your plug-in the same way you debug locally.

启动新创建的调试配置允许您以与本地调试相同的方式调试插件。

回答by Jawher

Now I'm confused as to why the same plug-in is behaving differently in the production environment, as against the dev environment and when I was debugging it from my IDE. The target platform in both cases is the same eclipse version. What could be the reasons?

现在我很困惑为什么同一个插件在生产环境中表现不同,与开发环境相比,当我从我的 IDE 调试它时。两种情况下的目标平台都是相同的 eclipse 版本。可能是什么原因?

This is a classic: Eclipse plugins and RCP applications do indeed behave differently between PDT (the Eclipse IDE) and the exported product.

这是一个经典:Eclipse 插件和 RCP 应用程序在 PDT(Eclipse IDE)和导出的产品之间的行为确实不同。

In your case, a NullPointerException thrown from the exported version but not from Eclipse is 9 times out of 10 an image or other resource files (properties, etc.) that is loaded by your code but is not listed in the build.properties of your plugin.

在您的情况下,从导出版本而不是从 Eclipse 抛出的 NullPointerException 是由您的代码加载但未在 build.properties 中列出的图像或其他资源文件(属性等)的 10 次中的 9 次插入。

Anyway, you'll need to check the logs to retrieve the stacktrace and hunt down its cause. Such logs could be found in your friend's workspace under le .metadata/.logfile

无论如何,您需要检查日志以检索堆栈跟踪并找出其原因。此类日志可以在您朋友的工作区中的 le.metadata/.log文件下找到

回答by Stuart Cardall

See the Apache Wiki for Developing with Eclipse.

请参阅Apache Wiki 以使用 Eclipse 进行开发

Under Windows 10 with Tomcat running as a windows service I started:

在将 Tomcat 作为 Windows 服务运行的 Windows 10 下,我开始了:

tomcat8.5\bin\Tomcat8w.exe

tomcat8.5\bin\Tomcat8w.exe

& added in the Javatab as the firstentry in Java Optionsto enable remote debugging:

&在所添加的Java标签作为第一中条目的Java选项来启用远程调试:

-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n

-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n

回答by Chris Gerken

From your development workspace as it stands now, use the "Debug As -> Eclipse Application" menu item to startup a test workspace. When it starts up, you'll have two workspaces running: the original development workspace and the new test workspace. You can set breakpoints in your plugin code in the development workspace and run your plugin in the test workspace.

从现在的开发工作区,使用“Debug As -> Eclipse Application”菜单项启动测试工作区。当它启动时,您将有两个工作区在运行:原始开发工作区和新的测试工作区。您可以在开发工作区中的插件代码中设置断点,并在测试工作区中运行您的插件。

When your plugin execution in the test workspace gets to one of your breakpoints, execution will pause and you can use the Debug view in your development workspace to look at variables, set more breakpoints or anything else you want to do to debuf your plugin.

当您在测试工作区中的插件执行到达您的断点之一时,执行将暂停,您可以使用开发工作区中的调试视图来查看变量、设置更多断点或您想做的任何其他事情来调试插件。