jvmti

How to get Object ID as used in Heap Dump

 ̄綄美尐妖づ 提交于 2019-12-11 05:19:42
问题 I would like to be able to get the same ID that is being used in Java heap dumps (created via jmap or JMX, etc). This is to be able to identify the live object at the still running application versus an older memory snapshot (the heap dump) of the same app. I have already tested a little and it is obvioulsy not the hashCode, neither the JDI unique ID (which you can see in your debuggers). From checking the code in the sun.jvm.hotspot.utilities I assume it is the objects address in memory. But

JDI, Java Byte code instrumentation and Java agents (JWDP, JVMTI)

一笑奈何 提交于 2019-12-11 04:38:17
问题 I am new in the realm of debuggers, instrumentation and JVMTI. So I have few questions about them. What is the difference between JDI(java debugger interface), JWDP, javaagent and native agent(JVMTI). and where does the java instrumentation API fit in picture. I am using JDI to intercept exceptions in target java application. but I found out that JDI is not good enough if we talk about how it impacts the performance of target app. I read that most good applications does this with combining

Communication between JVMTI agent and separate JVM

二次信任 提交于 2019-12-11 04:23:35
问题 First off i apologize as this is somewhat answered already here, but I think my situation is a bit different. How to communicate with jvmti agent attached on a running JVM My main question is... I am wondering if there are anyways using the JNI or other libraries to communicate between a JVMTI Native Agent and a completely separate JVM. Here is a small illustration So whats happening here. The JVM on the left is loaded with a native agent. Just for discussion sake let's assume I have no

Identifying exceptions through JVMTI

你。 提交于 2019-12-10 18:16:37
问题 I'm writing an instrumentation tool for Java applications using JVMTI. I've seen that JVMTI detects when an exception has been thrown and when has been caught according to http://docs.oracle.com/javase/7/docs/platform/jvmti/jvmti.html#Exception. This document states for both events Exception and ExceptionCatch The exception field identifies the thrown exception object. although it does not indicate on how to compare them during the run (i.e. to compare an exception provided in Exception

Failed to redefine class When I try to retransform class

大憨熊 提交于 2019-12-09 07:31:25
I was trying to modify class dynamically, such as call sleep() before a line. I attached agent to a jvm during runtime using Attach method. Then I got target class from jvm, and modified it(Add a line to call sleep() ). And I got redine class error. I am using JDK1.6. I am using ASM core API to modify class. The Error: Caused by: java.lang.UnsupportedOperationException: class redefinition failed: attempted to change the schema (add/remove fields) at sun.instrument.InstrumentationImpl.retransformClasses0(Native Method) at sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl

Overhead of enabling JVMTI *capability* to query local variables

走远了吗. 提交于 2019-12-08 04:11:35
问题 I'm working on a simple dynamic language that runs on the JVM. One of the required capabilities is this: only when an exception is thrown , I need to be able to query the local variables for all frames in the call stack at the time the exception is thrown. This capability is not available in standard Java or reflection. Thus I'm looking at the following idea: Write a simple JVMTI shared object in C When an exception gets thrown in Java-land, trigger a JVMTI function Code in the JVMTI lib

Identify the current JVM with Java or JVMTI

雨燕双飞 提交于 2019-12-08 02:04:06
问题 I would like to identify the current JVM which is run. In the best case with a function described in the JVMTI Documentation, but I cannot find anything. What I meant, is something like this: VirtualMachine.list() delivers: [sun.tools.attach.WindowsAttachProvider@46ae506e: 2440 de.fu.profiler.view.MainFrame... But it displays all JVMs, not the current one being run. 回答1: You can get a unique name from the RuntimeMXBean. on most platforms, this includes the processid of the current process.

How to get parameter values in a MethodEntry callback

允我心安 提交于 2019-12-07 20:54:01
问题 I have the following java code public class Test { public void sayHello(String msg) { System.out.println(msg); } } new Test().sayHello("Bonjour"); I have a jvmti agent attached to java where I catch function calls. I want to get parameter value which was passed to my method (e.g. "Bonjour") static void JNICALL cbMethodEntry(jvmtiEnv *jvmti, JNIEnv* jni_env, jthread thread, jmethodID method) { // here I want to get a parameter value "Bonjour" // which was passed to my method sayHello("Bonjour"

How to retransform an executing method with JVMTI agent which has no further invocations?

Deadly 提交于 2019-12-05 02:21:58
I am instrumenting a class file during runtime for various purposes. I'm using a JVMTI agent to that end. My strategy to instrument a method is to call RetransformClasses function to invoke ClassFileLoadHook . This strategy works fine for all the methods which have any further invocation after the time of instrumentation because actual instrumentation happens at subsequent function call, but it doesn't work for any method which does not have further invocations like main function in a program. I want to instrument a method on the fly during its execution. I want some procedure like On-Stack

Got “UnsupportedOperationException” when try to retransformClasses

谁说我不能喝 提交于 2019-12-02 16:13:35
问题 JDK1.6, modify class loaded in jvm dynamically. When I comment the code: classReader.accept(classAdapter, ClassReader.SKIP_DEBUG); , the exception "UnsupportedOperationException" disapear. Actually, for testing my code, I didnt modify any field or method. But the program catch exception "UnsupportedOperationException" , after calling retransformClasses() . Anyone has similar exception? Can any give me some advices? thx Codes are as follow: public byte[] modifySleepMethod() throws Exception {