Java JVMTI 不能与 -Xdebug -Xrunjdwp 一起使用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1562979/
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-10-29 17:05:58  来源:igfitidea点击:

Java JVMTI doesn't work alongside -Xdebug -Xrunjdwp

javadebuggingjvmtijdwp

提问by Jim Garrison

I spent the last 4 hours trying to set up Eclipse TPTP memory profiling on a Tomcat instance that must be run remotely (i.e. not in Eclipse). This should be possible according to the TPTP and Agent Controller docs.

我花了最后 4 个小时试图在必须远程运行的 Tomcat 实例上设置 Eclipse TPTP 内存分析(即不在 Eclipse 中)。根据 TPTP 和 Agent Controller 文档,这应该是可能的。

I installed the TPTP components (4.6.0) into my Eclipse (Galileo) workbench, along with the Agent Controller according to the instructions on the website. To enable the agent, I added the following options to the command line that starts the Tomcat instance:

我根据网站上的说明将 TPTP 组件 (4.6.0) 以及代理控制器安装到我的 Eclipse (Galileo) 工作台中。为了启用代理,我在启动 Tomcat 实例的命令行中添加了以下选项:

-agentlib:JPIBootLoader=JPIAgent:server=enabled;HeapProf:allocsites=true

and added the following directories to the front of the PATH:

并将以下目录添加到 PATH 的前面:

D:\dev\tools\ac\plugins\org.eclipse.tptp.javaprofiler
D:\dev\tools\ac\bin

When attempting to start Tomcat I consistently got the following error message:

尝试启动 Tomcat 时,我始终收到以下错误消息:

ERROR: JDWP unable to get necessary JVMTI capabilities. ["debugInit.c",L279]

I did a lot of Googling but found nothing relevant; I tried reinstalling TPTP and various versions of the Agent Controller.

我做了很多谷歌搜索,但没有发现任何相关内容;我尝试重新安装 TPTP 和各种版本的代理控制器。

In the end the problem turned out to be that I was starting Tomcat with the "jpda" option, which catalina.bat translates into

最后问题是我用“jpda”选项启动了Tomcat,catalina.bat转换成

-Xdebug -Xrunjdwp:transport=.....

Removing the "jpda" command argument caused JVMTI to start working.

删除“jpda”命令参数会导致 JVMTI 开始工作。

SO, the question is: I found nothing during any of my searches to indicate that a JVMTI agent is incompatible with debugging. Can someone explain what is going on and why JVMTI + JDWP is not a valid setup?

所以,问题是:在我的任何搜索过程中,我都没有发现任何东西表明 JVMTI 代理与调试不兼容。有人可以解释发生了什么以及为什么 JVMTI + JDWP 不是有效设置吗?

回答by Codebling

None of the answers so far are correct and this is the first hit that comes up on Google if you query the error mentioned, so I feel some clarification is needed.

到目前为止,没有一个答案是正确的,如果您查询提到的错误,这是 Google 上出现的第一个结果,所以我觉得需要澄清一下。

JVMTI and JDWP dowork together, in fact they generally must be used together. You will get ERROR: JDWP unable to get necessary JVMTI capabilitiesif -Xrunjdwp(and/or possibly -agentlib:jdwp) is specified more than once on the command line. To fix it, make sure you only have one of -Xrunjdwpor -agentlib:jdwpin your command line.

JVMTI 和 JDWP确实是一起工作的,实际上它们一般必须一起使用。您将获得ERROR: JDWP unable to get necessary JVMTI capabilitiesif -Xrunjdwp(和/或可能-agentlib:jdwp)在命令行中被多次指定。要修复它,请确保您的命令行中只有-Xrunjdwp-agentlib:jdwp之一。

For more details, read on...

有关更多详细信息,请继续阅读...

JVMTI (Java Virtual Machine Tool Interface) is the successor to JVMDI (Java Virtual Machine Debug Interface) and JVMPI (Java Virtual Machine Profiling Interface). It incorporates the functionality of both JVMDI and JVMPI, both of which were deprecated in Java 5 and removed in Java 6. It is the API that exposes the internals of the JVM for the purposes of debugging and profiling.

JVMTI(Java Virtual Machine Tool Interface)是JVMDI(Java Virtual Machine Debug Interface)和JVMPI(Java Virtual Machine Profiling Interface)的继承者。它结合了 JVMDI 和 JVMPI 的功能,这两者都在 Java 5 中被弃用并在 Java 6 中被删除。它是为了调试和分析的目的公开 JVM 内部的 API。

JDWP (Java Debug Wire Protocol) is a protocol that describes a simple mechanism for transmitting commands and responses. As far as I know, it is the only way for a debugger sitting outside the JVM to communicate with it and to interface with the JVMTI.

JDWP(Java Debug Wire Protocol)是一种描述传输命令和响应的简单机制的协议。据我所知,这是位于 JVM 外部的调试器与其进行通信并与 JVMTI 交互的唯一方式。

JDI (Java Debugger Interface) is a client-side (debugger-side) API which exposes some of the features of JVMTI while making use of JDWP more or less transparently.

JDI(Java 调试器接口)是一个客户端(调试器端)API,它公开了 JVMTI 的一些特性,同时或多或少地透明地使用 JDWP。

The bugmentioned in Bob Dobbs's answer concerns the misleading error message, and the fact that the JVM will try to load JDWP once for every time it is specified on the command line. It doesn't state anywhere that JDWP and JVMTI cannot be used together.

Bob Dobbs 的回答中提到的错误涉及误导性错误消息,以及 JVM 每次在命令行上指定时都会尝试加载一次 JDWP 的事实。它没有说明 JDWP 和 JVMTI 不能一起使用。

More info here: https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzaha/jpdebuga.htm

更多信息请访问:https: //www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzaha/jpdebuga.htm

回答by Bob Dobbs

I ran into the same problem as you, but I came up with a JVM bug report (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6354345) that cast some light on the issue. It basically comes down to the Java agent library not ever being intended to be loaded twice into the same VM. Sucks, but seems like it's basic limitation of the agent system that you can't do both at the same time.

我遇到了和你一样的问题,但我想出了一份 JVM 错误报告 ( http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6354345) 来阐明这个问题。它基本上归结为 Java 代理库从来没有打算两次加载到同一个 VM 中。很糟糕,但似乎是代理系统的基本限制,您不能同时执行这两项操作。

回答by mel3kings

For me it was the same issue as Code Bling post, they were duplicate -Xrunjdwpdidn't realize there were a second -Xrunjdwpas it was hidden in the variable %JAVA_OPTIONS%, check your Application Server start script.

对我来说,这是与 Code Bling 帖子相同的问题,它们是重复的-Xrunjdwp,没有意识到还有一秒钟,-Xrunjdwp因为它隐藏在变量中%JAVA_OPTIONS%,请检查您的应用程序服务器启动脚本。