Commit 279a88e3 authored by Lukáš Marek's avatar Lukáš Marek

Created new branch for remote evaluation

parent 35d34d35
......@@ -3,16 +3,14 @@
OS=`uname`
if [ "${OS}" = "Darwin" ]; then
JBORAT_AGENT="src-agent-c/libdislagent.jnilib"
C_AGENT="src-agent-c/libdislagent.jnilib"
else
JBORAT_AGENT="src-agent-c/libdislagent.so"
C_AGENT="src-agent-c/libdislagent.so"
fi
# ipc.socket is the default communication
# to enable shared memory, remove ",ipc.socket" from the options
JBORAT_AGENT_OPTS="1234,localhost,ipc.socket"
java -agentpath:${JBORAT_AGENT}=${JBORAT_AGENT_OPTS} \
java -agentpath:${C_AGENT} \
-javaagent:build/dislagent-unspec.jar \
-Xbootclasspath/a:build/dislagent-unspec.jar:build/dislinstr.jar \
-cp bin/ \
......
......@@ -9,10 +9,10 @@
# -Ddislserver.uninstrumented="path" \
# -Ddislserver.port="portNum" \
# -Ddislserver.timestat=true \
# -Ddislserver.continuous=true \
java -Ddislserver.port="1234" \
$* \
java $* \
-jar build/dislserver-unspec.jar \
&
......
......@@ -5,7 +5,7 @@ endif
# Source lists
LIBNAME=dislagent
SOURCES= dislagent.c
SOURCES=dislagent.c
# Object files needed to create library
OBJECTS=$(SOURCES:%.c=%.o)
......@@ -23,15 +23,9 @@ endif
LINK_SHARED=$(LINK.c) -shared -o $@
# GNU Compiler options needed to build it
COMMON_FLAGS=-fno-strict-aliasing -fPIC -fno-omit-frame-pointer
COMMON_FLAGS=-fPIC
# Options that help find errors
COMMON_FLAGS+= -W -Wall -Wextra -O3 -Wno-unused-parameter
# To allow access to dladdr()
COMMON_FLAGS+= -D_GNU_SOURCE
# To prevent include of procfs.h
COMMON_FLAGS+= -DLINUX
# To make sure code is reentrant
COMMON_FLAGS+= -D_REENTRANT
CFLAGS += $(COMMON_FLAGS)
......
This diff is collapsed.
#include <jvmti.h>
#ifndef _JBORATCLIENTAGENT_H
#define _JBORATCLIENTAGENT_H
#ifndef _DISLAGENT_H
#define _DISLAGENT_H
#ifdef __cplusplus
extern "C" {
......@@ -14,4 +14,4 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved);
#endif
#endif /* _JBORATCLIENTAGENT_H */
#endif /* _DISLAGENT_H */
......@@ -19,6 +19,9 @@ public abstract class DiSLServer {
private static final String PROP_TIME_STAT = "dislserver.timestat";
private static final boolean timeStat = Boolean.getBoolean(PROP_TIME_STAT);
private static final String PROP_CONT = "dislserver.continuous";
private static final boolean continuous = Boolean.getBoolean(PROP_CONT);
private static final AtomicInteger aliveWorkers = new AtomicInteger();
private static final AtomicLong instrumentationTime = new AtomicLong();
......@@ -89,19 +92,22 @@ public abstract class DiSLServer {
if (aliveWorkers.decrementAndGet() == 0) {
disl.terminate();
if (timeStat) {
System.out.println("Instrumentation took " +
instrumentationTime.get() / 1000000 + " milliseconds");
}
if (debug) {
System.out.println("Instrumentation server is shutting down");
}
// no workers - shutdown
System.exit(0);
if(! continuous) {
disl.terminate();
if (debug) {
System.out.println("Instrumentation server is shutting down");
}
System.exit(0);
}
}
}
}
package ch.usi.dag.dislserver;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
public class NetClassReader {
private final Socket socket;
private final DataInputStream is;
private final OutputStream os;
private final DataOutputStream os;
public NetClassReader(Socket socket) throws IOException {
this.socket = socket;
is = new DataInputStream(socket.getInputStream());
os = new BufferedOutputStream(socket.getOutputStream());
is = new DataInputStream(new BufferedInputStream(socket.getInputStream()));
os = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()));
}
public ClassAsBytes readClassAsBytes() throws IOException {
......@@ -28,13 +29,9 @@ public class NetClassReader {
// bytes[cnl] - class name
// bytes[cl] - class code
// TODO jb !
//int nameLength = is.readInt();
//int codeLength = is.readInt();
int nameLength = is.readInt();
int codeLength = is.readInt();
int nameLength = readInt(is);
int codeLength = readInt(is);
// end of communication
if(nameLength == 0 && codeLength == 0) {
return null;
......@@ -65,56 +62,11 @@ public class NetClassReader {
// bytes[cnl] - class name
// bytes[cl] - class code
// TODO jb !
//os.write(cab.getName().length);
//os.write(cab.getCode().length);
writeInt(os, cab.getName().length);
writeInt(os, cab.getCode().length);
os.writeInt(cab.getName().length);
os.writeInt(cab.getCode().length);
os.write(cab.getName());
os.write(cab.getCode());
os.flush();
}
// TODO jb ! remove all below ===
private static int readInt(DataInputStream dis) throws IOException {
byte[] data = new byte[4];
dis.read(data);
return byteArrayToInt(data);
}
private static void writeInt(OutputStream os, int value) throws IOException {
os.write(intToByteArray(value));
}
private static int byteArrayToInt(byte[] b) {
int value = 0;
// REVERT THE VALUE OF THE PART CONTAINING THE INT
byte[] mybuf = new byte[4];
for (int i = 0; i < 4; i++) {
mybuf[i] = b[3 - i];
}
for (int i = 0; i < 4; i++) {
int shift = (4 - 1 - i) * 8;
// value += (mybuf[i + offset] & 0x000000FF) << shift;
value += (mybuf[i] & 0x000000FF) << shift;
}
return value;
}
private static byte[] intToByteArray(int value) {
byte[] dest = new byte[4];
for (int idx = 0; idx < 4; idx++) {
dest[idx] = ((byte) (value >>> (idx * 8)));
}
return dest;
}
}
......@@ -101,13 +101,16 @@ public class Worker extends Thread {
throw e;
}
// default answer - no modification
ClassAsBytes replyData = cab;
ClassAsBytes replyData = null;
// class was modified - send modified data
if(instrClass != null) {
// class was modified - send modified data
replyData = new ClassAsBytes(cab.getName(), instrClass);
}
else {
// zero length means no modification
replyData = new ClassAsBytes(new byte[0], new byte[0]);
}
sc.sendClassAsBytes(replyData);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment