Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/* Qilin - a Java Pointer Analysis Framework
* Copyright (C) 2021-2030 Qilin developers
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3.0 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
*/
package qilin.pta.toolkits.selectx;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import qilin.core.PTA;
import qilin.core.PointsToAnalysis;
import qilin.core.builder.MethodNodeFactory;
import qilin.core.builder.callgraph.Edge;
import qilin.core.pag.*;
import qilin.util.PTAUtils;
import qilin.util.queue.QueueReader;
import sootup.core.jimple.basic.Local;
import sootup.core.jimple.basic.Value;
import sootup.core.jimple.common.constant.NullConstant;
import sootup.core.jimple.common.expr.AbstractInstanceInvokeExpr;
import sootup.core.jimple.common.expr.AbstractInvokeExpr;
import sootup.core.jimple.common.stmt.JAssignStmt;
import sootup.core.jimple.common.stmt.Stmt;
import sootup.core.model.SootMethod;
import sootup.core.types.ReferenceType;
public class Selectx {
private final PTA prePTA;
private final PAG prePAG;
private final Set sparkFields = new HashSet<>();
public Selectx(PTA pta) {
this.prePTA = pta;
this.prePAG = pta.getPag();
buildGraph();
}
public void addNewEdge(AllocNode from, LocalVarNode to) {
O fromE = O.v(from);
L toE = L.v(to, true);
fromE.addOutEdge(toE);
L toEI = L.v(to, false);
toEI.addOutEdge(fromE);
}
public void addAssignEdge(LocalVarNode from, LocalVarNode to) {
L fromE = L.v(from, true), toE = L.v(to, true);
fromE.addOutEdge(toE);
L fromEI = L.v(from, false), toEI = L.v(to, false);
toEI.addOutEdge(fromEI);
}
public void addEntryEdge(LocalVarNode from, LocalVarNode to, CallSite callSite) {
int i = getCallSiteNumber(callSite);
L fromE = L.v(from, true), toE = L.v(to, true);
if (fromE.addOutEntryEdge(i, toE)) {
toE.addInEntryEdge(i, fromE);
L fromEI = L.v(from, false), toEI = L.v(to, false);
toEI.addOutExitEdge(i, fromEI);
}
}
public void addExitEdge(LocalVarNode from, LocalVarNode to, CallSite callSite) {
int i = getCallSiteNumber(callSite);
L fromE = L.v(from, true), toE = L.v(to, true);
if (fromE.addOutExitEdge(i, toE)) {
L fromEI = L.v(from, false), toEI = L.v(to, false);
toEI.addOutEntryEdge(i, fromEI);
fromEI.addInEntryEdge(i, toEI);
}
}
public void addStoreEdge(LocalVarNode from, LocalVarNode base) {
L fromE = L.v(from, true), baseE = L.v(base, true);
L fromEI = L.v(from, false), baseEI = L.v(base, false);
fromE.addOutEdge(baseEI);
baseE.addOutEdge(fromEI);
}
public void addStaticStoreEdge(LocalVarNode from, GlobalVarNode to) {
L fromE = L.v(from, true);
G toE = G.v(to, true);
fromE.addOutEdge(toE);
L fromEI = L.v(from, false);
G toEI = G.v(to, false);
toEI.addOutEdge(fromEI);
}
public void addStaticLoadEdge(GlobalVarNode from, LocalVarNode to) {
G fromE = G.v(from, true);
L toE = L.v(to, true);
fromE.addOutEdge(toE);
G fromEI = G.v(from, false);
L toEI = L.v(to, false);
toEI.addOutEdge(fromEI);
}
private void propagate(Set workList, Set paraWorkList) {
while (!workList.isEmpty() || !paraWorkList.isEmpty()) {
while (!workList.isEmpty()) {
BNode node = workList.iterator().next();
workList.remove(node);
node.forwardTargets().filter(BNode::setVisited).forEach(workList::add);
if (node instanceof L) {
L l = (L) node;
l.getOutEntryEdges().stream()
.filter(tgt -> tgt.paras.add(tgt))
.forEach(paraWorkList::add);
}
}
while (!paraWorkList.isEmpty()) {
I node = paraWorkList.iterator().next();
paraWorkList.remove(node);
// para propagation.
node.getOutTargets().stream().filter(i -> i.update(node)).forEach(paraWorkList::add);
if (node instanceof L) {
L l = (L) node;
l.getOutGs().filter(BNode::setVisited).forEach(workList::add);
l.getOutEntryEdges().stream()
.filter(tgt -> tgt.paras.add(tgt))
.forEach(paraWorkList::add);
for (Map.Entry> entry : l.getOutExitEdges()) {
Integer i = entry.getKey();
Set tgts = entry.getValue();
l.paras.stream()
.flatMap(para -> para.getInEntryEdges(i).stream())
.forEach(
arg -> {
tgts.forEach(
tgt -> {
if (arg.addOutEdge(tgt)) { // add match edge
if (arg.isVisited() && tgt.setVisited()) {
workList.add(tgt);
}
if (tgt.update(arg)) {
paraWorkList.add(tgt);
}
}
});
});
}
}
} // para while
} // outer while
}
private void resetNodes() {
// reset nodes' visited state
G.g2GN.values().forEach(BNode::reset);
G.g2GP.values().forEach(BNode::reset);
L.l2LN.values().forEach(BNode::reset);
L.l2LP.values().forEach(BNode::reset);
O.o2O.values().forEach(BNode::reset);
// clear paras
L.l2LN.values().forEach(I::clearParas);
L.l2LP.values().forEach(I::clearParas);
O.o2O.values().forEach(I::clearParas);
}
public Map