/** * <p> * Constructor for ExecutionTraceProxy. * </p> */ public ExecutionTraceProxy() { this.trace = new ExecutionTraceImpl(); }
@Override public void classInitialized(String classNameWithDots) { trace.classInitialized(classNameWithDots); }
/** * <p> * copyOnWrite * </p> */ public void copyOnWrite() { if (trace.getProxyCount() > 1) { trace.removeProxy(); trace = trace.clone(); } }
ExecutionTraceImpl r = clone(); Branch targetDUBranch = targetDU.getControlDependentBranch(); ArrayList<Integer> removableCalls = new ArrayList<Integer>(); removeFromFinishCall(call, removableIndices); if (call.defuseCounterTrace.size() == 0) removableCalls.add(callPos); removeFinishCalls(r, removableCalls); return new ExecutionTraceProxy(r);
/** * {@inheritDoc} * * Returns a copy of this trace where all MethodCall-information traced from * objects other then the one identified by the given objectID is removed * from the finished_calls-field * * WARNING: this will not affect this.true_distances and other fields of * ExecutionTrace this only affects the finished_calls field (which should * suffice for BranchCoverageFitness-calculation) */ @Override public ExecutionTrace getTraceForObject(int objectId) { ExecutionTraceImpl r = clone(); ArrayList<Integer> removableCalls = new ArrayList<Integer>(); for (int i = 0; i < r.finishedCalls.size(); i++) { MethodCall call = r.finishedCalls.get(i); if ((call.callingObjectID != objectId) && (call.callingObjectID != 0)) { removableCalls.add(i); } } removeFinishCalls(r, removableCalls); return new ExecutionTraceProxy(r); }
/** * <p> * disableTraceCalls * </p> */ public static void disableTraceCalls() { ExecutionTraceImpl.disableTraceCalls(); }
/** * <p> * disable context instrumentation * </p> */ public static void disableContext(){ logger.info("disable context and trace instrumentation"); ExecutionTraceImpl.disableContext(); }
/** {@inheritDoc} */ @Override public void clear() { copyOnWrite(); trace.clear(); }
/** {@inheritDoc} */ @Override public void definitionPassed(Object object, Object caller, int defID) { copyOnWrite(); trace.definitionPassed(object, caller, defID); }
/** {@inheritDoc} */ @Override public void branchPassed(int branch, int bytecode_id, double true_distance, double false_distance) { copyOnWrite(); trace.branchPassed(branch, bytecode_id, true_distance, false_distance); }
/** {@inheritDoc} */ @Override public ExecutionTrace lazyClone() { ExecutionTraceProxy copy = new ExecutionTraceProxy(trace); trace.addProxy(); return copy; }
/** * Removes from the given MethodCall all trace information with an index in * removableIndices */ private static void removeFromFinishCall(MethodCall call, ArrayList<Integer> removableIndices) { checkSaneCall(call); Collections.sort(removableIndices); for (int i = removableIndices.size() - 1; i >= 0; i--) { int removableIndex = removableIndices.get(i); Integer removedBranch = call.branchTrace.remove(removableIndex); Double removedTrue = call.trueDistanceTrace.remove(removableIndex); Double removedFalse = call.falseDistanceTrace.remove(removableIndex); Integer removedCounter = call.defuseCounterTrace.remove(removableIndex); if ((removedCounter == null) || (removedBranch == null) || (removedTrue == null) || (removedFalse == null)) { throw new IllegalStateException("trace.finished_calls-traces not allowed to contain null"); } } }
public static void disableContext() { disableTraceCalls(); disableContext = true; }
public ExecutionTraceImpl clone() { ExecutionTraceImpl copy = new ExecutionTraceImpl(); for (MethodCall call : finishedCalls) { copy.finishedCalls.add(call.clone());