public int[] getParentAddresses(int address) { Set<Integer> parentAddresses = new HashSet<>(); for (ExecutionNode node : getNodePile(address)) { ExecutionNode parent = node.getParent(); if (null == parent) { continue; } parentAddresses.add(parent.getAddress()); } return Ints.toArray(parentAddresses); }
private void removeFromNodePile(MethodLocation location) { List<ExecutionNode> nodePile = locationToNodePile.remove(location); Map<MethodLocation, ExecutionNode> locationToChildNodeToRemove = new HashMap<>(); for (ExecutionNode removedNode : nodePile) { ExecutionNode parentNode = removedNode.getParent(); if (parentNode == null) { continue; } parentNode.removeChild(removedNode); recreateLocations.add(parentNode.getOp().getLocation()); // reexecuteLocations.add(parentNode.getOp().getLocation()); for (ExecutionNode childNode : removedNode.getChildren()) { Op childOp = childNode.getOp(); boolean pseudoChild = childOp instanceof FillArrayDataPayloadOp || childOp instanceof SwitchPayloadOp; if (!pseudoChild) { reparentNode(childNode, parentNode); } else { // pseudo child // Implementation was altered such that dexlib removed something, probably nop padding for (ExecutionNode grandChildNode : childNode.getChildren()) { reparentNode(grandChildNode, parentNode); } locationToChildNodeToRemove.put(childOp.getLocation(), childNode); } } } for (Entry<MethodLocation, ExecutionNode> entry : locationToChildNodeToRemove.entrySet()) { List<ExecutionNode> pile = locationToNodePile.get(entry.getKey()); pile.remove(entry.getValue()); } }
ExecutionNode shiftedParent = shiftedNode.getParent(); ExecutionContext newContext; if (shiftedParent != null) {
private static void testHeritage(ExecutionGraphManipulator manipulator, int address) { ExecutionNode template = manipulator.getTemplateNode(address); assertEquals(0, template.getChildren().size()); assertNotNull(template.getOp().getChildren()); ExecutionNode node = manipulator.getNodePile(address).get(0); assertEquals(template.getOp(), node.getOp()); List<ExecutionNode> children = node.getChildren(); assertEquals(1, children.size()); MethodLocation[] childLocations = node.getChildLocations(); assertEquals(1, childLocations.length); ExecutionNode child = node.getChildren().get(0); assertEquals(node, child.getParent()); assertEquals(node.getContext(), child.getContext().getParent()); Op childOp = child.getOp(); assertEquals(childOp.getLocation(), childLocations[0]); assertEquals(childOp.getLocation(), node.getOp().getChildren()[0]); }