Skip to content

Commit

Permalink
Merge pull request #207 from gmu-swe/instrument-plugin
Browse files Browse the repository at this point in the history
Improved Phosphor plugin and driver
  • Loading branch information
katherine-hough authored Nov 27, 2023
2 parents 972b5e4 + c3d97e3 commit 21cf9ab
Show file tree
Hide file tree
Showing 57 changed files with 2,550 additions and 2,826 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ jobs:
strategy:
fail-fast: false
matrix:
# java: [ '8', '11', '16', '17' ]
java: [ '8', '11', '16' ]
steps:
- uses: actions/checkout@v3
Expand All @@ -22,7 +21,7 @@ jobs:
distribution: 'temurin'
java-version: ${{ matrix.java }}
- name: Run tests
run: mvn install -ntp -Ddacapo.skip=false
run: mvn install -ntp -Pdacapo -pl :integration-tests
deploy:
runs-on: self-hosted
needs: build-and-test
Expand Down
178 changes: 51 additions & 127 deletions Phosphor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,58 @@
<artifactId>phosphor-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>9.6</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-util</artifactId>
<version>9.6</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-tree</artifactId>
<version>9.6</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-analysis</artifactId>
<version>9.6</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
<version>9.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
<manifestEntries>
<Premain-Class>
edu.columbia.cs.psl.phosphor.agent.PhosphorAgent
</Premain-Class>
<Can-Retransform-Classes>true</Can-Retransform-Classes>
</manifestEntries>
</archive>
<excludes>
<exclude>java/</exclude>
<exclude>sun/</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<doclint>none</doclint>
<quiet>true</quiet>
<source>8</source>
<excludePackageNames>sun.*:java.*</excludePackageNames>
<forceCreation>true</forceCreation>
</configuration>
<executions>
<execution>
<id>attach-javadoc</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>generate-stubs</id>
Expand Down Expand Up @@ -96,7 +109,8 @@
<excludes>
<!-- These classes will be overridden
by the ones inside the JAR -->
<exclude>edu/columbia/cs/psl/phosphor/org/objectweb/asm/tree/FrameNode.class
<exclude>
edu/columbia/cs/psl/phosphor/org/objectweb/asm/tree/FrameNode.class
</exclude>
</excludes>
</filter>
Expand All @@ -110,111 +124,21 @@
</excludes>
</filter>
</filters>
<createSourcesJar>true</createSourcesJar>
<shadeSourcesContent>true</shadeSourcesContent>
<minimizeJar>true</minimizeJar>
</configuration>
</execution>
</executions>
</plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>8</source><target>8</target></configuration></plugin>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>release-sign-artifacts</id>
<activation>
<property>
<name>gpg.passphrase</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>make-graph</id>
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>edu.columbia.cs.psl.phosphor.control.graph.BaseControlFlowGraphCreator
</mainClass>
<arguments>{$exec.args}</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>9.6</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-util</artifactId>
<version>9.6</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-tree</artifactId>
<version>9.6</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-analysis</artifactId>
<version>9.6</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
<version>9.6</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public static synchronized java.util.LinkedList<String> replaceAutoTaintMethods(
try {
if (classMap.containsKey(className)) {
for (Class<?> clazz : classMap.get(className)) {
PreMain.getInstrumentationHelper().retransformClasses(clazz);
Phosphor.getInstrumentation().retransformClasses(clazz);
}
}
} catch (NonModifiableClassException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ public HackyClassWriter(ClassReader classReader, int flags) {

@Override
protected String getCommonSuperClass(String type1, String type2) {
if (PreMain.RUNTIME_INST) {
if (Phosphor.RUNTIME_INST) {
return "java/lang/Object";
}
Class<?> clazz1;
Class<?> clazz2;
try {
clazz1 = Class.forName(type1.replace('/', '.'), false, PreMain.bigLoader);
clazz2 = Class.forName(type2.replace('/', '.'), false, PreMain.bigLoader);
clazz1 = Class.forName(type1.replace('/', '.'), false, Phosphor.bigLoader);
clazz2 = Class.forName(type2.replace('/', '.'), false, Phosphor.bigLoader);
} catch (Throwable t) {
return "java/lang/Object";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import edu.columbia.cs.psl.phosphor.runtime.NonModifiableClassException;

public interface InstrumentationHelper {
void addTransformer(PhosphorBaseTransformer classSupertypeReadingTransformer);
void addTransformer(PhosphorBaseTransformer classSupertypeReadingTransformer, boolean canRedefineClasses);

void retransformClasses(Class<?> clazz) throws NonModifiableClassException;
public interface InstrumentationAdaptor {
void addTransformer(PhosphorBaseTransformer transformer);

Class<?>[] getAllLoadedClasses();

void addTransformer(PhosphorBaseTransformer transformer, boolean canRedefineClasses);

void retransformClasses(Class<?> clazz) throws NonModifiableClassException;
}
Loading

0 comments on commit 21cf9ab

Please sign in to comment.