protected void warnAboutImpreciseCallGraph(CGNode caller, CallSiteReference site) { IntIterator indices = caller.getIR().getCallInstructionIndices(site).intIterator(); IMethod callerMethod = caller.getMethod(); Position pos = null; if(indices.hasNext() && callerMethod instanceof AstMethod) { pos = ((AstMethod)callerMethod).getSourcePosition(indices.next()); } System.err.println("Detected improbable call to Function.prototype.call " + (pos == null ? "in function " + caller : "at position " + pos) + "; this is likely caused by call graph imprecision."); }
protected void warnAboutImpreciseCallGraph(CGNode caller, CallSiteReference site) { IntIterator indices = caller.getIR().getCallInstructionIndices(site).intIterator(); IMethod callerMethod = caller.getMethod(); Position pos = null; if(indices.hasNext() && callerMethod instanceof AstMethod) { pos = ((AstMethod)callerMethod).getSourcePosition(indices.next()); } System.err.println("Detected improbable call to Function.prototype.call " + (pos == null ? "in function " + caller : "at position " + pos) + "; this is likely caused by call graph imprecision."); }
/** * Returns all exceptions for the given call site in the given call graph * node, which will be caught. * * @return caught exceptions */ public Set<TypeReference> getCaughtExceptions(CallSiteReference callsite) { Set<TypeReference> result = null; if (dummy) { result = Collections.emptySet(); } else { IntSet iindices = ir.getCallInstructionIndices(callsite); IntIterator it = iindices.intIterator(); while (it.hasNext()) { int iindex = it.next(); SSAInstruction instruction = ir.getInstructions()[iindex]; if (!((instruction instanceof SSAInvokeInstruction))) { throw new IllegalArgumentException("The given callsite dose not correspond to an invoke instruction." + instruction); } ISSABasicBlock block = ir.getBasicBlockForInstruction(instruction); if (result == null) { result = new LinkedHashSet<>(collectCaughtExceptions(block)); } else { result.retainAll(collectCaughtExceptions(block)); } } } return result; }
/** * Returns all exceptions for the given call site in the given call graph * node, which will be caught. * * @return caught exceptions */ public Set<TypeReference> getCaughtExceptions(CallSiteReference callsite) { Set<TypeReference> result = null; if (dummy) { result = Collections.emptySet(); } else { IntSet iindices = ir.getCallInstructionIndices(callsite); IntIterator it = iindices.intIterator(); while (it.hasNext()) { int iindex = it.next(); SSAInstruction instruction = ir.getInstructions()[iindex]; if (!((instruction instanceof SSAInvokeInstruction))) { throw new IllegalArgumentException("The given callsite dose not correspond to an invoke instruction." + instruction); } ISSABasicBlock block = ir.getBasicBlockForInstruction(instruction); if (result == null) { result = new LinkedHashSet<>(collectCaughtExceptions(block)); } else { result.retainAll(collectCaughtExceptions(block)); } } } return result; }
SSAInstruction call = caller.getIR().getInstructions()[caller.getIR().getCallInstructionIndices(site).intIterator().next()]; if (call.getNumberOfUses() > 1) { LocalPointerKey fileNameV = new LocalPointerKey(caller, call.getUse(1));
SSAInstruction call = caller.getIR().getInstructions()[caller.getIR().getCallInstructionIndices(site).intIterator().next()]; if (call.getNumberOfUses() > 1) { LocalPointerKey fileNameV = new LocalPointerKey(caller, call.getUse(1));
IMethod method = caller.getMethod(); if(method instanceof AstMethod) { int line = ((AstMethod)method).getLineNumber(caller.getIR().getCallInstructionIndices(site).intIterator().next()); System.err.println("creating " + ref.getName() + " at line " + line + " in " + caller); } else {
IMethod method = caller.getMethod(); if(method instanceof AstMethod) { int line = ((AstMethod)method).getLineNumber(caller.getIR().getCallInstructionIndices(site).intIterator().next()); System.err.println("creating " + ref.getName() + " at line " + line + " in " + caller); } else {
private Collection<Statement> findTargetStatement(CallGraph CG) { final Collection<Statement> ss = HashSetFactory.make(); for(CGNode n : getNodes(CG, "suffix:_slice_target_fn")) { for(CGNode caller : Iterator2Iterable.make(CG.getPredNodes(n))) { for(CallSiteReference site : Iterator2Iterable.make(CG.getPossibleSites(caller, n))) { caller.getIR().getCallInstructionIndices(site).foreach(x -> ss.add(new NormalStatement(caller, x))); } } } return ss; } }
public static Statement findCallTo(CGNode n, String methodName) { IR ir = n.getIR(); for (SSAInstruction s : Iterator2Iterable.make(ir.iterateAllInstructions())) { if (s instanceof SSAInvokeInstruction) { SSAInvokeInstruction call = (SSAInvokeInstruction) s; if (call.getCallSite().getDeclaredTarget().getName().toString().equals(methodName)) { IntSet indices = ir.getCallInstructionIndices(((SSAInvokeInstruction) s).getCallSite()); Assertions.productionAssertion(indices.size() == 1, "expected 1 but got " + indices.size()); return new NormalStatement(n, indices.intIterator().next()); } } } Assertions.UNREACHABLE("failed to find call to " + methodName + " in " + n); return null; }
public static PointerKey getParam(CGNode n, String methodName, HeapModel heapModel) { IR ir = n.getIR(); for (SSAInstruction s : Iterator2Iterable.make(ir.iterateAllInstructions())) { if (s instanceof SSAInvokeInstruction) { SSAInvokeInstruction call = (SSAInvokeInstruction) s; if (call.getCallSite().getDeclaredTarget().getName().toString().equals(methodName)) { IntSet indices = ir.getCallInstructionIndices(((SSAInvokeInstruction) s).getCallSite()); Assertions.productionAssertion(indices.size() == 1, "expected 1 but got " + indices.size()); SSAInstruction callInstr = ir.getInstructions()[indices.intIterator().next()]; Assertions.productionAssertion(callInstr.getNumberOfUses() == 1, "multiple uses for call"); return heapModel.getPointerKeyForLocal(n, callInstr.getUse(0)); } } } Assertions.UNREACHABLE("failed to find call to " + methodName + " in " + n); return null; }
System.err.println("cannot find " + fn_name + " at " + ((AstMethod)ir.getMethod()).getSourcePosition(ir.getCallInstructionIndices(invk.getCallSite()).intIterator().next())); return;
System.err.println("cannot find " + fn_name + " at " + ((AstMethod)ir.getMethod()).getSourcePosition(ir.getCallInstructionIndices(invk.getCallSite()).intIterator().next())); return;