Skip to content

Commit e91e83c

Browse files
authored
Merge pull request #205 from barbosamaatheus/add_pa
Add new OA options
2 parents 7f52f46 + 156ce90 commit e91e83c

File tree

8 files changed

+136
-14
lines changed

8 files changed

+136
-14
lines changed
Binary file not shown.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import subprocess
2+
import os
3+
import time
4+
import shutil
5+
from datetime import datetime
6+
import platform
7+
8+
# CONFIGURATION
9+
SOURCE_BASE = "."
10+
FILES_TO_MOVE = [
11+
"output/data/soot-results.csv",
12+
"AnalysisRecords.csv",
13+
"conflicts_log.txt",
14+
"outConsole.txt",
15+
"out.txt",
16+
"out.json",
17+
"HasMainMethod.csv",
18+
"PANotResolve.csv",
19+
"visited_methods.txt",
20+
"time.txt"
21+
]
22+
23+
BASE_RESULTS_DIR = "../results"
24+
RUNS_PER_MODE = 10
25+
MODES = ["ioa", "ioa-without-pa"]
26+
27+
def ensure_dirs():
28+
for mode in MODES:
29+
os.makedirs(os.path.join(BASE_RESULTS_DIR, mode), exist_ok=True)
30+
31+
def move_files_to_result_folder(mode, run_number):
32+
dest_dir = os.path.join(BASE_RESULTS_DIR, mode, f"data{run_number}")
33+
os.makedirs(dest_dir, exist_ok=True)
34+
35+
for filename in FILES_TO_MOVE:
36+
src_path = os.path.join(SOURCE_BASE, filename)
37+
dest_path = os.path.join(dest_dir, os.path.basename(filename))
38+
39+
if os.path.exists(src_path):
40+
shutil.move(src_path, dest_path)
41+
print(f"[OK] moved: {filename}{os.path.relpath(dest_path)}")
42+
else:
43+
print(f"[WARNING] File not found: {src_path}")
44+
45+
def get_gradle_command():
46+
if platform.system() == "Windows":
47+
return "gradlew.bat"
48+
else:
49+
return "./gradlew"
50+
51+
def run_soot(mode, run_number):
52+
print(f"[{datetime.now().strftime('%H:%M:%S')}] [{mode.upper()}] Run {run_number} started.")
53+
try:
54+
subprocess.run(
55+
[get_gradle_command(), "run", "-DmainClass=services.outputProcessors.soot.Main", f"--args=-{mode}"],
56+
check=True
57+
)
58+
except subprocess.CalledProcessError as e:
59+
print(f"[ERROR] Run {run_number} ({mode}) failed: {e}")
60+
return
61+
62+
move_files_to_result_folder(mode, run_number)
63+
print(f"[{datetime.now().strftime('%H:%M:%S')}] Results moved to results/{mode}/data{run_number}/")
64+
65+
def main():
66+
ensure_dirs()
67+
for mode in MODES:
68+
for i in range(1, RUNS_PER_MODE + 1):
69+
run_soot(mode, i)
70+
71+
if __name__ == "__main__":
72+
main()

src/main/services/outputProcessors/soot/Main.groovy

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,16 @@ class Main {
8989
detectionAlgorithms.add(new ConflictDetectionAlgorithm("Confluence Inter", "dfp-confluence-interprocedural", sootWrapper, appArguments.getTimeout()))
9090
}
9191
if (appArguments.getOaIntra()) {
92-
detectionAlgorithms.add(new ConflictDetectionAlgorithm("OA Intra", "overriding-intraprocedural", sootWrapper, appArguments.getTimeout()))
92+
detectionAlgorithms.add(new ConflictDetectionAlgorithm("OA Intra", "oa", sootWrapper, appArguments.getTimeout()))
9393
}
9494
if (appArguments.getOaInter()) {
95-
detectionAlgorithms.add(new ConflictDetectionAlgorithm("OA Inter", "overriding-interprocedural", sootWrapper, appArguments.getTimeout()))
95+
detectionAlgorithms.add(new ConflictDetectionAlgorithm("OA Inter", "ioa", sootWrapper, appArguments.getTimeout()))
96+
}
97+
if (appArguments.getOaIntraWithoutPA()) {
98+
detectionAlgorithms.add(new ConflictDetectionAlgorithm("OA Intra Without Pointer Analysis", "oa-without-pa", sootWrapper, appArguments.getTimeout()))
99+
}
100+
if (appArguments.getOaInterWithoutPA()) {
101+
detectionAlgorithms.add(new ConflictDetectionAlgorithm("OA Inter Without Pointer Analysis", "ioa-without-pa", sootWrapper, appArguments.getTimeout()))
96102
}
97103

98104
if (appArguments.getDfpIntra()) {

src/main/services/outputProcessors/soot/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ Options:
4848
dfp-confluence-interprocedural
4949
-idf,--svfa-interprocedural Run svfa-interprocedural
5050
-idfp,--dfp-inter Run dfp-inter
51-
-ioa,--overriding-interprocedural Run overriding-interprocedural
52-
-oa,--overriding-intraprocedural Run overriding-intraprocedural
51+
-ioa, --overriding-interprocedural Run interprocedural overriding analysis
52+
-oa, --overriding-intraprocedural Run intraprocedural overriding analysis
53+
-ioaWithoutPA, --ioa-without-pa Run interprocedural overriding analysis without Pointer Analysis
54+
-oaWithoutPA, --oa-without-pa Run intraprocedural overriding analysis without Pointer Analysis
5355
-pd,--pessimistic-dataflow Run pessimistic-dataflow
5456
-pdg,--pdg Run pdg
5557
-pdge,--pdge Run pdg-e

src/main/services/outputProcessors/soot/RunSootAnalysisOutputProcessor.groovy

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ class RunSootAnalysisOutputProcessor implements OutputProcessor {
4141
new NonCommutativeConflictDetectionAlgorithm("DF Inter", "svfa-interprocedural", this.sootWrapper, TIMEOUT, true),
4242
new ConflictDetectionAlgorithm("Confluence Intra", "dfp-confluence-intraprocedural", this.sootWrapper, TIMEOUT),
4343
new ConflictDetectionAlgorithm("Confluence Inter", "dfp-confluence-interprocedural", this.sootWrapper, TIMEOUT, true),
44-
new ConflictDetectionAlgorithm("OA Intra", "overriding-intraprocedural", this.sootWrapper, TIMEOUT),
45-
new ConflictDetectionAlgorithm("OA Inter", "overriding-interprocedural", this.sootWrapper, TIMEOUT, true),
44+
new ConflictDetectionAlgorithm("OA Intra", "oa", this.sootWrapper, TIMEOUT),
45+
new ConflictDetectionAlgorithm("OA Inter", "ioa", this.sootWrapper, TIMEOUT, true),
46+
new ConflictDetectionAlgorithm("OA Intra Without Pointer Analysis", "oa-without-pa", this.sootWrapper, TIMEOUT),
47+
new ConflictDetectionAlgorithm("OA Inter Without Pointer Analysis", "ioa-without-pa", this.sootWrapper, TIMEOUT, true),
4648
new NonCommutativeConflictDetectionAlgorithm("DFP-Intra", "dfp-intra", this.sootWrapper, TIMEOUT),
4749
new NonCommutativeConflictDetectionAlgorithm("DFP-Inter", "dfp-inter", this.sootWrapper, TIMEOUT, true),
4850
new NonCommutativeConflictDetectionAlgorithm("CD", "cd", this.sootWrapper, TIMEOUT),

src/main/services/outputProcessors/soot/ScenarioReader.groovy

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package services.outputProcessors.soot
22

3+
import com.xlson.groovycsv.PropertyMapper
4+
35
import static com.xlson.groovycsv.CsvParser.parseCsv
46

57
class ScenarioReader {
@@ -17,14 +19,8 @@ class ScenarioReader {
1719
String classPathName = line["className"]
1820
String methodSignature = line["method"]
1921
String commitSHA = line["merge commit"]
20-
String entrypoints = line["entrypoints"]
21-
22-
String scenarioDirectory = getScenarioDirectory(outputPath, projectName, commitSHA)
23-
24-
if (line.hasProperty("realistic case path")) {
25-
String realisticCasePath = line["realistic case path"]
26-
scenarioDirectory = getScenarioDirectory(outputPath, projectName, commitSHA, realisticCasePath)
27-
}
22+
String entrypoints = getEntrypointColumn(line);
23+
String scenarioDirectory = getCorrectScenarioDirectory(line, outputPath, projectName, commitSHA)
2824

2925
boolean hasBuild = line["has_build"] == "true"
3026

@@ -35,6 +31,22 @@ class ScenarioReader {
3531
return result
3632
}
3733

34+
static private String getEntrypointColumn(Object line) {
35+
if (line instanceof Map && line.containsKey("entrypoints")) {
36+
return line["entrypoints"]?.toString()
37+
}
38+
return null;
39+
}
40+
41+
static private String getCorrectScenarioDirectory(Object line, String outputPath, String projectName, String commitSHA) {
42+
if (line.containsKey("realistic case path")) {
43+
String realisticCasePath = line["realistic case path"]
44+
return getScenarioDirectory(outputPath, projectName, commitSHA, realisticCasePath)
45+
} else {
46+
return getScenarioDirectory(outputPath, projectName, commitSHA)
47+
}
48+
}
49+
3850
static private String getScenarioDirectory(String outputPath, String projectName, String commitSHA, String realisticCasePath) {
3951
return "${getScenarioDirectory(outputPath, projectName, commitSHA)}/${realisticCasePath}"
4052
}

src/main/services/outputProcessors/soot/arguments/ArgsParser.groovy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class ArgsParser {
2525
this.cli.icf(longOpt: 'dfp-confluence-interprocedural', "Run dfp-confluence-interprocedural")
2626
this.cli.oa(longOpt: 'overriding-intraprocedural', "Run overriding-intraprocedural")
2727
this.cli.ioa(longOpt: 'overriding-interprocedural', "Run overriding-interprocedural")
28+
this.cli.oawopa(longOpt: 'oa-without-pa', "Run oa-without-pa")
29+
this.cli.ioawopa(longOpt: 'ioa-without-pa', "Run ioa-without-pa")
2830
this.cli.dfp(longOpt: 'dfp-intra', "Run dfp-intra")
2931
this.cli.idfp(longOpt: 'dfp-inter', "Run dfp-inter")
3032
this.cli.cd(longOpt: 'cd', "Run cd")
@@ -78,6 +80,12 @@ class ArgsParser {
7880
if (this.options.ioa) {
7981
args.setOaInter(true)
8082
}
83+
if (this.options.oaWithoutPA) {
84+
args.setOaIntraWithoutPA(true)
85+
}
86+
if (this.options.ioaWithoutPA) {
87+
args.setOaInterWithoutPA(true)
88+
}
8189
if (this.options.dfp) {
8290
args.setDfpIntra(true)
8391
}

src/main/services/outputProcessors/soot/arguments/Arguments.groovy

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ class Arguments {
99
private boolean cfInter
1010
private boolean oaIntra;
1111
private boolean oaInter;
12+
private boolean oaIntraWithoutPA;
13+
private boolean oaInterWithoutPA;
1214
private boolean dfpIntra
1315
private boolean dfpInter
1416
private boolean cd
@@ -31,6 +33,8 @@ class Arguments {
3133
cfInter = false
3234
oaIntra = false
3335
oaInter = false
36+
oaIntraWithoutPA = false
37+
oaInterWithoutPA = false
3438
dfpIntra = false
3539
dfpInter = false
3640
cd = false
@@ -45,6 +49,22 @@ class Arguments {
4549
depthLimit = 5
4650
}
4751

52+
boolean getOaIntraWithoutPA() {
53+
return oaIntraWithoutPA
54+
}
55+
56+
void setOaIntraWithoutPA(boolean oaIntraWithoutPA) {
57+
this.oaIntraWithoutPA = oaIntraWithoutPA
58+
}
59+
60+
boolean getOaInterWithoutPA() {
61+
return oaInterWithoutPA
62+
}
63+
64+
void setOaInterWithoutPA(boolean oaInterWithoutPA) {
65+
this.oaInterWithoutPA = oaInterWithoutPA
66+
}
67+
4868
void setDepthLimit(long depthLimit) {
4969
this.depthLimit = depthLimit
5070
}

0 commit comments

Comments
 (0)