public MaxAddressVisitsExceededException(ExecutionNode node, String methodDescriptor) { super("Exceeded max address visits @" + node.getAddress() + " " + node + " in " + methodDescriptor); }
public MaxMethodVisitsExceededException(ExecutionNode node, String methodDescriptor) { this("Exceeded max method visits @" + node.getAddress() + " " + node + " in " + methodDescriptor); }
protected int getNodeIndex(ExecutionNode node) { return getNodePile(node.getAddress()).indexOf(node); }
private static StringBuilder getNodeState(ExecutionNode node, ExecutionGraph graph) { MethodState state = node.getContext().getMethodState(); String op = node.toString().replaceAll(DOT, "?").replace("\"", "\\\""); String stateStr = state.toString().replaceAll(DOT, "?").replace("\"", "\\\"").trim(); int nodeIndex = graph.getNodeIndex(node); StringBuilder sb = new StringBuilder(); sb.append("\"@").append(node.getAddress()).append('.').append(nodeIndex).append(" :: "); sb.append(op).append('\n').append(stateStr).append('"'); return sb; } }
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 static ExecutionNode buildNode(int address, String nodeString, String stateString) { ExecutionNode node = mock(ExecutionNode.class); when(node.getAddress()).thenReturn(address); when(node.toString()).thenReturn(nodeString); MethodState state = mock(MethodState.class); when(state.toString()).thenReturn(stateString); ExecutionContext context = mock(ExecutionContext.class); when(context.getMethodState()).thenReturn(state); when(node.getContext()).thenReturn(context); return node; }
log.trace("r{} read after {} @{} with {}", register, address, current.getAddress(), current.getOp()); log.trace("r{} assigned after {} @{} with {}", register, address, current.getAddress(), current.getOp());
int childAddress = exceptionResolver.resolve(e, node.getAddress()); if (childAddress <= 0) { throw new RuntimeException("Real exception was thrown executing " + node +
boolean isNext = child.getAddress() == original.getLocation().getCodeAddress() + original.getCodeUnits(); peepAddresses.add(address); if (isNext) {
private static void spawnExceptionChildren(ExecutionGraph graph, ExecutionNode node, ExceptionHandlerAddressResolver exceptionResolver) throws UnhandledVirtualException { if (node.mayThrowException()) { for (Throwable exception : node.getExceptions()) { if (log.isTraceEnabled()) { log.trace("{} may throw virtual exception: ", node, exception); } int childAddress = exceptionResolver.resolve(exception, node.getAddress()); if (childAddress >= 0) { ExecutionNode childNode = spawnChild(graph, node, childAddress); childNode.getContext().getMethodState().assignExceptionRegister(exception); } else { if (node.getChildLocations().length == 0) { if (log.isErrorEnabled()) { // No children, probably a real exception log.error("{} unhandled virtual exception: ", node, exception); } throw new UnhandledVirtualException(exception); } else { // Op has children, doesn't *always* throw, probably virtual exception if (log.isTraceEnabled()) { log.trace("{} possible unhandled virtual exception: ", node, exception); } } } } } }
private void checkMaxVisits(ExecutionNode node, VirtualMethod localMethod, TIntIntMap addressToVisitCount) throws MaxAddressVisitsExceededException, MaxMethodVisitsExceededException { if (totalVisits > getMaxMethodVisits()) { throw new MaxMethodVisitsExceededException(node, localMethod.getSignature()); } int address = node.getAddress(); int visitCount = addressToVisitCount.get(address); if (visitCount > getMaxAddressVisits()) { throw new MaxAddressVisitsExceededException(node, localMethod.getSignature()); } boolean adjusted = addressToVisitCount.adjustValue(address, 1); if (!adjusted) { addressToVisitCount.put(address, 1); } }