当前位置: 首页>>代码示例>>Java>>正文


Java IExplodedBasicBlock类代码示例

本文整理汇总了Java中com.ibm.wala.ssa.analysis.IExplodedBasicBlock的典型用法代码示例。如果您正苦于以下问题:Java IExplodedBasicBlock类的具体用法?Java IExplodedBasicBlock怎么用?Java IExplodedBasicBlock使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IExplodedBasicBlock类属于com.ibm.wala.ssa.analysis包,在下文中一共展示了IExplodedBasicBlock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLineNumbers

import com.ibm.wala.ssa.analysis.IExplodedBasicBlock; //导入依赖的package包/类
/**
     * Get source code line number for each instruction
     * @param sgNodes
     * @param print
     * @return
     */
    public static HashMap<SSAInstructionKey, Integer> getLineNumbers(HashMap<Integer,BasicBlockInContext<IExplodedBasicBlock>> sgNodes) {
        log.debug("** get source code line number for each instruction");
        HashMap<SSAInstructionKey, Integer> map = new HashMap<SSAInstructionKey, Integer>();
        for(BasicBlockInContext<IExplodedBasicBlock> bbic : sgNodes.values()) {
            SSAInstruction inst = bbic.getLastInstruction();
            if(inst == null) {
                continue;
            }
//            ConcreteJavaMethod method = (ConcreteJavaMethod) bbic.getMethod();
            IMethod method =  bbic.getMethod();
            int lineNumber = method.getLineNumber(bbic.getLastInstructionIndex());
            map.put(new SSAInstructionKey(inst), lineNumber);
            log.debug(lineNumber + ". " + inst);
        }
        return map;
    }
 
开发者ID:logicalhacking,项目名称:DASCA,代码行数:23,代码来源:AnalysisUtil.java

示例2: getNodeTransferFunction

import com.ibm.wala.ssa.analysis.IExplodedBasicBlock; //导入依赖的package包/类
@Override
public UnaryOperator<BitVectorVariable> getNodeTransferFunction(BasicBlockInContext<IExplodedBasicBlock> node) {
  IExplodedBasicBlock ebb = node.getDelegate();
  SSAInstruction instruction = ebb.getInstruction();
  int instructionIndex = ebb.getFirstInstructionIndex();
  CGNode cgNode = node.getNode();
  if (instruction instanceof SSAPutInstruction && ((SSAPutInstruction) instruction).isStatic()) {
    // kill all defs of the same static field, and gen this instruction
    final SSAPutInstruction putInstr = (SSAPutInstruction) instruction;
    final IField field = cha.resolveField(putInstr.getDeclaredField());
    assert field != null;
    BitVector kill = staticField2DefStatements.get(field);
    BitVector gen = new BitVector();
    gen.set(putInstrNumbering.getMappedIndex(Pair.make(cgNode, instructionIndex)));
    return new BitVectorKillGen(kill, gen);
  } else {
    // identity function for non-putstatic instructions
    return BitVectorIdentity.instance();
  }
}
 
开发者ID:wala,项目名称:WALA-start,代码行数:21,代码来源:ContextInsensitiveReachingDefs.java

示例3: analyze

import com.ibm.wala.ssa.analysis.IExplodedBasicBlock; //导入依赖的package包/类
/**
 * run the analysis
 * 
 * @return the solver used for the analysis, which contains the analysis result
 */
public BitVectorSolver<BasicBlockInContext<IExplodedBasicBlock>> analyze() {
  // the framework describes the dataflow problem, in particular the underlying graph and the transfer functions
  BitVectorFramework<BasicBlockInContext<IExplodedBasicBlock>, Pair<CGNode, Integer>> framework = new BitVectorFramework<BasicBlockInContext<IExplodedBasicBlock>, Pair<CGNode, Integer>>(
      icfg, new TransferFunctions(), putInstrNumbering);
  BitVectorSolver<BasicBlockInContext<IExplodedBasicBlock>> solver = new BitVectorSolver<BasicBlockInContext<IExplodedBasicBlock>>(
      framework);
  try {
    solver.solve(null);
  } catch (CancelException e) {
    // this shouldn't happen
    assert false;
  }
  if (VERBOSE) {
    for (BasicBlockInContext<IExplodedBasicBlock> ebb : icfg) {
      System.out.println(ebb);
      System.out.println(ebb.getDelegate().getInstruction());
      System.out.println(solver.getIn(ebb));
      System.out.println(solver.getOut(ebb));
    }
  }
  return solver;
}
 
开发者ID:wala,项目名称:WALA-start,代码行数:28,代码来源:ContextInsensitiveReachingDefs.java

示例4: collectInitialSeeds

import com.ibm.wala.ssa.analysis.IExplodedBasicBlock; //导入依赖的package包/类
/**
 * collect the putstatic instructions in the call graph as {@link PathEdge} seeds for the analysis
 */
private Collection<PathEdge<BasicBlockInContext<IExplodedBasicBlock>>> collectInitialSeeds() {
  Collection<PathEdge<BasicBlockInContext<IExplodedBasicBlock>>> result = HashSetFactory.make();
  for (BasicBlockInContext<IExplodedBasicBlock> bb : supergraph) {
    IExplodedBasicBlock ebb = bb.getDelegate();
    SSAInstruction instruction = ebb.getInstruction();
    if (instruction instanceof SSAPutInstruction) {
      SSAPutInstruction putInstr = (SSAPutInstruction) instruction;
      if (putInstr.isStatic()) {
        final CGNode cgNode = bb.getNode();
        Pair<CGNode, Integer> fact = Pair.make(cgNode, ebb.getFirstInstructionIndex());
        int factNum = domain.add(fact);
        BasicBlockInContext<IExplodedBasicBlock> fakeEntry = getFakeEntry(cgNode);
        // note that the fact number used for the source of this path edge doesn't really matter
        result.add(PathEdge.createPathEdge(fakeEntry, factNum, bb, factNum));

      }
    }
  }
  return result;
}
 
开发者ID:wala,项目名称:WALA-start,代码行数:24,代码来源:ContextSensitiveReachingDefs.java

示例5: getNodeTransferFunction

import com.ibm.wala.ssa.analysis.IExplodedBasicBlock; //导入依赖的package包/类
@Override
public UnaryOperator<BitVectorVariable> getNodeTransferFunction(IExplodedBasicBlock node) {
  SSAInstruction instruction = node.getInstruction();
  int instructionIndex = node.getFirstInstructionIndex();
  if (instruction instanceof SSAPutInstruction && ((SSAPutInstruction) instruction).isStatic()) {
    // kill all defs of the same static field, and gen this instruction
    final SSAPutInstruction putInstr = (SSAPutInstruction) instruction;
    final IField field = cha.resolveField(putInstr.getDeclaredField());
    assert field != null;
    BitVector kill = staticField2DefStatements.get(field);
    BitVector gen = new BitVector();
    gen.set(putInstrNumbering.getMappedIndex(instructionIndex));
    return new BitVectorKillGen(kill, gen);
  } else {
    // identity function for non-putstatic instructions
    return BitVectorIdentity.instance();
  }
}
 
开发者ID:wala,项目名称:WALA-start,代码行数:19,代码来源:IntraprocReachingDefs.java

示例6: analyze

import com.ibm.wala.ssa.analysis.IExplodedBasicBlock; //导入依赖的package包/类
/**
 * run the analysis
 * 
 * @return the solver used for the analysis, which contains the analysis result
 */
public BitVectorSolver<IExplodedBasicBlock> analyze() {
  // the framework describes the dataflow problem, in particular the underlying graph and the transfer functions
  BitVectorFramework<IExplodedBasicBlock, Integer> framework = new BitVectorFramework<IExplodedBasicBlock, Integer>(ecfg,
      new TransferFunctions(), putInstrNumbering);
  BitVectorSolver<IExplodedBasicBlock> solver = new BitVectorSolver<IExplodedBasicBlock>(framework);
  try {
    solver.solve(null);
  } catch (CancelException e) {
    // this shouldn't happen
    assert false;
  }
  if (VERBOSE) {
    for (IExplodedBasicBlock ebb : ecfg) {
      System.out.println(ebb);
      System.out.println(ebb.getInstruction());
      System.out.println(solver.getIn(ebb));
      System.out.println(solver.getOut(ebb));
    }
  }
  return solver;
}
 
开发者ID:wala,项目名称:WALA-start,代码行数:27,代码来源:IntraprocReachingDefs.java

示例7: analyze

import com.ibm.wala.ssa.analysis.IExplodedBasicBlock; //导入依赖的package包/类
/**
 * run the analysis
 *
 * @return the solver used for the analysis, which contains the analysis result
 */
public BitVectorSolver<BasicBlockInContext<IExplodedBasicBlock>> analyze() {
    // the framework describes the dataflow problem, in particular the underlying graph and the transfer functions
    BitVectorFramework<BasicBlockInContext<IExplodedBasicBlock>, JSTaintNode> framework = new BitVectorFramework<>(
            icfg, new TransferFunctions(), this.taintNodeNumbering);
    BitVectorSolver<BasicBlockInContext<IExplodedBasicBlock>> solver = new BitVectorSolver<>(framework);
    try {
        solver.solve(null);
    } catch (CancelException e) {
        // this shouldn't happen
        assert false;
    }

    if (VERBOSE) {
        this.dumpResult(System.out);
    }
    return solver;
}
 
开发者ID:ylimit,项目名称:HybridFlow,代码行数:23,代码来源:JSTaintAnalysis.java

示例8: getDefs

import com.ibm.wala.ssa.analysis.IExplodedBasicBlock; //导入依赖的package包/类
/**
 * Get corresponding instruction for the definition of each SSA value
 * @param sgNodes
 * @return
 */
public static HashMap<Integer, SSAInstruction> getDefs(HashMap<Integer,BasicBlockInContext<IExplodedBasicBlock>> sgNodes) {
    log.debug("** get definition instruction for each SSA value");
    HashMap<Integer, SSAInstruction> map = new HashMap<Integer, SSAInstruction>();
    for(BasicBlockInContext<IExplodedBasicBlock> bbic : sgNodes.values()) {
        SymbolTable symbolTable = bbic.getNode().getIR().getSymbolTable();
        DefUse du = bbic.getNode().getDU();

        for (int i = 0; i <= symbolTable.getMaxValueNumber(); i++) {
            log.debug(i + " [" + symbolTable.getValueString(i) + "] " + du.getDef(i));
            map.put(i, du.getDef(i));
        }
        break; // there are the same definitions in each basic block, iff there is only one method FIXME: read different scopes, if multiple methods are required
    }
    return map;
}
 
开发者ID:logicalhacking,项目名称:DASCA,代码行数:21,代码来源:AnalysisUtil.java

示例9: getEdgeTransferFunction

import com.ibm.wala.ssa.analysis.IExplodedBasicBlock; //导入依赖的package包/类
/**
 * for direct call-to-return edges at a call site, the edge transfer function will kill all facts, since we only want to
 * consider facts that arise from going through the callee
 */
@Override
public UnaryOperator<BitVectorVariable> getEdgeTransferFunction(BasicBlockInContext<IExplodedBasicBlock> src,
    BasicBlockInContext<IExplodedBasicBlock> dst) {
  if (isCallToReturnEdge(src, dst)) {
    return BitVectorKillAll.instance();
  } else {
    return BitVectorIdentity.instance();
  }
}
 
开发者ID:wala,项目名称:WALA-start,代码行数:14,代码来源:ContextInsensitiveReachingDefs.java

示例10: getCallNoneToReturnFlowFunction

import com.ibm.wala.ssa.analysis.IExplodedBasicBlock; //导入依赖的package包/类
/**
 * flow function from call node to return node when there are no targets for the call site; not a case we are expecting
 */
@Override
public IUnaryFlowFunction getCallNoneToReturnFlowFunction(BasicBlockInContext<IExplodedBasicBlock> src,
    BasicBlockInContext<IExplodedBasicBlock> dest) {
  // if we're missing callees, just keep what information we have
  return IdentityFlowFunction.identity();
}
 
开发者ID:wala,项目名称:WALA-start,代码行数:10,代码来源:ContextSensitiveReachingDefs.java

示例11: analyze

import com.ibm.wala.ssa.analysis.IExplodedBasicBlock; //导入依赖的package包/类
/**
 * perform the tabulation analysis and return the {@link TabulationResult}
 */
public TabulationResult<BasicBlockInContext<IExplodedBasicBlock>, CGNode, Pair<CGNode, Integer>> analyze() {
  PartiallyBalancedTabulationSolver<BasicBlockInContext<IExplodedBasicBlock>, CGNode, Pair<CGNode, Integer>> solver = PartiallyBalancedTabulationSolver
      .createPartiallyBalancedTabulationSolver(new ReachingDefsProblem(), null);
  TabulationResult<BasicBlockInContext<IExplodedBasicBlock>, CGNode, Pair<CGNode, Integer>> result = null;
  try {
    result = solver.solve();
  } catch (CancelException e) {
    // this shouldn't happen 
    assert false;
  }
  return result;

}
 
开发者ID:wala,项目名称:WALA-start,代码行数:17,代码来源:ContextSensitiveReachingDefs.java

示例12: getSQLExecutes

import com.ibm.wala.ssa.analysis.IExplodedBasicBlock; //导入依赖的package包/类
/**
 * Get the corresponding instruction for each SQL execution (java.sql)
 * @return
 */
public static ArrayList<SSAInstruction> getSQLExecutes(HashMap<Integer, BasicBlockInContext<IExplodedBasicBlock>> sgNodes) {
    log.debug("** get SQL execution instructions");
    ArrayList<SSAInstruction> list = new ArrayList<SSAInstruction>();
    for(BasicBlockInContext<IExplodedBasicBlock> bbic : sgNodes.values()) {
        SSAInstruction inst = bbic.getLastInstruction();
        if(inst != null && inst instanceof AstJavaInvokeInstruction && inst.toString().contains("java/sql") && inst.toString().contains("execute")) {
            log.debug("SQL execution instruction: " + inst.toString());
            list.add(inst);
        }
    }
    return list;
}
 
开发者ID:logicalhacking,项目名称:DASCA,代码行数:17,代码来源:AnalysisUtil.java

示例13: getConditions

import com.ibm.wala.ssa.analysis.IExplodedBasicBlock; //导入依赖的package包/类
/**
 * Get the corresponding instruction for each conditional branch
 * @return
 */
public static ArrayList<SSAInstruction> getConditions(HashMap<Integer, BasicBlockInContext<IExplodedBasicBlock>> sgNodes) {
    log.debug("** get conditional branch instructions");
    ArrayList<SSAInstruction> list = new ArrayList<SSAInstruction>();
    for(BasicBlockInContext<IExplodedBasicBlock> bbic : sgNodes.values()) {
        SSAInstruction inst = bbic.getLastInstruction();
        if(inst != null && inst instanceof SSAConditionalBranchInstruction) {
            log.debug("conditional branch instruction: " + inst);
            list.add(inst);
        }
    }
    return list;
}
 
开发者ID:logicalhacking,项目名称:DASCA,代码行数:17,代码来源:AnalysisUtil.java

示例14: printBlock

import com.ibm.wala.ssa.analysis.IExplodedBasicBlock; //导入依赖的package包/类
@SuppressWarnings("unused")
private static void printBlock(
    Iterator<BasicBlockInContext<IExplodedBasicBlock>> it) {

    while (it.hasNext()) {
        BasicBlockInContext<IExplodedBasicBlock> explBB = it.next();
        System.out.println(explBB);

        for (SSAInstruction ssa : explBB) {
            System.out.println(ssa);
        }
    }

}
 
开发者ID:logicalhacking,项目名称:DASCA,代码行数:15,代码来源:Main.java

示例15: main

import com.ibm.wala.ssa.analysis.IExplodedBasicBlock; //导入依赖的package包/类
/**
	   * Usage: CSReachingDefsDriver -scopeFile file_path -mainClass class_name
	   * 
	   * Uses main() method of class_name as entrypoint.
	   * 
	   * @throws IOException
	   * @throws ClassHierarchyException
	   * @throws CallGraphBuilderCancelException
	   * @throws IllegalArgumentException
	   */
	  public static void main(String[] args) throws IOException, ClassHierarchyException, IllegalArgumentException, CallGraphBuilderCancelException {
	    long start = System.currentTimeMillis();		
	    Properties p = CommandLine.parse(args);
	    String scopeFile = p.getProperty("scopeFile");
	    if (scopeFile == null) {
	    	throw new IllegalArgumentException("must specify scope file");
	    }
	    String mainClass = p.getProperty("mainClass");
	    if (mainClass == null) {
	      throw new IllegalArgumentException("must specify main class");
	    }
	    AnalysisScope scope = AnalysisScopeReader.readJavaScope(scopeFile, null, CSReachingDefsDriver.class.getClassLoader());
	    ExampleUtil.addDefaultExclusions(scope);
	    IClassHierarchy cha = ClassHierarchyFactory.make(scope);
	    System.out.println(cha.getNumberOfClasses() + " classes");
	    System.out.println(Warnings.asString());
	    Warnings.clear();
	    AnalysisOptions options = new AnalysisOptions();
	    Iterable<Entrypoint> entrypoints = Util.makeMainEntrypoints(scope, cha, mainClass);
	    options.setEntrypoints(entrypoints);
	    // you can dial down reflection handling if you like
	    options.setReflectionOptions(ReflectionOptions.NONE);
	    AnalysisCache cache = new AnalysisCacheImpl();
	    // other builders can be constructed with different Util methods
	    CallGraphBuilder builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope);
//	    CallGraphBuilder builder = Util.makeNCFABuilder(2, options, cache, cha, scope);
//	    CallGraphBuilder builder = Util.makeVanillaNCFABuilder(2, options, cache, cha, scope);
	    System.out.println("building call graph...");
	    CallGraph cg = builder.makeCallGraph(options, null);
//	    System.out.println(cg);
	    long end = System.currentTimeMillis();
	    System.out.println("done");
	    System.out.println("took " + (end-start) + "ms");
	    System.out.println(CallGraphStats.getStats(cg));
	    
	    ContextSensitiveReachingDefs reachingDefs = new ContextSensitiveReachingDefs(cg, cache);
	    TabulationResult<BasicBlockInContext<IExplodedBasicBlock>, CGNode, Pair<CGNode, Integer>> result = reachingDefs.analyze();
	    ISupergraph<BasicBlockInContext<IExplodedBasicBlock>, CGNode> supergraph = reachingDefs.getSupergraph();

	    // TODO print out some analysis results
	}
 
开发者ID:wala,项目名称:WALA-start,代码行数:52,代码来源:CSReachingDefsDriver.java


注:本文中的com.ibm.wala.ssa.analysis.IExplodedBasicBlock类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。