...
 
Commits (4)
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="output/build/disl" path="src-disl"/>
<classpathentry kind="src" output="output/build/util" path="src-util"/>
<classpathentry kind="src" output="output/build/test" path="src-test"/>
<classpathentry kind="src" output="output/build/shvm-dispatch" path="src-shvm-dispatch"/>
<classpathentry kind="src" path="disl/src/src-classparser"/>
<classpathentry kind="src" path="disl/src/src-exception"/>
<classpathentry kind="src" path="disl/src/src-main"/>
<classpathentry kind="src" path="disl/src/src-resolver"/>
<classpathentry kind="src" path="disl/src/src-coderep"/>
<classpathentry kind="src" path="disl/src/src-util"/>
<classpathentry kind="src" path="disl/src/src-snippet"/>
<classpathentry kind="src" path="disl/src/src-processor"/>
<classpathentry kind="src" path="disl/src/src-guard"/>
<classpathentry kind="src" path="disl/src/src-localvar"/>
<classpathentry kind="src" path="disl/src/src-scope"/>
<classpathentry kind="src" path="disl-server/src"/>
<classpathentry kind="src" path="disl/src/src-staticcontext"/>
<classpathentry kind="src" path="disl/src/src-staticcontext-uid"/>
<classpathentry kind="src" path="disl/src/src-marker"/>
<classpathentry kind="src" path="disl/src/src-weaver"/>
<classpathentry kind="src" path="disl/src/src-weaver-pe"/>
<classpathentry kind="src" path="disl/src/src-annotation"/>
<classpathentry kind="src" path="disl/src/src-context"/>
<classpathentry kind="src" path="disl/src-test"/>
<classpathentry kind="src" path="shvm/src/src-msg-analyze"/>
<classpathentry kind="src" path="shvm/src/src-msg-instr"/>
<classpathentry kind="src" path="shvm/src/src-msg-analyze-mtdispatch"/>
<classpathentry kind="src" path="shvm/src/src-remoteanalysis"/>
<classpathentry kind="src" path="shvm/src/src-reqdispatch"/>
<classpathentry kind="src" path="shvm/src/src-shadow"/>
<classpathentry kind="src" path="shvm/src/src-util"/>
<classpathentry kind="src" path="shvm/src/src-server-api"/>
<classpathentry kind="src" path="shvm/src-test"/>
<classpathentry kind="src" path="shvm-server/src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="output/lib/disl-bypass.jar"/>
<classpathentry kind="lib" path="lib/disl/log4j.jar" sourcepath="lib/devel/log4j-source.jar"/>
<classpathentry kind="lib" path="lib/test/junit.jar" sourcepath="lib/devel/junit-source.jar"/>
<classpathentry kind="lib" path="lib/test/hamcrest-core.jar"/>
<classpathentry kind="lib" path="lib/disl/asm-tree.jar" sourcepath="lib/devel/asm-tree-source.jar"/>
<classpathentry kind="lib" path="lib/disl/asm.jar" sourcepath="lib/devel/asm-source.jar"/>
<classpathentry kind="lib" path="lib/disl/asm-analysis.jar" sourcepath="lib/devel/asm-analysis-source.jar"/>
<classpathentry kind="lib" path="lib/disl/asm-commons.jar" sourcepath="lib/devel/asm-commons-source.jar"/>
<classpathentry kind="lib" path="lib/disl/asm-util.jar" sourcepath="lib/devel/asm-util-source.jar"/>
<classpathentry kind="lib" path="lib/disl/protobuf-lite.jar"/>
<classpathentry kind="output" path="output/build/disl"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>DiSL</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
package ch.usi.dag.dislserver; package ch.usi.dag.dislserver;
import ch.usi.dag.dislserver.Protocol.*; import ch.usi.dag.dislre.protocol.Main.*;
import ch.usi.dag.dislre.protocol.DiSL.*;
import ch.usi.dag.util.logging.Logger; import ch.usi.dag.util.logging.Logger;
import com.google.protobuf.CodedInputStream; import com.google.protobuf.CodedInputStream;
import com.google.protobuf.CodedOutputStream; import com.google.protobuf.CodedOutputStream;
...@@ -141,7 +142,7 @@ final class ConnectionHandler implements Runnable { ...@@ -141,7 +142,7 @@ final class ConnectionHandler implements Runnable {
timer.mark (DiSLServer.ElapsedTime.PROCESS); timer.mark (DiSLServer.ElapsedTime.PROCESS);
sendMessage (response, timer); sendMessage (response, timer);
if (response.getInstrumentClassResponse ().getResult () == Protocol.InstrumentClassResponse.InstrumentClassResult.ERROR) { if (response.getInstrumentClassResponse ().getResult () == InstrumentClassResponse.InstrumentClassResult.ERROR) {
// //
// Error during instrumentation. Report it to the client // Error during instrumentation. Report it to the client
// and stop receiving requests from this connection. // and stop receiving requests from this connection.
......
...@@ -4,9 +4,9 @@ import ch.usi.dag.disl.DiSL; ...@@ -4,9 +4,9 @@ import ch.usi.dag.disl.DiSL;
import ch.usi.dag.disl.DiSL.CodeOption; import ch.usi.dag.disl.DiSL.CodeOption;
import ch.usi.dag.disl.DiSLException; import ch.usi.dag.disl.DiSLException;
import ch.usi.dag.disl.JavaNames; import ch.usi.dag.disl.JavaNames;
import ch.usi.dag.dislserver.Protocol.ClassInfo; import ch.usi.dag.dislre.protocol.DiSL.InstrClassInfo;
import ch.usi.dag.dislserver.Protocol.InstrumentClassRequest; import ch.usi.dag.dislre.protocol.DiSL.InstrumentClassRequest;
import ch.usi.dag.dislserver.Protocol.InstrumentClassResponse; import ch.usi.dag.dislre.protocol.DiSL.InstrumentClassResponse;
import ch.usi.dag.util.Strings; import ch.usi.dag.util.Strings;
import ch.usi.dag.util.logging.Logger; import ch.usi.dag.util.logging.Logger;
import com.google.protobuf.ByteString; import com.google.protobuf.ByteString;
...@@ -45,9 +45,9 @@ final class RequestProcessor { ...@@ -45,9 +45,9 @@ final class RequestProcessor {
// //
public InstrumentClassResponse process (final InstrumentClassRequest request) { InstrumentClassResponse process (final InstrumentClassRequest request) {
final byte [] classBytes = request.getClassBytes ().toByteArray (); final byte [] classBytes = request.getClassBytes ().toByteArray ();
final ClassInfo classInfo = request.getClassInfo (); final InstrClassInfo classInfo = request.getClassInfo ();
final String className = __getClassName (classInfo.getClassName (), classBytes); final String className = __getClassName (classInfo.getClassName (), classBytes);
final Set <CodeOption> options = CodeOption.setOf (request.getFlags ()); final Set <CodeOption> options = CodeOption.setOf (request.getFlags ());
...@@ -82,13 +82,13 @@ final class RequestProcessor { ...@@ -82,13 +82,13 @@ final class RequestProcessor {
} }
return InstrumentClassResponse.newBuilder () return InstrumentClassResponse.newBuilder ()
.setResult (Protocol.InstrumentClassResponse.InstrumentClassResult.CLASS_MODIFIED) .setResult (InstrumentClassResponse.InstrumentClassResult.CLASS_MODIFIED)
.setClassBytes (ByteString.copyFrom (newClassBytes)) .setClassBytes (ByteString.copyFrom (newClassBytes))
.build (); .build ();
} else { } else {
return InstrumentClassResponse.newBuilder () return InstrumentClassResponse.newBuilder ()
.setResult (Protocol.InstrumentClassResponse.InstrumentClassResult.CLASS_UNMODIFIED) .setResult (InstrumentClassResponse.InstrumentClassResult.CLASS_UNMODIFIED)
.build (); .build ();
} }
...@@ -100,7 +100,7 @@ final class RequestProcessor { ...@@ -100,7 +100,7 @@ final class RequestProcessor {
__log.error (message); __log.error (message);
return InstrumentClassResponse.newBuilder () return InstrumentClassResponse.newBuilder ()
.setResult (Protocol.InstrumentClassResponse.InstrumentClassResult.ERROR) .setResult (InstrumentClassResponse.InstrumentClassResult.ERROR)
.setErrorMessage (message) .setErrorMessage (message)
.build (); .build ();
} }
......
# ShadowVM server
The original lightweight implementation of analysis server. It doesn't do
instrumentation, only the analysis is performed.
Its only functionality is to receive the analysis requests and pass them to the
shvm object model library.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -9,6 +9,8 @@ import java.nio.channels.ClosedByInterruptException; ...@@ -9,6 +9,8 @@ import java.nio.channels.ClosedByInterruptException;
import java.nio.channels.ServerSocketChannel; import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel; import java.nio.channels.SocketChannel;
import ch.usi.dag.dislre.protocol.Main;
import ch.usi.dag.util.logging.Logger; import ch.usi.dag.util.logging.Logger;
...@@ -92,7 +94,7 @@ public abstract class DiSLREServer { ...@@ -92,7 +94,7 @@ public abstract class DiSLREServer {
final DataInputStream is = new DataInputStream ( final DataInputStream is = new DataInputStream (
new BufferedInputStream (sock.getInputStream ())); new BufferedInputStream (sock.getInputStream ()));
Protocol.AgentMessage agentMessage; Main.ClientMessage clientMessage;
int messageSize; int messageSize;
byte[] byteArray; byte[] byteArray;
while (true) { while (true) {
...@@ -107,9 +109,9 @@ public abstract class DiSLREServer { ...@@ -107,9 +109,9 @@ public abstract class DiSLREServer {
is.readFully (byteArray,0, messageSize); is.readFully (byteArray,0, messageSize);
agentMessage = Protocol.AgentMessage.parseFrom (byteArray); clientMessage = Main.ClientMessage.parseFrom (byteArray);
RequestDispatcher.ProcessMessage (server, agentMessage, __log); RequestDispatcher.ProcessMessage (server, clientMessage, __log);
} }
} catch (final Exception e) { } catch (final Exception e) {
......
package ch.usi.dag.dislreserver; package ch.usi.dag.dislreserver;
import ch.usi.dag.dislreserver.Protocol.*; import ch.usi.dag.dislre.protocol.Main.*;
import ch.usi.dag.dislre.protocol.Analysis.*;
import ch.usi.dag.util.logging.Logger; import ch.usi.dag.util.logging.Logger;
...@@ -15,30 +16,30 @@ final class RequestDispatcher { ...@@ -15,30 +16,30 @@ final class RequestDispatcher {
* Process the agent message, and pass the unpacked data to {@link SHVM} instance. * Process the agent message, and pass the unpacked data to {@link SHVM} instance.
* *
* @param shadowVM ShadowVM instance to process the requests. * @param shadowVM ShadowVM instance to process the requests.
* @param agentMessage The agent message. * @param clientMessage The agent message.
* @param logger Logger * @param logger Logger
* @throws DiSLREServerException * @throws DiSLREServerException
*/ */
static void ProcessMessage( static void ProcessMessage(
final SHVM shadowVM, final AgentMessage agentMessage, final Logger logger final SHVM shadowVM, final ClientMessage clientMessage, final Logger logger
) throws DiSLREServerException ) throws DiSLREServerException
{ {
switch (agentMessage.getRequestCase ()) switch (clientMessage.getRequestCase ())
{ {
case ANALYZE: case ANALYZE:
Analyze analyze = agentMessage.getAnalyze (); Analyze analyze = clientMessage.getAnalyze ();
shadowVM.HandleAnalyze ( shadowVM.HandleAnalyze (
analyze.getOrderingID (), analyze.getOrderingID (),
analyze.getInvocationCount (), analyze.getInvocationCount (),
analyze.getRawData ().toByteArray () analyze.getRawData ().toByteArray ()
); );
break; break;
case CLOSE: case CLOSE_CONNECTION:
shadowVM.HandleClose (); shadowVM.HandleClose ();
break; break;
case CLASS_INFO: case CLASS_INFO:
ClassInfo classInfo = agentMessage.getClassInfo (); ClassInfo classInfo = clientMessage.getClassInfo ();
shadowVM.HandleClassInfo ( shadowVM.HandleClassInfo (
classInfo.getClassTag (), classInfo.getClassTag (),
classInfo.getClassSignature (), classInfo.getClassSignature (),
...@@ -48,7 +49,7 @@ final class RequestDispatcher { ...@@ -48,7 +49,7 @@ final class RequestDispatcher {
); );
break; break;
case NEW_CLASS: case NEW_CLASS:
NewClass newClass = agentMessage.getNewClass (); NewClass newClass = clientMessage.getNewClass ();
shadowVM.HandleNewClass ( shadowVM.HandleNewClass (
newClass.getClassName (), newClass.getClassName (),
newClass.getClassLoaderTag (), newClass.getClassLoaderTag (),
...@@ -56,24 +57,24 @@ final class RequestDispatcher { ...@@ -56,24 +57,24 @@ final class RequestDispatcher {
); );
break; break;
case THREAD_END: case THREAD_END:
shadowVM.HandleThreadEnd (agentMessage.getThreadEnd ().getThreadId ()); shadowVM.HandleThreadEnd (clientMessage.getThreadEnd ().getThreadId ());
break; break;
case REGISTER_ANALYSIS: case REGISTER_ANALYSIS:
RegisterAnalysis registerAnalysis = agentMessage.getRegisterAnalysis (); RegisterAnalysis registerAnalysis = clientMessage.getRegisterAnalysis ();
shadowVM.HandleRegisterAnalysis ( shadowVM.HandleRegisterAnalysis (
registerAnalysis.getAnalysisId (), registerAnalysis.getAnalysisId (),
registerAnalysis.getDescriptor () registerAnalysis.getDescriptor ()
); );
break; break;
case STRING_INFO: case STRING_INFO:
StringInfo stringInfo = agentMessage.getStringInfo (); StringInfo stringInfo = clientMessage.getStringInfo ();
shadowVM.HandleStringInfo ( shadowVM.HandleStringInfo (
stringInfo.getStringTag (), stringInfo.getStringTag (),
stringInfo.getStringData () stringInfo.getStringData ()
); );
break; break;
case THREAD_INFO: case THREAD_INFO:
ThreadInfo threadInfo = agentMessage.getThreadInfo (); ThreadInfo threadInfo = clientMessage.getThreadInfo ();
shadowVM.HandleThreadInfo ( shadowVM.HandleThreadInfo (
threadInfo.getThreadTag (), threadInfo.getThreadTag (),
threadInfo.getName (), threadInfo.getName (),
...@@ -81,9 +82,9 @@ final class RequestDispatcher { ...@@ -81,9 +82,9 @@ final class RequestDispatcher {
); );
break; break;
case OBJECT_FREE: case OBJECT_FREE:
int count = agentMessage.getObjectFree().getCount (); int count = clientMessage.getObjectFree().getCount ();
long[] ids = new long[count]; long[] ids = new long[count];
byte[] byteArray = agentMessage.getObjectFree ().getRawData ().toByteArray (); byte[] byteArray = clientMessage.getObjectFree ().getRawData ().toByteArray ();
logger.error ( logger.error (
"Serious error in data transfer: Indicated length (%d) does not match real length (%d)", "Serious error in data transfer: Indicated length (%d) does not match real length (%d)",
...@@ -99,8 +100,8 @@ final class RequestDispatcher { ...@@ -99,8 +100,8 @@ final class RequestDispatcher {
break; break;
case REQUEST_NOT_SET: case REQUEST_NOT_SET:
default: default:
logger.error ( logger.info (
"Serious problem in data transfer: Unknown type of message from agent" "Not implemented request case %s", clientMessage.getRequestCase ().name ()
); );
} }
......
# Shadow VM server # Shadow VM object model
This is the ShadowVM object model. The core of the analysis. It only exposes
the public API defined in `src/src-server-api`
## TODO
* Move the whole implementation into new package. Current is `ch.usi.dag.dislreserver`,
which does not makes a sense, since the object model is separated from the server.
...@@ -4,7 +4,7 @@ import java.util.List; ...@@ -4,7 +4,7 @@ import java.util.List;
// Each thread has dedicated queue where new tasks are submitted. // Each thread has dedicated queue where new tasks are submitted.
public class AnalysisDispatcher { class AnalysisDispatcher {
// Epoch is used during object free event sending. Each task is assigned // Epoch is used during object free event sending. Each task is assigned
// with current epoch number. When free event arrives it increments the // with current epoch number. When free event arrives it increments the
...@@ -70,7 +70,7 @@ public class AnalysisDispatcher { ...@@ -70,7 +70,7 @@ public class AnalysisDispatcher {
ateManager.executorIsEnding(threadId); ateManager.executorIsEnding(threadId);
} }
public void exit() { void exit() {
// create end of processing analysis task // create end of processing analysis task
AnalysisTask at = new AnalysisTask(); AnalysisTask at = new AnalysisTask();
......
...@@ -2,8 +2,6 @@ package ch.usi.dag.dislreserver; ...@@ -2,8 +2,6 @@ package ch.usi.dag.dislreserver;
import java.util.List; import java.util.List;
import ch.usi.dag.dislreserver.AnalysisInvocation;
/** /**
* Holds unprocessed task data for some thread * Holds unprocessed task data for some thread
*/ */
...@@ -17,7 +15,7 @@ class AnalysisTask { ...@@ -17,7 +15,7 @@ class AnalysisTask {
/** /**
* List of invocations in this task * List of invocations in this task
*/ */
protected List<AnalysisInvocation> invocations; List<AnalysisInvocation> invocations;
/** /**
* The epoch determined by objectFree events * The epoch determined by objectFree events
...@@ -48,7 +46,7 @@ class AnalysisTask { ...@@ -48,7 +46,7 @@ class AnalysisTask {
return signalsEnd; return signalsEnd;
} }
public List<AnalysisInvocation> getInvocations() { List<AnalysisInvocation> getInvocations() {
return invocations; return invocations;
} }
......
...@@ -65,7 +65,7 @@ class AnalysisTaskExecutor { ...@@ -65,7 +65,7 @@ class AnalysisTaskExecutor {
} }
} }
public synchronized AnalysisTask getTask() throws InterruptedException { synchronized AnalysisTask getTask() throws InterruptedException {
// executor thread is driving whole executor from this method // executor thread is driving whole executor from this method
// - the state of the executor epoch is updated here // - the state of the executor epoch is updated here
...@@ -114,7 +114,7 @@ class AnalysisTaskExecutor { ...@@ -114,7 +114,7 @@ class AnalysisTaskExecutor {
} }
// works with executorEpoch -> synchronized // works with executorEpoch -> synchronized
public synchronized void globalEpochChanged(long newEpoch) { synchronized void globalEpochChanged(long newEpoch) {
globalEpoch = newEpoch; globalEpoch = newEpoch;
...@@ -123,7 +123,7 @@ class AnalysisTaskExecutor { ...@@ -123,7 +123,7 @@ class AnalysisTaskExecutor {
} }
// works with executorEpoch -> synchronized // works with executorEpoch -> synchronized
public synchronized void waitForEpochProcessing(long epochToProcess) synchronized void waitForEpochProcessing(long epochToProcess)
throws InterruptedException { throws InterruptedException {
while (true) { while (true) {
...@@ -141,7 +141,7 @@ class AnalysisTaskExecutor { ...@@ -141,7 +141,7 @@ class AnalysisTaskExecutor {
} }
// await for executor to finish all jobs // await for executor to finish all jobs
public void awaitTermination() throws InterruptedException { void awaitTermination() throws InterruptedException {
executingThread.join(); executingThread.join();
} }
} }
...@@ -5,9 +5,9 @@ package ch.usi.dag.dislreserver; ...@@ -5,9 +5,9 @@ package ch.usi.dag.dislreserver;
*/ */
class AnalysisThread extends Thread { class AnalysisThread extends Thread {
final protected AnalysisTaskExecutor taskExecutor; private final AnalysisTaskExecutor taskExecutor;
public AnalysisThread(AnalysisTaskExecutor taskHolder) { AnalysisThread(AnalysisTaskExecutor taskHolder) {
this.taskExecutor = taskHolder; this.taskExecutor = taskHolder;
} }
......
...@@ -2,32 +2,32 @@ package ch.usi.dag.dislreserver; ...@@ -2,32 +2,32 @@ package ch.usi.dag.dislreserver;
class ObjectFreeTask { class ObjectFreeTask {
protected boolean signalsEnd = false; private boolean signalsEnd = false;
protected long[] objFreeIDs; private long[] objFreeIDs;
protected long closingEpoch; private long closingEpoch;
/** /**
* Constructed task signals end of the processing * Constructed task signals end of the processing
*/ */
public ObjectFreeTask() { ObjectFreeTask() {
signalsEnd = true; signalsEnd = true;
} }
public ObjectFreeTask(long[] objFreeIDs, long closingEpoch) { ObjectFreeTask(long[] objFreeIDs, long closingEpoch) {
super(); super();
this.objFreeIDs = objFreeIDs; this.objFreeIDs = objFreeIDs;
this.closingEpoch = closingEpoch; this.closingEpoch = closingEpoch;
} }
public boolean isSignalingEnd() { boolean isSignalingEnd() {
return signalsEnd; return signalsEnd;
} }
public long[] getObjFreeIDs() { long[] getObjFreeIDs() {
return objFreeIDs; return objFreeIDs;
} }
public long getClosingEpoch() { long getClosingEpoch() {
return closingEpoch; return closingEpoch;
} }
} }
...@@ -14,15 +14,14 @@ import java.util.concurrent.LinkedBlockingQueue; ...@@ -14,15 +14,14 @@ import java.util.concurrent.LinkedBlockingQueue;
*/ */
class ObjectFreeTaskExecutor extends Thread { class ObjectFreeTaskExecutor extends Thread {
final ATEManager ateManager; private final ATEManager ateManager;
final BlockingQueue<ObjectFreeTask> taskQueue = private final BlockingQueue<ObjectFreeTask> taskQueue = new LinkedBlockingQueue<ObjectFreeTask>();
new LinkedBlockingQueue<ObjectFreeTask>();
/** /**
* Current shadow VM context. * Current shadow VM context.
*/ */
final SHVMContext __shvmContext; private final SHVMContext __shvmContext;
/** /**
......
...@@ -16,11 +16,11 @@ import ch.usi.dag.util.logging.Logger; ...@@ -16,11 +16,11 @@ import ch.usi.dag.util.logging.Logger;
* *
* Takes care of handling the requests to analysis invocations. * Takes care of handling the requests to analysis invocations.
*/ */
public final class AnalysisHandler { final class AnalysisHandler {
private AnalysisDispatcher dispatcher; private AnalysisDispatcher dispatcher;
public AnalysisDispatcher getDispatcher() { AnalysisDispatcher getDispatcher() {
return dispatcher; return dispatcher;
} }
...@@ -46,7 +46,7 @@ public final class AnalysisHandler { ...@@ -46,7 +46,7 @@ public final class AnalysisHandler {
* @param is Input stream with the rest of the data. * @param is Input stream with the rest of the data.
* @throws DiSLREServerException * @throws DiSLREServerException
*/ */
public void handle (final long orderingID, final int invocationCount, final DataInputStream is) void handle (final long orderingID, final int invocationCount, final DataInputStream is)
throws DiSLREServerException throws DiSLREServerException
{ {
...@@ -216,7 +216,7 @@ public final class AnalysisHandler { ...@@ -216,7 +216,7 @@ public final class AnalysisHandler {
dispatcher.objectsFreedEvent(objFreeIDs); dispatcher.objectsFreedEvent(objFreeIDs);
} }
public void exit() { void exit() {
dispatcher.exit(); dispatcher.exit();
} }
} }
...@@ -3,7 +3,7 @@ package ch.usi.dag.dislreserver; ...@@ -3,7 +3,7 @@ package ch.usi.dag.dislreserver;
import java.lang.reflect.Method; import java.lang.reflect.Method;
public final class AnalysisInvocation { final class AnalysisInvocation {
private final Method __method; private final Method __method;
private final Object __target; private final Object __target;
...@@ -11,7 +11,7 @@ public final class AnalysisInvocation { ...@@ -11,7 +11,7 @@ public final class AnalysisInvocation {
// //
public AnalysisInvocation ( AnalysisInvocation (
final Method method, final Object target, final Object [] args final Method method, final Object target, final Object [] args
) { ) {
__method = method; __method = method;
...@@ -19,7 +19,7 @@ public final class AnalysisInvocation { ...@@ -19,7 +19,7 @@ public final class AnalysisInvocation {
__args = args; __args = args;
} }
public void invoke () { void invoke () {
try { try {
__method.invoke (__target, __args); __method.invoke (__target, __args);
......
cmake_minimum_required(VERSION 3.13)
project(src_disl_agent C)
set(CMAKE_C_STANDARD 11)
include_directories(.)
include_directories(protocol)
include_directories(../src-jdk-include)
include_directories(../src-jdk-include/macosx)
add_executable(src_disl_agent
protocol/disl.pb-c.c
protocol/disl.pb-c.h
protocol/main.pb-c.c
protocol/main.pb-c.h
protocol/shvm.pb-c.c
protocol/shvm.pb-c.h
bytecode.c
bytecode.h
classparser.c
classparser.h
codeflags.h
common.c
common.h
config.h
connection.c
connection.h
connpool.c
connpool.h
debug.h
dislagent.c
jvmtiutil.c
jvmtiutil.h
list.h
msgchannel.c
msgchannel.h
network.c
network.h
sessions.c
sessions.h
threads.h)
...@@ -108,12 +108,11 @@ LIBRARY := $(TARGET_DIR)/$(LIBRARY_NAME) ...@@ -108,12 +108,11 @@ LIBRARY := $(TARGET_DIR)/$(LIBRARY_NAME)
# Source and object files needed to create the library # Source and object files needed to create the library
SOURCES = bytecode.c common.c jvmtiutil.c connection.c \ SOURCES = bytecode.c common.c jvmtiutil.c connection.c \
connpool.c msgchannel.c network.c classparser.c \ connpool.c msgchannel.c network.c classparser.c \
dislserver.pb-c.c protobuf-c.c dislagent.c \ dislagent.c sessions.c \
sessions.c protocol/protobuf-c.c protocol/main.pb-c.c protocol/disl.pb-c.c protocol/shvm.pb-c.c
HEADERS = $(wildcard *.h) codeflags.h dislserver.pb-c.h HEADERS = $(wildcard *.h) codeflags.h $(wildcard protocol/*.h)
GENSRCS = bytecode.c codeflags.h \ GENSRCS = bytecode.c codeflags.h
dislserver.pb-c.c dislserver.pb-c.h
OBJECTS = $(addprefix $(BUILD_DIR)/,$(SOURCES:%.c=%.o)) OBJECTS = $(addprefix $(BUILD_DIR)/,$(SOURCES:%.c=%.o))
SRCDEPS = $(SOURCES:%.c=%.d) SRCDEPS = $(SOURCES:%.c=%.d)
...@@ -182,6 +181,7 @@ bytecode.c codeflags.h: ...@@ -182,6 +181,7 @@ bytecode.c codeflags.h:
$(BUILD_DIR): $(BUILD_DIR):
mkdir $@ mkdir $@
mkdir $@/protocol
# Compilation and linking targets # Compilation and linking targets
......
# DiSL instrumentation agent
## Usage
### Options
* `disl.instrumentation` - As an argument takes list of paths to instrumentation
jars, separated by `:`
* `disl.bypass` - Sets the bypass. Options are `dynamic`, `never` and `bootstrap`
more of them -> here
* `disl.splitmethods` - default is true
* `disl.excepthandler` - default is false
* `disl.forceinterface` - default false
* `disl.forcesuperclass` - default false
* `debug`
\ No newline at end of file
/**
* This file is part of src_disl_agent
*
* Created by Vít Kabele on 25/11/2018.
*/
#include "config.h"
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "connection.h" #include "connection.h"
#include "network.h" #include "network.h"
#include "msgchannel.h" #include "msgchannel.h"
#include "dislserver.pb-c.h" #include "protocol/main.pb-c.h"
#include "sessions.h" #include "sessions.h"
#include "bytecode.h" #include "bytecode.h"
...@@ -188,7 +188,7 @@ __instrument_class ( ...@@ -188,7 +188,7 @@ __instrument_class (
ClientMessage message = CLIENT_MESSAGE__INIT; ClientMessage message = CLIENT_MESSAGE__INIT;
message.session_id = agent_config.session_id; message.session_id = agent_config.session_id;
ClassInfo class_info = CLASS_INFO__INIT; InstrClassInfo class_info = INSTR_CLASS_INFO__INIT;
class_info.classname = (char *) class_name; class_info.classname = (char *) class_name;
class_info.classloadertag = classloader_tag; class_info.classloadertag = classloader_tag;
......
This diff is collapsed.
This diff is collapsed.
...@@ -52,51 +52,6 @@ void analyze__free_unpacked ...@@ -52,51 +52,6 @@ void analyze__free_unpacked
assert(message->base.descriptor == &analyze__descriptor); assert(message->base.descriptor == &analyze__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
} }
void close__init
(Close *message)
{
static const Close init_value = CLOSE__INIT;
*message = init_value;
}
size_t close__get_packed_size
(const Close *message)
{
assert(message->base.descriptor == &close__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t close__pack
(const Close *message,
uint8_t *out)
{
assert(message->base.descriptor == &close__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t close__pack_to_buffer
(const Close *message,
ProtobufCBuffer *buffer)
{
assert(message->base.descriptor == &close__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
Close *
close__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (Close *)
protobuf_c_message_unpack (&close__descriptor,
allocator, len, data);
}
void close__free_unpacked
(Close *message,
ProtobufCAllocator *allocator)
{
if(!message)
return;
assert(message->base.descriptor == &close__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
void class_info__init void class_info__init
(ClassInfo *message) (ClassInfo *message)
{ {
...@@ -412,51 +367,6 @@ void thread_info__free_unpacked ...@@ -412,51 +367,6 @@ void thread_info__free_unpacked
assert(message->base.descriptor == &thread_info__descriptor); assert(message->base.descriptor == &thread_info__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
} }
void agent_message__init
(AgentMessage *message)
{
static const AgentMessage init_value = AGENT_MESSAGE__INIT;
*message = init_value;
}
size_t agent_message__get_packed_size
(const AgentMessage *message)
{
assert(message->base.descriptor == &agent_message__descriptor);
return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message));
}
size_t agent_message__pack
(const AgentMessage *message,
uint8_t *out)
{
assert(message->base.descriptor == &agent_message__descriptor);
return protobuf_c_message_pack ((const ProtobufCMessage*)message, out);
}
size_t agent_message__pack_to_buffer
(const AgentMessage *message,
ProtobufCBuffer *buffer)
{
assert(message->base.descriptor == &agent_message__descriptor);
return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer);
}
AgentMessage *
agent_message__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data)
{
return (AgentMessage *)
protobuf_c_message_unpack (&agent_message__descriptor,
allocator, len, data);
}
void agent_message__free_unpacked
(AgentMessage *message,
ProtobufCAllocator *allocator)
{
if(!message)
return;
assert(message->base.descriptor == &agent_message__descriptor);
protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator);
}
static const ProtobufCFieldDescriptor analyze__field_descriptors[3] = static const ProtobufCFieldDescriptor analyze__field_descriptors[3] =
{ {
{ {
...@@ -521,24 +431,6 @@ const ProtobufCMessageDescriptor analyze__descriptor = ...@@ -521,24 +431,6 @@ const ProtobufCMessageDescriptor analyze__descriptor =
(ProtobufCMessageInit) analyze__init, (ProtobufCMessageInit) analyze__init,
NULL,NULL,NULL /* reserved[123] */ NULL,NULL,NULL /* reserved[123] */
}; };
#define close__field_descriptors NULL
#define close__field_indices_by_name NULL
#define close__number_ranges NULL
const ProtobufCMessageDescriptor close__descriptor =
{
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"Close",
"Close",
"Close",
"",
sizeof(Close),
0,
close__field_descriptors,
close__field_indices_by_name,
0, close__number_ranges,
(ProtobufCMessageInit) close__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor class_info__field_descriptors[5] = static const ProtobufCFieldDescriptor class_info__field_descriptors[5] =
{ {
{ {
...@@ -949,158 +841,3 @@ const ProtobufCMessageDescriptor thread_info__descriptor = ...@@ -949,158 +841,3 @@ const ProtobufCMessageDescriptor thread_info__descriptor =
(ProtobufCMessageInit) thread_info__init, (ProtobufCMessageInit) thread_info__init,
NULL,NULL,NULL /* reserved[123] */ NULL,NULL,NULL /* reserved[123] */
}; };
static const ProtobufCFieldDescriptor agent_message__field_descriptors[10] =
{
{
"ShvmID",
1,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_INT32,
0, /* quantifier_offset */
offsetof(AgentMessage, shvmid),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"analyze",
2,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(AgentMessage, request_case),
offsetof(AgentMessage, analyze),
&analyze__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"close",
3,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(AgentMessage, request_case),
offsetof(AgentMessage, close),
&close__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"class_info",
4,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(AgentMessage, request_case),
offsetof(AgentMessage, class_info),
&class_info__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"new_class",
5,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(AgentMessage, request_case),
offsetof(AgentMessage, new_class),
&new_class__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"object_free",
6,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(AgentMessage, request_case),
offsetof(AgentMessage, object_free),
&object_free__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"register_analysis",
7,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(AgentMessage, request_case),
offsetof(AgentMessage, register_analysis),
&register_analysis__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"string_info",
8,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(AgentMessage, request_case),
offsetof(AgentMessage, string_info),
&string_info__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"thread_end",
9,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(AgentMessage, request_case),
offsetof(AgentMessage, thread_end),
&thread_end__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"thread_info",
10,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(AgentMessage, request_case),
offsetof(AgentMessage, thread_info),
&thread_info__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned agent_message__field_indices_by_name[] = {
0, /* field[0] = ShvmID */
1, /* field[1] = analyze */
3, /* field[3] = class_info */
2, /* field[2] = close */
4, /* field[4] = new_class */
5, /* field[5] = object_free */
6, /* field[6] = register_analysis */
7, /* field[7] = string_info */
8, /* field[8] = thread_end */
9, /* field[9] = thread_info */
};
static const ProtobufCIntRange agent_message__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 10 }
};
const ProtobufCMessageDescriptor agent_message__descriptor =
{
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"AgentMessage",
"AgentMessage",
"AgentMessage",
"",
sizeof(AgentMessage),
10,
agent_message__field_descriptors,
agent_message__field_indices_by_name,
1, agent_message__number_ranges,
(ProtobufCMessageInit) agent_message__init,
NULL,NULL,NULL /* reserved[123] */
};
...@@ -16,7 +16,6 @@ PROTOBUF_C__BEGIN_DECLS ...@@ -16,7 +16,6 @@ PROTOBUF_C__BEGIN_DECLS
typedef struct _Analyze Analyze; typedef struct _Analyze Analyze;
typedef struct _Close Close;
typedef struct _ClassInfo ClassInfo; typedef struct _ClassInfo ClassInfo;
typedef struct _NewClass NewClass; typedef struct _NewClass NewClass;
typedef struct _ObjectFree ObjectFree; typedef struct _ObjectFree ObjectFree;
...@@ -24,7 +23,6 @@ typedef struct _RegisterAnalysis RegisterAnalysis; ...@@ -24,7 +23,6 @@ typedef struct _RegisterAnalysis RegisterAnalysis;
typedef struct _StringInfo StringInfo; typedef struct _StringInfo StringInfo;
typedef struct _ThreadEnd ThreadEnd; typedef struct _ThreadEnd ThreadEnd;
typedef struct _ThreadInfo ThreadInfo; typedef struct _ThreadInfo ThreadInfo;
typedef struct _AgentMessage AgentMessage;
/* --- enums --- */ /* --- enums --- */
...@@ -44,15 +42,6 @@ struct _Analyze ...@@ -44,15 +42,6 @@ struct _Analyze
, 0, 0, {0,NULL} } , 0, 0, {0,NULL} }
struct _Close
{
ProtobufCMessage base;
};
#define CLOSE__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&close__descriptor) \
}
struct _ClassInfo struct _ClassInfo
{ {
ProtobufCMessage base; ProtobufCMessage base;
...@@ -134,45 +123,6 @@ struct _ThreadInfo ...@@ -134,45 +123,6 @@ struct _ThreadInfo
, 0, (char *)protobuf_c_empty_string, 0 } , 0, (char *)protobuf_c_empty_string, 0 }
typedef enum {
AGENT_MESSAGE__REQUEST__NOT_SET = 0,
AGENT_MESSAGE__REQUEST_ANALYZE = 2,
AGENT_MESSAGE__REQUEST_CLOSE = 3,
AGENT_MESSAGE__REQUEST_CLASS_INFO = 4,
AGENT_MESSAGE__REQUEST_NEW_CLASS = 5,
AGENT_MESSAGE__REQUEST_OBJECT_FREE = 6,
AGENT_MESSAGE__REQUEST_REGISTER_ANALYSIS = 7,
AGENT_MESSAGE__REQUEST_STRING_INFO = 8,
AGENT_MESSAGE__REQUEST_THREAD_END = 9,
AGENT_MESSAGE__REQUEST_THREAD_INFO = 10
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(AGENT_MESSAGE__REQUEST)
} AgentMessage__RequestCase;
/*
* Pack together messages from client to simply distinguish them at the server side.
*/
struct _AgentMessage
{
ProtobufCMessage base;
int32_t shvmid;
AgentMessage__RequestCase request_case;
union {
Analyze *analyze;
Close *close;
ClassInfo *class_info;
NewClass *new_class;
ObjectFree *object_free;
RegisterAnalysis *register_analysis;
StringInfo *string_info;
ThreadEnd *thread_end;
ThreadInfo *thread_info;
};
};
#define AGENT_MESSAGE__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&agent_message__descriptor) \
, 0, AGENT_MESSAGE__REQUEST__NOT_SET, {0} }
/* Analyze methods */ /* Analyze methods */
void analyze__init void analyze__init
(Analyze *message); (Analyze *message);
...@@ -192,25 +142,6 @@ Analyze * ...@@ -192,25 +142,6 @@ Analyze *
void analyze__free_unpacked void analyze__free_unpacked
(Analyze *message, (Analyze *message,
ProtobufCAllocator *allocator); ProtobufCAllocator *allocator);
/* Close methods */
void close__init
(Close *message);
size_t close__get_packed_size
(const Close *message);
size_t close__pack
(const Close *message,
uint8_t *out);
size_t close__pack_to_buffer
(const Close *message,
ProtobufCBuffer *buffer);
Close *
close__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void close__free_unpacked
(Close *message,
ProtobufCAllocator *allocator);
/* ClassInfo methods */ /* ClassInfo methods */
void class_info__init void class_info__init
(ClassInfo *message); (ClassInfo *message);
...@@ -344,33 +275,11 @@ ThreadInfo * ...@@ -344,33 +275,11 @@ ThreadInfo *
void thread_info__free_unpacked void thread_info__free_unpacked
(ThreadInfo *message, (ThreadInfo *message,
ProtobufCAllocator *allocator); ProtobufCAllocator *allocator);
/* AgentMessage methods */
void agent_message__init
(AgentMessage *message);
size_t agent_message__get_packed_size
(const AgentMessage *message);
size_t agent_message__pack
(const AgentMessage *message,
uint8_t *out);
size_t agent_message__pack_to_buffer
(const AgentMessage *message,
ProtobufCBuffer *buffer);
AgentMessage *
agent_message__unpack
(ProtobufCAllocator *allocator,
size_t len,
const uint8_t *data);
void agent_message__free_unpacked
(AgentMessage *message,
ProtobufCAllocator *allocator);
/* --- per-message closures --- */ /* --- per-message closures --- */
typedef void (*Analyze_Closure) typedef void (*Analyze_Closure)
(const Analyze *message, (const Analyze *message,
void *closure_data); void *closure_data);
typedef void (*Close_Closure)
(const Close *message,
void *closure_data);
typedef void (*ClassInfo_Closure) typedef void (*ClassInfo_Closure)
(const ClassInfo *message, (const ClassInfo *message,
void *closure_data); void *closure_data);
...@@ -392,9 +301,6 @@ typedef void (*ThreadEnd_Closure) ...@@ -392,9 +301,6 @@ typedef void (*ThreadEnd_Closure)
typedef void (*ThreadInfo_Closure) typedef void (*ThreadInfo_Closure)
(const ThreadInfo *message, (const ThreadInfo *message,
void *closure_data); void *closure_data);
typedef void (*AgentMessage_Closure)
(const AgentMessage *message,
void *closure_data);
/* --- services --- */ /* --- services --- */
...@@ -402,7 +308,6 @@ typedef void (*AgentMessage_Closure) ...@@ -402,7 +308,6 @@ typedef void (*AgentMessage_Closure)
/* --- descriptors --- */ /* --- descriptors --- */
extern const ProtobufCMessageDescriptor analyze__descriptor; extern const ProtobufCMessageDescriptor analyze__descriptor;
extern const ProtobufCMessageDescriptor close__descriptor;
extern const ProtobufCMessageDescriptor class_info__descriptor; extern const ProtobufCMessageDescriptor class_info__descriptor;
extern const ProtobufCMessageDescriptor new_class__descriptor; extern const ProtobufCMessageDescriptor new_class__descriptor;
extern const ProtobufCMessageDescriptor object_free__descriptor; extern const ProtobufCMessageDescriptor object_free__descriptor;
...@@ -410,7 +315,6 @@ extern const ProtobufCMessageDescriptor register_analysis__descriptor; ...@@ -410,7 +315,6 @@ extern const ProtobufCMessageDescriptor register_analysis__descriptor;
extern const ProtobufCMessageDescriptor string_info__descriptor; extern const ProtobufCMessageDescriptor string_info__descriptor;
extern const ProtobufCMessageDescriptor thread_end__descriptor; extern const ProtobufCMessageDescriptor thread_end__descriptor;
extern const ProtobufCMessageDescriptor thread_info__descriptor; extern const ProtobufCMessageDescriptor thread_info__descriptor;
extern const ProtobufCMessageDescriptor agent_message__descriptor;
PROTOBUF_C__END_DECLS PROTOBUF_C__END_DECLS
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "sessions.h" #include "sessions.h"
#include "common.h" #include "common.h"
#include "dislserver.pb-c.h" #include "protocol/main.pb-c.h"
#include "network.h" #include "network.h"
/* /*
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "connection.h" #include "connection.h"
#include "config.h" #include "config.h"
#include "dislserver.pb-c.h" #include "protocol/main.pb-c.h"
void void
send_client_message(ClientMessage message, struct connection * conn); send_client_message(ClientMessage message, struct connection * conn);
......
syntax = "proto3";
option java_package = "ch.usi.dag.dislre.protocol";
option java_outer_classname = "DiSL";
option optimize_for = LITE_RUNTIME;
// Common type to send errors
message Error {
int32 code = 1;
string message = 2;
}
// When the client obtains the session_id, next step should be sending
// the instrumentation jar (or more of them) to the instrumentation server.
message InstrumentationDelivery {
repeated int32 sizes = 1;
bytes instrumentation = 2;
}
// This is server response to InstrumentationDelivery message
message InstrumentationAcceptConfirmation {
bool instrumentation_accepted = 1;
repeated Error errors = 2;
}
message InstrClassInfo {
string className = 1;
int64 classLoaderTag = 2;
}
// This is the request to the instrumentaion server to instrument attached class.
message InstrumentClassRequest {
int32 flags = 2;
InstrClassInfo classInfo = 5;
bytes classBytes = 4;
repeated InstrClassInfo superTypes = 6;
}
// Server response containing either the instrumented classbytes or error message
message InstrumentClassResponse {
enum InstrumentClassResult {
CLASS_UNMODIFIED = 0;
CLASS_MODIFIED = 1;
ERROR = 3;
}
InstrumentClassResult result = 1;
string errorMessage = 2;
bytes classBytes = 3;
}
/**
* This is the description of protocol used in communication between agents and
* servers.
* The document is divided into three parts:
* 1. The common session initialization and handshake. This part has to be fully
* implemented by every server.
* 2. The DiSL part - Contains messages related to instrumentation. Might be omitted
* in implementation, that only does analysis, but the server should inform
* the client, that the functionality is missing.
* 3. The SHVM part - Contains messages related to the remote analysis. Might be
* omitted in implementations, that only does analysis, but the server should
* inform the client, that the functionality is missing.
*/
syntax = "proto3"; syntax = "proto3";
option java_package = "ch.usi.dag.dislserver"; option java_package = "ch.usi.dag.dislre.protocol";
option java_outer_classname = "Protocol"; option java_outer_classname = "Main";
option optimize_for = LITE_RUNTIME; option optimize_for = LITE_RUNTIME;
// Common type to send errors /**
message Error { * Messages specific for instrumentation
int32 code = 1; */
string message = 2; import public "disl.proto";
}
/**
* Messages specific for analysis
*/
import public "shvm.proto";
// Request server to initialize session // Request server to initialize session
// This is sent as the clients first message // This is sent as the clients first message
...@@ -24,64 +41,36 @@ message SessionInitResponse { ...@@ -24,64 +41,36 @@ message SessionInitResponse {
repeated Error errors = 3; repeated Error errors = 3;
} }
// When the client obtains the session_id, next step should be sending /**
// the instrumentation jar (or more of them) to the instrumentation server. * Notify server about closing connection
message InstrumentationDelivery { */
repeated int32 sizes = 1;
bytes instrumentation = 2;
}
// This is server response to InstrumentationDelivery message
message InstrumentationAcceptConfirmation {
bool instrumentation_accepted = 1;
repeated Error errors = 2;
}
message ClassInfo {
string className = 1;
int64 classLoaderTag = 2;
}
// This is the request to the instrumentaion server to instrument attached class.
message InstrumentClassRequest {
int32 flags = 2;
ClassInfo classInfo = 5;
bytes classBytes = 4;
repeated ClassInfo superTypes = 6;
}
// Server response containing either the instrumented classbytes or error message
message InstrumentClassResponse {
enum InstrumentClassResult {
CLASS_UNMODIFIED = 0;
CLASS_MODIFIED = 1;
ERROR = 3;
}
InstrumentClassResult result = 1;
string errorMessage = 2;
bytes classBytes = 3;
}
// Notify server about closing connection
message CloseConnection { message CloseConnection {
enum CloseReason { enum CloseReason {
FINISHED = 0; FINISHED = 0;
} }
CloseReason reason = 2; CloseReason reason = 2;
} }
// Pack together messages from client to simply distinguish them at the server side. // Pack together messages from client to simply distinguish them at the server side.
message ClientMessage { message ClientMessage {
int32 session_id = 1; int32 session_id = 1;
oneof request { oneof request {
/// Instrumentation messages
SessionInitRequest session_init_request = 2; SessionInitRequest session_init_request = 2;
InstrumentationDelivery instrumentation_delivery = 3; InstrumentationDelivery instrumentation_delivery = 3;
InstrumentClassRequest instrument_class_request = 4; InstrumentClassRequest instrument_class_request = 4;
CloseConnection close_connection = 5; CloseConnection close_connection = 5;
/// Analysis messages
Analyze analyze = 10;
CloseConnection close = 11;
ClassInfo class_info = 12;
NewClass new_class = 13;
ObjectFree object_free = 14;
RegisterAnalysis register_analysis = 15;
StringInfo string_info = 16;
ThreadEnd thread_end = 17;
ThreadInfo thread_info = 18;
} }
} }
......
syntax = "proto3"; syntax = "proto3";
option java_package = "ch.usi.dag.dislreserver"; option java_package = "ch.usi.dag.dislre.protocol";
option java_outer_classname = "Protocol"; option java_outer_classname = "Analysis";
option optimize_for = LITE_RUNTIME; option optimize_for = LITE_RUNTIME;
message Analyze { message Analyze {
...@@ -10,8 +10,6 @@ message Analyze { ...@@ -10,8 +10,6 @@ message Analyze {
bytes RawData = 3; bytes RawData = 3;
} }
message Close {}
message ClassInfo { message ClassInfo {
int64 classTag = 1; int64 classTag = 1;
string ClassSignature = 2; string ClassSignature = 2;
...@@ -51,19 +49,3 @@ message ThreadInfo { ...@@ -51,19 +49,3 @@ message ThreadInfo {
bool IsDaemon = 3; bool IsDaemon = 3;
} }
// Pack together messages from client to simply distinguish them at the server side.
message AgentMessage {
int32 ShvmID = 1;
oneof request {
Analyze analyze = 2;
Close close = 3;
ClassInfo class_info = 4;
NewClass new_class = 5;
ObjectFree object_free = 6;
RegisterAnalysis register_analysis = 7;
StringInfo string_info = 8;
ThreadEnd thread_end = 9;
ThreadInfo thread_info = 10;
}
}
...@@ -63,7 +63,10 @@ SOURCES = common.c jvmtiutil.c config.c \ ...@@ -63,7 +63,10 @@ SOURCES = common.c jvmtiutil.c config.c \
shared/blockingqueue.c \ shared/blockingqueue.c \
shared/threadlocal.c shared/messagetype.c \ shared/threadlocal.c shared/messagetype.c \
tagger.c sender.c dislreagent.c pbmanager.c redispatcher.c netref.c \ tagger.c sender.c dislreagent.c pbmanager.c redispatcher.c netref.c \
globalbuffer.c tlocalbuffer.c freehandler.c shvm.pb-c.c protobuf-c.c globalbuffer.c tlocalbuffer.c freehandler.c \
disl/connection.c disl/connpool.c disl/msgchannel.c disl/network.c \
disl/disl.c disl/bytecode.c disl/classparser.c sessions.c \
protocol/protobuf-c.c protocol/shvm.pb-c.c protocol/main.pb-c.c protocol/disl.pb-c.c
HEADERS = $(wildcard *.h) HEADERS = $(w