diff --git a/DiSLProject2022/.gitignore b/DiSLProject2022/.gitignore new file mode 100644 index 0000000..b9abff2 --- /dev/null +++ b/DiSLProject2022/.gitignore @@ -0,0 +1,5 @@ +bin-profiler +build/profiler.jar +*.iml +.idea/ + diff --git a/DiSLProject2022/README.md b/DiSLProject2022/README.md new file mode 100644 index 0000000..9dae370 --- /dev/null +++ b/DiSLProject2022/README.md @@ -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` (where 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=` +in the root of the folder, where ** 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
` +where *
* 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
` +where *
* 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` diff --git a/DiSLProject2022/build.xml b/DiSLProject2022/build.xml new file mode 100644 index 0000000..c1c0bb9 --- /dev/null +++ b/DiSLProject2022/build.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DiSLProject2022/build/app.jar b/DiSLProject2022/build/app.jar new file mode 100644 index 0000000..15dd373 Binary files /dev/null and b/DiSLProject2022/build/app.jar differ diff --git a/DiSLProject2022/exclusion.lst b/DiSLProject2022/exclusion.lst new file mode 100644 index 0000000..b5b0560 --- /dev/null +++ b/DiSLProject2022/exclusion.lst @@ -0,0 +1 @@ +jdk.internal.module.*.* diff --git a/DiSLProject2022/lib/args4j.jar b/DiSLProject2022/lib/args4j.jar new file mode 100644 index 0000000..61be8f3 Binary files /dev/null and b/DiSLProject2022/lib/args4j.jar differ diff --git a/DiSLProject2022/lib/asm-analysis.jar b/DiSLProject2022/lib/asm-analysis.jar new file mode 100644 index 0000000..9d575ca Binary files /dev/null and b/DiSLProject2022/lib/asm-analysis.jar differ diff --git a/DiSLProject2022/lib/asm-commons.jar b/DiSLProject2022/lib/asm-commons.jar new file mode 100644 index 0000000..01028a0 Binary files /dev/null and b/DiSLProject2022/lib/asm-commons.jar differ diff --git a/DiSLProject2022/lib/asm-tree.jar b/DiSLProject2022/lib/asm-tree.jar new file mode 100644 index 0000000..0a6833a Binary files /dev/null and b/DiSLProject2022/lib/asm-tree.jar differ diff --git a/DiSLProject2022/lib/asm-util.jar b/DiSLProject2022/lib/asm-util.jar new file mode 100644 index 0000000..3afe6e6 Binary files /dev/null and b/DiSLProject2022/lib/asm-util.jar differ diff --git a/DiSLProject2022/lib/asm.jar b/DiSLProject2022/lib/asm.jar new file mode 100644 index 0000000..3557ae4 Binary files /dev/null and b/DiSLProject2022/lib/asm.jar differ diff --git a/DiSLProject2022/lib/classgraph.jar b/DiSLProject2022/lib/classgraph.jar new file mode 100644 index 0000000..fb295b3 Binary files /dev/null and b/DiSLProject2022/lib/classgraph.jar differ diff --git a/DiSLProject2022/lib/disl-bypass.jar b/DiSLProject2022/lib/disl-bypass.jar new file mode 100644 index 0000000..6407798 Binary files /dev/null and b/DiSLProject2022/lib/disl-bypass.jar differ diff --git a/DiSLProject2022/lib/disl-controller.jar b/DiSLProject2022/lib/disl-controller.jar new file mode 100644 index 0000000..a4696fe Binary files /dev/null and b/DiSLProject2022/lib/disl-controller.jar differ diff --git a/DiSLProject2022/lib/disl-preprocessor.jar b/DiSLProject2022/lib/disl-preprocessor.jar new file mode 100644 index 0000000..e21cd6c Binary files /dev/null and b/DiSLProject2022/lib/disl-preprocessor.jar differ diff --git a/DiSLProject2022/lib/disl-server.jar b/DiSLProject2022/lib/disl-server.jar new file mode 100644 index 0000000..17e5107 Binary files /dev/null and b/DiSLProject2022/lib/disl-server.jar differ diff --git a/DiSLProject2022/lib/dislre-dispatch.jar b/DiSLProject2022/lib/dislre-dispatch.jar new file mode 100644 index 0000000..de0a050 Binary files /dev/null and b/DiSLProject2022/lib/dislre-dispatch.jar differ diff --git a/DiSLProject2022/lib/dislre-server.jar b/DiSLProject2022/lib/dislre-server.jar new file mode 100644 index 0000000..23e3b25 Binary files /dev/null and b/DiSLProject2022/lib/dislre-server.jar differ diff --git a/DiSLProject2022/lib/libdislagent.jnilib b/DiSLProject2022/lib/libdislagent.jnilib new file mode 100644 index 0000000..c1de5c2 Binary files /dev/null and b/DiSLProject2022/lib/libdislagent.jnilib differ diff --git a/DiSLProject2022/lib/libdislagent.so b/DiSLProject2022/lib/libdislagent.so new file mode 100644 index 0000000..1e74bf1 Binary files /dev/null and b/DiSLProject2022/lib/libdislagent.so differ diff --git a/DiSLProject2022/lib/libdislreagent.jnilib b/DiSLProject2022/lib/libdislreagent.jnilib new file mode 100644 index 0000000..0de9bfd Binary files /dev/null and b/DiSLProject2022/lib/libdislreagent.jnilib differ diff --git a/DiSLProject2022/lib/libdislreagent.so b/DiSLProject2022/lib/libdislreagent.so new file mode 100644 index 0000000..c0958e0 Binary files /dev/null and b/DiSLProject2022/lib/libdislreagent.so differ diff --git a/DiSLProject2022/lib/narcissus.jar b/DiSLProject2022/lib/narcissus.jar new file mode 100644 index 0000000..4efe733 Binary files /dev/null and b/DiSLProject2022/lib/narcissus.jar differ diff --git a/DiSLProject2022/lib/protobuf-javalite.jar b/DiSLProject2022/lib/protobuf-javalite.jar new file mode 100644 index 0000000..37e8650 Binary files /dev/null and b/DiSLProject2022/lib/protobuf-javalite.jar differ diff --git a/DiSLProject2022/lib/protobuf-lite.jar b/DiSLProject2022/lib/protobuf-lite.jar new file mode 100644 index 0000000..a307055 Binary files /dev/null and b/DiSLProject2022/lib/protobuf-lite.jar differ diff --git a/DiSLProject2022/run.sh b/DiSLProject2022/run.sh new file mode 100755 index 0000000..b197724 --- /dev/null +++ b/DiSLProject2022/run.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + exit; +fi + +$JAVA_HOME/bin/java -cp build/app.jar $* diff --git a/DiSLProject2022/runInstrumented.sh b/DiSLProject2022/runInstrumented.sh new file mode 100755 index 0000000..14a3bd3 --- /dev/null +++ b/DiSLProject2022/runInstrumented.sh @@ -0,0 +1,24 @@ +#!/bin/sh + + +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + 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 $* diff --git a/DiSLProject2022/src-profiler/ex1/Instrumentation.java b/DiSLProject2022/src-profiler/ex1/Instrumentation.java new file mode 100644 index 0000000..8562abe --- /dev/null +++ b/DiSLProject2022/src-profiler/ex1/Instrumentation.java @@ -0,0 +1,4 @@ +package ex1; + +public class Instrumentation { +} diff --git a/DiSLProject2022/src-profiler/ex10/Instrumentation.java b/DiSLProject2022/src-profiler/ex10/Instrumentation.java new file mode 100644 index 0000000..3925438 --- /dev/null +++ b/DiSLProject2022/src-profiler/ex10/Instrumentation.java @@ -0,0 +1,4 @@ +package ex10; + +public class Instrumentation { +} diff --git a/DiSLProject2022/src-profiler/ex11/Instrumentation.java b/DiSLProject2022/src-profiler/ex11/Instrumentation.java new file mode 100644 index 0000000..14a0f82 --- /dev/null +++ b/DiSLProject2022/src-profiler/ex11/Instrumentation.java @@ -0,0 +1,4 @@ +package ex11; + +public class Instrumentation { +} diff --git a/DiSLProject2022/src-profiler/ex2/Instrumentation.java b/DiSLProject2022/src-profiler/ex2/Instrumentation.java new file mode 100644 index 0000000..9811186 --- /dev/null +++ b/DiSLProject2022/src-profiler/ex2/Instrumentation.java @@ -0,0 +1,4 @@ +package ex2; + +public class Instrumentation { +} diff --git a/DiSLProject2022/src-profiler/ex3/Instrumentation.java b/DiSLProject2022/src-profiler/ex3/Instrumentation.java new file mode 100644 index 0000000..f193fd5 --- /dev/null +++ b/DiSLProject2022/src-profiler/ex3/Instrumentation.java @@ -0,0 +1,4 @@ +package ex3; + +public class Instrumentation { +} diff --git a/DiSLProject2022/src-profiler/ex4/Instrumentation.java b/DiSLProject2022/src-profiler/ex4/Instrumentation.java new file mode 100644 index 0000000..4bd3be4 --- /dev/null +++ b/DiSLProject2022/src-profiler/ex4/Instrumentation.java @@ -0,0 +1,4 @@ +package ex4; + +public class Instrumentation { +} diff --git a/DiSLProject2022/src-profiler/ex5/Instrumentation.java b/DiSLProject2022/src-profiler/ex5/Instrumentation.java new file mode 100644 index 0000000..6ef7782 --- /dev/null +++ b/DiSLProject2022/src-profiler/ex5/Instrumentation.java @@ -0,0 +1,4 @@ +package ex5; + +public class Instrumentation { +} diff --git a/DiSLProject2022/src-profiler/ex6/Instrumentation.java b/DiSLProject2022/src-profiler/ex6/Instrumentation.java new file mode 100644 index 0000000..6857793 --- /dev/null +++ b/DiSLProject2022/src-profiler/ex6/Instrumentation.java @@ -0,0 +1,4 @@ +package ex6; + +public class Instrumentation { +} diff --git a/DiSLProject2022/src-profiler/ex7/Instrumentation.java b/DiSLProject2022/src-profiler/ex7/Instrumentation.java new file mode 100644 index 0000000..25e5226 --- /dev/null +++ b/DiSLProject2022/src-profiler/ex7/Instrumentation.java @@ -0,0 +1,4 @@ +package ex7; + +public class Instrumentation { +} diff --git a/DiSLProject2022/src-profiler/ex8/Instrumentation.java b/DiSLProject2022/src-profiler/ex8/Instrumentation.java new file mode 100644 index 0000000..d51ca10 --- /dev/null +++ b/DiSLProject2022/src-profiler/ex8/Instrumentation.java @@ -0,0 +1,4 @@ +package ex8; + +public class Instrumentation { +} diff --git a/DiSLProject2022/src-profiler/ex9/Instrumentation.java b/DiSLProject2022/src-profiler/ex9/Instrumentation.java new file mode 100644 index 0000000..79baf7b --- /dev/null +++ b/DiSLProject2022/src-profiler/ex9/Instrumentation.java @@ -0,0 +1,4 @@ +package ex9; + +public class Instrumentation { +} diff --git a/DiSLProject2022/startDiSLServer.sh b/DiSLProject2022/startDiSLServer.sh new file mode 100755 index 0000000..8734089 --- /dev/null +++ b/DiSLProject2022/startDiSLServer.sh @@ -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 &