Skip to content

Commit

Permalink
refactor code; upgrade soot to 4.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
QilinPTA committed May 20, 2024
1 parent 50d5474 commit c50e27a
Show file tree
Hide file tree
Showing 87 changed files with 2,263 additions and 501 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: 'true'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: hdjay2013
password: ${{ secrets.DOCKER }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: hdjay2013/qilin:latest
- name: Checkout
uses: actions/checkout@v2
with:
submodules: 'true'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: hdjay2013
password: ${{ secrets.DOCKER }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: hdjay2013/qilin:latest
26 changes: 13 additions & 13 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
os: [ ubuntu-latest, macos-latest ]
# os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
with:
submodules: 'true'
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- name: Setup and execute Gradle 'test' task
uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7
with:
arguments: test
- uses: actions/checkout@v2
with:
submodules: 'true'
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- name: Setup and execute Gradle 'test' task
uses: gradle/gradle-build-action@937999e9cc2425eddc7fd62d1053baf041147db7
with:
arguments: test
54 changes: 41 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,89 @@
[![Gradle](https://github.com/QilinPTA/Qilin/actions/workflows/gradle.yml/badge.svg?event=push)](https://github.com/QilinPTA/Qilin/actions/workflows/gradle.yml)
[![Docker](https://github.com/QilinPTA/Qilin/actions/workflows/docker-image.yml/badge.svg?event=push)](https://github.com/QilinPTA/Qilin/actions/workflows/docker-image.yml)
[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/QilinPTA/Qilin)
[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/QilinPTA/Qilin)

> :warning: [Documentation for Qilin](https://qilinpta.github.io/) is under development.
# News
* <b>[DebloaterX](https://github.com/DongjieHe/DebloaterX) published in our [OOPSLA paper](https://dongjiehe.github.io/mypaper/OOPSLA2023_DebloaterX_Preprint.pdf) is now available in Qilin</b>

* <b>[DebloaterX](https://github.com/DongjieHe/DebloaterX) published in
our [OOPSLA paper](https://dongjiehe.github.io/mypaper/OOPSLA2023_DebloaterX_Preprint.pdf) is now available in
Qilin</b>
* <b>Qilin now supports Soot-4.4.0</b>

# Qilin: A fully imperative Java Pointer Analysis Framework.
The repository hosts Qilin, a new Java pointer analysis framework for supporting fine-grained context-sensitivity. For technical details, please refer to our [ECOOP'22 paper](https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.ECOOP.2022.30).

The repository hosts Qilin, a new Java pointer analysis framework for supporting fine-grained context-sensitivity. For
technical details, please refer to
our [ECOOP'22 paper](https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.ECOOP.2022.30).

## A Quick Start

### Prerequisites

* Java 16+ (Qilin uses the pattern matching for `instanceof` provided since Java 16).
* Python 3.5+ (the api `subprocess.run` used in `artifact/qilin.py` is added in Python 3.5).

### Download
This repository contains a `submodule` that contains a set of real-world ready-to-use benchmarks for Qilin.

This repository contains a `submodule` that contains a set of real-world ready-to-use benchmarks for Qilin.
If you want to run Qilin on these benchmarks, please use the following command to fetch the Qilin source code:

```
$ git clone --recurse-submodules https://github.com/QilinPTA/Qilin.git
```

If you have cloned Qilin in a normal way, you still can use the command below to download these benchmarks:

```
$ git submodule update --init
```

### Building Qilin with Gradle

We use Gradle as the build automation tool. To build Qilin, use

```
$ ./run.sh
```
This script contains commands to generate `Qilin-VERSION-SNAPSHOT.jar`, which will be automatically moved into `artifact/`.

For users who want to build Qilin in IDE, please refer to [this page](https://github.com/QilinPTA/Qilin/wiki/Set-up-the-Debugging-Environment-for-Qilin-in-IntelliJ-IDEA).
This script contains commands to generate `Qilin-VERSION-SNAPSHOT.jar`, which will be automatically moved
into `artifact/`.

For users who want to build Qilin in IDE, please refer
to [this page](https://github.com/QilinPTA/Qilin/wiki/Set-up-the-Debugging-Environment-for-Qilin-in-IntelliJ-IDEA).

### Using Qilin

You can use Qilin either through its command-line interface (e.g., `driver.Main`) or as a library.
For researchers who are working on Java pointer analysis, we have provided a whole set of scripts, benchmarks (e.g., `DaCapo2006`) and jdk libraries under `artifact/`.
For researchers who are working on Java pointer analysis, we have provided a whole set of scripts, benchmarks (
e.g., `DaCapo2006`) and jdk libraries under `artifact/`.

To test Qilin, you can directly do:

```
$ cd artifact
$ python3 run.py antlr ci -print
```
The above command will analyse `antlr` with a context-insensitive pointer analysis with some metrics being displayed on the screen.

The above command will analyse `antlr` with a context-insensitive pointer analysis with some metrics being displayed on
the screen.
We plan to optimise the `run.py` script to make its help info more user-friendly.

## Documentation

| About Qilin | Setup Guide | User Guide | Developer Guide |
| ------------- |:-------------:| -----:|-----:|
| Introducing Qilin -- [what it does](https://qilinpta.github.io/Qilin/#what-is-qilin) and [how we design it](https://github.com/QilinPTA/Qilin/wiki/Qilin-Design#qilin-design) | A step by step [setup guide](https://github.com/QilinPTA/Qilin/wiki/Setup-Guide#getting-started) to build Qilin | [Command-line options](https://github.com/QilinPTA/Qilin/wiki/Full-list-of-Qilin-options) of Qilin, and running Qilin with [an example](https://github.com/QilinPTA/Qilin/wiki/Analyse-a-Simple-Java-Program#an-example) | Detailed [technical documentation](https://qilinpta.github.io/Qilin/QilinCodeStructure.html) and how to [use Qilin as a lib](https://github.com/QilinPTA/Qilin/wiki/Qilin-as-a-lib) for your tool or [write your own analyses](https://github.com/QilinPTA/Qilin/wiki/Write-your-own-analysis-in-Qilin) in Qilin |
| About Qilin | Setup Guide | User Guide | Developer Guide |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------:|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| Introducing Qilin -- [what it does](https://qilinpta.github.io/Qilin/#what-is-qilin) and [how we design it](https://github.com/QilinPTA/Qilin/wiki/Qilin-Design#qilin-design) | A step by step [setup guide](https://github.com/QilinPTA/Qilin/wiki/Setup-Guide#getting-started) to build Qilin | [Command-line options](https://github.com/QilinPTA/Qilin/wiki/Full-list-of-Qilin-options) of Qilin, and running Qilin with [an example](https://github.com/QilinPTA/Qilin/wiki/Analyse-a-Simple-Java-Program#an-example) | Detailed [technical documentation](https://qilinpta.github.io/Qilin/QilinCodeStructure.html) and how to [use Qilin as a lib](https://github.com/QilinPTA/Qilin/wiki/Qilin-as-a-lib) for your tool or [write your own analyses](https://github.com/QilinPTA/Qilin/wiki/Write-your-own-analysis-in-Qilin) in Qilin |

## Contributing to Qilin
Contributions are always welcome. Qilin is an open-source project that we publish in the hope that it will be useful to the research community as a whole.
If you have a new feature or a bug fix that you would like to see in the official code repository, please open a merge request here on Github and leave a short description of what you have done.

Contributions are always welcome. Qilin is an open-source project that we publish in the hope that it will be useful to
the research community as a whole.
If you have a new feature or a bug fix that you would like to see in the official code repository, please open a merge
request here on Github and leave a short description of what you have done.

## License

Qilin is licenced under the GPL v2.1 license, see the LICENSE file.

9 changes: 7 additions & 2 deletions artifact/qilin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/usr/bin/python3

import os, sys, subprocess
import fnmatch
import os
import subprocess
import sys

from util.opt import *

# HOME
Expand All @@ -10,6 +13,7 @@
XMX = '-Xmx512g'
timeout = -1


def qilinJarFile():
qilinJars = []
for f in os.listdir(PA_HOME):
Expand All @@ -28,7 +32,8 @@ def qilinJarFile():
else:
sys.exit('could not find Qilin executable file.')

CLASSPATH = os.pathsep.join([os.path.join(PA_HOME, qilinJarFile()),])

CLASSPATH = os.pathsep.join([os.path.join(PA_HOME, qilinJarFile()), ])

runJava_cmd = 'java -Xms1g %s -cp ' + CLASSPATH + ' driver.Main %s'
OPTIONMESSAGE = 'The valid OPTIONs are:\n' \
Expand Down
20 changes: 13 additions & 7 deletions artifact/run.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/python3

import os, sys, shutil
import os
import shutil
import sys

assert sys.version_info >= (3, 5), "Python version does not meet the minimum requirements, i.e., >= 3.5"

Expand All @@ -16,16 +18,17 @@
from util.benchmark import JREVERSION

# ANALYSES = ['1o', 'Z-2o', 'E-2o', 'T-2o', '2o', 'Z-3o', 'T-3o', 'E-3o', '3o', '1c', '2c', 'M-2o', '2h', '2t', 'Z-2c', 'M-2c']
ANALYSES = ['insens', '1o', 'Z-2o', 'E-2o', 'T-2o', '2o', '2t', '1c', 'M-2o', '2h', 'B-2o', '1c', 's-1c', 's-2c', '2c', '3o', 'T-3o', 'E-3o', 'Z-3o']
ANALYSES = ['insens', '1o', 'Z-2o', 'E-2o', 'T-2o', '2o', '2t', '1c', 'M-2o', '2h', 'B-2o', '1c', 's-1c', 's-2c', '2c',
'3o', 'T-3o', 'E-3o', 'Z-3o']

# for ZIPPEROPTIONS
OoM = {
'E-3o': ['eclipse', ],
'Z-3o': ['eclipse', ],
'3o': ['chart', 'eclipse', 'checkstyle', 'findbugs', 'xalan'],
'3o+D':['eclipse',],
'3o+DX':['eclipse'],
'3o+DC':['eclipse']
'3o+D': ['eclipse', ],
'3o+DX': ['eclipse'],
'3o+DC': ['eclipse']
}
TIMEOUT = {
'3o': ['bloat'],
Expand Down Expand Up @@ -104,15 +107,18 @@ def runPTA(analysis, bm, OPTIONSTYLE):
print(cmd)
pta.runPointsToAnalysis(cmd.split())


OPTIONMESSAGE = 'The valid OPTIONs are:\n' \
+ option('-help|-h', 'print this message.') \
+ option('-print', 'print the analyses results on screen.') \
+ option('-clean', 'remove previous outputs.') \
+ option('-cd', 'enable context debloating.') \
+ option('-cda=<[CONCH|DEBLOATERX|COLLECTION]>', 'specify the debloating approach (default value is CONCH)') \
+ option('-cda=<[CONCH|DEBLOATERX|COLLECTION]>',
'specify the debloating approach (default value is CONCH)') \
+ option('-dump', 'dump statistics into files.') \
+ option('<PTA>', 'specify pointer analysis.') \
+ option('-cga=<[CHA|VTA|RTA|GEOM|SPARK|QILIN]>', 'specify the callgraph construction algorithm (default value is QILIN)') \
+ option('-cga=<[CHA|VTA|RTA|GEOM|SPARK|QILIN]>',
'specify the callgraph construction algorithm (default value is QILIN)') \
+ option('<Benchmark>', 'specify benchmark.') \
+ option('-jre=<[jre1.6.0_45|jre1.8.0_312]>', 'specify the JRE version.') \
+ option('-out=<out>', 'specify output path.') \
Expand Down
21 changes: 14 additions & 7 deletions artifact/runbach.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
#!/usr/bin/python3
import os, sys, shutil
import os
import shutil
import sys

import qilin as pta
from util.opt import *
import util.TerminalColor as tc
import util.dacapobach as db
from util.opt import *

ANALYSES = ['insens', 'Z-2o', 'E-2o', '2o', 'Z-3o', 'E-3o', '3o']

# eclipse and jython are always unscalable.
UNSCALABLE = {
'3o': ['avrora', 'batik', 'h2', 'luindex', 'lusearch', 'pmd', 'sunflow', 'tradebeans', 'xalan'], # OoM
'E-3o': ['avrora', 'batik', 'h2', 'luindex', 'lusearch', 'pmd', 'sunflow', 'tradebeans', 'xalan'], # OoM
'Z-3o': ['avrora', 'batik', 'h2', 'luindex', 'lusearch', 'pmd', 'sunflow', 'tradebeans', 'xalan'], # OoM
'3o': ['avrora', 'batik', 'h2', 'luindex', 'lusearch', 'pmd', 'sunflow', 'tradebeans', 'xalan'], # OoM
'E-3o': ['avrora', 'batik', 'h2', 'luindex', 'lusearch', 'pmd', 'sunflow', 'tradebeans', 'xalan'], # OoM
'Z-3o': ['avrora', 'batik', 'h2', 'luindex', 'lusearch', 'pmd', 'sunflow', 'tradebeans', 'xalan'], # OoM
'3o+D': ['batik', 'h2'],
'3o+DX': ['h2'],
}
Expand All @@ -26,9 +29,11 @@

BATCHPATH = 'benchmarks/dacapo-bach/'


def getPath(dir, file):
return os.path.join(dir, file)


def getPTACommand(analysis, bm, OPTIONSTYLE):
options = []
options += BASICOPTIONS
Expand Down Expand Up @@ -88,12 +93,14 @@ def runPTA(analysis, bm, OPTIONSTYLE):
+ option('-clean', 'remove previous outputs.') \
+ option('-dump', 'dump statistics into files.') \
+ option('<PTA>', 'specify pointer analysis.') \
+ option('-cga=<[CHA|VTA|RTA|GEOM|SPARK|QILIN]>', 'specify the callgraph construction algorithm (default value is QILIN)') \
+ option('-cga=<[CHA|VTA|RTA|GEOM|SPARK|QILIN]>',
'specify the callgraph construction algorithm (default value is QILIN)') \
+ option('<Benchmark>', 'specify benchmark.') \
+ option('-out=<out>', 'specify output path.') \
+ option('-pre', 'run pre-analysis only.') \
+ option('-cd', 'enable context debloating.') \
+ option('-cda=<[CONCH|DEBLOATERX|COLLECTION]>', 'specify the debloating approach (default value is CONCH)') \
+ option('-cda=<[CONCH|DEBLOATERX|COLLECTION]>',
'specify the debloating approach (default value is CONCH)') \
+ option('-OS=<zipper|mahjong>', 'specify the style of configurations.') \
+ option('-all', 'run all analyses for specified benchmark(s) if ONLY benchmark(s) is specified;\n\
run specified analyses for all benchmark(s) if ONLY analyses is specified;\n\
Expand Down
2 changes: 2 additions & 0 deletions artifact/util/Util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import subprocess
from util.ptaout import PTAOutput


def checkJavaVersion():
javaversion = subprocess.check_output(['java', '-version'], stderr=subprocess.STDOUT)
jv = javaversion.decode("utf-8")
Expand All @@ -16,6 +17,7 @@ def checkJavaVersion():
print('Error: JRE version does not meet the minimum requirement, i.e., >= 16')
exit()


def checkConsistency(pta1, pta2):
if pta1.app != pta2.app or pta1.analysisName != pta2.analysisName or \
pta1.mayFailCasts != pta2.mayFailCasts or \
Expand Down
Loading

0 comments on commit c50e27a

Please sign in to comment.