@Override public InstanceKey getInstanceKeyForAllocation(CGNode node, NewSiteReference allocation) { if (node.getMethod() instanceof JavaScriptConstructor) { InstanceKey bk = base.getInstanceKeyForAllocation(node, allocation); return new NormalAllocationInNode(node, allocation, bk.getConcreteType()); } else { return base.getInstanceKeyForAllocation(node, allocation); } }
private void handleStringBuilderToString(final NormalAllocationInNode nain, final OrdinalSetMapping<InstanceKey> mapping, final Map<InstanceKeySite, Set<InstanceKey>> unresolvedDependencies) { if (hasSignature(nain, "java.lang.StringBuilder.toString()Ljava/lang/String;")) { final Context context = nain.getNode().getContext(); final CGNode caller = (CGNode) context.get(ContextKey.CALLER);
if(((NormalAllocationInNode)receivers[0]).getSite().getDeclaredType().getClassLoader().equals(ClassLoaderReference.Application))
@Override public InstanceKey getInstanceKeyForAllocation(CGNode node, NewSiteReference allocation) { if (node.getMethod() instanceof JavaScriptConstructor) { InstanceKey bk = base.getInstanceKeyForAllocation(node, allocation); return new NormalAllocationInNode(node, allocation, bk.getConcreteType()); } else { return base.getInstanceKeyForAllocation(node, allocation); } }
IMethod m = ((NormalAllocationInNode) k).getNode().getMethod(); if (m.getSignature().equals("java.lang.StringBuilder.toString()Ljava/lang/String;")) { Context context = ((NormalAllocationInNode) k).getNode().getContext(); CGNode caller = (CGNode) context.get(ContextKey.CALLER); CallSiteReference csr = (CallSiteReference) context.get(ContextKey.CALLSITE);
return new ZeroLengthArrayInNode(nodeToUse, allocation, type); } else { return new NormalAllocationInNode(nodeToUse, allocation, type); InstanceKey key = new NormalAllocationInNode(nodeToUse, allocation, type);
private void handleUriWitAppendPath(final NormalAllocationInNode ik, final PointerAnalysis<InstanceKey> pa, final OrdinalSetMapping<InstanceKey> mapping, final Map<InstanceKeySite, Set<InstanceKey>> unresolvedDependencies) { final CGNode allocNode = ik.getNode(); final Context context = allocNode.getContext(); final CGNode caller = (CGNode) context.get(ContextKey.CALLER);
@Override public boolean equals(Object obj) { // instanceof is OK because this class is final if (obj instanceof NormalAllocationInNode) { AllocationSiteInNode other = (AllocationSiteInNode) obj; return getNode().equals(other.getNode()) && getSite().equals(other.getSite()); } else { return false; } }
return new ZeroLengthArrayInNode(nodeToUse, allocation, type); } else { return new NormalAllocationInNode(nodeToUse, allocation, type); InstanceKey key = new NormalAllocationInNode(nodeToUse, allocation, type);
private void handleUriParse(final NormalAllocationInNode ik, final PointerAnalysis<InstanceKey> pa, final OrdinalSetMapping<InstanceKey> mapping, final Map<InstanceKeySite, Set<InstanceKey>> unresolvedDependencies) { final CGNode allocNode = ik.getNode(); final Context context = allocNode.getContext(); final CGNode caller = (CGNode) context.get(ContextKey.CALLER); if (hasSignature(allocNode, "android.net.Uri.parse(Ljava/lang/String;)Landroid/net/Uri;")) { final CallSiteReference csr = (CallSiteReference) context.get(ContextKey.CALLSITE); final SSAInvokeInstruction invoke = (SSAInvokeInstruction) caller.getIR().getBasicBlocksForCall(csr)[0].getLastInstruction(); final OrdinalSet<InstanceKey> points = pa.getPointsToSet(new LocalPointerKey(caller, invoke.getUse(0))); if (!points.isEmpty()) { final InstanceKey stringKey = points.iterator().next(); final UriParseString node = new UriParseString( mapping.getMappedIndex(ik), mapping.getMappedIndex(stringKey)); addNode(node); nodeMap.put(ik, node); final Set<InstanceKey> iks = Collections.singleton(stringKey); unresolvedDependencies.put(node, iks); } } }
@Override public boolean equals(Object obj) { // instanceof is OK because this class is final if (obj instanceof NormalAllocationInNode) { AllocationSiteInNode other = (AllocationSiteInNode) obj; return getNode().equals(other.getNode()) && getSite().equals(other.getSite()); } else { return false; } }
/** * convert a pointer key to one in the memory access map's heap model * * TODO move this somewhere more appropriate * * @throws UnsupportedOperationException if it doesn't know how to handle a {@link PointerKey} */ public static PointerKey convertPointerKeyToHeapModel(PointerKey pk, HeapModel h) { if (pk == null) { throw new IllegalArgumentException("null pk"); } if (pk instanceof LocalPointerKey) { LocalPointerKey lpk = (LocalPointerKey) pk; return h.getPointerKeyForLocal(lpk.getNode(), lpk.getValueNumber()); } else if (pk instanceof ArrayContentsKey) { ArrayContentsKey ack = (ArrayContentsKey) pk; InstanceKey ik = ack.getInstanceKey(); if (ik instanceof NormalAllocationInNode) { NormalAllocationInNode nain = (NormalAllocationInNode) ik; ik = h.getInstanceKeyForAllocation(nain.getNode(), nain.getSite()); } else { assert false : "need to handle " + ik.getClass(); } return h.getPointerKeyForArrayContents(ik); } else if (pk instanceof ReturnValueKey) { ReturnValueKey rvk = (ReturnValueKey) pk; return h.getPointerKeyForReturnValue(rvk.getNode()); } throw new UnsupportedOperationException("need to handle " + pk.getClass()); }
/** * convert a pointer key to one in the memory access map's heap model * * TODO move this somewhere more appropriate * * @throws UnsupportedOperationException if it doesn't know how to handle a {@link PointerKey} */ public static PointerKey convertPointerKeyToHeapModel(PointerKey pk, HeapModel h) { if (pk == null) { throw new IllegalArgumentException("null pk"); } if (pk instanceof LocalPointerKey) { LocalPointerKey lpk = (LocalPointerKey) pk; return h.getPointerKeyForLocal(lpk.getNode(), lpk.getValueNumber()); } else if (pk instanceof ArrayContentsKey) { ArrayContentsKey ack = (ArrayContentsKey) pk; InstanceKey ik = ack.getInstanceKey(); if (ik instanceof NormalAllocationInNode) { NormalAllocationInNode nain = (NormalAllocationInNode) ik; ik = h.getInstanceKeyForAllocation(nain.getNode(), nain.getSite()); } else { assert false : "need to handle " + ik.getClass(); } return h.getPointerKeyForArrayContents(ik); } else if (pk instanceof ReturnValueKey) { ReturnValueKey rvk = (ReturnValueKey) pk; return h.getPointerKeyForReturnValue(rvk.getNode()); } throw new UnsupportedOperationException("need to handle " + pk.getClass()); }
if (ik instanceof NormalAllocationInNode){ NormalAllocationInNode normalIk1 = (NormalAllocationInNode) ik; IR ir2 = normalIk1.getNode().getIR(); int pc2 = normalIk1.getSite().getProgramCounter(); irViewer.setIRAndPc(ir2, pc2); IR ir3 = normalIk2.getNode().getIR(); int pc3 = normalIk2.getSite().getProgramCounter(); irViewer.setIRAndPc(ir3, pc3); } else if (userObject instanceof CGNode){
if (ik instanceof NormalAllocationInNode){ NormalAllocationInNode normalIk1 = (NormalAllocationInNode) ik; IR ir2 = normalIk1.getNode().getIR(); int pc2 = normalIk1.getSite().getProgramCounter(); irViewer.setIRAndPc(ir2, pc2); IR ir3 = normalIk2.getNode().getIR(); int pc3 = normalIk2.getSite().getProgramCounter(); irViewer.setIRAndPc(ir3, pc3); } else if (userObject instanceof CGNode){