Package soot

Examples of soot.Value


                if( !m.isConcrete() ) continue;
                if( !m.hasActiveBody() ) continue;
                for( Iterator sIt = m.getActiveBody().getUnits().iterator(); sIt.hasNext(); ) {
                    final Stmt s = (Stmt) sIt.next();
                    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() );
View Full Code Here


                        addEdge( source, s, clinit, Kind.CLINIT );
                    }
                }
            }
            if( s instanceof AssignStmt ) {
                Value rhs = ((AssignStmt)s).getRightOp();
                if( rhs instanceof NewExpr ) {
                    NewExpr r = (NewExpr) rhs;
                    SootClass cl = r.getBaseType().getSootClass();
                    for (SootMethod clinit : EntryPoints.v().clinitsOf(cl)) {
                        addEdge( source, s, clinit, Kind.CLINIT );
                    }
                } else if( rhs instanceof NewArrayExpr || rhs instanceof NewMultiArrayExpr ) {
                    Type t = rhs.getType();
                    if( t instanceof ArrayType ) t = ((ArrayType)t).baseType;
                    if( t instanceof RefType ) {
                        SootClass cl = ((RefType) t).getSootClass();
                        for (SootMethod clinit : EntryPoints.v().clinitsOf(cl)) {
                            addEdge( source, s, clinit, Kind.CLINIT );
View Full Code Here

        //add all field references that are in use boxes
        for (Unit unit : this.graph) {
      Stmt s = (Stmt) unit;
      List<ValueBox> useBoxes = s.getUseBoxes();
      for (ValueBox useBox : useBoxes) {
        Value val = useBox.getValue();
        if(val instanceof FieldRef) {
          FieldRef fieldRef = (FieldRef) val;
          if(fieldRef.getType() instanceof RefLikeType)
            usedFieldRefs.add(new EquivalentValue(fieldRef));           
        }
      }
    }
       
        //prune all fields that are written to
        if(!usedFieldRefs.isEmpty()) {
     
        if(!Scene.v().hasCallGraph()) {
          throw new IllegalStateException("No call graph found!");
        }
             
      CallGraph cg = Scene.v().getCallGraph();
      ReachableMethods reachableMethods = new ReachableMethods(cg,Collections.<MethodOrMethodContext>singletonList(container));
      reachableMethods.update();
      for (Iterator<MethodOrMethodContext> iterator = reachableMethods.listener(); iterator.hasNext();) {
        SootMethod m = (SootMethod) iterator.next();
        if(m.hasActiveBody() &&
        //exclude static initializer of same class (assume that it has already been executed)
         !(m.getName().equals(SootMethod.staticInitializerName) && m.getDeclaringClass().equals(container.getDeclaringClass()))) {       
          for (Unit u : m.getActiveBody().getUnits()) {
            List<ValueBox> defBoxes = u.getDefBoxes();
            for (ValueBox defBox : defBoxes) {
              Value value = defBox.getValue();
              if(value instanceof FieldRef) {
                usedFieldRefs.remove(new EquivalentValue(value));
              }
            }
          }
View Full Code Here

        out.putAll(in);

        if (s instanceof DefinitionStmt) {
            DefinitionStmt ds = (DefinitionStmt) s;
            Value lhs = ds.getLeftOp();
            Value rhs = ds.getRightOp();

            if (rhs instanceof CastExpr) {
              //un-box casted value
        CastExpr castExpr = (CastExpr) rhs;
              rhs = castExpr.getOp();
View Full Code Here

    public void classForName(SootMethod source, Stmt s) {
          List<Local> stringConstants = (List<Local>) methodToStringConstants.get(source);
          if( stringConstants == null )
              methodToStringConstants.put(source, stringConstants = new ArrayList<Local>());
      InvokeExpr ie = s.getInvokeExpr();
          Value className = ie.getArg(0);
          if( className instanceof StringConstant ) {
              String cls = ((StringConstant) className ).value;
              constantForName( cls, source, s );
          } else {
              Local constant = (Local) className;
View Full Code Here

         */
        StronglyConnectedComponentsFast<Unit> sccAnalysis = new StronglyConnectedComponentsFast<Unit>(g);
        for (List<Unit> scc : sccAnalysis.getTrueComponents()) {
      for (Unit unit : scc) {
        for (ValueBox vb : unit.getDefBoxes()) {
          Value defValue = vb.getValue();
          if(defValue instanceof Local) {
            Local defLocal = (Local) defValue;
            if(defLocal.getType() instanceof RefLikeType) {
              Object instanceKey = getFlowBefore(unit).get(defLocal);
              //if key is not already UNKNOWN
View Full Code Here

          continue;
         
        // add a node for each lock in this lockset
        for( EquivalentValue lockEqVal : tn1.lockset )
        {
          Value lock = lockEqVal.getValue();
       
          if( !lockOrder.containsNode(lockToLockNum.get(lock)) )
            lockOrder.addNode(lockToLockNum.get(lock));
        }
         
        // Get list of tn1's target methods
        if(tn1.transitiveTargets == null)
        {
            tn1.transitiveTargets = new HashSet<MethodOrMethodContext>();
            for(Unit tn1Invoke : tn1.invokes)
            {
              Iterator<MethodOrMethodContext> targetIt = tt.iterator(tn1Invoke);
              while(targetIt.hasNext())
                tn1.transitiveTargets.add(targetIt.next());
            }
          }
       
        // compare to each other tn
        Iterator<CriticalSection> deadlockIt2 = criticalSections.iterator();
        while(deadlockIt2.hasNext() && !foundDeadlock)
        {
          CriticalSection tn2 = deadlockIt2.next();
         
          // skip if unlocked
          if( tn2.group == null )
            continue;
         
          // add a node for each lock in this lockset
          for( EquivalentValue lockEqVal : tn2.lockset )
          {
            Value lock = lockEqVal.getValue();
             
              if( !lockOrder.containsNode(lockToLockNum.get(lock)) )
                lockOrder.addNode(lockToLockNum.get(lock));
            }
                           
            if( tn1.transitiveTargets.contains(tn2.method) && !foundDeadlock )
            {
              // This implies the partial ordering (locks in tn1) before (locks in tn2)
              if(true) //optionPrintDebug)
              {
                G.v().out.println("[DeadlockDetector] locks in " + (tn1.name) + " before locks in " + (tn2.name) + ": " +
                  "outer: " + tn1.name + " inner: " + tn2.name);
              }
             
              // Check if tn2locks before tn1locks is in our lock order
            for( EquivalentValue lock2EqVal : tn2.lockset )
            {
              Value lock2 = lock2EqVal.getValue();
              Integer lock2Num = lockToLockNum.get(lock2);

                List afterTn2 = new ArrayList();
              afterTn2.addAll( lockOrder.getSuccsOf(lock2Num) ); // filter here!
              ListIterator lit = afterTn2.listIterator();
              while(lit.hasNext())
              {
                Integer to = (Integer) lit.next(); // node the edges go to
                List labels = lockOrder.getLabelsForEdges(lock2Num, to);
                boolean keep = false;
                if(labels != null) // this shouldn't really happen... is something wrong with the edge-labelled graph?
                {
                  for(Object l : labels)
                  {
                    CriticalSection labelTn = (CriticalSection) l;
                   
                    // Check if labelTn and tn1 share a static lock
                    boolean tnsShareAStaticLock = false;
                    for( EquivalentValue tn1LockEqVal : tn1.lockset )
                    {
                      Integer tn1LockNum = lockToLockNum.get(tn1LockEqVal.getValue());
                      if(tn1LockNum < 0)
                      {
                        // this is a static lock... see if some lock in labelTn has the same #
                        for( EquivalentValue labelTnLockEqVal : labelTn.lockset )
                        {
                          if(lockToLockNum.get(labelTnLockEqVal.getValue()) == tn1LockNum)
                          {
                            tnsShareAStaticLock = true;
                          }
                        }
                      }
                    }
                   
                    if(!tnsShareAStaticLock) // !hasStaticLockInCommon(tn1, labelTn))
                    {
                      keep = true;
                      break;
                    }
                  }
                }
                if(!keep)
                  lit.remove();
              }

/*                  for( int i = 0; i < afterTn2.size(); i++ )
                {
                  List succs = lockOrder.getSuccsOf(afterTn2.get(i)); // but not here
                  for( Object o : succs )
                  {
                    if(!afterTn2.contains(o))
                      afterTn2.add(o);
                  }
                }
*/
               
              for( EquivalentValue lock1EqVal : tn1.lockset )
              {
                Value lock1 = lock1EqVal.getValue();
                Integer lock1Num = lockToLockNum.get(lock1);
               
                  if( ( lock1Num != lock2Num ||
                      lock1Num > 0 ) &&
                      afterTn2.contains(lock1Num) )
                  {
                    if(!optionRepairDeadlock)
                    {
                      G.v().out.println("[DeadlockDetector] DEADLOCK HAS BEEN DETECTED: not correcting");
                    foundDeadlock = true;
                    }
                    else
                    {
                      G.v().out.println("[DeadlockDetector] DEADLOCK HAS BEEN DETECTED while inspecting " + lock1Num + " ("+lock1+") and " + lock2Num + " ("+lock2+") ");
                 
                    // Create a deadlock avoidance edge
                    DeadlockAvoidanceEdge dae = new DeadlockAvoidanceEdge(tn1.method.getDeclaringClass());
                    EquivalentValue daeEqVal = new EquivalentValue(dae);
                   
                    // Register it as a static lock
                    Integer daeNum = new Integer(-lockPTSets.size()); // negative indicates a static lock
                    permanentOrder.addNode(daeNum);
                    lockToLockNum.put(dae, daeNum);
                    PointsToSetInternal dummyLockPT = new HashPointsToSet(lock1.getType(), (PAG) Scene.v().getPointsToAnalysis());
                    lockPTSets.add(dummyLockPT);

                    // Add it to the locksets of tn1 and whoever says l2 before l1
                    for(EquivalentValue lockEqVal : tn1.lockset)
                    {
View Full Code Here

     
        // Order locks in tn's lockset according to the visible order (insertion sort)
        List<EquivalentValue> newLockset = new ArrayList();
        for(EquivalentValue lockEqVal : tn.lockset)
        {
          Value lockToInsert = lockEqVal.getValue();
          Integer lockNumToInsert = lockToLockNum.get(lockToInsert);
          int i = 0;
          while( i < newLockset.size() )
          {
            EquivalentValue existingLockEqVal = newLockset.get(i);
            Value existingLock = existingLockEqVal.getValue();
            Integer existingLockNum = lockToLockNum.get(existingLock);
            if( visibleOrder.containsEdge(lockNumToInsert, existingLockNum) ||
              lockNumToInsert < existingLockNum )
//              !visibleOrder.containsEdge(existingLockNum, lockNumToInsert) ) // if(! existing before toinsert )
              break;
View Full Code Here

                if (Modifier.isStatic(field.getModifiers())) {
                    continue;
                }

                boolean finalize = true;
                Value fieldValue = null;

                for (Iterator methods = entityClass.getMethods().iterator(); (methods
                        .hasNext() && finalize);) {
                    SootMethod method = (SootMethod) methods.next();
View Full Code Here

                    if (!stmt.containsInvokeExpr()) {
                        continue;
                    }

                    ValueBox box = stmt.getInvokeExprBox();
                    Value value = box.getValue();

                    if (value instanceof InstanceInvokeExpr) {
                        InstanceInvokeExpr r = (InstanceInvokeExpr) value;

                        if (_debug) {
View Full Code Here

TOP

Related Classes of soot.Value

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.