- 浏览: 541272 次
文章分类
最新评论
-agentlib和-Xdebug区别
http://www.cnblogs.com/lailailai/p/4560399.html
写服务端程序,在开发环境下打开远程调试还是非常有用的,还原现场非常容易,让请求方再发个请求即可。如果下来本地调试的话很多环境与管理服务的地址配置什么的都可能不一样,增加了可变因素。
在需要启动服务调试的jvm启动参数中加入(注意:参数要排在启动类名的前面)
-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address= 1234
|
dt_socket:使用的通信方式
server:是主动连接调试器还是作为服务器等待调试器连接
suspend:是否在启动JVM时就暂停,并等待调试器连接
address:地址和端口,地址可以省略,两者用冒号分隔
根据文档和stackoverflow上的讨论,JVM 1.5以后的版本应该使用类似下面的命令(老的还是可以使用的):
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address= 1234
|
就是一个agentlib就行了,后面的参数都没有变,如果用intellij的远程调试配置的话,它会默认给出这两种参数,让你放到服务器的JVM参数里。
下面摘抄一下官方文档:
-Xdebug
-Xdebug
enables debugging capabilities in the JVM which are used by the Java Virtual Machine Tools Interface (JVMTI). JVMTI is
a low-level debugging interface used by debuggers and profiling tools. With it, you can inspect the state and control the execution of applications running in the JVM.
The subset of JVMTI that is most typically used by profilers is always available. However, the functionality used by debuggers to be able to step through the code and set breakpoints has
some overhead associated with it and is not always available. To enable this functionality you must use the-Xdebug
option.
WARNING: | When running with -Xdebug the JVM is not running at its full speed. Thus, the option should not be used for applications when running in production environments. |
Operation
Include this option at startup.
java
-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n
myApp
-Xrunjdwp
This option loads the JPDA reference implementation of JDWP. This library resides in the target VM and uses JVMDI and JNI to interact with it. It uses a transport and the JDWP protocol to communicate with a separate debugger application.
Operation
Format:-Xrunjdwp:<name1>[=<value1>],<name2>[=<value2>]...
The-Xrunjdwp
option can be further qualified by specifying one of the sub-options listed inTable2-8.
java-Xrunjdwp:transport=dt_socket,server=y,address=8000
myApp
- Listens for a socket connection on port 8000.
-
Suspends this VM before main class loads (
suspend=y
by default). - Once the debugger application connects, it can send a JDWP command to resume the VM.
-Xrunjdwp:transport=dt_shmem,server=y,suspend=n
-
Chooses an available shared memory transport address and print it to
stdout
. - Listens for a shared memory connection at that address.
- Allows the VM to begin executing before the debugger application attaches.
-Xrunjdwp:transport=dt_socket,address=myhost:8000
- Attaches to a running debugger application via socket on host myhost at port 8000.
- Suspends this VM before main class loads.
-Xrunjdwp:transport=dt_shmem,address=mysharedmemory
-
Attaches to a running debugger application via shared memory at transport address
mysharedmemory
. - Suspends this VM before main class loads.
-Xrunjdwp:transport=dt_socket,server=y,address=8000,onthrow=java.io.IOException,launch=/usr/local/bin/debugstub
-
Waits for an instance of
java.io.IOException
to be thrown in this VM. -
Suspends the VM (
suspend=y
by default). - Listens for a socket connection on port 8000.
- Executes the following:
/usr/local/bin/debugstub dt_socket myhost:8000
This program can launch a debugger process in a separate window which will attach to this VM and begin debugging it.
-Xrunjdwp:transport=dt_shmem,server=y,onuncaught=y,launch=d:\bin\debugstub.exe
- Waits for an uncaught exception to be thrown in this VM.
- Suspends the VM.
- Selects a shared memory transport address and listen for a connection at that address.
- Executes the following:
d:\bin\debugstub.exe dt_shmem <address>
where<address>
is the selected shared memory address.
This program can launch a debugger process in a separate window which will attach to this VM and begin debugging it.
另外一篇文档(JPDA Connection and Invocation Details):
Sun VM Invocation Options
This section describes the options necessary to invoke Sun VMs for debugging.
Sun's VM implementations require command line options to load the JDWP agent for debugging. From 5.0 onwards the-agentlib:jdwpoption is used to load and specify options to the JDWP agent. For releases prior to 5.0, the-Xdebugand-Xrunjdwpoptions are used (the 5.0 implementation also supports the-Xdebugand-Xrunjdwpoptions but the newer-agentlib:jdwpoption is preferable as the JDWP agent in 5.0 uses the JVM TI interface to the VM rather than the older JVMDI interface).
If your debugger application uses the JDISun Command Line Launching Connector, the connector will use the-Xdebugand-Xrunjdwpoptions as the Connector may be used to connect to a pre-5.0 target VM.
If the target VM is 5.0 or newer the-agentlib:jdwpoption is specified as follows:
For releases prior to 5.0 the-Xdebugand-Xrunjdwpoptions are used:
-agentlib:jdwp and -Xrunjdwp sub-options
The -agentlib:jdwp and -Xrunjdwp option can be further qualified with sub-options. The sub-options are specified as follows:
-agentlib:jdwp=<name1>[=<value1>],<name2>[=<value2>]...
or
-Xrunjdwp:<name1>[=<value1>],<name2>[=<value2>]...
The table below describes the options that can be used:
help | no | N/A | Prints a brief help message and exits the VM. |
transport | yes | none | Name of the transport to use in connecting to debugger application. |
server | no | "n" |
If "y", listen for a debugger application to attach; otherwise, attach to the debugger application at the specifiedaddress.
If "y" and no address is specified, choose atransport addressat which to listen for a debugger application, and print the address to the standard output stream. |
address |
yes, ifserver=n no, otherwise |
"" | Transport addressfor the connection. If server=n, attempt to attach to debugger application at this address. If server=y, listen for a connection at this address. |
timeout | no | "" | If server=y specifies the timeout, in milliseconds, to wait for the debugger to attach. If server=n specifies the timeout, in milliseconds, to use when attaching to the debugger. Note that the timeout option may be ignored by some transport implementations. |
launch | no | none |
At completion of JDWP initialization, launch the process given in this string. This option is used in combination withonthrowand/oronuncaughtto provide "Just-In-Time debugging"
in which a debugger process is launched when a particular event occurs in this VM.
Note that the launched process is not started in its own window. In most cases the launched process should be a small application which in turns launches the debugger application in its own window. The following strings are appended to the string given in this argument (space-delimited). They can aid the launched debugger in establishing a connection with this VM. The resulting string is executed.
|
onthrow | no | none | Delay initialization of the JDWP library until an exception of the given class is thrown in this VM. The exception class name must be package-qualified.Connection establishment is included in JDWP initialization, so it will not begin until the exception is thrown. |
onuncaught | no | "n" | If "y", delay initialization of the JDWP library until an uncaught exception is thrown in this VM. Connection establishment is included in JDWP initialization, so it will not begin until the exception is thrown. See the JDI specification for com.sun.jdi.ExceptionEvent for a definition of uncaught exceptions. |
suspend | no | "y" | If "y", VMStartEvent has a suspendPolicy of SUSPEND_ALL. If "n", VMStartEvent has a suspendPolicy of SUSPEND_NONE. |
相关推荐
执行java时带上参数-agentlib:<动态文件所在路径>\classloader 注意此处不要后缀名.dll(或者.so)。 如: windows下执行java: java -agentlib:C:\classloader HelloWorld Linux、Unix等系列操作系统下执行java: ...
JBOSS等JAVA Application Server(应用服务器),修改启动脚本,把执行java的命令行加上参数-agentlib:<所在路径>\lanswon 适用环境 操作系统:Windows 98/2000/XP 等Windows系统 JDK:1.5.0及以上版本
java -agentlib:c:\jvm\deClass Hello deClass就是deClass.dll,注意不需要加.dll tomcat 修改tomcat的bin目录下catalina.bat set JAVA_OPTS=-agentlib:c:\jvm\deClass linux下 拷贝libdeclass.so到/lib下 java -...
执行java时带上参数-agentlib:<动态文件所在路径>\classloader 注意此处不要后缀名.dll(或者.so)。 如: 我把classloader.dll放在C:\目录下; 运行加密后的class文件命令如下: windows下执行java: java -agentlib:...
自定义main方法),运行java时,带上参数-agentlib:<所在路径>\hidea Tomcat等JAVA Web Server,修改启动脚本,把执行java的命令行加上参数-agentlib:<所在路径>\hidea JBOSS等JAVA Application Server...
Tomcat、Jboss等Java application server修改启动脚本,把执行java的命令行后面加上参数-agentlib:<动态链接库文件所在路径>\classloader 适应环境: 操作系统:所有操作系统,Windows系统、Linux/Unix,只是运行...
SUN JDK 1.6/1.7 64bit的JDBC-ODBC Bridge有个缺陷:会随机抛出异常如下,在所有的ODBC Driver上。 java.sql.SQLException: [Microsoft][ODBC Driver...java -agentlib:JdbcOdbcPatch -Xmx... -Xms... 有问题请联系我
独立的应用程序,运行java时,带上参数-agentlib:<动态库文件所在路径>\classloader Tomcat、Jboss等Java application server修改启动脚本, 把执行java的命令行后面加上参数-agentlib:<动态链接库文件所在路径>\...
执行java时带上参数-agentlib:<动态文件所在路径>\classloader 注意此处不要后缀名.dll(或者.so)。 如: 我把classloader.dll放在C:\目录下; 运行加密后的class文件命令如下: windows下执行java: java -agentlib:...
在您使用的Java Web Server的启动参数中,增加以下内容: -agentlib:的存放目录>\brainysoft即 可。 举例 : 假设您的Java Web Server为Tomcat,以Windows平台为例,Tomcat的存放目录为C:\Tomcat 5.5 ,...
加密核心用 c++ 编写,可以良好运行在 windows 和 linux 系统下。 系统介绍 Java 类文件加密专家是一款针对Java应用程序Class二进制文件加密的软件,系统核心由纯C语言编写,运行效率极高。传统的Java程序加密的...
1. 查询是否默认安装有JDK [root@localhost bin]# java -version java version 1.6.0_22 OpenJDK Runtime Environment (IcedTea6 1.10.4) (rhel-1.41.1.10.4.el6-x86_64) OpenJDK 64-Bit Server VM ...
3.EJB组件 运行加密后的EJB组件的方式与运行WEB应用程序类似,找到您的EJB容器的启动配置文件,加入-agentlib: <brainysoft.dll的存放目录>\brainysoft 即可。 <br> 应用环境 JavaClass文件加密...
see also, -agentlib:jdwp=help and -agentlib:hprof=help -agentpath:[=] load native agent library by full pathname -javaagent:[=] load Java programming language agent, see java.lang.instrument -...
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar eladmin-starter-2.6.10.jar >nohup.out 2>&1 & 若外置依赖启动参数需添加。外置依赖可以大大减少jar包的体积。方便后续更新部署 -D...
众所周知,Java编译后的Jar包和Class文件,可以轻而易举的使用反编译工具(如JD-GUI)进行反编译,拿到源码。为了保护自己发布的Jar包和Class文件,采用的方式大多是混淆方式,这种方式对于Class文件的加密是不彻底...
用法要使 Schmetterling 调试进程,您必须使用以下编译器选项打开dt_socket : -agentlib:jdwp=transport=dt_socket,server=y,suspend=n因此,对于 leiningen,在您的 project.clj 中添加以下行: :jvm-opts ["-...
-agentlib:jdwp=transport=dt_socket,address=localhost:35795,suspend=y,server=y BeTraceThread 可以参考 * 具体启动参数可以参考JDI相关文档,JDI的三种attach方式都支持,然后用以下方式 * java -classpath ...
阿里巴巴Socket GraalVM本机图像演示 要求 安装了本机映像的GraalVM 20.3.0 ...$ java -agentlib:native-image-agent=config-output-dir=./target/native-image/ -jar target/ali-rsocket-graal-demo.jar
干草堆垛机文件索引器和搜索软件。建立项目只需运行: mvn clean install这将创建CLI客户端jar。运行服务器只需运行HaystackerApplication.kt 。运行shell客户端从终端(不适用于IntelliJ): java -jar haystacker-...