Domanda

Se voglio realizzare un profiler utilizzando bytecode strumentazione , dovrei scrivere un agente nativo con JVMTI o dovrei scrivere un < strong> agente java utilizzando il pacchetto java.lang.instrument?

Se voglio usare librerie come ASM - che sembra essere obbligatorio se si desidera creare un serio profiler - devo utilizzare un agente java. Il che mi confonde, perché ho pensato un agente nativo può fare tutto quello che un agente di Java può fare di più. Ma a me, sembra più facile scrivere un agente java.

Ci sono alternative? Qualora un uso agente java e l'agente nativo combinato comunque?

È stato utile?

Soluzione

Nearly everyone writes a java agent (with ASM or BCEL) as they don't want to have to write a C/C++ bytecode instrumentor from scratch as there are none publicly available.

What you won't be able to do is instrument and profile/monitor the primordial JVM, and accessing native functions requires JNI calls. There are also several JVMTI calls that may be unavailable to you (if memory serves).

I wrote my own instrumentor in C several years ago, and I'm in the process of writing a new one which I hope to open source ( depending on my evil overlords :-) )

How about a half way house, a separate pre-started JVM that your native agent sends bytecode to. In that JVM your easy-peasy to write ASM based instrumentor does the hard work and sends the resulting bytecode back to the native agent over the wire. Yeah it seems a bit over-complicated but it's easier that writing your own BCI library.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top