Skip to content

Commit

Permalink
feat(spgroup#31): export result data in file and console.
Browse files Browse the repository at this point in the history
  • Loading branch information
barbosamaatheus committed Sep 29, 2021
1 parent fcb7e0c commit 8a2cf04
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/main/java/br/unb/cic/analysis/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ private void exportResults() throws Exception {
final String out = "out.txt";
final FileWriter fw = new FileWriter(out);
conflicts.forEach(c -> {
try {
fw.write(c + "\n");
}
try {
fw.write(c + "\n\n");
}
catch(Exception e) {
System.out.println("error exporting the results " + e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,15 @@ protected void internalTransform(String s, Map<String, String> map) {
List<SootMethod> methods = Scene.v().getEntryPoints();
methods.forEach(sootMethod -> traverse(new ArraySparseSet<>(), sootMethod, Statement.Type.IN_BETWEEN));

logger.log(Level.INFO, () -> String.format("%s", "CONFLICTS: " + getConflicts()));
Set<Conflict> conflictsFilter = new HashSet<>();
filterConflicts(getConflicts(), conflictsFilter);

logger.log(Level.INFO, () -> String.format("%s", "Number of conflicts filter: " + conflictsFilter.size()));
conflictsFilter.forEach(conflict -> {
logger.log(Level.INFO, conflict.toStringAbstract());
});

//logger.log(Level.INFO, () -> String.format("%s", "CONFLICTS: " + conflictsFilter));

/* left.forEach(dataFlowAbstraction -> {
String leftStmt = String.format("%s", "LEFT: " + dataFlowAbstraction.getStmt());
Expand All @@ -89,6 +97,19 @@ protected void internalTransform(String s, Map<String, String> map) {
}); */
}

private void filterConflicts(Set<Conflict> conflictsResults, Set<Conflict> conflictsFilter) {
conflictsResults.forEach(conflict -> {
if (conflictsFilter.isEmpty()) {
conflictsFilter.add(conflict);
}
conflictsFilter.forEach(filter -> {
if ((!conflict.getSourceTraversedLine().get(0).equals(filter.getSourceTraversedLine().get(0))) && (!conflict.getSinkTraversedLine().get(0).equals(filter.getSinkTraversedLine().get(0)))) {
conflictsFilter.add(conflict);
}
});
});
}

/**
* This method captures the safe body of the current method and delegates the analysis function to units of (LEFT or RIGHT) or units of BASE.
*
Expand Down
25 changes: 21 additions & 4 deletions src/main/java/br/unb/cic/analysis/model/Conflict.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,22 @@ public Integer getSinkLineNumber() {
return sinkLineNumber;
}

public List<TraversedLine> getSourceTraversedLine() {
return sourceTraversedLine;
}

public void setSourceTraversedLine(List<TraversedLine> sourceTraversedLine) {
this.sourceTraversedLine = sourceTraversedLine;
}

public List<TraversedLine> getSinkTraversedLine() {
return sinkTraversedLine;
}

public void setSinkTraversedLine(List<TraversedLine> sinkTraversedLine) {
this.sinkTraversedLine = sinkTraversedLine;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand All @@ -91,14 +107,15 @@ public int hashCode() {
return Objects.hash(sourceClassName, sourceMethodName, sourceLineNumber, sinkClassName, sinkMethodName, sinkLineNumber);
}

/* @Override
public String toString() {

public String toStringAbstract() {
return String.format("source(%s, %s, %d, %s, %s) => sink(%s, %s, %d, %s, %s)", sourceTraversedLine.get(0).getSootClass(),
sourceTraversedLine.get(0).getSootMethod(), sourceTraversedLine.get(0).getLineNumber(), sourceUnit,
sourceTraversedLine,
sinkTraversedLine.get(0).getSootClass(), sinkTraversedLine.get(0).getSootMethod(),
sinkTraversedLine.get(0).getSootClass(), sinkTraversedLine.get(0).getSootMethod(),
sinkTraversedLine.get(0).getLineNumber(), sinkUnit, sinkTraversedLine);
}*/
}


@Override
public String toString() {
Expand Down

0 comments on commit 8a2cf04

Please sign in to comment.