Search in sources :

Example 1 with StringTag

use of soot.tagkit.StringTag in project soot by Sable.

the class SparkTransformer method addTags.

protected void addTags(PAG pag) {
    final Tag unknown = new StringTag("Untagged Spark node");
    final Map<Node, Tag> nodeToTag = pag.getNodeTags();
    for (final SootClass c : Scene.v().getClasses()) {
        for (final SootMethod m : c.getMethods()) {
            if (!m.isConcrete())
                continue;
            if (!m.hasActiveBody())
                continue;
            for (final Unit u : m.getActiveBody().getUnits()) {
                final Stmt s = (Stmt) u;
                if (s instanceof DefinitionStmt) {
                    Value lhs = ((DefinitionStmt) s).getLeftOp();
                    VarNode v = null;
                    if (lhs instanceof Local) {
                        v = pag.findLocalVarNode(lhs);
                    } else if (lhs instanceof FieldRef) {
                        v = pag.findGlobalVarNode(((FieldRef) lhs).getField());
                    }
                    if (v != null) {
                        PointsToSetInternal p2set = v.getP2Set();
                        p2set.forall(new P2SetVisitor() {

                            public final void visit(Node n) {
                                addTag(s, n, nodeToTag, unknown);
                            }
                        });
                        Node[] simpleSources = pag.simpleInvLookup(v);
                        for (Node element : simpleSources) {
                            addTag(s, element, nodeToTag, unknown);
                        }
                        simpleSources = pag.allocInvLookup(v);
                        for (Node element : simpleSources) {
                            addTag(s, element, nodeToTag, unknown);
                        }
                        simpleSources = pag.loadInvLookup(v);
                        for (Node element : simpleSources) {
                            addTag(s, element, nodeToTag, unknown);
                        }
                    }
                }
            }
        }
    }
}
Also used : StringTag(soot.tagkit.StringTag) VarNode(soot.jimple.spark.pag.VarNode) FieldRef(soot.jimple.FieldRef) PointsToSetInternal(soot.jimple.spark.sets.PointsToSetInternal) Node(soot.jimple.spark.pag.Node) VarNode(soot.jimple.spark.pag.VarNode) AllocNode(soot.jimple.spark.pag.AllocNode) Local(soot.Local) SootClass(soot.SootClass) Unit(soot.Unit) Stmt(soot.jimple.Stmt) DefinitionStmt(soot.jimple.DefinitionStmt) Value(soot.Value) SootMethod(soot.SootMethod) Tag(soot.tagkit.Tag) StringTag(soot.tagkit.StringTag) DefinitionStmt(soot.jimple.DefinitionStmt) P2SetVisitor(soot.jimple.spark.sets.P2SetVisitor)

Example 2 with StringTag

use of soot.tagkit.StringTag in project soot by Sable.

the class Attribute method addTag.

public void addTag(Tag t) {
    if (t instanceof LineNumberTag) {
        int lnNum = (new Integer(((LineNumberTag) t).toString())).intValue();
        javaStartLn(lnNum);
        javaEndLn(lnNum);
    } else if (t instanceof JimpleLineNumberTag) {
        JimpleLineNumberTag jlnTag = (JimpleLineNumberTag) t;
        jimpleStartLn(jlnTag.getStartLineNumber());
        jimpleEndLn(jlnTag.getEndLineNumber());
    } else if (t instanceof SourceLnPosTag) {
        SourceLnPosTag jlnTag = (SourceLnPosTag) t;
        javaStartLn(jlnTag.startLn());
        javaEndLn(jlnTag.endLn());
        javaStartPos(jlnTag.startPos());
        javaEndPos(jlnTag.endPos());
    } else if (t instanceof LinkTag) {
        LinkTag lt = (LinkTag) t;
        Host h = lt.getLink();
        LinkAttribute link = new LinkAttribute(lt.getInfo(), getJimpleLnOfHost(h), getJavaLnOfHost(h), lt.getClassName(), lt.getAnalysisType());
        addLink(link);
    } else if (t instanceof StringTag) {
        StringTag st = (StringTag) t;
        StringAttribute string = new StringAttribute(formatForXML(st.getInfo()), st.getAnalysisType());
        addText(string);
    } else if (t instanceof PositionTag) {
        PositionTag pt = (PositionTag) t;
        jimpleStartPos(pt.getStartOffset());
        jimpleEndPos(pt.getEndOffset());
    } else if (t instanceof ColorTag) {
        ColorTag ct = (ColorTag) t;
        ColorAttribute ca = new ColorAttribute(ct.getRed(), ct.getGreen(), ct.getBlue(), ct.isForeground(), ct.getAnalysisType());
        // color(ca);
        addColor(ca);
    } else /*else if (t instanceof SourcePositionTag){
        }
        else if (t instanceof SourceLineNumberTag){
        }*/
    {
        // System.out.println("t is: "+t.getClass());
        StringAttribute sa = new StringAttribute(t.toString(), t.getName());
        addText(sa);
    }
}
Also used : SourceLnPosTag(soot.tagkit.SourceLnPosTag) StringTag(soot.tagkit.StringTag) LinkTag(soot.tagkit.LinkTag) ColorTag(soot.tagkit.ColorTag) PositionTag(soot.tagkit.PositionTag) Host(soot.tagkit.Host) JimpleLineNumberTag(soot.tagkit.JimpleLineNumberTag) LineNumberTag(soot.tagkit.LineNumberTag) JimpleLineNumberTag(soot.tagkit.JimpleLineNumberTag)

Example 3 with StringTag

use of soot.tagkit.StringTag in project soot by Sable.

the class JavaAttribute method printAttributeTag.

private void printAttributeTag(Tag t) {
    if (t instanceof LineNumberTag) {
        int lnNum = (new Integer(((LineNumberTag) t).toString())).intValue();
        printJavaLnAttr(lnNum, lnNum);
    } else if (t instanceof JimpleLineNumberTag) {
        JimpleLineNumberTag jlnTag = (JimpleLineNumberTag) t;
        printJimpleLnAttr(jlnTag.getStartLineNumber(), jlnTag.getEndLineNumber());
    } else /*else if (t instanceof SourceLineNumberTag) {
            SourceLineNumberTag jlnTag = (SourceLineNumberTag)t; 
			printJavaLnAttr(jlnTag.getStartLineNumber(), jlnTag.getEndLineNumber());
		}*/
    if (t instanceof LinkTag) {
        LinkTag lt = (LinkTag) t;
        Host h = lt.getLink();
        printLinkAttr(formatForXML(lt.toString()), getJimpleLnOfHost(h), getJavaLnOfHost(h), lt.getClassName());
    } else if (t instanceof StringTag) {
        printTextAttr(formatForXML(((StringTag) t).toString()));
    } else if (t instanceof SourcePositionTag) {
        SourcePositionTag pt = (SourcePositionTag) t;
        printSourcePositionAttr(pt.getStartOffset(), pt.getEndOffset());
    } else if (t instanceof PositionTag) {
        PositionTag pt = (PositionTag) t;
        printJimplePositionAttr(pt.getStartOffset(), pt.getEndOffset());
    } else if (t instanceof ColorTag) {
        ColorTag ct = (ColorTag) t;
        printColorAttr(ct.getRed(), ct.getGreen(), ct.getBlue(), ct.isForeground());
    } else {
        printTextAttr(t.toString());
    }
}
Also used : StringTag(soot.tagkit.StringTag) SourcePositionTag(soot.tagkit.SourcePositionTag) JimpleLineNumberTag(soot.tagkit.JimpleLineNumberTag) LineNumberTag(soot.tagkit.LineNumberTag) JimpleLineNumberTag(soot.tagkit.JimpleLineNumberTag) LinkTag(soot.tagkit.LinkTag) ColorTag(soot.tagkit.ColorTag) SourcePositionTag(soot.tagkit.SourcePositionTag) PositionTag(soot.tagkit.PositionTag) Host(soot.tagkit.Host)

Example 4 with StringTag

use of soot.tagkit.StringTag in project soot by Sable.

the class NullTransformer method internalTransform.

protected void internalTransform(Body b, String phaseName, java.util.Map options) {
    NullnessAnalysis na = new NullnessAnalysis(new BriefUnitGraph(b));
    java.util.Iterator uIt = b.getUnits().iterator();
    while (uIt.hasNext()) {
        Unit u = (Unit) uIt.next();
        StringBuffer n = new StringBuffer();
        u.addTag(new StringTag("IN: " + na.getFlowBefore(u).toString()));
        if (u.fallsThrough()) {
            ArraySparseSet s = (ArraySparseSet) na.getFallFlowAfter(u);
            u.addTag(new StringTag("FALL: " + s.toString()));
        }
        if (u.branches()) {
            ArraySparseSet t = (ArraySparseSet) na.getBranchFlowAfter(u).get(0);
            u.addTag(new StringTag("BRANCH: " + t.toString()));
        }
    }
}
Also used : StringTag(soot.tagkit.StringTag) ArraySparseSet(soot.toolkits.scalar.ArraySparseSet) BriefUnitGraph(soot.toolkits.graph.BriefUnitGraph) Unit(soot.Unit)

Example 5 with StringTag

use of soot.tagkit.StringTag in project soot by Sable.

the class PAG method addNodeTag.

private void addNodeTag(Node node, SootMethod m) {
    if (nodeToTag != null) {
        Tag tag;
        if (m == null) {
            tag = new StringTag(node.toString());
        } else {
            tag = new LinkTag(node.toString(), m, m.getDeclaringClass().getName());
        }
        nodeToTag.put(node, tag);
    }
}
Also used : StringTag(soot.tagkit.StringTag) LinkTag(soot.tagkit.LinkTag) Tag(soot.tagkit.Tag) StringTag(soot.tagkit.StringTag) LinkTag(soot.tagkit.LinkTag)

Aggregations

StringTag (soot.tagkit.StringTag)5 LinkTag (soot.tagkit.LinkTag)3 Unit (soot.Unit)2 ColorTag (soot.tagkit.ColorTag)2 Host (soot.tagkit.Host)2 JimpleLineNumberTag (soot.tagkit.JimpleLineNumberTag)2 LineNumberTag (soot.tagkit.LineNumberTag)2 PositionTag (soot.tagkit.PositionTag)2 Tag (soot.tagkit.Tag)2 Local (soot.Local)1 SootClass (soot.SootClass)1 SootMethod (soot.SootMethod)1 Value (soot.Value)1 DefinitionStmt (soot.jimple.DefinitionStmt)1 FieldRef (soot.jimple.FieldRef)1 Stmt (soot.jimple.Stmt)1 AllocNode (soot.jimple.spark.pag.AllocNode)1 Node (soot.jimple.spark.pag.Node)1 VarNode (soot.jimple.spark.pag.VarNode)1 P2SetVisitor (soot.jimple.spark.sets.P2SetVisitor)1