Commit 18aef79f authored by Lukáš Marek's avatar Lukáš Marek

Added jar support for DiSL - see ClassByteLoadersource for usage info

parent 09525bc3
asm.path=lib/asm-debug-all-4.0_RC1.jar asm.path=lib/asm-debug-all-4.0_RC1.jar
jborat.path=lib/jborat.jar jborat.path=lib/jborat.jar
jborat-runtime.path=lib/jborat-runtime.jar jborat-runtime.path=lib/jborat-runtime.jar
instr.jar.name=dislinstr.jar
\ No newline at end of file
...@@ -11,7 +11,11 @@ ...@@ -11,7 +11,11 @@
<target name="package" depends="compile"> <target name="package" depends="compile">
<mkdir dir="build"/> <mkdir dir="build"/>
<jar basedir="bin" destfile="build/disl-${disl.version}.jar"/> <jar basedir="bin" destfile="build/disl-${disl.version}.jar">
<manifest>
<attribute name="Class-Path" value="${instr.jar.name}"/>
</manifest>
</jar>
</target> </target>
......
...@@ -62,8 +62,9 @@ public class DiSL implements Instrumentation { ...@@ -62,8 +62,9 @@ public class DiSL implements Instrumentation {
if(dislClasses == null) { if(dislClasses == null) {
throw new InitException("Cannot load DiSL classes. Please set" + throw new InitException("Cannot load DiSL classes. Please set" +
" the property " + ClassByteLoader.DISL_CLASSES " the property " + ClassByteLoader.PROP_DISL_CLASSES
+ " or supply " + ClassByteLoader.INSTR_JAR); + " or supply jar with DiSL classes"
+ " and proper manifest");
} }
// *** parse disl classes *** // *** parse disl classes ***
......
...@@ -16,16 +16,24 @@ import ch.usi.dag.disl.exception.InitException; ...@@ -16,16 +16,24 @@ import ch.usi.dag.disl.exception.InitException;
public abstract class ClassByteLoader { public abstract class ClassByteLoader {
private static final String MANIFEST = "META-INF/MANIFEST.MF"; private static final String MANIFEST = "META-INF/MANIFEST.MF";
public static final String INSTR_JAR = "dislinstr.jar";
public static final String DISL_CLASSES = "disl.classes"; public static final String PROP_DISL_CLASSES = "disl.classes";
public static final String ATTR_DISL_CLASSES = "DiSL-Classes";
public static final String DISL_CLASSES_DELIM = ":"; public static final String DISL_CLASSES_DELIM = ":";
// TODO ! jar support - add jar dependency // How to use jar support
// TODO ! jar support - create ant task for test compilation // 1) Create jar with a name specified in build.properties (instr.jar.name)
// TODO ! jar support - create processor manifest // 2) Include manifest file that contains names of all used DiSL classes
// TODO ! jar support - test // - for the name of the manifest attribute see ATTR_DISL_CLASSES
// Jar should contain all additional classes needed for instrumentation
// like Markers, Static analyses, ...
//
// NOTE: Example of the usage is processor test case
// To build the jar for the processor test case go to the test directory
// and call "ant package -Dtest.name=processor"
// To run the test case with the instrumentation located in jar call
// "./run-pkg.sh processor"
public static List<InputStream> loadDiSLClasses() public static List<InputStream> loadDiSLClasses()
throws InitException { throws InitException {
...@@ -48,7 +56,7 @@ public abstract class ClassByteLoader { ...@@ -48,7 +56,7 @@ public abstract class ClassByteLoader {
private static List<InputStream> loadClassesFromProperty() private static List<InputStream> loadClassesFromProperty()
throws IOException { throws IOException {
String classesList = System.getProperty(DISL_CLASSES); String classesList = System.getProperty(PROP_DISL_CLASSES);
if ( (classesList != null) && (! classesList.isEmpty()) ) { if ( (classesList != null) && (! classesList.isEmpty()) ) {
...@@ -105,7 +113,7 @@ public abstract class ClassByteLoader { ...@@ -105,7 +113,7 @@ public abstract class ClassByteLoader {
// contains disl classes // contains disl classes
if(attrs != null) { if(attrs != null) {
String dislClasses = attrs.getValue(DISL_CLASSES); String dislClasses = attrs.getValue(ATTR_DISL_CLASSES);
if(dislClasses != null) { if(dislClasses != null) {
return dislClasses; return dislClasses;
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
<target name="check-disl-jar"> <target name="check-disl-jar">
<available file="${disl.jar.path}" property="disl.jar.present"/> <available file="${disl.jar.path}" property="disl.jar.present"/>
</target> </target>
<target name="report-missing-jar" depends="check-disl-jar" unless="disl.jar.present"> <target name="report-missing-jar" depends="check-disl-jar" unless="disl.jar.present">
<fail message="DiSL jar not found at ${disl.jar.path}. Build DiSL first!" /> <fail message="DiSL jar not found at ${disl.jar.path}. Build DiSL first!" />
</target> </target>
...@@ -25,16 +25,37 @@ ...@@ -25,16 +25,37 @@
<classpath refid="buildpath"/> <classpath refid="buildpath"/>
</javac> </javac>
</target> </target>
<target name="agent" description="create simple agent jar file" > <target name="agent" description="create simple agent jar file" >
<mkdir dir="build"/> <mkdir dir="build"/>
<jar jarfile="build/agent-light.jar"> <jar jarfile="build/agent-light.jar">
<manifest> <manifest>
<attribute name="Premain-Class" value="ch.usi.dag.disl.test.agent.Agent"/> <attribute name="Premain-Class" value="ch.usi.dag.disl.test.agent.Agent"/>
</manifest> </manifest>
</jar> </jar>
</target> </target>
<target name="check-test-property">
<condition property="test.set">
<isset property="test.name"/>
</condition>
</target>
<target name="report-missing-property" depends="check-test-property" unless="test.set">
<fail message="Property test.name is not set. Set it using -Dtest.name=value" />
</target>
<property name="test.path" value="ch/usi/dag/disl/test/${test.name}"/>
<target name="package" depends="report-missing-property" description="create instrumentation package for specified test">
<jar jarfile="../build/${instr.jar.name}"
basedir="./bin"
includes="${test.path}/*"
excludes="${test.path}/TargetClass.class ${test.path}/MANIFEST.MF"
manifest="./src/${test.path}/MANIFEST.MF">
</jar>
</target>
<target name="clean"> <target name="clean">
<delete dir="bin"/> <delete dir="bin"/>
<delete dir="build"/> <delete dir="build"/>
......
# /bin/sh
EXPECTED_ARGS=1
if [ $# -ne $EXPECTED_ARGS ]
then
echo "Usage: `basename $0` {test case}"
exit
fi
TARGET_CLASS="ch.usi.dag.disl.test.$1.TargetClass"
java -javaagent:../lib/jborat-agent.jar -Dch.usi.dag.jborat.exclusionList="conf/exclusion.lst" -Dch.usi.dag.jborat.liblist="conf/lib.lst" -Dch.usi.dag.jborat.instrumentation="ch.usi.dag.disl.DiSL" -Dch.usi.dag.jborat.codemergerList="conf/codemerger.lst" -Dch.usi.dag.jborat.uninstrumented="uninstrumented" -Dch.usi.dag.jborat.instrumented="instrumented" -Xbootclasspath/p:../lib/Thread_jborat.jar:../lib/jborat-runtime.jar -Ddisl.dynbypass=yes -cp "./bin/" ${TARGET_CLASS}
Manifest-Version: 1.0
DiSL-Classes: ch/usi/dag/disl/test/processor/DiSLClass.class:ch/usi/dag/disl/test/processor/ProcessorTest.class
\ No newline at end of file
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