Added DiSL project

This commit is contained in:
Claudio Maggioni 2023-01-02 10:46:59 +01:00
parent 431eb23b4e
commit 031b07d70e
39 changed files with 172 additions and 0 deletions

5
DiSLProject2022/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
bin-profiler
build/profiler.jar
*.iml
.idea/

57
DiSLProject2022/README.md Normal file
View File

@ -0,0 +1,57 @@
This bundle contains the template of the various exercises that compose the DiSL project.
Please refer to the text of the DiSL project for more information on the the purpose of each exercise.
## Bundle structure
Each exercise is composed of two parts: 1) profiler and 2) observed application.
- Profiler code is located in the `src-profiler` folder. In each exercise, there is always a single DiSL class (i.e., the class containing DiSL snippets) which is called `Instrumentation`. You can add as many profiler classes as you like to the `src-profiler` folder. However, all DiSL snippets *must* be added to the existing `Instrumentation` class.
- Observed applications compiled are located as `jar` archive in the `build` folder. In each exercise, the main class of the observed application is always called `Main`. The source code of the observed application is not provided.
- Both the profiler and the observed applications are contained in a package called `ex<i>` (where <i> is a progressive integer number). For example, both the profiler and the observed applications that refer to the first exercise are contained in package `ex1`.
## How to build
Building requires the `ant` program.
You have to compile and build the sources each time you want to use a different profiler.
To run the build process, execute
`ant -Ddislclass=<DiSL class>`
in the root of the folder, where *<DiSL class>* is the fully qualified name of the DiSL class corresponding to the profiler you want to run.
For example, if you want to use the profiler that refers to the first exercise, run:
`ant -Ddislclass=ex1.Instrumentation`.
The build process will generate the JARs `build/profiler.jar`, containing the profiler.
## How to run the observed application (uninstrumented)
The observed application (without any profiler) can be normally run via:
`bash ./run.sh <main class>`
where *<main class>* is the fully qualified name of the main class you want to run.
For example, to run the main class of the first exercise, run:
`bash ./run.sh ex1.Main`
## How to run the observed application (instrumented)
To run the observed application instrumented with a profiler:
- *First*, start the DiSL Server by executing `bash ./startDiSLServer.sh`.
- *Then*, start the observed application (with the profiler attached) by executing `bash ./runInstrumented.sh <main class>`
where *<main class>* is the fully qualified name of the main class you want to run.
**Note**: the profiler that will be applied to the observed application is *always* the one corresponding to the DiSL class specified at build time!
## Cleanup
You can run `ant clean` to discard generated profiler JAR.
Please do not erease the following file/folder:
- folder: `build`
- file: `build/app.jar`
otherwise you need to download them again from iCorsi.
## Summary
To run e.g. the instrumented observed application of the first exercise, execute, in order:
- `ant clean`
- `ant -Ddislclass=ex1.Instrumentation`
- `bash ./startDiSLServer.sh`
- `bash ./runInstrumented.sh ex1.Main`

30
DiSLProject2022/build.xml Normal file
View File

@ -0,0 +1,30 @@
<project name="AJPDislProject" default="build" basedir=".">
<path id="profiler.classpath">
<fileset dir="lib" includes="*.jar" />
</path>
<target name="compile-profiler">
<mkdir dir="bin-profiler" />
<javac includeantruntime="false" destdir="bin-profiler" srcdir="src-profiler" debug="false" classpathref="profiler.classpath" />
</target>
<target name="build-profiler" depends="compile-profiler">
<mkdir dir="build"/>
<jar destfile="build/profiler.jar" basedir="bin-profiler">
<manifest>
<attribute name="DiSL-Classes" value="${dislclass}" />
</manifest>
</jar>
</target>
<target name="build" depends="build-profiler" />
<target name="clean">
<delete dir="bin-profiler" />
<delete file="build/profiler.jar" />
<delete dir="dump" />
</target>
</project>

Binary file not shown.

View File

@ -0,0 +1 @@
jdk.internal.module.*.*

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
DiSLProject2022/lib/asm.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

8
DiSLProject2022/run.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <Name of main class>"
exit;
fi
$JAVA_HOME/bin/java -cp build/app.jar $*

View File

@ -0,0 +1,24 @@
#!/bin/sh
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <Name of main class>"
exit 0
fi
AGENT_EXT=.so
#Checks if OS is MacOS
if [ "$(uname -s)" = "Darwin" ]; then
AGENT_EXT=.jnilib
fi
AGENT_FLAGS=
JAVA_VERSION=$("$JAVA_HOME/bin/java" -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1)
if [ "$JAVA_VERSION" -gt "8" ]; then
AGENT_FLAGS="$AGENT_FLAGS --patch-module java.base=lib/disl-bypass.jar --add-exports java.base/ch.usi.dag.disl.dynamicbypass=ALL-UNNAMED"
fi
"$JAVA_HOME"/bin/java -agentpath:lib/libdislagent$AGENT_EXT $AGENT_FLAGS -Xbootclasspath/a:lib/disl-bypass.jar:build/profiler.jar -cp build/app.jar -noverify $*

View File

@ -0,0 +1,4 @@
package ex1;
public class Instrumentation {
}

View File

@ -0,0 +1,4 @@
package ex10;
public class Instrumentation {
}

View File

@ -0,0 +1,4 @@
package ex11;
public class Instrumentation {
}

View File

@ -0,0 +1,4 @@
package ex2;
public class Instrumentation {
}

View File

@ -0,0 +1,4 @@
package ex3;
public class Instrumentation {
}

View File

@ -0,0 +1,4 @@
package ex4;
public class Instrumentation {
}

View File

@ -0,0 +1,4 @@
package ex5;
public class Instrumentation {
}

View File

@ -0,0 +1,4 @@
package ex6;
public class Instrumentation {
}

View File

@ -0,0 +1,4 @@
package ex7;
public class Instrumentation {
}

View File

@ -0,0 +1,4 @@
package ex8;
public class Instrumentation {
}

View File

@ -0,0 +1,4 @@
package ex9;
public class Instrumentation {
}

View File

@ -0,0 +1,3 @@
#!/bin/sh
$JAVA_HOME/bin/java -Ddisl.exclusionList="exclusion.lst" -cp build/profiler.jar:lib/disl-server.jar ch.usi.dag.dislserver.DiSLServer &